--- /tmp/dsg/dolibarr/htdocs/bookmarks/github_bookmarks.lib.php +++ /tmp/dsg/dolibarr/htdocs/bookmarks/client_bookmarks.lib.php @@ -29,176 +29,182 @@ */ function printDropdownBookmarksList() { - global $conf, $user, $db, $langs; - - require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; - - $langs->load("bookmarks"); - - $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; - } - if (is_array($_POST)) { - foreach ($_POST as $key => $val) { - if (preg_match('/^search_/', $key) && $val != '') { - $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val; - } - } - } - $url .= ($tmpurl ? '?'.$tmpurl : ''); - } - - $searchForm = ''."\n"; - $searchForm .= '
global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' onsubmit="return false"' : '').'>'; - $searchForm .= ''; - - - // Url to list bookmark - $listbtn = ''; - $listbtn .= ''.$langs->trans('Bookmarks').''; - - // Url to go on create new bookmark page - $newbtn = ''; - if (!empty($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&url='.urlencode($url); - $newbtn .= ''; - $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; - } - - // Menu with list of bookmarks - $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; - $sql .= " AND entity IN (".getEntity('bookmarks').")"; - $sql .= " ORDER BY position"; - if ($resql = $db->query($sql)) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $bookmarkList = ''; - - $searchForm .= ''; - } else { - $searchForm .= ''; - } - } else { - dol_print_error($db); - } - - $searchForm .= '
'; - - // Generate the return string - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $html = $searchForm; - - $html .= ' + global $conf, $user, $db, $langs; + + require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; + + $langs->load("bookmarks"); + + $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; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if (preg_match('/^search_/', $key) && $val != '') $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val; + } + } + $url .= ($tmpurl ? '?'.$tmpurl : ''); + } + + $searchForm = ''."\n"; + $searchForm .= '
global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' onsubmit="return false"' : '').'>'; + $searchForm .= ''; + + + // Url to list bookmark + $listbtn = ''; + $listbtn .= ''.$langs->trans('Bookmarks').''; + + // Url to go on create new bookmark page + $newbtn = ''; + if (!empty($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&url='.urlencode($url); + $newbtn .= ''; + $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; + } + + // Menu with list of bookmarks + $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; + $sql .= " AND entity IN (".getEntity('bookmarks').")"; + $sql .= " ORDER BY position"; + if ($resql = $db->query($sql)) + { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $bookmarkList = ''; + + $searchForm .= ''; + } else { + $searchForm .= ''; + } + } + else + { + dol_print_error($db); + } + + $searchForm .= '
'; + + // Generate the return string + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $html = $searchForm; + + $html .= ' '; - } else { - $html = ' - - - '; - - $html .= ' - - - '; - - $html .= ' - - - '; - - $html .= ' + } else { + $html = ' + + + '; + + $html .= ' + + + '; + + $html .= ' + + + '; + + $html .= ' '; - } - - return $html; + $( document ).on("keyup", "#top-bookmark-search-input", function () { + + var filter = $(this).val(), count = 0; + $("#dropdown-bookmarks-list .bookmark-item").each(function () { + + if ($(this).text().search(new RegExp(filter, "i")) < 0) { + $(this).addClass("hidden-search-result"); + } else { + $(this).removeClass("hidden-search-result"); + count++; + } + }); + $("#top-bookmark-search-filter-count").text(count); + }); + '; + } + + return $html; } --- /tmp/dsg/dolibarr/htdocs/bookmarks/github_card.php +++ /tmp/dsg/dolibarr/htdocs/bookmarks/client_card.php @@ -32,13 +32,13 @@ // Security check if (!$user->rights->bookmark->lire) { - restrictedArea($user, 'bookmarks'); + restrictedArea($user, 'bookmarks'); } $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); -$title = (string) GETPOST("title", "alpha"); -$url = (string) GETPOST("url", "alpha"); +$title = GETPOST("title", "alpha"); +$url = GETPOST("url", "alpha"); $urlsource = GETPOST("urlsource", "alpha"); $target = GETPOST("target", "alpha"); $userid = GETPOST("userid", "int"); @@ -71,9 +71,8 @@ if ($action == 'update') $object->fetch(GETPOST("id", 'int')); // Check if null because user not admin can't set an user and send empty value here. - if (!empty($userid)) { + if (!empty($userid)) $object->fk_user = $userid; - } $object->title = $title; $object->url = $url; $object->target = $target; @@ -101,17 +100,23 @@ if (empty($backtopage)) $backtopage = ($urlsource ? $urlsource : ((!empty($url) && !preg_match('/^http/i', $url)) ? $url : DOL_URL_ROOT.'/bookmarks/list.php')); header("Location: ".$backtopage); exit; - } else { + } + else + { if ($object->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessages($langs->transnoentities("WarningBookmarkAlreadyExists"), null, 'warnings'); - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } $action = $invertedaction; } - } else { + } + else + { $action = $invertedaction; } } @@ -146,15 +151,14 @@ print '
'."\n"; print ''; print ''; - print ''; print load_fiche_titre($langs->trans("NewBookmark")); - print dol_get_fiche_head($head, $hselected, $langs->trans("Bookmark"), 0, 'bookmark'); + dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), 0, 'bookmark'); print ''; - print ''; + print ''; dol_set_focus('#titlebookmark'); // Url @@ -168,21 +172,21 @@ // Owner print ''; // Position print ''; print '
'.$langs->trans("BookmarkTitle").''.$langs->trans("SetHereATitleForLink").'
'.$langs->trans("BookmarkTitle").''.$langs->trans("SetHereATitleForLink").'
'.$langs->trans("Owner").''; - print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print img_picto('', 'user').' '.$form->select_dolusers(isset($_POST['userid']) ? $_POST['userid'] : $user->id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ' 
'.$langs->trans("Position").''; - print 'position).'">'; + print 'position).'">'; print ' 
'; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; print '   '; - print ''; + print ''; print '
'; print '
'; @@ -216,15 +220,15 @@ } - print dol_get_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark'); + dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); - - print '
'; - - print '
'; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); + + print '
'; + + print '
'; print ''; print ''; @@ -252,7 +256,7 @@ print ''; } print ''; @@ -260,8 +264,10 @@ if ($action == 'edit') { $liste = array(1=>$langs->trans("OpenANewWindow"), 0=>$langs->trans("ReplaceWindow")); - print $form->selectarray('target', $liste, GETPOSTISSET("target") ? GETPOST("target") : $object->target); - } else { + print $form->selectarray('target', $liste, isset($_POST["target"]) ? $_POST["target"] : $object->target); + } + else + { if ($object->target == 0) print $langs->trans("ReplaceWindow"); if ($object->target == 1) print $langs->trans("OpenANewWindow"); } @@ -270,14 +276,18 @@ print ''; @@ -296,11 +306,11 @@ print ''; - print dol_get_fiche_end(); + dol_fiche_end(); if ($action == 'edit') { - print '
   
'; + print '
   
'; print ''; } @@ -312,13 +322,13 @@ // Edit if ($user->rights->bookmark->creer && $action != 'edit') { - print ''.$langs->trans("Edit").''."\n"; + print " id."&action=edit\">".$langs->trans("Edit")."\n"; } // Remove if ($user->rights->bookmark->supprimer && $action != 'edit') { - print ''.$langs->trans("Delete").''."\n"; + print " id."&action=delete\">".$langs->trans("Delete")."\n"; } print ''; --- /tmp/dsg/dolibarr/htdocs/bookmarks/github_list.php +++ /tmp/dsg/dolibarr/htdocs/bookmarks/client_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2012 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,12 +27,12 @@ // Load translation files required by the page $langs->loadLangs(array('bookmarks', 'admin')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bookmarklist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search // Security check if (!$user->rights->bookmark->lire) { @@ -42,8 +42,8 @@ // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; @@ -72,7 +72,9 @@ { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -113,7 +115,9 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} else { +} +else +{ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -154,7 +158,7 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.'/bookmarks/list.php'), '', !empty($user->rights->bookmark->creer)); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create', '', !empty($user->rights->bookmark->creer)); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bookmark', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -197,14 +201,14 @@ // Title print "\n"; // Url print '\n"; @@ -226,7 +230,9 @@ } $tmpuser = $cacheOfUsers[$obj->fk_user]; print $tmpuser->getNomUrl(1); - } else { + } + else + { print $langs->trans("Public"); } print "\n"; @@ -241,12 +247,14 @@ print '";
'; @@ -239,7 +243,7 @@ } print ''; - if ($action == 'edit') print 'title).'">'; + if ($action == 'edit') print 'title).'">'; else print $object->title; print '
'; - if ($action == 'edit') print 'url).'">'; + if ($action == 'edit') print 'url).'">'; else print 'target ? ' target="_blank"' : '').'>'.$object->url.''; print '
'.$langs->trans("Owner").''; if ($action == 'edit' && $user->admin) { - print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : ($object->fk_user ? $object->fk_user : ''), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - } else { + print img_picto('', 'user').' '.$form->select_dolusers(isset($_POST['userid']) ? $_POST['userid'] : ($object->fk_user ? $object->fk_user : ''), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + } + else + { if ($object->fk_user > 0) { $fuser = new User($db); $fuser->fetch($object->fk_user); print $fuser->getNomUrl(1); - } else { + } + else + { print $langs->trans("Public"); } } @@ -285,7 +295,7 @@ // Position print '
'.$langs->trans("Position").''; - if ($action == 'edit') print 'position).'">'; + if ($action == 'edit') print 'position).'">'; else print $object->position; print '
"; $linkintern = 1; - if ($linkintern) print ''; + if ($linkintern) print "url."\">"; print $title; if ($linkintern) print ""; print "'; - if (!$linkintern) print 'target ? ' target="newlink" rel="noopener"' : '').'>'; + if (!$linkintern) print 'target ? ' target="newlink"' : '').'>'; print $link; if (!$linkintern) print ''; print "'; if ($user->rights->bookmark->creer) { - print ''.img_edit().""; + print 'rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().""; } if ($user->rights->bookmark->supprimer) { - print 'rowid.'">'.img_delete().''; - } else { + print 'rowid.'">'.img_delete().''; + } + else + { print " "; } print "