Fix url suggested for bookmark did not always include params

This commit is contained in:
Laurent Destailleur
2017-06-27 11:12:03 +02:00
parent 08af9bf365
commit 92287ab18d
3 changed files with 43 additions and 21 deletions

View File

@@ -40,7 +40,26 @@ function printBookmarksList($aDb, $aLangs)
$langs->load("bookmarks");
$url= $_SERVER["PHP_SELF"].(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):'');
$url= $_SERVER["PHP_SELF"];
if (! empty($_SERVER["QUERY_STRING"]))
{
$url.=(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):'');
}
else
{
global $sortfield,$sortorder;
$tmpurl='';
// No urlencode, all param $url will be urlencoded later
if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield;
if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder;
foreach($_POST as $key => $val)
{
if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val;
}
$url.=($tmpurl?'?'.$tmpurl:'');
}
$ret = '';
@@ -55,7 +74,8 @@ function printBookmarksList($aDb, $aLangs)
// Url to go on create new bookmark page
if ($user->rights->bookmark->creer)
{
$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url);
//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url);
$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url);
$ret.= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'...</option>';
}
// Menu with all bookmarks

View File

@@ -39,6 +39,7 @@ $id=GETPOST("id");
$action=GETPOST("action","alpha");
$title=GETPOST("title","alpha");
$url=GETPOST("url","alpha");
$urlsource=GETPOST("urlsource","alpha");
$target=GETPOST("target","alpha");
$userid=GETPOST("userid","int");
$position=GETPOST("position","int");
@@ -64,7 +65,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if (GETPOST("cancel"))
{
if (empty($backtopage)) $backtopage=(GETPOST("urlsource")?GETPOST("urlsource"):((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/list.php'));
if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/list.php'));
header("Location: ".$backtopage);
exit;
}
@@ -97,7 +98,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if ($res > 0)
{
if (empty($backtopage)) $backtopage=(GETPOST("urlsource")?GETPOST("urlsource"):DOL_URL_ROOT.'/bookmarks/list.php');
if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/list.php'));
header("Location: ".$backtopage);
exit;
}
@@ -121,6 +122,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
}
}
/*
* View
*/
@@ -153,15 +155,15 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("NewBookmark"));
dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark');
dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), 0, 'bookmark');
print '<table class="border" width="100%">';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("BookmarkTitle").'</td><td><input id="titlebookmark" class="flat minwidth100" name="title" value="'.$title.'"></td><td class="hideonsmartphone">'.$langs->trans("SetHereATitleForLink").'</td></tr>';
dol_set_focus('#titlebookmark');
// Url
print '<tr><td class="fieldrequired">'.$langs->trans("UrlOrLink").'</td><td><input class="flat quatrevingtpercent" name="url" value="'.$url.'"></td><td class="hideonsmartphone">'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("UrlOrLink").'</td><td><input class="flat quatrevingtpercent" name="url" value="'.dol_escape_htmltag($url).'"></td><td class="hideonsmartphone">'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
// Target
print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
@@ -219,14 +221,14 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
}
dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark');
dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark');
$linkback = '<a href="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@@ -304,7 +306,7 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
print '</table>';
print '</div>';
dol_fiche_end();
if ($action == 'edit')

View File

@@ -301,6 +301,16 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
print "<!-- End SearchForm -->\n";
}
if (is_array($moredata) && ! empty($moredata['bookmarks']))
{
print "\n";
print "<!-- Begin Bookmarks -->\n";
print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
print $moredata['bookmarks'];
print '</div>'."\n";
print "<!-- End Bookmarks -->\n";
}
// We update newmenu with entries found into database
$menuArbo = new Menubase($db,'auguria');
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
@@ -564,16 +574,6 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
if ($altok) print '<div class="blockvmenuend"></div>'; // End menu block
}
if (is_array($moredata) && ! empty($moredata['bookmarks']))
{
print "\n";
print "<!-- Begin Bookmarks -->\n";
print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
print $moredata['bookmarks'];
print '</div>'."\n";
print "<!-- End Bookmarks -->\n";
}
return count($menu_array);
}