dolibarr 25.0.0-alpha
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}
37if (!defined('NOREQUIREMENU')) {
38 define('NOREQUIREMENU', 1);
39}
40//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
41
42require_once '../main.inc.php';
51if (GETPOST('lang', 'aZ09')) {
52 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
53}
54
55$langs->loadLangs(array("bookmarks"));
56
57$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
58$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
59
60
61/*
62 * View
63 */
64
65// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
66if (GETPOSTINT('cache')) {
67 header('Cache-Control: max-age='.GETPOSTINT('cache').', public');
68 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
69 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
70 // HTTP/1.0
71 header('Pragma: token=public');
72} else {
73 // HTTP/1.0
74 header('Cache-Control: no-cache');
75}
76
77$title = $langs->trans("Bookmarks");
78
79// URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests
80$head = '<!-- Bookmarks -->'."\n"; // This is used by DoliDroid to know page is a bookmark selection page
81$arrayofjs = array();
82$arrayofcss = array();
83top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
84
85
86
87print '<body>'."\n";
88print '<div>';
89//print '<br>';
90
91// Instantiate hooks of thirdparty module
92$hookmanager->initHooks(array('bookmarks'));
93
94// Define $bookmarks
95$bookmarkList = '';
96$searchForm = '';
97
98
99if (!isModEnabled('bookmark')) {
100 $langs->load("admin");
101 $bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Bookmarks")).'</span>';
102 $bookmarkList .= '<br><br>';
103} else {
104 // Menu with list of bookmarks
105 $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
106 $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)";
107 $sql .= " AND entity IN (".getEntity('bookmarks').")";
108 $sql .= " ORDER BY position";
109 if ($resql = $db->query($sql)) {
110 $bookmarkList = '<div id="dropdown-bookmarks-list" class="start">';
111 $i = 0;
112 while ((!getDolGlobalString('BOOKMARKS_SHOW_IN_MENU') || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
113 $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).'" >';
114 $bookmarkList .= dol_escape_htmltag($obj->title);
115 $bookmarkList .= '</a>';
116 $i++;
117 }
118 if ($i == 0) {
119 $langs->load("other");
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();
dol_now($mode='gmt')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.