auguria.lib.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <?php
  2. /* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/menus/standard/auguria.lib.php
  21. * \brief Library for file auguria menus
  22. */
  23. require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
  24. /**
  25. * Core function to output top menu auguria
  26. *
  27. * @param DoliDB $db Database handler
  28. * @param string $atarget Target
  29. * @param int $type_user 0=Menu for backoffice, 1=Menu for front office
  30. * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
  31. * @param Menu $menu Object Menu to return back list of menu entries
  32. * @param int $noout Disable output (Initialise &$menu only).
  33. * @param string $mode 'top', 'topnb', 'left', 'jmobile'
  34. * @return int 0
  35. */
  36. function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode='')
  37. {
  38. global $user,$conf,$langs,$dolibarr_main_db_name;
  39. $mainmenu=$_SESSION["mainmenu"];
  40. $leftmenu=$_SESSION["leftmenu"];
  41. $id='mainmenu';
  42. $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
  43. // Show personalized menus
  44. $menuArbo = new Menubase($db,'auguria');
  45. $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu);
  46. if (empty($noout)) print_start_menu_array_auguria();
  47. // Show/Hide vertical menu
  48. if ($mode != 'jmobile' && $mode != 'topnb' && (GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  49. {
  50. $showmode=1;
  51. $classname = 'class="tmenu menuhider"';
  52. $idsel='menu';
  53. if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode);
  54. if (empty($noout)) print_text_menu_entry_auguria('', 1, '#', $id, $idsel, $classname, $atarget);
  55. if (empty($noout)) print_end_menu_entry_auguria($showmode);
  56. $menu->add('#', '', 0, $showmode, $atarget, "xxx", '');
  57. }
  58. $num = count($newTabMenu);
  59. for($i = 0; $i < $num; $i++)
  60. {
  61. $idsel=(empty($newTabMenu[$i]['mainmenu'])?'none':$newTabMenu[$i]['mainmenu']);
  62. $showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
  63. if ($showmode == 1)
  64. {
  65. $url = $shorturl = $newTabMenu[$i]['url'];
  66. if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
  67. {
  68. $tmp=explode('?',$newTabMenu[$i]['url'],2);
  69. $url = $shorturl = $tmp[0];
  70. $param = (isset($tmp[1])?$tmp[1]:'');
  71. // Complete param to force leftmenu to '' to closed opend menu when we click on a link with no leftmenu defined.
  72. if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url']))
  73. {
  74. $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['url'].'&leftmenu=';
  75. }
  76. if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url']))
  77. {
  78. $param.=($param?'&':'').'leftmenu=';
  79. }
  80. //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
  81. $url = dol_buildpath($url,1).($param?'?'.$param:'');
  82. $shorturl = $shorturl.($param?'?'.$param:'');
  83. }
  84. $url=preg_replace('/__LOGIN__/',$user->login,$url);
  85. $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl);
  86. $url=preg_replace('/__USERID__/',$user->id,$url);
  87. $shorturl=preg_replace('/__USERID__/',$user->id,$shorturl);
  88. // Define the class (top menu selected or not)
  89. if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
  90. else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"';
  91. else $classname='class="tmenu"';
  92. }
  93. else if ($showmode == 2) $classname='class="tmenu"';
  94. if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode);
  95. if (empty($noout)) print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget));
  96. if (empty($noout)) print_end_menu_entry_auguria($showmode);
  97. $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), '');
  98. }
  99. $showmode=1;
  100. if (empty($noout)) print_start_menu_entry_auguria('','class="tmenuend"',$showmode);
  101. if (empty($noout)) print_end_menu_entry_auguria($showmode);
  102. if (empty($noout)) print_end_menu_array_auguria();
  103. print "\n";
  104. return 0;
  105. }
  106. /**
  107. * Output start menu array
  108. *
  109. * @return void
  110. */
  111. function print_start_menu_array_auguria()
  112. {
  113. print '<div class="tmenudiv">';
  114. print '<ul class="tmenu">';
  115. }
  116. /**
  117. * Output start menu entry
  118. *
  119. * @param string $idsel Text
  120. * @param string $classname String to add a css class
  121. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  122. * @return void
  123. */
  124. function print_start_menu_entry_auguria($idsel,$classname,$showmode)
  125. {
  126. if ($showmode)
  127. {
  128. print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
  129. print '<div class="tmenuleft tmenusep"></div><div class="tmenucenter">';
  130. }
  131. }
  132. /**
  133. * Output menu entry
  134. *
  135. * @param string $text Text
  136. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  137. * @param string $url Url
  138. * @param string $id Id
  139. * @param string $idsel Id sel
  140. * @param string $classname Class name
  141. * @param string $atarget Target
  142. * @return void
  143. */
  144. function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget)
  145. {
  146. global $langs;
  147. if ($showmode == 1)
  148. {
  149. print '<a class="tmenuimage" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
  150. print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  151. print '</a>';
  152. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
  153. print '<span class="mainmenuaspan">';
  154. print $text;
  155. print '</span>';
  156. print '</a>';
  157. }
  158. if ($showmode == 2)
  159. {
  160. print '<div class="'.$id.' '.$idsel.' tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
  161. print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
  162. print '<span class="mainmenuaspan">';
  163. print $text;
  164. print '</span>';
  165. print '</a>';
  166. }
  167. }
  168. /**
  169. * Output end menu entry
  170. *
  171. * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
  172. * @return void
  173. */
  174. function print_end_menu_entry_auguria($showmode)
  175. {
  176. if ($showmode)
  177. {
  178. print '</div></li>';
  179. }
  180. print "\n";
  181. }
  182. /**
  183. * Output menu array
  184. *
  185. * @return void
  186. */
  187. function print_end_menu_array_auguria()
  188. {
  189. print '</ul>';
  190. print '</div>';
  191. print "\n";
  192. }
  193. /**
  194. * Core function to output left menu auguria
  195. *
  196. * @param DoliDB $db Database handler
  197. * @param array $menu_array_before Table of menu entries to show before entries of menu handler
  198. * @param array $menu_array_after Table of menu entries to show after entries of menu handler
  199. * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
  200. * @param Menu $menu Object Menu to return back list of menu entries
  201. * @param int $noout Disable output (Initialise &$menu only).
  202. * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x'
  203. * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all)
  204. * @param array $moredata An array with more data to output
  205. * @return int Nb of entries
  206. */
  207. function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu,$noout=0,$forcemainmenu='',$forceleftmenu='',$moredata=null)
  208. {
  209. global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
  210. $newmenu = $menu;
  211. $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]);
  212. $leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"]));
  213. // Show logo company
  214. if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  215. {
  216. $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
  217. if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
  218. {
  219. $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode('thumbs/'.$mysoc->logo_mini);
  220. }
  221. else
  222. {
  223. $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
  224. }
  225. $title=$langs->trans("GoIntoSetupToChangeLogo");
  226. print "\n".'<!-- Show logo on menu -->'."\n";
  227. print '<div class="blockvmenuimpair blockvmenulogo">'."\n";
  228. print '<div class="menu_titre" id="menu_titre_logo"></div>';
  229. print '<div class="menu_top" id="menu_top_logo"></div>';
  230. print '<div class="menu_contenu" id="menu_contenu_logo">';
  231. print '<div class="center"><img title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 80%"></div>'."\n";
  232. print '</div>';
  233. print '<div class="menu_end" id="menu_end_logo"></div>';
  234. print '</div>'."\n";
  235. }
  236. if (is_array($moredata) && ! empty($moredata['searchform']))
  237. {
  238. print "\n";
  239. print "<!-- Begin SearchForm -->\n";
  240. print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n";
  241. print $moredata['searchform'];
  242. print '</div>'."\n";
  243. print "<!-- End SearchForm -->\n";
  244. }
  245. // We update newmenu with entries found into database
  246. $menuArbo = new Menubase($db,'auguria');
  247. $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
  248. // We update newmenu for special dynamic menus
  249. if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account
  250. {
  251. $sql = "SELECT rowid, label, courant, rappro, courant";
  252. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
  253. $sql.= " WHERE entity = ".$conf->entity;
  254. $sql.= " AND clos = 0";
  255. $sql.= " ORDER BY label";
  256. $resql = $db->query($sql);
  257. if ($resql)
  258. {
  259. $numr = $db->num_rows($resql);
  260. $i = 0;
  261. if ($numr > 0) $newmenu->add('/compta/bank/index.php',$langs->trans("BankAccounts"),0,$user->rights->banque->lire);
  262. while ($i < $numr)
  263. {
  264. $objp = $db->fetch_object($resql);
  265. $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
  266. if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
  267. {
  268. $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
  269. }
  270. $i++;
  271. }
  272. }
  273. else dol_print_error($db);
  274. $db->free($resql);
  275. }
  276. if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account
  277. {
  278. $newmenu->add('',$langs->trans("Journaux"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accounting');
  279. $sql = "SELECT rowid, label, accountancy_journal";
  280. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
  281. $sql.= " WHERE entity = ".$conf->entity;
  282. $sql.= " AND clos = 0";
  283. $sql.= " ORDER BY label";
  284. $resql = $db->query($sql);
  285. if ($resql)
  286. {
  287. $numr = $db->num_rows($resql);
  288. $i = 0;
  289. if ($numr > 0)
  290. while ($i < $numr)
  291. {
  292. $objp = $db->fetch_object($resql);
  293. $newmenu->add('/accountancy/journal/bankjournal.php?id_account='.$objp->rowid,$langs->trans("Journal").' - '.$objp->label,1,$user->rights->accounting->comptarapport->lire,'','accountancy','accounting');
  294. $i++;
  295. }
  296. }
  297. else dol_print_error($db);
  298. $db->free($resql);
  299. // Add other journal
  300. $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire);
  301. $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire);
  302. }
  303. if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP
  304. {
  305. $MAXFTP=20;
  306. $i=1;
  307. while ($i <= $MAXFTP)
  308. {
  309. $paramkey='FTP_NAME_'.$i;
  310. //print $paramkey;
  311. if (! empty($conf->global->$paramkey))
  312. {
  313. $link="/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i;
  314. $newmenu->add($link, dol_trunc($conf->global->$paramkey,24));
  315. }
  316. $i++;
  317. }
  318. }
  319. // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
  320. //var_dump($menu_array_before);exit;
  321. //var_dump($menu_array_after);exit;
  322. $menu_array=$newmenu->liste;
  323. if (is_array($menu_array_before)) $menu_array=array_merge($menu_array_before, $menu_array);
  324. if (is_array($menu_array_after)) $menu_array=array_merge($menu_array, $menu_array_after);
  325. //var_dump($menu_array);exit;
  326. if (! is_array($menu_array)) return 0;
  327. // Show menu
  328. if (empty($noout))
  329. {
  330. $alt=0; $altok=0; $blockvmenuopened=false;
  331. $num=count($menu_array);
  332. for ($i = 0; $i < $num; $i++)
  333. {
  334. $showmenu=true;
  335. if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false;
  336. $alt++;
  337. if (empty($menu_array[$i]['level']) && $showmenu)
  338. {
  339. $altok++;
  340. $blockvmenuopened=true;
  341. $lastopened=true;
  342. for($j = ($i + 1); $j < $num; $j++)
  343. {
  344. if (empty($menu_array[$j]['level'])) $lastopened=false;
  345. }
  346. if ($altok % 2 == 0)
  347. {
  348. print '<div class="blockvmenuimpair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n";
  349. }
  350. else
  351. {
  352. print '<div class="blockvmenupair'.($lastopened?' blockvmenulast':'').($altok == 1 ? ' blockvmenufirst':'').'">'."\n";
  353. }
  354. }
  355. // Place tabulation
  356. $tabstring='';
  357. $tabul=($menu_array[$i]['level'] - 1);
  358. if ($tabul > 0)
  359. {
  360. for ($j=0; $j < $tabul; $j++)
  361. {
  362. $tabstring.='&nbsp; &nbsp;';
  363. }
  364. }
  365. // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser.
  366. $url=dol_buildpath($menu_array[$i]['url'],1);
  367. $url=preg_replace('/__LOGIN__/',$user->login,$url);
  368. $url=preg_replace('/__USERID__/',$user->id,$url);
  369. if (! preg_match('/mainmenu=/i',$menu_array[$i]['url']))
  370. {
  371. if (! preg_match('/\?/',$url)) $url.='?';
  372. else $url.='&';
  373. $url.='mainmenu='.$mainmenu;
  374. }
  375. 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'].' -->'."\n";
  376. // Menu niveau 0
  377. if ($menu_array[$i]['level'] == 0)
  378. {
  379. if ($menu_array[$i]['enabled'])
  380. {
  381. print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>';
  382. }
  383. else if ($showmenu)
  384. {
  385. print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n";
  386. }
  387. if ($showmenu)
  388. print '<div class="menu_top"></div>'."\n";
  389. }
  390. // Menu niveau > 0
  391. if ($menu_array[$i]['level'] > 0)
  392. {
  393. if ($menu_array[$i]['enabled'])
  394. {
  395. print '<div class="menu_contenu">'.$tabstring;
  396. if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>';
  397. else print '<span class="vsmenu">';
  398. print $menu_array[$i]['titre'];
  399. if ($menu_array[$i]['url']) print '</a>';
  400. else print '</span>';
  401. // If title is not pure text and contains a table, no carriage return added
  402. if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>';
  403. print '</div>'."\n";
  404. }
  405. else if ($showmenu)
  406. {
  407. print '<div class="menu_contenu">'.$tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</font><br></div>'."\n";
  408. }
  409. }
  410. // If next is a new block or if there is nothing after
  411. if (empty($menu_array[$i+1]['level']))
  412. {
  413. if ($showmenu)
  414. print '<div class="menu_end"></div>'."\n";
  415. if ($blockvmenuopened) { print "</div>\n"; $blockvmenuopened=false; }
  416. }
  417. }
  418. if ($altok) print '<div class="blockvmenuend"></div>';
  419. }
  420. if (is_array($moredata) && ! empty($moredata['bookmarks']))
  421. {
  422. print "\n";
  423. print "<!-- Begin Bookmarks -->\n";
  424. print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n";
  425. print $moredata['bookmarks'];
  426. print '</div>'."\n";
  427. print "<!-- End Bookmarks -->\n";
  428. }
  429. return count($menu_array);
  430. }
  431. /**
  432. * Function to test if an entry is enabled or not
  433. *
  434. * @param string $type_user 0=We need backoffice menu, 1=We need frontoffice menu
  435. * @param array $menuentry Array for menu entry
  436. * @param array $listofmodulesforexternal Array with list of modules allowed to external users
  437. * @return int 0=Hide, 1=Show, 2=Show gray
  438. */
  439. function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal)
  440. {
  441. global $conf;
  442. //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
  443. //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
  444. if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition
  445. if ($type_user && $menuentry['module'])
  446. {
  447. $tmploops=explode('|',$menuentry['module']);
  448. $found=0;
  449. foreach($tmploops as $tmploop)
  450. {
  451. if (in_array($tmploop, $listofmodulesforexternal)) {
  452. $found++; break;
  453. }
  454. }
  455. if (! $found) return 0; // Entry is for menus all excluded to external users
  456. }
  457. if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external
  458. if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on
  459. if (! $menuentry['perms']) return 2; // No permissions and user is external
  460. return 1;
  461. }