2010-10-02 23:31:14 +02:00
< ? php
2022-07-26 16:14:19 +02:00
/* Copyright ( C ) 2010 - 2022 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2010-10-02 23:31:14 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2010-10-02 23:31:14 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
* or see https :// www . gnu . org /
2010-10-02 23:31:14 +02:00
*/
/**
2011-10-24 14:11:49 +02:00
* \file htdocs / core / menus / standard / auguria . lib . php
2010-10-02 23:31:14 +02:00
* \brief Library for file auguria menus
*/
2013-03-30 14:27:13 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php' ;
2010-10-02 23:31:14 +02:00
/**
* Core function to output top menu auguria
*
2012-02-17 10:04:10 +01:00
* @ param DoliDB $db Database handler
2020-04-28 02:58:33 +02:00
* @ param string $atarget Target ( Example : '' or '_top' )
2013-03-29 16:16:26 +01:00
* @ param int $type_user 0 = Menu for backoffice , 1 = Menu for front office
2016-05-17 19:49:37 +02:00
* @ param array $tabMenu If array with menu entries already loaded , we put this array here ( in most cases , it ' s empty )
* @ param Menu $menu Object Menu to return back list of menu entries
2020-04-28 02:58:33 +02:00
* @ param int $noout 1 = Disable output ( Initialise & $menu only ) .
2016-06-12 20:23:25 +02:00
* @ param string $mode 'top' , 'topnb' , 'left' , 'jmobile'
2014-04-25 20:11:38 +02:00
* @ return int 0
2010-10-02 23:31:14 +02:00
*/
2019-01-27 15:20:16 +01:00
function print_auguria_menu ( $db , $atarget , $type_user , & $tabMenu , & $menu , $noout = 0 , $mode = '' )
2010-10-02 23:31:14 +02:00
{
2020-04-10 10:59:32 +02:00
global $user , $conf , $langs , $mysoc ;
2019-10-11 14:24:47 +02:00
global $dolibarr_main_db_name ;
2010-10-02 23:31:14 +02:00
2020-04-10 10:59:32 +02:00
$mainmenu = ( empty ( $_SESSION [ " mainmenu " ]) ? '' : $_SESSION [ " mainmenu " ]);
$leftmenu = ( empty ( $_SESSION [ " leftmenu " ]) ? '' : $_SESSION [ " leftmenu " ]);
2013-02-24 21:16:36 +01:00
2020-04-10 10:59:32 +02:00
$id = 'mainmenu' ;
$listofmodulesforexternal = explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL );
2013-01-02 21:35:28 +01:00
2013-03-29 16:16:26 +01:00
// Show personalized menus
2019-01-27 11:55:16 +01:00
$menuArbo = new Menubase ( $db , 'auguria' );
$newTabMenu = $menuArbo -> menuTopCharger ( '' , '' , $type_user , 'auguria' , $tabMenu );
2010-10-02 23:31:14 +02:00
2019-12-19 13:41:43 +01:00
$substitarray = getCommonSubstitutionArray ( $langs , 0 , null , null );
2021-02-23 22:03:23 +01:00
if ( empty ( $noout )) {
print_start_menu_array_auguria ();
}
2011-11-26 18:32:48 +01:00
2019-10-11 14:24:47 +02:00
global $usemenuhider ;
$usemenuhider = 1 ;
2017-06-13 15:57:30 +02:00
2020-10-31 14:32:18 +01:00
// Show/Hide vertical menu. The hamburger icon for .menuhider action.
2021-02-23 22:03:23 +01:00
if ( $mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) {
2020-10-31 14:32:18 +01:00
$showmode = 1 ;
2022-05-02 20:10:42 +02:00
$classname = 'class="tmenu menuhider nohover"' ;
2020-10-31 14:32:18 +01:00
$idsel = 'menu' ;
2017-06-13 15:57:30 +02:00
2022-05-02 20:10:42 +02:00
$menu -> add ( '#' , ( getDolGlobalInt ( 'THEME_TOPMENU_DISABLE_IMAGE' ) == 1 ? '<span class="fa fa-bars"></span>' : '' ), 0 , $showmode , $atarget , " xxx " , '' , 0 , $id , $idsel , $classname );
2016-06-12 20:23:25 +02:00
}
2017-06-13 15:57:30 +02:00
2011-09-20 18:12:52 +02:00
$num = count ( $newTabMenu );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2022-07-26 16:14:19 +02:00
//var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']);
2020-04-10 10:59:32 +02:00
$idsel = ( empty ( $newTabMenu [ $i ][ 'mainmenu' ]) ? 'none' : $newTabMenu [ $i ][ 'mainmenu' ]);
2013-01-02 21:35:28 +01:00
2020-11-01 18:25:21 +01:00
$shorturl = '' ;
2020-04-10 10:59:32 +02:00
$showmode = dol_auguria_showmenu ( $type_user , $newTabMenu [ $i ], $listofmodulesforexternal );
2020-10-31 16:56:43 +01:00
if ( $showmode == 1 ) {
2017-12-09 15:35:01 +01:00
$newTabMenu [ $i ][ 'url' ] = make_substitutions ( $newTabMenu [ $i ][ 'url' ], $substitarray );
2017-09-23 03:22:48 +02:00
2022-07-26 16:14:19 +02:00
// url = url from host, shorturl = relative path into dolibarr sources
2013-03-29 16:16:26 +01:00
$url = $shorturl = $newTabMenu [ $i ][ 'url' ];
2022-07-26 16:14:19 +02:00
if ( ! preg_match ( " /^(http: \ / \ /|https: \ / \ /)/i " , $newTabMenu [ $i ][ 'url' ])) { // Do not change url content for external links
2020-10-31 14:32:18 +01:00
$tmp = explode ( '?' , $newTabMenu [ $i ][ 'url' ], 2 );
2013-07-07 13:17:48 +02:00
$url = $shorturl = $tmp [ 0 ];
2020-04-10 10:59:32 +02:00
$param = ( isset ( $tmp [ 1 ]) ? $tmp [ 1 ] : '' );
2013-07-07 03:26:51 +02:00
2017-06-27 10:34:41 +02:00
// Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
2021-02-23 22:03:23 +01:00
if (( ! preg_match ( '/mainmenu/i' , $param )) && ( ! preg_match ( '/leftmenu/i' , $param )) && ! empty ( $newTabMenu [ $i ][ 'url' ])) {
2020-10-31 14:32:18 +01:00
$param .= ( $param ? '&' : '' ) . 'mainmenu=' . $newTabMenu [ $i ][ 'mainmenu' ] . '&leftmenu=' ;
}
2021-02-23 22:03:23 +01:00
if (( ! preg_match ( '/mainmenu/i' , $param )) && ( ! preg_match ( '/leftmenu/i' , $param )) && empty ( $newTabMenu [ $i ][ 'url' ])) {
2020-10-31 14:32:18 +01:00
$param .= ( $param ? '&' : '' ) . 'leftmenu=' ;
}
2013-01-02 21:35:28 +01:00
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
2020-04-10 10:59:32 +02:00
$url = dol_buildpath ( $url , 1 ) . ( $param ? '?' . $param : '' );
2017-06-27 04:25:41 +02:00
//$shorturl = $shorturl.($param?'?'.$param:'');
$shorturl = $url ;
2017-06-27 10:34:41 +02:00
2021-02-23 22:03:23 +01:00
if ( DOL_URL_ROOT ) {
$shorturl = preg_replace ( '/^' . preg_quote ( DOL_URL_ROOT , '/' ) . '/' , '' , $shorturl );
}
2010-10-02 23:31:14 +02:00
}
2015-09-12 18:00:19 +02:00
2017-05-19 00:52:13 +02:00
// TODO Find a generic solution
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/search_project_user=__search_project_user__/' , $shorturl )) {
2020-10-31 14:32:18 +01:00
$search_project_user = GETPOST ( 'search_project_user' , 'int' );
2021-02-23 22:03:23 +01:00
if ( $search_project_user ) {
$shorturl = preg_replace ( '/search_project_user=__search_project_user__/' , 'search_project_user=' . $search_project_user , $shorturl );
} else {
$shorturl = preg_replace ( '/search_project_user=__search_project_user__/' , '' , $shorturl );
}
2017-05-19 00:52:13 +02:00
}
2017-06-14 10:48:34 +02:00
2013-01-02 21:35:28 +01:00
// Define the class (top menu selected or not)
2021-02-23 22:03:23 +01:00
if ( ! empty ( $_SESSION [ 'idmenu' ]) && $newTabMenu [ $i ][ 'rowid' ] == $_SESSION [ 'idmenu' ]) {
$classname = 'class="tmenusel"' ;
} elseif ( ! empty ( $_SESSION [ " mainmenu " ]) && $newTabMenu [ $i ][ 'mainmenu' ] == $_SESSION [ " mainmenu " ]) {
$classname = 'class="tmenusel"' ;
} else {
$classname = 'class="tmenu"' ;
}
2020-10-31 16:56:43 +01:00
} elseif ( $showmode == 2 ) {
$classname = 'class="tmenu"' ;
} else {
$classname = '' ;
}
2013-02-27 21:40:43 +01:00
2020-04-10 10:59:32 +02:00
$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 );
2017-06-27 04:25:41 +02:00
}
// Sort on position
$menu -> liste = dol_sort_array ( $menu -> liste , 'position' );
// Output menu entries
2019-10-11 14:24:47 +02:00
// Show logo company
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> global -> MAIN_MENU_INVERT ) && empty ( $noout ) && ! empty ( $conf -> global -> MAIN_SHOW_LOGO ) && empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER )) {
2019-10-11 14:24:47 +02:00
//$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI);
2020-04-10 10:59:32 +02:00
$mysoc -> logo_squarred_mini = ( empty ( $conf -> global -> MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI ) ? '' : $conf -> global -> MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI );
2020-04-28 18:30:38 +02:00
2020-04-28 02:58:33 +02:00
$logoContainerAdditionalClass = 'backgroundforcompanylogo' ;
if ( ! empty ( $conf -> global -> MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND )) {
$logoContainerAdditionalClass = '' ;
}
2020-04-28 18:30:38 +02:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $mysoc -> logo_squarred_mini ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/thumbs/' . $mysoc -> logo_squarred_mini )) {
2020-04-10 10:59:32 +02:00
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode ( 'logos/thumbs/' . $mysoc -> logo_squarred_mini );
2021-03-01 20:37:16 +01:00
/* } elseif ( ! empty ( $mysoc -> logo_mini ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/thumbs/' . $mysoc -> logo_mini ))
{
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode ( 'logos/thumbs/' . $mysoc -> logo_mini );
} */
} else {
2020-05-25 13:36:56 +02:00
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_512x512_white.png' ;
2020-04-28 02:58:33 +02:00
$logoContainerAdditionalClass = '' ;
2019-10-11 14:24:47 +02:00
}
2020-04-28 18:30:38 +02:00
2020-04-10 10:59:32 +02:00
$title = $langs -> trans ( " GoIntoSetupToChangeLogo " );
2010-10-02 23:31:14 +02:00
2019-10-11 14:24:47 +02:00
print " \n " . '<!-- Show logo on menu -->' . " \n " ;
2020-04-28 02:58:33 +02:00
print_start_menu_entry_auguria ( 'companylogo' , 'class="tmenu tmenucompanylogo nohover"' , 1 );
2013-07-28 05:35:51 +02:00
2020-04-28 02:58:33 +02:00
print '<div class="center ' . $logoContainerAdditionalClass . ' menulogocontainer"><img class="mycompany" title="' . dol_escape_htmltag ( $title ) . '" alt="" src="' . $urllogo . '" style="max-width: 100px"></div>' . " \n " ;
2010-10-02 23:31:14 +02:00
2019-10-11 14:24:47 +02:00
print_end_menu_entry_auguria ( 4 );
}
if ( empty ( $noout )) {
2020-04-28 02:58:33 +02:00
foreach ( $menu -> liste as $menuval ) {
2019-10-11 14:24:47 +02:00
print_start_menu_entry_auguria ( $menuval [ 'idsel' ], $menuval [ 'classname' ], $menuval [ 'enabled' ]);
2020-10-31 14:32:18 +01:00
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 ));
print_end_menu_entry_auguria ( $menuval [ 'enabled' ]);
2019-10-11 14:24:47 +02:00
}
}
2020-04-10 10:59:32 +02:00
$showmode = 1 ;
2019-10-11 14:24:47 +02:00
if ( empty ( $noout )) {
print_start_menu_entry_auguria ( '' , 'class="tmenuend"' , $showmode );
print_end_menu_entry_auguria ( $showmode );
print_end_menu_array_auguria ();
}
2014-04-25 20:11:38 +02:00
return 0 ;
2010-10-02 23:31:14 +02:00
}
2012-03-19 17:18:11 +01:00
/**
2012-05-01 23:40:23 +02:00
* Output start menu array
2012-03-19 17:18:11 +01:00
*
* @ return void
*/
2010-10-02 23:31:14 +02:00
function print_start_menu_array_auguria ()
{
2020-10-31 14:32:18 +01:00
global $conf ;
2017-06-13 15:57:30 +02:00
2012-05-01 23:40:23 +02:00
print '<div class="tmenudiv">' ;
2019-11-13 19:37:08 +01:00
print '<ul role="navigation" class="tmenu"' . ( empty ( $conf -> global -> MAIN_OPTIMIZEFORTEXTBROWSER ) ? '' : ' title="Top menu"' ) . '>' ;
2010-10-02 23:31:14 +02:00
}
2012-03-19 17:18:11 +01:00
/**
2012-05-01 23:40:23 +02:00
* Output start menu entry
2012-03-19 17:18:11 +01:00
*
* @ param string $idsel Text
2012-05-09 00:28:02 +02:00
* @ param string $classname String to add a css class
2013-03-24 03:51:49 +01:00
* @ param int $showmode 0 = hide , 1 = allowed or 2 = not allowed
2012-03-19 17:18:11 +01:00
* @ return void
*/
2019-01-27 15:20:16 +01:00
function print_start_menu_entry_auguria ( $idsel , $classname , $showmode )
2010-10-02 23:31:14 +02:00
{
2021-02-23 22:03:23 +01:00
if ( $showmode ) {
2013-03-24 03:51:49 +01:00
print '<li ' . $classname . ' id="mainmenutd_' . $idsel . '">' ;
2018-02-05 23:06:48 +01:00
//print '<div class="tmenuleft tmenusep"></div>';
print '<div class="tmenucenter">' ;
2013-03-24 03:51:49 +01:00
}
2010-10-02 23:31:14 +02:00
}
2012-03-19 17:18:11 +01:00
/**
* Output menu entry
*
* @ param string $text Text
2013-03-29 16:16:26 +01:00
* @ param int $showmode 0 = hide , 1 = allowed or 2 = not allowed
2013-02-27 21:40:43 +01:00
* @ param string $url Url
* @ param string $id Id
* @ param string $idsel Id sel
* @ param string $classname Class name
* @ param string $atarget Target
2012-03-19 17:18:11 +01:00
* @ return void
*/
2013-03-15 18:00:29 +01:00
function print_text_menu_entry_auguria ( $text , $showmode , $url , $id , $idsel , $classname , $atarget )
2010-10-02 23:31:14 +02:00
{
2022-06-09 21:33:39 +02:00
global $langs , $conf ;
2013-03-30 14:27:13 +01:00
2022-05-02 16:47:28 +02:00
$classnameimg = str_replace ( 'class="' , 'class="tmenuimage ' , $classname );
$classnametxt = str_replace ( 'class="' , 'class="tmenulabel ' , $classname );
2020-04-28 02:58:33 +02:00
if ( $showmode == 1 ) {
2022-07-26 16:14:19 +02:00
print '<a ' . $classnameimg . ' tabindex="-1" href="' . $url . '"' . ( $atarget ? ' target="' . $atarget . '"' : '' ) . ' title="' . dol_escape_htmltag ( $text ) . '">' ;
print '<div class="' . $id . ' ' . $idsel . ' topmenuimage aaa"><span class="' . $id . ' tmenuimageforpng" id="mainmenuspan_' . $idsel . '"></span></div>' ;
2013-03-30 14:27:13 +01:00
print '</a>' ;
2022-05-02 16:47:28 +02:00
if ( empty ( $conf -> global -> THEME_TOPMENU_DISABLE_TEXT )) {
2022-07-26 16:14:19 +02:00
print '<a ' . $classnametxt . ' id="mainmenua_' . $idsel . '" href="' . $url . '"' . ( $atarget ? ' target="' . $atarget . '"' : '' ) . ' title="' . dol_escape_htmltag ( $text ) . '">' ;
2022-05-02 16:47:28 +02:00
print '<span class="mainmenuaspan">' ;
print $text ;
print '</span>' ;
print '</a>' ;
}
2020-04-28 02:58:33 +02:00
} elseif ( $showmode == 2 ) {
2022-05-02 20:10:42 +02:00
print '<div ' . $classnameimg . ' title="' . dol_escape_htmltag ( $text . ' - ' . $langs -> trans ( " NotAllowed " )) . '">' ;
print '<div class="' . $id . ' ' . $idsel . ' topmenuimage tmenudisabled"><span class="' . $id . ' tmenuimageforpng tmenudisabled" id="mainmenuspan_' . $idsel . '"></span></div>' ;
print '</div>' ;
2022-05-02 16:47:28 +02:00
if ( empty ( $conf -> global -> THEME_TOPMENU_DISABLE_TEXT )) {
print '<span ' . $classnametxt . ' id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag ( $text . ' - ' . $langs -> trans ( " NotAllowed " )) . '">' ;
print '<span class="mainmenuaspan">' ;
print $text ;
print '</span>' ;
print '</span>' ;
}
2013-02-27 21:40:43 +01:00
}
2010-10-02 23:31:14 +02:00
}
2012-03-19 17:18:11 +01:00
/**
* Output end menu entry
*
2013-03-24 03:51:49 +01:00
* @ param int $showmode 0 = hide , 1 = allowed or 2 = not allowed
2012-03-19 17:18:11 +01:00
* @ return void
*/
2013-03-24 03:51:49 +01:00
function print_end_menu_entry_auguria ( $showmode )
2010-10-02 23:31:14 +02:00
{
2021-02-23 22:03:23 +01:00
if ( $showmode ) {
2013-03-24 03:51:49 +01:00
print '</div></li>' ;
}
2013-03-29 16:16:26 +01:00
print " \n " ;
2010-10-02 23:31:14 +02:00
}
2012-03-19 17:18:11 +01:00
/**
* Output menu array
*
* @ return void
*/
2010-10-02 23:31:14 +02:00
function print_end_menu_array_auguria ()
{
2012-05-01 23:40:23 +02:00
print '</ul>' ;
2013-02-24 21:16:36 +01:00
print '</div>' ;
2010-10-02 23:31:14 +02:00
print " \n " ;
}
/**
* Core function to output left menu auguria
2019-10-11 14:24:47 +02:00
* Fill & $menu ( example with $forcemainmenu = 'home' $forceleftmenu = 'all' , return left menu tree of Home )
2010-10-02 23:31:14 +02:00
*
2013-03-05 15:42:26 +01:00
* @ param DoliDB $db Database handler
2019-10-11 14:24:47 +02:00
* @ param array $menu_array_before Table of menu entries to show before entries of menu handler ( menu -> liste filled with menu -> add )
* @ param array $menu_array_after Table of menu entries to show after entries of menu handler ( menu -> liste filled with menu -> add )
2015-10-30 09:36:57 +01:00
* @ param array $tabMenu If array with menu entries already loaded , we put this array here ( in most cases , it ' s empty )
2014-09-27 16:00:11 +02:00
* @ param Menu $menu Object Menu to return back list of menu entries
2013-03-29 16:16:26 +01:00
* @ param int $noout Disable output ( Initialise & $menu only ) .
* @ param string $forcemainmenu 'x' = Force mainmenu to mainmenu = 'x'
2019-10-11 14:24:47 +02:00
* @ param string $forceleftmenu 'all' = Force leftmenu to '' ( = all ) . If value come being '' , we change it to value in session and 'none' if not defined in session .
2015-10-30 09:36:57 +01:00
* @ param array $moredata An array with more data to output
2022-07-26 16:14:19 +02:00
* @ param int $type_user 0 = Menu for backoffice , 1 = Menu for front office
2019-10-11 14:24:47 +02:00
* @ return int Nb of menu entries
2010-10-02 23:31:14 +02:00
*/
2022-07-26 16:14:19 +02:00
function print_left_auguria_menu ( $db , $menu_array_before , $menu_array_after , & $tabMenu , & $menu , $noout = 0 , $forcemainmenu = '' , $forceleftmenu = '' , $moredata = null , $type_user = 0 )
2010-10-02 23:31:14 +02:00
{
2022-07-26 16:14:19 +02:00
global $user , $conf , $langs , $hookmanager ;
global $dolibarr_main_db_name , $mysoc ;
2013-02-24 21:16:36 +01:00
2013-03-05 15:42:26 +01:00
$newmenu = $menu ;
2013-02-24 21:16:36 +01:00
2020-04-10 10:59:32 +02:00
$mainmenu = ( $forcemainmenu ? $forcemainmenu : $_SESSION [ " mainmenu " ]);
$leftmenu = ( $forceleftmenu ? '' : ( empty ( $_SESSION [ " leftmenu " ]) ? 'none' : $_SESSION [ " leftmenu " ]));
2013-02-24 21:16:36 +01:00
2016-11-07 10:14:04 +01:00
global $usemenuhider ;
2019-09-07 15:44:48 +02:00
$usemenuhider = 0 ;
2017-06-13 15:57:30 +02:00
2021-02-23 22:03:23 +01:00
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
2020-10-31 14:32:18 +01:00
print " \n " ;
print " <!-- Begin SearchForm --> \n " ;
print '<div id="blockvmenusearch" class="blockvmenusearch">' . " \n " ;
print $moredata [ 'searchform' ];
print '</div>' . " \n " ;
print " <!-- End SearchForm --> \n " ;
2015-10-30 09:36:57 +01:00
}
2017-06-13 15:57:30 +02:00
2021-02-23 22:03:23 +01:00
if ( is_array ( $moredata ) && ! empty ( $moredata [ 'bookmarks' ])) {
2020-10-31 14:32:18 +01:00
print " \n " ;
print " <!-- Begin Bookmarks --> \n " ;
print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . " \n " ;
print $moredata [ 'bookmarks' ];
print '</div>' . " \n " ;
print " <!-- End Bookmarks --> \n " ;
2017-06-27 11:12:03 +02:00
}
2019-12-19 13:41:43 +01:00
$substitarray = getCommonSubstitutionArray ( $langs , 0 , null , null );
2013-04-15 13:11:29 +02:00
// We update newmenu with entries found into database
2019-01-27 11:55:16 +01:00
$menuArbo = new Menubase ( $db , 'auguria' );
2020-04-10 10:59:32 +02:00
$newmenu = $menuArbo -> menuLeftCharger ( $newmenu , $mainmenu , $leftmenu , ( $user -> socid ? 1 : 0 ), 'auguria' , $tabMenu );
2013-02-24 21:16:36 +01:00
2013-06-05 16:24:32 +02:00
// We update newmenu for special dynamic menus
2022-06-09 21:33:39 +02:00
if ( isModEnabled ( 'banque' ) && $user -> rights -> banque -> lire && $mainmenu == 'bank' ) { // Entry for each bank account
2020-10-31 14:32:18 +01:00
include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ; // Required for to get Account::TYPE_CASH for example
2017-06-14 11:28:42 +02:00
2013-06-05 16:24:32 +02:00
$sql = " SELECT rowid, label, courant, rappro, courant " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " bank_account " ;
$sql .= " WHERE entity = " . $conf -> entity ;
$sql .= " AND clos = 0 " ;
$sql .= " ORDER BY label " ;
2013-07-07 03:26:51 +02:00
2013-06-05 16:24:32 +02:00
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2013-06-05 16:24:32 +02:00
$numr = $db -> num_rows ( $resql );
$i = 0 ;
2013-07-07 03:26:51 +02:00
2021-02-23 22:03:23 +01:00
if ( $numr > 0 ) {
$newmenu -> add ( '/compta/bank/list.php' , $langs -> trans ( " BankAccounts " ), 0 , $user -> rights -> banque -> lire );
}
2013-07-07 03:26:51 +02:00
2021-02-23 22:03:23 +01:00
while ( $i < $numr ) {
2013-06-05 16:24:32 +02:00
$objp = $db -> fetch_object ( $resql );
2019-01-27 11:55:16 +01:00
$newmenu -> add ( '/compta/bank/card.php?id=' . $objp -> rowid , $objp -> label , 1 , $user -> rights -> banque -> lire );
2021-02-23 22:03:23 +01:00
if ( $objp -> rappro && $objp -> courant != Account :: TYPE_CASH && empty ( $objp -> clos )) { // If not cash account and not closed and can be reconciliate
2019-01-27 11:55:16 +01:00
$newmenu -> add ( '/compta/bank/bankentries_list.php?id=' . $objp -> rowid , $langs -> trans ( " Conciliate " ), 2 , $user -> rights -> banque -> consolidate );
2013-06-05 16:24:32 +02:00
}
$i ++ ;
}
2021-02-23 22:03:23 +01:00
} else {
dol_print_error ( $db );
}
2013-06-05 16:24:32 +02:00
$db -> free ( $resql );
2013-04-15 13:11:29 +02:00
}
2015-01-30 15:47:27 +01:00
2022-06-09 21:33:39 +02:00
if ( isModEnabled ( 'accounting' ) && ! empty ( $user -> rights -> accounting -> comptarapport -> lire ) && $mainmenu == 'accountancy' ) { // Entry in accountancy journal for each bank account
2023-06-15 14:22:07 +02:00
$newmenu -> add ( '' , $langs -> trans ( " RegistrationInAccounting " ), 1 , $user -> rights -> accounting -> comptarapport -> lire , '' , 'accountancy' , 'accountancy_journal' , 10 );
2015-01-03 15:07:54 +01:00
2017-06-18 22:17:32 +02:00
// Multi journal
$sql = " SELECT rowid, code, label, nature " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " accounting_journal " ;
$sql .= " WHERE entity = " . $conf -> entity ;
$sql .= " AND active = 1 " ;
$sql .= " ORDER BY label DESC " ;
2017-06-18 22:17:32 +02:00
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2017-06-18 22:17:32 +02:00
$numr = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $numr > 0 ) {
while ( $i < $numr ) {
2017-06-18 22:17:32 +02:00
$objp = $db -> fetch_object ( $resql );
2020-04-10 10:59:32 +02:00
$nature = '' ;
2017-08-29 12:43:47 +02:00
2017-06-18 22:17:32 +02:00
// Must match array $sourceList defined into journals_list.php
2022-06-09 21:33:39 +02:00
if ( $objp -> nature == 2 && isModEnabled ( 'facture' ) && empty ( $conf -> global -> ACCOUNTING_DISABLE_BINDING_ON_SALES )) {
2021-02-23 22:03:23 +01:00
$nature = " sells " ;
}
2020-08-18 07:38:46 +02:00
if ( $objp -> nature == 3
2022-06-09 21:33:39 +02:00
&& (( isModEnabled ( 'fournisseur' ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || isModEnabled ( 'supplier_invoice' ))
2021-02-23 22:03:23 +01:00
&& empty ( $conf -> global -> ACCOUNTING_DISABLE_BINDING_ON_PURCHASES )) {
2020-08-18 07:38:46 +02:00
$nature = " purchases " ;
2021-02-23 22:03:23 +01:00
}
2022-06-09 21:33:39 +02:00
if ( $objp -> nature == 4 && isModEnabled ( 'banque' )) {
2021-02-23 22:03:23 +01:00
$nature = " bank " ;
}
2022-06-09 21:33:39 +02:00
if ( $objp -> nature == 5 && isModEnabled ( 'expensereport' ) && empty ( $conf -> global -> ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS )) {
2021-02-23 22:03:23 +01:00
$nature = " expensereports " ;
}
if ( $objp -> nature == 1 ) {
$nature = " various " ;
}
if ( $objp -> nature == 8 ) {
$nature = " inventory " ;
}
if ( $objp -> nature == 9 ) {
$nature = " hasnew " ;
}
2017-06-18 22:17:32 +02:00
// To enable when page exists
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> global -> ACCOUNTANCY_SHOW_DEVELOP_JOURNAL )) {
2022-02-14 04:52:39 +01:00
if ( $nature == 'hasnew' || $nature == 'inventory' ) {
2021-02-23 22:03:23 +01:00
$nature = '' ;
}
2017-06-18 22:17:32 +02:00
}
2021-02-23 22:03:23 +01:00
if ( $nature ) {
2020-10-31 14:32:18 +01:00
$langs -> load ( 'accountancy' );
$journallabel = $langs -> transnoentities ( $objp -> label ); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ...
$newmenu -> add ( '/accountancy/journal/' . $nature . 'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal=' . $objp -> rowid , $journallabel , 2 , $user -> rights -> accounting -> comptarapport -> lire );
2017-06-18 22:17:32 +02:00
}
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-06-18 22:17:32 +02:00
// Should not happend. Entries are added
2019-01-27 11:55:16 +01:00
$newmenu -> add ( '' , $langs -> trans ( " NoJournalDefined " ), 2 , $user -> rights -> accounting -> comptarapport -> lire );
2017-06-18 22:17:32 +02:00
}
2021-02-23 22:03:23 +01:00
} else {
dol_print_error ( $db );
}
2017-06-18 22:17:32 +02:00
$db -> free ( $resql );
2015-01-03 15:07:54 +01:00
}
2013-04-15 13:11:29 +02:00
2022-06-09 21:33:39 +02:00
if ( isModEnabled ( 'ftp' ) && $mainmenu == 'ftp' ) { // Entry for FTP
2019-11-13 19:37:08 +01:00
$MAXFTP = 20 ;
$i = 1 ;
2021-02-23 22:03:23 +01:00
while ( $i <= $MAXFTP ) {
2019-11-13 19:37:08 +01:00
$paramkey = 'FTP_NAME_' . $i ;
2013-06-05 16:24:32 +02:00
//print $paramkey;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> $paramkey )) {
2019-11-13 19:37:08 +01:00
$link = " /ftp/index.php?idmenu= " . $_SESSION [ " idmenu " ] . " &numero_ftp= " . $i ;
2013-07-07 03:26:51 +02:00
2019-01-27 11:55:16 +01:00
$newmenu -> add ( $link , dol_trunc ( $conf -> global -> $paramkey , 24 ));
2013-06-05 16:24:32 +02:00
}
$i ++ ;
}
2013-07-07 03:26:51 +02:00
}
2013-04-15 13:11:29 +02:00
// Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after
2013-02-24 21:16:36 +01:00
//var_dump($menu_array_before);exit;
//var_dump($menu_array_after);exit;
2019-11-13 19:37:08 +01:00
$menu_array = $newmenu -> liste ;
2021-02-23 22:03:23 +01:00
if ( is_array ( $menu_array_before )) {
$menu_array = array_merge ( $menu_array_before , $menu_array );
}
if ( is_array ( $menu_array_after )) {
$menu_array = array_merge ( $menu_array , $menu_array_after );
}
2013-02-24 21:16:36 +01:00
//var_dump($menu_array);exit;
2021-02-23 22:03:23 +01:00
if ( ! is_array ( $menu_array )) {
return 0 ;
}
2013-02-24 21:16:36 +01:00
2022-07-26 16:14:19 +02:00
// Allow the $menu_array of the menu to be manipulated by modules
$parameters = array (
'mainmenu' => $mainmenu ,
);
$hook_items = $menu_array ;
$reshook = $hookmanager -> executeHooks ( 'menuLeftMenuItems' , $parameters , $hook_items ); // Note that $action and $object may have been modified by some hooks
if ( is_numeric ( $reshook )) {
if ( $reshook == 0 && ! empty ( $hookmanager -> results )) {
$menu_array [] = $hookmanager -> results ; // add
} elseif ( $reshook == 1 ) {
$menu_array = $hookmanager -> results ; // replace
}
// @todo Sort menu items by 'position' value
// $position = array();
// foreach ($menu_array as $key => $row) {
// $position[$key] = $row['position'];
// }
// $array1_sort_order = SORT_ASC;
// array_multisort($position, $array1_sort_order, $menu_array);
}
2013-02-24 21:16:36 +01:00
// Show menu
2019-11-13 19:37:08 +01:00
$invert = empty ( $conf -> global -> MAIN_MENU_INVERT ) ? " " : " invert " ;
2021-02-23 22:03:23 +01:00
if ( empty ( $noout )) {
2021-03-01 20:37:16 +01:00
$altok = 0 ;
$blockvmenuopened = false ;
$lastlevel0 = '' ;
2019-11-13 19:37:08 +01:00
$num = count ( $menu_array );
2021-02-23 22:03:23 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) { // Loop on each menu entry
2019-11-13 19:37:08 +01:00
$showmenu = true ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> MAIN_MENU_HIDE_UNAUTHORIZED ) && empty ( $menu_array [ $i ][ 'enabled' ])) {
$showmenu = false ;
}
2013-04-01 16:02:16 +02:00
2017-06-10 16:13:37 +02:00
// Begin of new left menu block
2021-02-23 22:03:23 +01:00
if ( empty ( $menu_array [ $i ][ 'level' ]) && $showmenu ) {
2015-10-30 09:36:57 +01:00
$altok ++ ;
2019-11-13 19:37:08 +01:00
$blockvmenuopened = true ;
$lastopened = true ;
2021-02-23 22:03:23 +01:00
for ( $j = ( $i + 1 ); $j < $num ; $j ++ ) {
if ( empty ( $menu_array [ $j ][ 'level' ])) {
$lastopened = false ;
}
2017-06-13 15:57:30 +02:00
}
2021-02-23 22:03:23 +01:00
if ( $altok % 2 == 0 ) {
2019-11-13 19:37:08 +01:00
print '<div class="blockvmenu blockvmenuimpair' . $invert . ( $lastopened ? ' blockvmenulast' : '' ) . ( $altok == 1 ? ' blockvmenufirst' : '' ) . '">' . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:37:08 +01:00
print '<div class="blockvmenu blockvmenupair' . $invert . ( $lastopened ? ' blockvmenulast' : '' ) . ( $altok == 1 ? ' blockvmenufirst' : '' ) . '">' . " \n " ;
2013-04-01 16:02:16 +02:00
}
2013-02-24 21:16:36 +01:00
}
2017-06-10 16:13:37 +02:00
// Add tabulation
2019-11-13 19:37:08 +01:00
$tabstring = '' ;
$tabul = ( $menu_array [ $i ][ 'level' ] - 1 );
2021-02-23 22:03:23 +01:00
if ( $tabul > 0 ) {
for ( $j = 0 ; $j < $tabul ; $j ++ ) {
2019-11-13 19:37:08 +01:00
$tabstring .= ' ' ;
2013-04-01 16:02:16 +02:00
}
2013-02-24 21:16:36 +01:00
}
2017-12-09 15:35:01 +01:00
// $menu_array[$i]['url'] can be a relative url, a full external url. We try substitution
2019-12-19 13:41:43 +01:00
2017-12-09 15:35:01 +01:00
$menu_array [ $i ][ 'url' ] = make_substitutions ( $menu_array [ $i ][ 'url' ], $substitarray );
2018-04-06 14:04:52 +02:00
$url = $shorturl = $shorturlwithoutparam = $menu_array [ $i ][ 'url' ];
2021-02-23 22:03:23 +01:00
if ( ! preg_match ( " /^(http: \ / \ /|https: \ / \ /)/i " , $menu_array [ $i ][ 'url' ])) {
2019-11-13 19:37:08 +01:00
$tmp = explode ( '?' , $menu_array [ $i ][ 'url' ], 2 );
2018-04-06 14:04:52 +02:00
$url = $shorturl = $tmp [ 0 ];
2019-11-13 19:37:08 +01:00
$param = ( isset ( $tmp [ 1 ]) ? $tmp [ 1 ] : '' ); // params in url of the menu link
2018-09-09 12:53:30 +02:00
2018-04-06 14:04:52 +02:00
// Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
2021-02-23 22:03:23 +01:00
if (( ! preg_match ( '/mainmenu/i' , $param )) && ( ! preg_match ( '/leftmenu/i' , $param )) && ! empty ( $menu_array [ $i ][ 'mainmenu' ])) {
2019-11-13 19:37:08 +01:00
$param .= ( $param ? '&' : '' ) . 'mainmenu=' . $menu_array [ $i ][ 'mainmenu' ] . '&leftmenu=' ;
2018-04-06 14:04:52 +02:00
}
2021-02-23 22:03:23 +01:00
if (( ! preg_match ( '/mainmenu/i' , $param )) && ( ! preg_match ( '/leftmenu/i' , $param )) && empty ( $menu_array [ $i ][ 'mainmenu' ])) {
2019-11-13 19:37:08 +01:00
$param .= ( $param ? '&' : '' ) . 'leftmenu=' ;
2018-04-06 14:04:52 +02:00
}
//$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad
2019-11-13 19:37:08 +01:00
$url = dol_buildpath ( $url , 1 ) . ( $param ? '?' . $param : '' );
2018-04-06 14:04:52 +02:00
$shorturlwithoutparam = $shorturl ;
2019-11-13 19:37:08 +01:00
$shorturl = $shorturl . ( $param ? '?' . $param : '' );
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
2018-04-06 14:04:52 +02:00
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 " ;
2013-07-07 03:26:51 +02:00
2017-06-10 16:13:37 +02:00
// Menu level 0
2021-02-23 22:03:23 +01:00
if ( $menu_array [ $i ][ 'level' ] == 0 ) {
if ( $menu_array [ $i ][ 'enabled' ]) { // Enabled so visible
2018-04-06 14:04:52 +02:00
print '<div class="menu_titre">' . $tabstring ;
2021-02-23 22:03:23 +01:00
if ( $shorturlwithoutparam ) {
2022-07-26 16:14:19 +02:00
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' ] . '"' : '' ) . '>' ;
2021-02-23 22:03:23 +01:00
} else {
print '<span class="vmenu">' ;
}
2019-11-13 19:37:08 +01:00
print ( $menu_array [ $i ][ 'prefix' ] ? $menu_array [ $i ][ 'prefix' ] : '' ) . $menu_array [ $i ][ 'titre' ];
2021-02-23 22:03:23 +01:00
if ( $shorturlwithoutparam ) {
print '</a>' ;
} else {
print '</span>' ;
}
2018-04-06 14:04:52 +02:00
print '</div>' . " \n " ;
2019-11-13 19:37:08 +01:00
$lastlevel0 = 'enabled' ;
2021-02-23 22:03:23 +01:00
} elseif ( $showmenu ) { // Not enabled but visible (so greyed)
2022-07-26 16:14:19 +02:00
print '<div class="menu_titre">' . $tabstring ;
print '<span class="vmenudisabled">' ;
print ( $menu_array [ $i ][ 'prefix' ] ? $menu_array [ $i ][ 'prefix' ] : '' ) . $menu_array [ $i ][ 'titre' ];
print '</span>' ;
print '</div>' . " \n " ;
2019-11-13 19:37:08 +01:00
$lastlevel0 = 'greyed' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$lastlevel0 = 'hidden' ;
2013-04-01 16:02:16 +02:00
}
2021-02-23 22:03:23 +01:00
if ( $showmenu ) {
2013-04-01 16:02:16 +02:00
print '<div class="menu_top"></div>' . " \n " ;
2017-06-10 16:13:37 +02:00
}
2013-02-24 21:16:36 +01:00
}
2018-04-06 14:04:52 +02:00
2017-06-10 16:13:37 +02:00
// Menu level > 0
2021-02-23 22:03:23 +01:00
if ( $menu_array [ $i ][ 'level' ] > 0 ) {
2017-06-13 15:57:30 +02:00
$cssmenu = '' ;
2021-02-23 22:03:23 +01:00
if ( $menu_array [ $i ][ 'url' ]) {
$cssmenu = ' menu_contenu' . dol_string_nospecial ( preg_replace ( '/\.php.*$/' , '' , $menu_array [ $i ][ 'url' ]));
}
2017-06-13 15:57:30 +02:00
2022-07-26 16:14:19 +02:00
if ( $menu_array [ $i ][ 'enabled' ] && $lastlevel0 == 'enabled' ) {
// Enabled so visible, except if parent was not enabled.
print '<div class="menu_contenu' . $cssmenu . '">' ;
print $tabstring ;
2021-02-23 22:03:23 +01:00
if ( $shorturlwithoutparam ) {
2022-07-26 16:14:19 +02:00
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' ] . '"' : '' ) . '>' ;
2021-02-23 22:03:23 +01:00
} else {
print '<span class="vsmenu" title="' . dol_escape_htmltag ( $menu_array [ $i ][ 'titre' ]) . '">' ;
}
2013-04-01 16:02:16 +02:00
print $menu_array [ $i ][ 'titre' ];
2021-02-23 22:03:23 +01:00
if ( $shorturlwithoutparam ) {
print '</a>' ;
} else {
print '</span>' ;
}
2013-04-01 16:02:16 +02:00
// If title is not pure text and contains a table, no carriage return added
2021-02-23 22:03:23 +01:00
if ( ! strstr ( $menu_array [ $i ][ 'titre' ], '<table' )) {
print '<br>' ;
}
2013-04-01 16:02:16 +02:00
print '</div>' . " \n " ;
2022-07-26 16:14:19 +02:00
} elseif ( $showmenu && $lastlevel0 == 'enabled' ) {
// Not enabled but visible (so greyed), except if parent was not enabled.
print '<div class="menu_contenu' . $cssmenu . '">' ;
print $tabstring ;
print '<span class="spanlilevel0 vsmenudisabled vsmenudisabledmargin">' . $menu_array [ $i ][ 'titre' ] . '</span><br>' ;
print '</div>' . " \n " ;
2013-04-01 16:02:16 +02:00
}
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
2013-06-14 19:51:53 +02:00
// If next is a new block or if there is nothing after
2021-02-23 22:03:23 +01:00
if ( empty ( $menu_array [ $i + 1 ][ 'level' ])) { // End menu block
if ( $showmenu ) {
2013-04-01 16:02:16 +02:00
print '<div class="menu_end"></div>' . " \n " ;
2021-02-23 22:03:23 +01:00
}
if ( $blockvmenuopened ) {
2021-03-01 20:37:16 +01:00
print '</div>' . " \n " ;
$blockvmenuopened = false ;
2021-02-23 22:03:23 +01:00
}
2013-02-24 21:16:36 +01:00
}
}
2017-06-13 15:57:30 +02:00
2021-02-23 22:03:23 +01:00
if ( $altok ) {
print '<div class="blockvmenuend"></div>' ; // End menu block
}
2013-03-29 16:16:26 +01:00
}
2013-03-30 20:34:13 +01:00
2013-02-24 21:16:36 +01:00
return count ( $menu_array );
2010-10-02 23:31:14 +02:00
}
2013-01-02 21:35:28 +01:00
/**
* Function to test if an entry is enabled or not
*
* @ param string $type_user 0 = We need backoffice menu , 1 = We need frontoffice menu
2014-09-27 16:00:11 +02:00
* @ param array $menuentry Array for menu entry
* @ param array $listofmodulesforexternal Array with list of modules allowed to external users
2013-01-02 21:35:28 +01:00
* @ return int 0 = Hide , 1 = Show , 2 = Show gray
*/
function dol_auguria_showmenu ( $type_user , & $menuentry , & $listofmodulesforexternal )
{
2013-03-10 13:22:51 +01:00
global $conf ;
2013-01-02 21:35:28 +01:00
//print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
//print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
2021-02-23 22:03:23 +01:00
if ( empty ( $menuentry [ 'enabled' ])) {
return 0 ; // Entry disabled by condition
}
if ( $type_user && $menuentry [ 'module' ]) {
2019-11-13 19:37:08 +01:00
$tmploops = explode ( '|' , $menuentry [ 'module' ]);
$found = 0 ;
2021-02-23 22:03:23 +01:00
foreach ( $tmploops as $tmploop ) {
2013-02-24 21:16:36 +01:00
if ( in_array ( $tmploop , $listofmodulesforexternal )) {
2021-03-01 20:37:16 +01:00
$found ++ ;
break ;
2013-02-24 21:16:36 +01:00
}
2013-01-02 21:35:28 +01:00
}
2021-02-23 22:03:23 +01:00
if ( ! $found ) {
return 0 ; // Entry is for menus all excluded to external users
}
}
if ( ! $menuentry [ 'perms' ] && $type_user ) {
return 0 ; // No permissions and user is external
}
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
}
if ( ! $menuentry [ 'perms' ]) {
return 2 ; // No permissions and user is external
2013-01-02 21:35:28 +01:00
}
return 1 ;
}