dolibarr  17.0.4
auguria.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2022 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  * or see https://www.gnu.org/
18  */
19 
24 require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
25 
26 
27 
40 function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '')
41 {
42  global $user, $conf, $langs, $mysoc;
43  global $dolibarr_main_db_name;
44 
45  $mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
46  $leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
47 
48  $id = 'mainmenu';
49  $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
50 
51  // Show personalized menus
52  $menuArbo = new Menubase($db, 'auguria');
53  $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria', $tabMenu);
54 
55  $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
56 
57  if (empty($noout)) {
59  }
60 
61  global $usemenuhider;
62  $usemenuhider = 1;
63 
64  // Show/Hide vertical menu. The hamburger icon for .menuhider action.
65  if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
66  $showmode = 1;
67  $classname = 'class="tmenu menuhider nohover"';
68  $idsel = 'menu';
69 
70  $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
71  }
72 
73  $num = count($newTabMenu);
74  for ($i = 0; $i < $num; $i++) {
75  //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']);
76  $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']);
77 
78  $shorturl = '';
79 
80  $showmode = dol_auguria_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal);
81  if ($showmode == 1) {
82  $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray);
83 
84  // url = url from host, shorturl = relative path into dolibarr sources
85  $url = $shorturl = $newTabMenu[$i]['url'];
86  if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links
87  $tmp = explode('?', $newTabMenu[$i]['url'], 2);
88  $url = $shorturl = $tmp[0];
89  $param = (isset($tmp[1]) ? $tmp[1] : '');
90 
91  // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
92  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($newTabMenu[$i]['url'])) {
93  $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
94  }
95  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($newTabMenu[$i]['url'])) {
96  $param .= ($param ? '&' : '').'leftmenu=';
97  }
98  //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
99  $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
100  //$shorturl = $shorturl.($param?'?'.$param:'');
101  $shorturl = $url;
102 
103  if (DOL_URL_ROOT) {
104  $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl);
105  }
106  }
107 
108  // TODO Find a generic solution
109  if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) {
110  $search_project_user = GETPOST('search_project_user', 'int');
111  if ($search_project_user) {
112  $shorturl = preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl);
113  } else {
114  $shorturl = preg_replace('/search_project_user=__search_project_user__/', '', $shorturl);
115  }
116  }
117 
118  // Define the class (top menu selected or not)
119  if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) {
120  $classname = 'class="tmenusel"';
121  } elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) {
122  $classname = 'class="tmenusel"';
123  } else {
124  $classname = 'class="tmenu"';
125  }
126  } elseif ($showmode == 2) {
127  $classname = 'class="tmenu"';
128  } else {
129  $classname = '';
130  }
131 
132  $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), $newTabMenu[$i]['position'], $id, $idsel, $classname);
133  }
134 
135  // Sort on position
136  $menu->liste = dol_sort_array($menu->liste, 'position');
137 
138  // Output menu entries
139  // Show logo company
140  if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
141  //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI);
142  $mysoc->logo_squarred_mini = (empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI);
143 
144  $logoContainerAdditionalClass = 'backgroundforcompanylogo';
145  if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)) {
146  $logoContainerAdditionalClass = '';
147  }
148 
149  if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
150  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
151  /*} elseif (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
152  {
153  $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
154  }*/
155  } else {
156  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png';
157  $logoContainerAdditionalClass = '';
158  }
159 
160  $title = $langs->trans("GoIntoSetupToChangeLogo");
161 
162  print "\n".'<!-- Show logo on menu -->'."\n";
163  print_start_menu_entry_auguria('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1);
164 
165  print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n";
166 
168  }
169 
170  if (empty($noout)) {
171  foreach ($menu->liste as $menuval) {
172  print_start_menu_entry_auguria($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
173  print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url'] != '#' ?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget));
174  print_end_menu_entry_auguria($menuval['enabled']);
175  }
176  }
177 
178  $showmode = 1;
179  if (empty($noout)) {
180  print_start_menu_entry_auguria('', 'class="tmenuend"', $showmode);
181  print_end_menu_entry_auguria($showmode);
183  }
184 
185  return 0;
186 }
187 
188 
195 {
196  global $conf;
197 
198  print '<div class="tmenudiv">';
199  print '<ul role="navigation" class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"').'>';
200 }
201 
210 function print_start_menu_entry_auguria($idsel, $classname, $showmode)
211 {
212  if ($showmode) {
213  print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
214  //print '<div class="tmenuleft tmenusep"></div>';
215  print '<div class="tmenucenter">';
216  }
217 }
218 
231 function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget)
232 {
233  global $langs, $conf;
234 
235  $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
236  $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
237 
238  if ($showmode == 1) {
239  print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
240  print '<div class="'.$id.' '.$idsel.' topmenuimage aaa"><span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span></div>';
241  print '</a>';
242  if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
243  print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
244  print '<span class="mainmenuaspan">';
245  print $text;
246  print '</span>';
247  print '</a>';
248  }
249  } elseif ($showmode == 2) {
250  print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
251  print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
252  print '</div>';
253  if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
254  print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
255  print '<span class="mainmenuaspan">';
256  print $text;
257  print '</span>';
258  print '</span>';
259  }
260  }
261 }
262 
269 function print_end_menu_entry_auguria($showmode)
270 {
271  if ($showmode) {
272  print '</div></li>';
273  }
274  print "\n";
275 }
276 
283 {
284  print '</ul>';
285  print '</div>';
286  print "\n";
287 }
288 
289 
290 
307 function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
308 {
309  global $user, $conf, $langs, $hookmanager;
310  global $dolibarr_main_db_name, $mysoc;
311 
312  $newmenu = $menu;
313 
314  $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]);
315  $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]));
316 
317  global $usemenuhider;
318  $usemenuhider = 0;
319 
320  if (is_array($moredata) && !empty($moredata['searchform'])) { // searchform can contains select2 code or link to show old search form or link to switch on search page
321  print "\n";
322  print "<!-- Begin SearchForm -->\n";
323  print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
324  print $moredata['searchform'];
325  print '</div>'."\n";
326  print "<!-- End SearchForm -->\n";
327  }
328 
329  if (is_array($moredata) && !empty($moredata['bookmarks'])) {
330  print "\n";
331  print "<!-- Begin Bookmarks -->\n";
332  print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
333  print $moredata['bookmarks'];
334  print '</div>'."\n";
335  print "<!-- End Bookmarks -->\n";
336  }
337 
338  $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
339 
340  // We update newmenu with entries found into database
341  $menuArbo = new Menubase($db, 'auguria');
342  $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, ($user->socid ? 1 : 0), 'auguria', $tabMenu);
343 
344  // We update newmenu for special dynamic menus
345  if (isModEnabled('banque') && $user->rights->banque->lire && $mainmenu == 'bank') { // Entry for each bank account
346  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example
347 
348  $sql = "SELECT rowid, label, courant, rappro, courant";
349  $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
350  $sql .= " WHERE entity = ".$conf->entity;
351  $sql .= " AND clos = 0";
352  $sql .= " ORDER BY label";
353 
354  $resql = $db->query($sql);
355  if ($resql) {
356  $numr = $db->num_rows($resql);
357  $i = 0;
358 
359  if ($numr > 0) {
360  $newmenu->add('/compta/bank/list.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire);
361  }
362 
363  while ($i < $numr) {
364  $objp = $db->fetch_object($resql);
365  $newmenu->add('/compta/bank/card.php?id='.$objp->rowid, $objp->label, 1, $user->rights->banque->lire);
366  if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) { // If not cash account and not closed and can be reconciliate
367  $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid, $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate);
368  }
369  $i++;
370  }
371  } else {
372  dol_print_error($db);
373  }
374  $db->free($resql);
375  }
376 
377  if (isModEnabled('accounting') && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account
378  $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->rights->accounting->comptarapport->lire, '', 'accountancy', 'accountancy_journal', 10);
379 
380  // Multi journal
381  $sql = "SELECT rowid, code, label, nature";
382  $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
383  $sql .= " WHERE entity = ".$conf->entity;
384  $sql .= " AND active = 1";
385  $sql .= " ORDER BY label DESC";
386 
387  $resql = $db->query($sql);
388  if ($resql) {
389  $numr = $db->num_rows($resql);
390  $i = 0;
391 
392  if ($numr > 0) {
393  while ($i < $numr) {
394  $objp = $db->fetch_object($resql);
395 
396  $nature = '';
397 
398  // Must match array $sourceList defined into journals_list.php
399  if ($objp->nature == 2 && isModEnabled('facture') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
400  $nature = "sells";
401  }
402  if ($objp->nature == 3
403  && ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_invoice'))
404  && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
405  $nature = "purchases";
406  }
407  if ($objp->nature == 4 && isModEnabled('banque')) {
408  $nature = "bank";
409  }
410  if ($objp->nature == 5 && isModEnabled('expensereport') && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
411  $nature = "expensereports";
412  }
413  if ($objp->nature == 1) {
414  $nature = "various";
415  }
416  if ($objp->nature == 8) {
417  $nature = "inventory";
418  }
419  if ($objp->nature == 9) {
420  $nature = "hasnew";
421  }
422 
423  // To enable when page exists
424  if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
425  if ($nature == 'hasnew' || $nature == 'inventory') {
426  $nature = '';
427  }
428  }
429 
430  if ($nature) {
431  $langs->load('accountancy');
432  $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ...
433  $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire);
434  }
435  $i++;
436  }
437  } else {
438  // Should not happend. Entries are added
439  $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire);
440  }
441  } else {
442  dol_print_error($db);
443  }
444  $db->free($resql);
445  }
446 
447  if (isModEnabled('ftp') && $mainmenu == 'ftp') { // Entry for FTP
448  $MAXFTP = 20;
449  $i = 1;
450  while ($i <= $MAXFTP) {
451  $paramkey = 'FTP_NAME_'.$i;
452  //print $paramkey;
453  if (!empty($conf->global->$paramkey)) {
454  $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
455 
456  $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24));
457  }
458  $i++;
459  }
460  }
461 
462 
463  // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
464  //var_dump($menu_array_before);exit;
465  //var_dump($menu_array_after);exit;
466  $menu_array = $newmenu->liste;
467  if (is_array($menu_array_before)) {
468  $menu_array = array_merge($menu_array_before, $menu_array);
469  }
470  if (is_array($menu_array_after)) {
471  $menu_array = array_merge($menu_array, $menu_array_after);
472  }
473  //var_dump($menu_array);exit;
474  if (!is_array($menu_array)) {
475  return 0;
476  }
477 
478  // Allow the $menu_array of the menu to be manipulated by modules
479  $parameters = array(
480  'mainmenu' => $mainmenu,
481  );
482  $hook_items = $menu_array;
483  $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
484 
485  if (is_numeric($reshook)) {
486  if ($reshook == 0 && !empty($hookmanager->results)) {
487  $menu_array[] = $hookmanager->results; // add
488  } elseif ($reshook == 1) {
489  $menu_array = $hookmanager->results; // replace
490  }
491 
492  // @todo Sort menu items by 'position' value
493  // $position = array();
494  // foreach ($menu_array as $key => $row) {
495  // $position[$key] = $row['position'];
496  // }
497  // $array1_sort_order = SORT_ASC;
498  // array_multisort($position, $array1_sort_order, $menu_array);
499  }
500 
501  // Show menu
502  $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert";
503  if (empty($noout)) {
504  $altok = 0;
505  $blockvmenuopened = false;
506  $lastlevel0 = '';
507  $num = count($menu_array);
508  for ($i = 0; $i < $num; $i++) { // Loop on each menu entry
509  $showmenu = true;
510  if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) {
511  $showmenu = false;
512  }
513 
514  // Begin of new left menu block
515  if (empty($menu_array[$i]['level']) && $showmenu) {
516  $altok++;
517  $blockvmenuopened = true;
518  $lastopened = true;
519  for ($j = ($i + 1); $j < $num; $j++) {
520  if (empty($menu_array[$j]['level'])) {
521  $lastopened = false;
522  }
523  }
524  if ($altok % 2 == 0) {
525  print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
526  } else {
527  print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
528  }
529  }
530 
531  // Add tabulation
532  $tabstring = '';
533  $tabul = ($menu_array[$i]['level'] - 1);
534  if ($tabul > 0) {
535  for ($j = 0; $j < $tabul; $j++) {
536  $tabstring .= '&nbsp;&nbsp;&nbsp;';
537  }
538  }
539 
540  // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
541 
542  $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
543 
544  $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
545  if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
546  $tmp = explode('?', $menu_array[$i]['url'], 2);
547  $url = $shorturl = $tmp[0];
548  $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link
549 
550  // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
551  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
552  $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
553  }
554  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
555  $param .= ($param ? '&' : '').'leftmenu=';
556  }
557  //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
558  $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
559  $shorturlwithoutparam = $shorturl;
560  $shorturl = $shorturl.($param ? '?'.$param : '');
561  }
562 
563 
564  print '<!-- Process menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' enabled='.$menu_array[$i]['enabled'].', position='.$menu_array[$i]['position'].' -->'."\n";
565 
566  // Menu level 0
567  if ($menu_array[$i]['level'] == 0) {
568  if ($menu_array[$i]['enabled']) { // Enabled so visible
569  print '<div class="menu_titre">'.$tabstring;
570  if ($shorturlwithoutparam) {
571  print '<a class="vmenu" title="'.dol_escape_htmltag(dol_string_nohtmltag($menu_array[$i]['titre'])).'" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>';
572  } else {
573  print '<span class="vmenu">';
574  }
575  print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre'];
576  if ($shorturlwithoutparam) {
577  print '</a>';
578  } else {
579  print '</span>';
580  }
581  print '</div>'."\n";
582  $lastlevel0 = 'enabled';
583  } elseif ($showmenu) { // Not enabled but visible (so greyed)
584  print '<div class="menu_titre">'.$tabstring;
585  print '<span class="vmenudisabled">';
586  print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre'];
587  print '</span>';
588  print '</div>'."\n";
589  $lastlevel0 = 'greyed';
590  } else {
591  $lastlevel0 = 'hidden';
592  }
593  if ($showmenu) {
594  print '<div class="menu_top"></div>'."\n";
595  }
596  }
597 
598  // Menu level > 0
599  if ($menu_array[$i]['level'] > 0) {
600  $cssmenu = '';
601  if ($menu_array[$i]['url']) {
602  $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
603  }
604 
605  if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {
606  // Enabled so visible, except if parent was not enabled.
607  print '<div class="menu_contenu'.$cssmenu.'">';
608  print $tabstring;
609  if ($shorturlwithoutparam) {
610  print '<a class="vsmenu" title="'.dol_escape_htmltag(dol_string_nohtmltag($menu_array[$i]['titre'])).'" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>';
611  } else {
612  print '<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i]['titre']).'">';
613  }
614  print $menu_array[$i]['titre'];
615  if ($shorturlwithoutparam) {
616  print '</a>';
617  } else {
618  print '</span>';
619  }
620  // If title is not pure text and contains a table, no carriage return added
621  if (!strstr($menu_array[$i]['titre'], '<table')) {
622  print '<br>';
623  }
624  print '</div>'."\n";
625  } elseif ($showmenu && $lastlevel0 == 'enabled') {
626  // Not enabled but visible (so greyed), except if parent was not enabled.
627  print '<div class="menu_contenu'.$cssmenu.'">';
628  print $tabstring;
629  print '<span class="spanlilevel0 vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</span><br>';
630  print '</div>'."\n";
631  }
632  }
633 
634  // If next is a new block or if there is nothing after
635  if (empty($menu_array[$i + 1]['level'])) { // End menu block
636  if ($showmenu) {
637  print '<div class="menu_end"></div>'."\n";
638  }
639  if ($blockvmenuopened) {
640  print '</div>'."\n";
641  $blockvmenuopened = false;
642  }
643  }
644  }
645 
646  if ($altok) {
647  print '<div class="blockvmenuend"></div>'; // End menu block
648  }
649  }
650 
651  return count($menu_array);
652 }
653 
654 
663 function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
664 {
665  global $conf;
666 
667  //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
668  //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
669  if (empty($menuentry['enabled'])) {
670  return 0; // Entry disabled by condition
671  }
672  if ($type_user && $menuentry['module']) {
673  $tmploops = explode('|', $menuentry['module']);
674  $found = 0;
675  foreach ($tmploops as $tmploop) {
676  if (in_array($tmploop, $listofmodulesforexternal)) {
677  $found++;
678  break;
679  }
680  }
681  if (!$found) {
682  return 0; // Entry is for menus all excluded to external users
683  }
684  }
685  if (!$menuentry['perms'] && $type_user) {
686  return 0; // No permissions and user is external
687  }
688  if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
689  return 0; // No permissions and option to hide when not allowed, even for internal user, is on
690  }
691  if (!$menuentry['perms']) {
692  return 2; // No permissions and user is external
693  }
694  return 1;
695 }
print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget)
Output menu entry.
print_start_menu_entry_auguria($idsel, $classname, $showmode)
Output start menu entry.
print_end_menu_array_auguria()
Output menu array.
print_end_menu_entry_auguria($showmode)
Output end menu entry.
print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout=0, $forcemainmenu='', $forceleftmenu='', $moredata=null, $type_user=0)
Core function to output left menu auguria Fill &$menu (example with $forcemainmenu='home' $forceleftm...
print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout=0, $mode='')
Core function to output top menu auguria.
Definition: auguria.lib.php:40
print_start_menu_array_auguria()
Output start menu array.
dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
const TYPE_CASH
Cash account.
Class to manage menu entries.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isModEnabled($module)
Is Dolibarr module enabled.