dolibarr  20.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  *
4  * This file is a modified version of datepicker.php from phpBSM to fix some
5  * bugs, to add new features and to dramatically increase speed.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
27 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
28 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
29 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
30 if (!defined('NOCSRFCHECK')) {
31  define('NOCSRFCHECK', 1);
32 }
33 if (!defined('NOTOKENRENEWAL')) {
34  define('NOTOKENRENEWAL', 1);
35 }
36 //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
37 if (!defined('NOREQUIREMENU')) {
38  define('NOREQUIREMENU', 1);
39 }
40 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
41 
42 require_once '../main.inc.php';
43 
44 if (GETPOST('lang', 'aZ09')) {
45  $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
46 }
47 
48 $langs->loadLangs(array("bookmarks"));
49 
50 $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
51 $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
52 
53 
54 /*
55  * View
56  */
57 
58 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
59 if (empty($dolibarr_nocache) && GETPOSTINT('cache')) {
60  header('Cache-Control: max-age='.GETPOSTINT('cache').', public');
61  // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
62  header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
63  // HTTP/1.0
64  header('Pragma: token=public');
65 } else {
66  // HTTP/1.0
67  header('Cache-Control: no-cache');
68 }
69 
70 $title = $langs->trans("Bookmarks");
71 
72 // URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests
73 $head = '<!-- Bookmarks -->'."\n"; // This is used by DoliDroid to know page is a bookmark selection page
74 $arrayofjs = array();
75 $arrayofcss = array();
76 top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
77 
78 
79 
80 print '<body>'."\n";
81 print '<div>';
82 //print '<br>';
83 
84 // Instantiate hooks of thirdparty module
85 $hookmanager->initHooks(array('bookmarks'));
86 
87 // Define $bookmarks
88 $bookmarkList = '';
89 $searchForm = '';
90 
91 
92 if (empty($conf->bookmark->enabled)) {
93  $langs->load("admin");
94  $bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Bookmarks")).'</span>';
95  $bookmarkList .= '<br><br>';
96 } else {
97  // Menu with list of bookmarks
98  $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
99  $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)";
100  $sql .= " AND entity IN (".getEntity('bookmarks').")";
101  $sql .= " ORDER BY position";
102  if ($resql = $db->query($sql)) {
103  $bookmarkList = '<div id="dropdown-bookmarks-list" class="start">';
104  $i = 0;
105  while ((!getDolGlobalString('BOOKMARKS_SHOW_IN_MENU') || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
106  $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).'" >';
107  $bookmarkList .= dol_escape_htmltag($obj->title);
108  $bookmarkList .= '</a>';
109  $i++;
110  }
111  if ($i == 0) {
112  $bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("NoBookmarks").'</span>';
113  $bookmarkList .= '<br><br>';
114  }
115 
116  $newcardbutton = '';
117  $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'));
118 
119  // Url to list bookmark
120  $bookmarkList .= '<br>';
121  $bookmarkList .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('EditBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >';
122  $bookmarkList .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('EditBookmarks').'</a>';
123  $bookmarkList .= '<br>';
124  $bookmarkList .= '<br>';
125 
126  $bookmarkList .= '<center>'.$newcardbutton.'</center>';
127 
128  $bookmarkList .= '</div>';
129 
130 
131  $searchForm .= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >';
132  } else {
133  dol_print_error($db);
134  }
135 }
136 
137 // Execute hook printBookmarks
138 $parameters = array('bookmarks'=>$bookmarkList);
139 $reshook = $hookmanager->executeHooks('printBookmarks', $parameters); // Note that $action and $object may have been modified by some hooks
140 if (empty($reshook)) {
141  $bookmarkList .= $hookmanager->resPrint;
142 } else {
143  $bookmarkList = $hookmanager->resPrint;
144 }
145 
146 
147 print "\n";
148 print "<!-- Begin Bookmarks list -->\n";
149 print '<div class="center"><div class="center" style="padding: 6px;">';
150 print '<style>.menu_titre { padding-top: 7px; }</style>';
151 print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
152 print $bookmarkList;
153 print '</div>'."\n";
154 print '</div></div>';
155 print "\n<!-- End SearchForm -->\n";
156 
157 print '</div>';
158 print '</body></html>'."\n";
159 
160 $db->close();
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
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 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.
Definition: main.inc.php:1749