dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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 * or see https://www.gnu.org/
20 */
21
26require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
27
28
29
42function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '')
43{
44 global $user, $conf, $langs, $mysoc;
45 global $dolibarr_main_db_name;
46
47 $mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
48 $leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
49
50 $id = 'mainmenu';
51 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
52
53 // Show personalized menus
54 $menuArbo = new Menubase($db, 'auguria');
55 $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria', $tabMenu);
56 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu';
57
58 $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
59
60 if (empty($noout)) {
62 }
63
64 global $usemenuhider;
65 $usemenuhider = 1;
66
67 // Show/Hide vertical menu. The hamburger icon for .menuhider action.
68 if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
69 $showmode = 1;
70 $classname = 'class="tmenu menuhider nohover"';
71 $idsel = 'menu';
72
73 $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '<span class="fa fa-bars"></span>' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname, '<span class="fas fa-bars size12x"></span>');
74 }
75
76 $num = count($newTabMenu);
77 for ($i = 0; $i < $num; $i++) {
78 //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']);
79 $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']);
80
81 $shorturl = '';
82
83 $showmode = dol_auguria_showmenu($type_user, $newTabMenu[$i], $listofmodulesforexternal);
84 if ($showmode == 1) {
85 $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray);
86 // url = url from host, shorturl = relative path into dolibarr sources
87 $url = $shorturl = $newTabMenu[$i]['url'];
88
89 if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links
90 $tmp = explode('?', $newTabMenu[$i]['url'], 2);
91 $url = $shorturl = $tmp[0];
92 $param = (isset($tmp[1]) ? $tmp[1] : '');
93
94 // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
95 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($newTabMenu[$i]['url'])) {
96 // @phan-suppress-next-line PhanTypeSuspiciousStringExpression,PhanTypeInvalidDimOffset
97 $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
98 }
99 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($newTabMenu[$i]['url'])) {
100 $param .= ($param ? '&' : '').'leftmenu=';
101 }
102 //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
103 $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
104 //$shorturl = $shorturl.($param?'?'.$param:'');
105 $shorturl = $url;
106
107 if (DOL_URL_ROOT) {
108 $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl);
109 }
110 }
111
112 // Phan issue #4881 requires that we reforce the type
113 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu';
114
115 // TODO Find a generic solution
116 if (preg_match('/search_project_user=__search_project_user__/', $shorturl)) {
117 $search_project_user = GETPOSTINT('search_project_user');
118 if ($search_project_user) {
119 $shorturl = preg_replace('/search_project_user=__search_project_user__/', 'search_project_user='.$search_project_user, $shorturl);
120 } else {
121 $shorturl = preg_replace('/search_project_user=__search_project_user__/', '', $shorturl);
122 }
123 }
124
125 // Phan issue #4881 requires that we reforce the type
126 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string}> $newTabMenu';
127
128 // Define the class (top menu selected or not)
129 if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) {
130 $classname = 'class="tmenusel"';
131 } elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) {
132 $classname = 'class="tmenusel"';
133 } else {
134 $classname = 'class="tmenu"';
135 }
136 } elseif ($showmode == 2) {
137 $classname = 'class="tmenu"';
138 } else {
139 $classname = '';
140 }
141
142 $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']);
143 }
144
145 // Sort on position
146 $menu->liste = dol_sort_array($menu->liste, 'position');
147
148 // Output menu entries
149 // Show logo company
150 if (!getDolGlobalString('MAIN_MENU_INVERT') && empty($noout) && getDolGlobalString('MAIN_SHOW_LOGO') && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
151 //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI);
152 $mysoc->logo_squarred_mini = (!getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI);
153
154 $logoContainerAdditionalClass = 'backgroundforcompanylogo';
155 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND')) {
156 $logoContainerAdditionalClass = '';
157 }
158
159 if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
160 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
161 /*} elseif (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
162 {
163 $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
164 }*/
165 } else {
166 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png';
167 $logoContainerAdditionalClass = '';
168 }
169
170 $title = $langs->trans("GoIntoSetupToChangeLogo");
171
172 print "\n".'<!-- Show logo on menu -->'."\n";
173 print_start_menu_entry_auguria('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1);
174
175 print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n";
176
178 }
179
180 if (empty($noout)) {
181 foreach ($menu->liste as $menuval) {
182 print_start_menu_entry_auguria($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
183 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);
184 print_end_menu_entry_auguria($menuval['enabled']);
185 }
186 }
187
188 $showmode = 1;
189 if (empty($noout) && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
190 print_start_menu_entry_auguria('', 'class="tmenuend"', $showmode);
193 }
194
195 return 0;
196}
197
198
205{
206 print '<div class="tmenudiv">';
207 print '<ul role="navigation" class="tmenu"'.(getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ' alt="Top menu"' : '').'>';
208}
209
218function print_start_menu_entry_auguria($idsel, $classname, $showmode)
219{
220 if ($showmode) {
221 print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
222 //print '<div class="tmenuleft tmenusep"></div>';
223 print '<div class="tmenucenter">';
224 }
225}
226
240function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array())
241{
242 global $langs;
243
244 $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
245 $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
246
247 if ($showmode == 1) {
248 print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
249 print '<div class="'.$id.' '.$idsel.' topmenuimage">';
250 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
251 print $menuval['prefix'];
252 } elseif (!empty($menuval['prefix']) && strpos($menuval['prefix'], 'fa-') === 0) {
253 print '<span class="'.$id.' '.$menuval['prefix'].'" id="mainmenuspan_'.$idsel.'"></span>';
254 } else {
255 print '<span class="'.$id.' tmenuimageforpng" id="mainmenuspan_'.$idsel.'"></span>';
256 }
257 print '</div>';
258 print '</a>';
259 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
260 print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
261 print '<span class="mainmenuaspan">';
262 print $text;
263 print '</span>';
264 print '</a>';
265 }
266 } elseif ($showmode == 2) {
267 print '<div '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
268 print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled">';
269 if (!empty($menuval['prefix']) && strpos($menuval['prefix'], '<span') === 0) {
270 print $menuval['prefix'];
271 } else {
272 print '<span class="'.$id.' tmenuimageforpng tmenudisabled" id="mainmenuspan_'.$idsel.'"></span>';
273 }
274 print '</div>';
275 print '</div>';
276 if (!getDolGlobalString('THEME_TOPMENU_DISABLE_TEXT')) {
277 print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
278 print '<span class="mainmenuaspan">';
279 print $text;
280 print '</span>';
281 print '</span>';
282 }
283 }
284}
285
293{
294 if ($showmode) {
295 print '</div></li>';
296 }
297 print "\n";
298}
299
306{
307 print '</ul>';
308 print '</div>';
309 print "\n";
310}
311
312
313
330function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0)
331{
332 global $user, $conf, $langs, $hookmanager;
333 global $dolibarr_main_db_name, $mysoc;
334
335 $newmenu = $menu;
336
337 $mainmenu = ($forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]);
338 $leftmenu = ($forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]));
339
340 global $usemenuhider;
341 $usemenuhider = 0;
342
343 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
344 print "\n";
345 print "<!-- Begin SearchForm -->\n";
346 print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
347 print $moredata['searchform'];
348 print '</div>'."\n";
349 print "<!-- End SearchForm -->\n";
350 }
351
352 if (is_array($moredata) && !empty($moredata['bookmarks'])) {
353 print "\n";
354 print "<!-- Begin Bookmarks -->\n";
355 print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
356 print $moredata['bookmarks'];
357 print '</div>'."\n";
358 print "<!-- End Bookmarks -->\n";
359 }
360
361 $substitarray = getCommonSubstitutionArray($langs, 0, null, null);
362
363 // We update newmenu with entries found into database
364 $menuArbo = new Menubase($db, 'auguria');
365 $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, ($user->socid ? 1 : 0), 'auguria', $tabMenu);
366
367 // We update newmenu for special dynamic menus
368 if (isModEnabled('bank') && $user->hasRight('banque', 'lire') && $mainmenu == 'bank') { // Entry for each bank account
369 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example
370
371 $sql = "SELECT rowid, label, courant, rappro, courant";
372 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
373 $sql .= " WHERE entity = ".$conf->entity;
374 $sql .= " AND clos = 0";
375 $sql .= " ORDER BY label";
376
377 $resql = $db->query($sql);
378 if ($resql) {
379 $numr = $db->num_rows($resql);
380 $i = 0;
381
382 if ($numr > 0) {
383 $newmenu->add('/compta/bank/list.php?search_status=opened', $langs->trans("BankAccounts"), 0, $user->hasRight('banque', 'lire'));
384 }
385
386 while ($i < $numr) {
387 $objp = $db->fetch_object($resql);
388 $newmenu->add('/compta/bank/card.php?id='.$objp->rowid, $objp->label, 1, $user->hasRight('banque', 'lire'));
389 if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) { // If not cash account and not closed and can be reconciliate
390 $newmenu->add('/compta/bank/bankentries_list.php?id='.$objp->rowid, $langs->trans("Conciliate"), 2, $user->hasRight('banque', 'consolidate'));
391 }
392 $i++;
393 }
394 } else {
395 dol_print_error($db);
396 }
397 $db->free($resql);
398 }
399
400 if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account
401 $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', 'accountancy', 'accountancy_journal', 10);
402
403 // Multi journal
404 $sql = "SELECT rowid, code, label, nature";
405 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
406 $sql .= " WHERE entity = ".$conf->entity;
407 $sql .= " AND active = 1";
408 $sql .= " ORDER BY label DESC";
409
410 $resql = $db->query($sql);
411 if ($resql) {
412 $numr = $db->num_rows($resql);
413 $i = 0;
414
415 if ($numr > 0) {
416 while ($i < $numr) {
417 $objp = $db->fetch_object($resql);
418
419 $nature = '';
420
421 // Must match array $sourceList defined into journals_list.php
422 if ($objp->nature == 2 && isModEnabled('invoice') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
423 $nature = "sells";
424 }
425 if ($objp->nature == 3
426 && isModEnabled('supplier_invoice')
427 && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
428 $nature = "purchases";
429 }
430 if ($objp->nature == 4 && isModEnabled('bank')) {
431 $nature = "bank";
432 }
433 if ($objp->nature == 5 && isModEnabled('expensereport') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
434 $nature = "expensereports";
435 }
436 if ($objp->nature == 1) {
437 $nature = "various";
438 }
439 if ($objp->nature == 8) {
440 $nature = "inventory";
441 }
442 if ($objp->nature == 9) {
443 $nature = "hasnew";
444 }
445
446 // To enable when page exists
447 if (!getDolGlobalString('ACCOUNTANCY_SHOW_DEVELOP_JOURNAL')) {
448 if ($nature == 'hasnew' || $nature == 'inventory') {
449 $nature = '';
450 }
451 }
452
453 if ($nature) {
454 $langs->load('accountancy');
455 $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ...
456 $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
457 }
458 $i++;
459 }
460 } else {
461 // Should not happen. Entries are added
462 $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire'));
463 }
464 } else {
465 dol_print_error($db);
466 }
467 $db->free($resql);
468 }
469
470 if (isModEnabled('ftp') && $mainmenu == 'ftp') { // Entry for FTP
471 $MAXFTP = 20;
472 $i = 1;
473 while ($i <= $MAXFTP) {
474 $paramkey = 'FTP_NAME_'.$i;
475 //print $paramkey;
476 if (getDolGlobalString($paramkey)) {
477 $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
478
479 $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24));
480 }
481 $i++;
482 }
483 }
484
485
486 // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
487 //var_dump($menu_array_before);exit;
488 //var_dump($menu_array_after);exit;
489 $menu_array = $newmenu->liste;
490 if (is_array($menu_array_before)) {
491 $menu_array = array_merge($menu_array_before, $menu_array);
492 }
493 if (is_array($menu_array_after)) {
494 $menu_array = array_merge($menu_array, $menu_array_after);
495 }
496 //var_dump($menu_array);exit;
497 if (!is_array($menu_array)) {
498 return 0;
499 }
500
501 // Allow the $menu_array of the menu to be manipulated by modules
502 $parameters = array(
503 'mainmenu' => $mainmenu,
504 );
505 $hook_items = $menu_array;
506 $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
507
508 if (is_numeric($reshook)) {
509 if ($reshook == 0 && !empty($hookmanager->resArray)) {
510 $menu_array[] = $hookmanager->resArray; // add
511 } elseif ($reshook == 1) {
512 $menu_array = $hookmanager->resArray; // replace
513 }
514
515 // @todo Sort menu items by 'position' value
516 // $position = array();
517 // foreach ($menu_array as $key => $row) {
518 // $position[$key] = $row['position'];
519 // }
520 // $array1_sort_order = SORT_ASC;
521 // array_multisort($position, $array1_sort_order, $menu_array);
522 }
523
524 // Phan has a hard time tracking the type, for instance because it get hookmanager->results
525 // Force the typing at this point to get useful analysis below:
526 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,prefix:string,level:int}> $menu_array';
527
528 // Show menu
529 $invert = !getDolGlobalString('MAIN_MENU_INVERT') ? "" : "invert";
530 if (empty($noout)) {
531 $altok = 0;
532 $blockvmenuopened = false;
533 $lastlevel0 = '';
534 $num = count($menu_array);
535 foreach (array_keys($menu_array) as $i) { // Loop on each menu entry (foreach better for static analysis)
536 $showmenu = true;
537 if (getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED') && empty($menu_array[$i]['enabled'])) {
538 $showmenu = false;
539 }
540
541 // Begin of new left menu block
542 if (empty($menu_array[$i]['level']) && $showmenu) {
543 $altok++;
544 $blockvmenuopened = true;
545 $lastopened = true;
546 for ($j = ($i + 1); $j < $num; $j++) {
547 if (empty($menu_array[$j]['level'])) {
548 $lastopened = false;
549 }
550 }
551 if ($altok % 2 == 0) {
552 print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
553 } else {
554 print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n";
555 }
556 }
557
558 // Add tabulation
559 $tabstring = '';
560 $tabul = ($menu_array[$i]['level'] - 1);
561 if ($tabul > 0) {
562 for ($j = 0; $j < $tabul; $j++) {
563 $tabstring .= '&nbsp;&nbsp;&nbsp;';
564 }
565 }
566
567 // $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
568
569 $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray);
570
571 $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url'];
572 if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
573 $tmp = explode('?', $menu_array[$i]['url'], 2);
574 $url = $shorturl = $tmp[0];
575 $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link
576
577 // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
578 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
579 $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
580 }
581 if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
582 $param .= ($param ? '&' : '').'leftmenu=';
583 }
584 //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
585 $url = dol_buildpath($url, 1).($param ? '?'.$param : '');
586 $shorturlwithoutparam = $shorturl;
587 $shorturl .= ($param ? '?'.$param : '');
588 }
589
590
591 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";
592
593 // Menu level 0
594 if ($menu_array[$i]['level'] == 0) {
595 if ($menu_array[$i]['enabled']) { // Enabled so visible
596 print '<div class="menu_titre">'.$tabstring;
597 if ($shorturlwithoutparam) {
598 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'].'"' : '').'>';
599 } else {
600 print '<span class="vmenu">';
601 }
602 if (!empty($menu_array[$i]['prefix'])) {
603 if (preg_match('/^fa\-[a-zA-Z0-9\-_]+$/', $menu_array[$i]['prefix'])) {
604 print '<span class="fas '.$menu_array[$i]['prefix'].' paddingright pictofixedwidth"></span>';
605 } else {
606 print $menu_array[$i]['prefix'];
607 }
608 }
609
610 // print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '');
611 print $menu_array[$i]['titre'];
612 if ($shorturlwithoutparam) {
613 print '</a>';
614 } else {
615 print '</span>';
616 }
617 print '</div>'."\n";
618 $lastlevel0 = 'enabled';
619 } elseif ($showmenu) { // Not enabled but visible (so greyed)
620 print '<div class="menu_titre">'.$tabstring;
621 print '<span class="vmenudisabled">';
622 if (!empty($menu_array[$i]['prefix'])) {
623 print $menu_array[$i]['prefix'];
624 }
625 print $menu_array[$i]['titre'];
626 print '</span>';
627 print '</div>'."\n";
628 $lastlevel0 = 'greyed';
629 } else {
630 $lastlevel0 = 'hidden';
631 }
632 if ($showmenu) {
633 print '<div class="menu_top"></div>'."\n";
634 }
635 }
636
637 // Menu level > 0
638 if ($menu_array[$i]['level'] > 0) {
639 $cssmenu = '';
640 if ($menu_array[$i]['url']) {
641 $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
642 }
643
644 if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {
645 // Enabled so visible, except if parent was not enabled.
646 print '<div class="menu_contenu'.$cssmenu.'">';
647 print $tabstring;
648 if ($shorturlwithoutparam) {
649 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'].'"' : '').'>';
650 } else {
651 print '<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i]['titre']).'">';
652 }
653 print $menu_array[$i]['titre'];
654 if ($shorturlwithoutparam) {
655 print '</a>';
656 } else {
657 print '</span>';
658 }
659 // If title is not pure text and contains a table, no carriage return added
660 if (!strstr($menu_array[$i]['titre'], '<table')) {
661 print '<br>';
662 }
663 print '</div>'."\n";
664 } elseif ($showmenu && $lastlevel0 == 'enabled') {
665 // Not enabled but visible (so greyed), except if parent was not enabled.
666 print '<div class="menu_contenu'.$cssmenu.'">';
667 print $tabstring;
668 print '<span class="spanlilevel0 vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</span><br>';
669 print '</div>'."\n";
670 }
671 }
672
673 // If next is a new block or if there is nothing after
674 if (empty($menu_array[$i + 1]['level'])) { // End menu block
675 if ($showmenu) {
676 print '<div class="menu_end"></div>'."\n";
677 }
678 if ($blockvmenuopened) {
679 print '</div>'."\n";
680 $blockvmenuopened = false;
681 }
682 }
683 }
684
685 if ($altok) {
686 print '<div class="blockvmenuend"></div>'; // End menu block
687 }
688 }
689
690 return count($menu_array);
691}
692
693
702function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
703{
704 global $conf;
705
706 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
707 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
708 if (empty($menuentry['enabled'])) {
709 return 0; // Entry disabled by condition
710 }
711 if ($type_user && $menuentry['module']) {
712 $tmploops = explode('|', (string) $menuentry['module']);
713 $found = 0;
714 foreach ($tmploops as $tmploop) {
715 if (in_array($tmploop, $listofmodulesforexternal)) {
716 $found++;
717 break;
718 }
719 }
720 if (!$found) {
721 return 0; // Entry is for menus all excluded to external users
722 }
723 }
724 if (!$menuentry['perms'] && $type_user) {
725 return 0; // No permissions and user is external
726 }
727 if (!$menuentry['perms'] && getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED')) {
728 return 0; // No permissions and option to hide when not allowed, even for internal user, is on
729 }
730 if (!$menuentry['perms']) {
731 return 2; // No permissions and user is external
732 }
733 return 1;
734}
$id
Definition account.php:48
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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 the value of a given key, which produces ascending (default) or descending out...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79