* * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/bookmarks/bookmarks.lib.php * \ingroup bookmarks * \brief File with library for bookmark module */ /** * Add area with bookmarks in top menu * * @return string */ 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='.urlencode($sortfield); } if ($sortorder) { $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.urlencode($sortorder); } if (is_array($_POST)) { foreach ($_POST as $key => $val) { if (preg_match('/^search_/', $key) && $val != '') { $tmpurl .= ($tmpurl ? '&' : '').http_build_query(array($key => $val)); } } } $url .= ($tmpurl ? '?'.$tmpurl : ''); } $searchForm = ''."\n"; $searchForm .= '
global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' onsubmit="return false"' : '').'>'; $searchForm .= ''; // Url to list bookmark $listbtn = ''; $listbtn .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('Bookmarks').''; // Url to go on create new bookmark page $newbtn = ''; if (!empty($user->rights->bookmark->creer)) { if (!preg_match('/bookmarks\/card.php/', $_SERVER['PHP_SELF'])) { //$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('', 'add', '', 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 = ".((int) $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 .= ' '; } return $html; }