dolibarr 19.0.3
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
24require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
25
26
27
40function 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(',', getDolGlobalString('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 && !getDolGlobalString('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, $newTabMenu[$i]['prefix']);
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 (!getDolGlobalString('MAIN_MENU_INVERT') && empty($noout) && getDolGlobalString('MAIN_SHOW_LOGO') && !getDolGlobalString('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 = (!getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI);
143
144 $logoContainerAdditionalClass = 'backgroundforcompanylogo';
145 if (getDolGlobalString('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), $menuval);
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);
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"'.(!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '' : ' title="Top menu"').'>';
200}
201
210function 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
232function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array())
233{
234 global $langs, $conf;
235
236 $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
237 $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
238
239 if ($showmode == 1) {
240 print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
241 print '<div class="'.$id.' '.$idsel.' topmenuimage">';
242
243 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
244 print $menuval['prefix'];
245 } elseif (!empty($menuval['prefix']) && strpos($menuval['prefix'], 'fa-') === 0) {
246 print '<span class="'.$id.' '.$menuval['prefix'].'" id="mainmenuspan_'.$idsel.'"></span>';
247 } else {
248 print '<span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span>';
249 }
250 print '</div>';
251 print '</a>';
252 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
253 print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
254 print '<span class="mainmenuaspan">';
255 print $text;
256 print '</span>';
257 print '</a>';
258 }
259 } elseif ($showmode == 2) {
260 print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
261 print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled">';
262 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
263 print $menuval['prefix'];
264 } else {
265 print '<span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span>';
266 }
267 print '</div>';
268 print '</div>';
269 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
270 print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
271 print '<span class="mainmenuaspan">';
272 print $text;
273 print '</span>';
274 print '</span>';
275 }
276 }
277}
278
286{
287 if ($showmode) {
288 print '</div></li>';
289 }
290 print "\n";
291}
292
299{
300 print '</ul>';
301 print '</div>';
302 print "\n";
303}
304
305
306
323function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
324{
325 global $user, $conf, $langs, $hookmanager;
326 global $dolibarr_main_db_name, $mysoc;
327
328 $newmenu = $menu;
329
330 $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]);
331 $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]));
332
333 global $usemenuhider;
334 $usemenuhider = 0;
335
336 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
337 print "\n";
338 print "<!-- Begin SearchForm -->\n";
339 print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
340 print $moredata['searchform'];
341 print '</div>'."\n";
342 print "<!-- End SearchForm -->\n";
343 }
344
345 if (is_array($moredata) && !empty($moredata['bookmarks'])) {
346 print "\n";
347 print "<!-- Begin Bookmarks -->\n";
348 print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
349 print $moredata['bookmarks'];
350 print '</div>'."\n";
351 print "<!-- End Bookmarks -->\n";
352 }
353
354 $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
355
356 // We update newmenu with entries found into database
357 $menuArbo = new Menubase($db, 'auguria');
358 $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, ($user->socid ? 1 : 0), 'auguria', $tabMenu);
359
360 // We update newmenu for special dynamic menus
361 if (isModEnabled('banque') && $user->hasRight('banque', 'lire') && $mainmenu == 'bank') { // Entry for each bank account
362 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example
363
364 $sql = "SELECT rowid, label, courant, rappro, courant";
365 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
366 $sql .= " WHERE entity = ".$conf->entity;
367 $sql .= " AND clos = 0";
368 $sql .= " ORDER BY label";
369
370 $resql = $db->query($sql);
371 if ($resql) {
372 $numr = $db->num_rows($resql);
373 $i = 0;
374
375 if ($numr > 0) {
376 $newmenu->add('/compta/bank/list.php', $langs->trans("BankAccounts"), 0, $user->hasRight('banque', 'lire'));
377 }
378
379 while ($i < $numr) {
380 $objp = $db->fetch_object($resql);
381 $newmenu->add('/compta/bank/card.php?id='.$objp->rowid, $objp->label, 1, $user->hasRight('banque', 'lire'));
382 if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) { // If not cash account and not closed and can be reconciliate
383 $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid, $langs->trans("Conciliate"), 2, $user->hasRight('banque', 'consolidate'));
384 }
385 $i++;
386 }
387 } else {
388 dol_print_error($db);
389 }
390 $db->free($resql);
391 }
392
393 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account
394 $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', 'accountancy', 'accountancy_journal', 10);
395
396 // Multi journal
397 $sql = "SELECT rowid, code, label, nature";
398 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
399 $sql .= " WHERE entity = ".$conf->entity;
400 $sql .= " AND active = 1";
401 $sql .= " ORDER BY label DESC";
402
403 $resql = $db->query($sql);
404 if ($resql) {
405 $numr = $db->num_rows($resql);
406 $i = 0;
407
408 if ($numr > 0) {
409 while ($i < $numr) {
410 $objp = $db->fetch_object($resql);
411
412 $nature = '';
413
414 // Must match array $sourceList defined into journals_list.php
415 if ($objp->nature == 2 && isModEnabled('facture') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
416 $nature = "sells";
417 }
418 if ($objp->nature == 3
419 && isModEnabled('supplier_invoice')
420 && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
421 $nature = "purchases";
422 }
423 if ($objp->nature == 4 && isModEnabled('banque')) {
424 $nature = "bank";
425 }
426 if ($objp->nature == 5 && isModEnabled('expensereport') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
427 $nature = "expensereports";
428 }
429 if ($objp->nature == 1) {
430 $nature = "various";
431 }
432 if ($objp->nature == 8) {
433 $nature = "inventory";
434 }
435 if ($objp->nature == 9) {
436 $nature = "hasnew";
437 }
438
439 // To enable when page exists
440 if (!getDolGlobalString('ACCOUNTANCY_SHOW_DEVELOP_JOURNAL')) {
441 if ($nature == 'hasnew' || $nature == 'inventory') {
442 $nature = '';
443 }
444 }
445
446 if ($nature) {
447 $langs->load('accountancy');
448 $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ...
449 $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
450 }
451 $i++;
452 }
453 } else {
454 // Should not happend. Entries are added
455 $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
456 }
457 } else {
458 dol_print_error($db);
459 }
460 $db->free($resql);
461 }
462
463 if (isModEnabled('ftp') && $mainmenu == 'ftp') { // Entry for FTP
464 $MAXFTP = 20;
465 $i = 1;
466 while ($i <= $MAXFTP) {
467 $paramkey = 'FTP_NAME_'.$i;
468 //print $paramkey;
469 if (!empty($conf->global->$paramkey)) {
470 $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
471
472 $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24));
473 }
474 $i++;
475 }
476 }
477
478
479 // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
480 //var_dump($menu_array_before);exit;
481 //var_dump($menu_array_after);exit;
482 $menu_array = $newmenu->liste;
483 if (is_array($menu_array_before)) {
484 $menu_array = array_merge($menu_array_before, $menu_array);
485 }
486 if (is_array($menu_array_after)) {
487 $menu_array = array_merge($menu_array, $menu_array_after);
488 }
489 //var_dump($menu_array);exit;
490 if (!is_array($menu_array)) {
491 return 0;
492 }
493
494 // Allow the $menu_array of the menu to be manipulated by modules
495 $parameters = array(
496 'mainmenu' => $mainmenu,
497 );
498 $hook_items = $menu_array;
499 $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
500
501 if (is_numeric($reshook)) {
502 if ($reshook == 0 && !empty($hookmanager->results)) {
503 $menu_array[] = $hookmanager->results; // add
504 } elseif ($reshook == 1) {
505 $menu_array = $hookmanager->results; // replace
506 }
507
508 // @todo Sort menu items by 'position' value
509 // $position = array();
510 // foreach ($menu_array as $key => $row) {
511 // $position[$key] = $row['position'];
512 // }
513 // $array1_sort_order = SORT_ASC;
514 // array_multisort($position, $array1_sort_order, $menu_array);
515 }
516
517 // Show menu
518 $invert = !getDolGlobalString('MAIN_MENU_INVERT') ? "" : "invert";
519 if (empty($noout)) {
520 $altok = 0;
521 $blockvmenuopened = false;
522 $lastlevel0 = '';
523 $num = count($menu_array);
524 for ($i = 0; $i < $num; $i++) { // Loop on each menu entry
525 $showmenu = true;
526 if (getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED') && empty($menu_array[$i]['enabled'])) {
527 $showmenu = false;
528 }
529
530 // Begin of new left menu block
531 if (empty($menu_array[$i]['level']) && $showmenu) {
532 $altok++;
533 $blockvmenuopened = true;
534 $lastopened = true;
535 for ($j = ($i + 1); $j < $num; $j++) {
536 if (empty($menu_array[$j]['level'])) {
537 $lastopened = false;
538 }
539 }
540 if ($altok % 2 == 0) {
541 print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
542 } else {
543 print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
544 }
545 }
546
547 // Add tabulation
548 $tabstring = '';
549 $tabul = ($menu_array[$i]['level'] - 1);
550 if ($tabul > 0) {
551 for ($j = 0; $j < $tabul; $j++) {
552 $tabstring .= '&nbsp;&nbsp;&nbsp;';
553 }
554 }
555
556 // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
557
558 $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
559
560 $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
561 if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
562 $tmp = explode('?', $menu_array[$i]['url'], 2);
563 $url = $shorturl = $tmp[0];
564 $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link
565
566 // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
567 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
568 $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
569 }
570 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
571 $param .= ($param ? '&' : '').'leftmenu=';
572 }
573 //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
574 $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
575 $shorturlwithoutparam = $shorturl;
576 $shorturl = $shorturl.($param ? '?'.$param : '');
577 }
578
579
580 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'].' prefix='.$menu_array[$i]['prefix'].' -->'."\n";
581
582 // Menu level 0
583 if ($menu_array[$i]['level'] == 0) {
584 if ($menu_array[$i]['enabled']) { // Enabled so visible
585 print '<div class="menu_titre">'.$tabstring;
586 if ($shorturlwithoutparam) {
587 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'].'"' : '').'>';
588 } else {
589 print '<span class="vmenu">';
590 }
591 if (!empty($menu_array[$i]['prefix'])) {
592 if (preg_match('/^fa\-[a-zA-Z0-9\-_]+$/', $menu_array[$i]['prefix'])) {
593 print '<span class="fas '.$menu_array[$i]['prefix'].' paddingright pictofixedwidth"></span>';
594 } else {
595 print $menu_array[$i]['prefix'];
596 }
597 }
598
599 // print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '');
600 print $menu_array[$i]['titre'];
601 if ($shorturlwithoutparam) {
602 print '</a>';
603 } else {
604 print '</span>';
605 }
606 print '</div>'."\n";
607 $lastlevel0 = 'enabled';
608 } elseif ($showmenu) { // Not enabled but visible (so greyed)
609 print '<div class="menu_titre">'.$tabstring;
610 print '<span class="vmenudisabled">';
611 if (!empty($menu_array[$i]['prefix'])) {
612 print $menu_array[$i]['prefix'];
613 }
614 print $menu_array[$i]['titre'];
615 print '</span>';
616 print '</div>'."\n";
617 $lastlevel0 = 'greyed';
618 } else {
619 $lastlevel0 = 'hidden';
620 }
621 if ($showmenu) {
622 print '<div class="menu_top"></div>'."\n";
623 }
624 }
625
626 // Menu level > 0
627 if ($menu_array[$i]['level'] > 0) {
628 $cssmenu = '';
629 if ($menu_array[$i]['url']) {
630 $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
631 }
632
633 if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {
634 // Enabled so visible, except if parent was not enabled.
635 print '<div class="menu_contenu'.$cssmenu.'">';
636 print $tabstring;
637 if ($shorturlwithoutparam) {
638 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'].'"' : '').'>';
639 } else {
640 print '<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i]['titre']).'">';
641 }
642 print $menu_array[$i]['titre'];
643 if ($shorturlwithoutparam) {
644 print '</a>';
645 } else {
646 print '</span>';
647 }
648 // If title is not pure text and contains a table, no carriage return added
649 if (!strstr($menu_array[$i]['titre'], '<table')) {
650 print '<br>';
651 }
652 print '</div>'."\n";
653 } elseif ($showmenu && $lastlevel0 == 'enabled') {
654 // Not enabled but visible (so greyed), except if parent was not enabled.
655 print '<div class="menu_contenu'.$cssmenu.'">';
656 print $tabstring;
657 print '<span class="spanlilevel0 vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</span><br>';
658 print '</div>'."\n";
659 }
660 }
661
662 // If next is a new block or if there is nothing after
663 if (empty($menu_array[$i + 1]['level'])) { // End menu block
664 if ($showmenu) {
665 print '<div class="menu_end"></div>'."\n";
666 }
667 if ($blockvmenuopened) {
668 print '</div>'."\n";
669 $blockvmenuopened = false;
670 }
671 }
672 }
673
674 if ($altok) {
675 print '<div class="blockvmenuend"></div>'; // End menu block
676 }
677 }
678
679 return count($menu_array);
680}
681
682
691function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
692{
693 global $conf;
694
695 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
696 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
697 if (empty($menuentry['enabled'])) {
698 return 0; // Entry disabled by condition
699 }
700 if ($type_user && $menuentry['module']) {
701 $tmploops = explode('|', $menuentry['module']);
702 $found = 0;
703 foreach ($tmploops as $tmploop) {
704 if (in_array($tmploop, $listofmodulesforexternal)) {
705 $found++;
706 break;
707 }
708 }
709 if (!$found) {
710 return 0; // Entry is for menus all excluded to external users
711 }
712 }
713 if (!$menuentry['perms'] && $type_user) {
714 return 0; // No permissions and user is external
715 }
716 if (!$menuentry['perms'] && getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED')) {
717 return 0; // No permissions and option to hide when not allowed, even for internal user, is on
718 }
719 if (!$menuentry['perms']) {
720 return 2; // No permissions and user is external
721 }
722 return 1;
723}
print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval=array())
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.
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.
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 a 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.
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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
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...