dolibarr 21.0.0-beta
bookmarks_page.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This file is a modified version of datepicker.php from phpBSM to fix some
6 * bugs, to add new features and to dramatically increase speed.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
27//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
28//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
29//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
30//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
31if (!defined('NOCSRFCHECK')) {
32 define('NOCSRFCHECK', 1);
33}
34if (!defined('NOTOKENRENEWAL')) {
35 define('NOTOKENRENEWAL', 1);
36}
37//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
38if (!defined('NOREQUIREMENU')) {
39 define('NOREQUIREMENU', 1);
40}
41//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
42
43require_once '../main.inc.php';
52if (GETPOST('lang', 'aZ09')) {
53 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
54}
55
56$langs->loadLangs(array("bookmarks"));
57
58$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
59$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
60
61
62/*
63 * View
64 */
65
66// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
67if (empty($dolibarr_nocache) && GETPOSTINT('cache')) {
68 header('Cache-Control: max-age='.GETPOSTINT('cache').', public');
69 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
70 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
71 // HTTP/1.0
72 header('Pragma: token=public');
73} else {
74 // HTTP/1.0
75 header('Cache-Control: no-cache');
76}
77
78$title = $langs->trans("Bookmarks");
79
80// URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests
81$head = '<!-- Bookmarks -->'."\n"; // This is used by DoliDroid to know page is a bookmark selection page
82$arrayofjs = array();
83$arrayofcss = array();
84top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
85
86
87
88print '<body>'."\n";
89print '<div>';
90//print '<br>';
91
92// Instantiate hooks of thirdparty module
93$hookmanager->initHooks(array('bookmarks'));
94
95// Define $bookmarks
96$bookmarkList = '';
97$searchForm = '';
98
99
100if (!isModEnabled('bookmark')) {
101 $langs->load("admin");
102 $bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Bookmarks")).'</span>';
103 $bookmarkList .= '<br><br>';
104} else {
105 // Menu with list of bookmarks
106 $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
107 $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)";
108 $sql .= " AND entity IN (".getEntity('bookmarks').")";
109 $sql .= " ORDER BY position";
110 if ($resql = $db->query($sql)) {
111 $bookmarkList = '<div id="dropdown-bookmarks-list" class="start">';
112 $i = 0;
113 while ((!getDolGlobalString('BOOKMARKS_SHOW_IN_MENU') || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
114 $bookmarkList .= '<a class="dropdown-item bookmark-item'.(strpos($obj->url, 'http') === 0 ? ' bookmark-item-external' : '').'" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank" rel="noopener noreferrer"' : '').' href="'.dol_escape_htmltag($obj->url).'" >';
115 $bookmarkList .= dol_escape_htmltag($obj->title);
116 $bookmarkList .= '</a>';
117 $i++;
118 }
119 if ($i == 0) {
120 $bookmarkList .= '<br><div class="opacitymedium center">'.$langs->trans("NoBookmarks").'</div>';
121 $bookmarkList .= '<br><br>';
122 }
123
124 $newcardbutton = '';
125 $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'), '', $user->hasRight('bookmark', 'creer'));
126
127 // Url to list bookmark
128 $bookmarkList .= '<br>';
129 $bookmarkList .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('EditBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >';
130 $bookmarkList .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('EditBookmarks').'</a>';
131 $bookmarkList .= '<br>';
132 $bookmarkList .= '<br>';
133
134 $bookmarkList .= '<center>'.$newcardbutton.'</center>';
135
136 $bookmarkList .= '</div>';
137
138
139 $searchForm .= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >';
140 } else {
141 dol_print_error($db);
142 }
143}
144
145// Execute hook printBookmarks
146$parameters = array('bookmarks'=>$bookmarkList);
147$reshook = $hookmanager->executeHooks('printBookmarks', $parameters); // Note that $action and $object may have been modified by some hooks
148if (empty($reshook)) {
149 $bookmarkList .= $hookmanager->resPrint;
150} else {
151 $bookmarkList = $hookmanager->resPrint;
152}
153
154
155print "\n";
156print "<!-- Begin Bookmarks list -->\n";
157print '<div class="center"><div class="center" style="padding: 30px;">';
158print '<style>.menu_titre { padding-top: 7px; }</style>';
159print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
160print $bookmarkList;
161print '</div>'."\n";
162print '</div></div>';
163print "\n<!-- End SearchForm -->\n";
164
165print '</div>';
166print '</body></html>'."\n";
167
168$db->close();
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.