2010-10-02 23:31:14 +02:00
< ? php
2013-02-24 21:16:36 +01:00
/* Copyright ( C ) 2010 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ capnetworks . 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
2011-08-01 01:45:11 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2010-10-02 23:31:14 +02:00
* or see http :// www . gnu . org /
*/
/**
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
* @ param string $atarget Target
2013-03-29 16:16:26 +01:00
* @ param int $type_user 0 = Menu for backoffice , 1 = Menu for front office
2013-02-22 19:16:03 +01:00
* @ param array & $tabMenu If array with menu entries already loaded , we put this array here ( in most cases , it ' s empty )
2013-03-05 15:42:26 +01:00
* @ param array & $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 ) .
2012-02-17 10:04:10 +01:00
* @ return void
2010-10-02 23:31:14 +02:00
*/
2013-03-29 16:16:26 +01:00
function print_auguria_menu ( $db , $atarget , $type_user , & $tabMenu , & $menu , $noout = 0 )
2010-10-02 23:31:14 +02:00
{
global $user , $conf , $langs , $dolibarr_main_db_name ;
2013-03-30 14:27:13 +01:00
$mainmenu = $_SESSION [ " mainmenu " ];
$leftmenu = $_SESSION [ " leftmenu " ];
2013-02-24 21:16:36 +01:00
2013-02-27 21:40:43 +01:00
$id = 'mainmenu' ;
2013-01-02 21:35:28 +01:00
$listofmodulesforexternal = explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL );
2013-03-29 16:16:26 +01:00
// Show personalized menus
2013-01-15 12:48:46 +01:00
$menuArbo = new Menubase ( $db , 'auguria' );
2012-01-03 09:41:01 +01:00
$newTabMenu = $menuArbo -> menuTopCharger ( '' , '' , $type_user , 'auguria' , $tabMenu );
2010-10-02 23:31:14 +02:00
2013-03-29 16:16:26 +01:00
if ( empty ( $noout )) print_start_menu_array_auguria ();
2011-11-26 18:32:48 +01:00
2011-09-20 18:12:52 +02:00
$num = count ( $newTabMenu );
for ( $i = 0 ; $i < $num ; $i ++ )
2010-10-02 23:31:14 +02:00
{
2013-01-02 21:35:28 +01:00
$idsel = ( empty ( $newTabMenu [ $i ][ 'mainmenu' ]) ? 'none' : $newTabMenu [ $i ][ 'mainmenu' ]);
$showmode = dol_auguria_showmenu ( $type_user , $newTabMenu [ $i ], $listofmodulesforexternal );
if ( $showmode == 1 )
2010-10-02 23:31:14 +02:00
{
2013-03-29 16:16:26 +01:00
$url = $shorturl = $newTabMenu [ $i ][ 'url' ];
if ( ! preg_match ( " /^(http: \ / \ /|https: \ / \ /)/i " , $newTabMenu [ $i ][ 'url' ]))
2010-10-02 23:31:14 +02:00
{
2013-07-07 13:17:48 +02:00
$tmp = explode ( '?' , $newTabMenu [ $i ][ 'url' ], 2 );
$url = $shorturl = $tmp [ 0 ];
2013-07-07 03:26:51 +02:00
$param = ( isset ( $tmp [ 1 ]) ? $tmp [ 1 ] : '' );
if ( ! preg_match ( '/mainmenu/i' , $url ) || ! preg_match ( '/leftmenu/i' , $url )) $param .= ( $param ? '&' : '' ) . 'mainmenu=' . $newTabMenu [ $i ][ 'mainmenu' ] . '&leftmenu=' ;
2013-01-02 21:35:28 +01:00
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
2013-07-07 03:26:51 +02:00
$url = dol_buildpath ( $url , 1 ) . ( $param ? '?' . $param : '' );
$shorturl = $shorturl . ( $param ? '?' . $param : '' );
2010-10-02 23:31:14 +02:00
}
2013-01-02 21:35:28 +01:00
$url = preg_replace ( '/__LOGIN__/' , $user -> login , $url );
2013-03-30 14:27:13 +01:00
$shorturl = preg_replace ( '/__LOGIN__/' , $user -> login , $shorturl );
2013-06-05 16:24:32 +02:00
$url = preg_replace ( '/__USERID__/' , $user -> id , $url );
$shorturl = preg_replace ( '/__USERID__/' , $user -> id , $shorturl );
2013-03-30 20:34:13 +01:00
2013-01-02 21:35:28 +01:00
// Define the class (top menu selected or not)
if ( ! empty ( $_SESSION [ 'idmenu' ]) && $newTabMenu [ $i ][ 'rowid' ] == $_SESSION [ 'idmenu' ]) $classname = 'class="tmenusel"' ;
else if ( ! empty ( $_SESSION [ " mainmenu " ]) && $newTabMenu [ $i ][ 'mainmenu' ] == $_SESSION [ " mainmenu " ]) $classname = 'class="tmenusel"' ;
else $classname = 'class="tmenu"' ;
2010-10-02 23:31:14 +02:00
}
2013-02-27 21:40:43 +01:00
else if ( $showmode == 2 ) $classname = 'class="tmenu"' ;
2013-03-30 14:27:13 +01:00
if ( empty ( $noout )) print_start_menu_entry_auguria ( $idsel , $classname , $showmode );
if ( empty ( $noout )) print_text_menu_entry_auguria ( $newTabMenu [ $i ][ 'titre' ], $showmode , $url , $id , $idsel , $classname , ( $newTabMenu [ $i ][ 'target' ] ? $newTabMenu [ $i ][ 'target' ] : $atarget ));
if ( empty ( $noout )) print_end_menu_entry_auguria ( $showmode );
2013-03-29 16:16:26 +01: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' ]), '' );
2010-10-02 23:31:14 +02:00
}
2013-08-06 03:01:56 +02:00
$showmode = 1 ;
2013-08-27 14:53:24 +02:00
if ( empty ( $noout )) print_start_menu_entry_auguria ( '' , 'class="tmenuend"' , $showmode );
if ( empty ( $noout )) print_end_menu_entry_auguria ( $showmode );
2013-07-28 05:35:51 +02:00
2013-03-29 16:16:26 +01:00
if ( empty ( $noout )) print_end_menu_array_auguria ();
2010-10-02 23:31:14 +02:00
print " \n " ;
}
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 ()
{
2012-05-01 23:40:23 +02:00
print '<div class="tmenudiv">' ;
print '<ul class="tmenu">' ;
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
*/
2013-03-24 03:51:49 +01:00
function print_start_menu_entry_auguria ( $idsel , $classname , $showmode )
2010-10-02 23:31:14 +02:00
{
2013-03-24 03:51:49 +01:00
if ( $showmode )
{
print '<li ' . $classname . ' id="mainmenutd_' . $idsel . '">' ;
print '<div class="tmenuleft"></div><div class="tmenucenter">' ;
}
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
{
2013-03-30 14:27:13 +01:00
global $langs ;
if ( $showmode == 1 )
{
print '<a class="tmenuimage" href="' . $url . '"' . ( $atarget ? ' target="' . $atarget . '"' : '' ) . '>' ;
print '<div class="' . $id . ' ' . $idsel . '"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>' ;
print '</a>' ;
print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . $url . '"' . ( $atarget ? ' target="' . $atarget . '"' : '' ) . '>' ;
print '<span class="mainmenuaspan">' ;
print $text ;
print '</span>' ;
print '</a>' ;
}
if ( $showmode == 2 )
{
2013-07-23 18:36:18 +02:00
print '<div class="' . $id . ' ' . $idsel . ' tmenudisabled"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>' ;
2013-03-30 14:27:13 +01:00
print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NotAllowed " )) . '">' ;
2013-03-05 15:42:26 +01:00
print '<span class="mainmenuaspan">' ;
print $text ;
print '</span>' ;
print '</a>' ;
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
{
2013-03-24 03:51:49 +01:00
if ( $showmode )
{
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
*
2013-03-05 15:42:26 +01:00
* @ param DoliDB $db Database handler
* @ param array $menu_array_before Table of menu entries to show before entries of menu handler
* @ param array $menu_array_after Table of menu entries to show after entries of menu handler
* @ param array & $tabMenu If array with menu entries already loaded , we put this array here ( in most cases , it ' s empty )
* @ param array & $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'
* @ param string $forceleftmenu 'all' = Force leftmenu to '' ( = all )
2012-02-17 10:04:10 +01:00
* @ return void
2010-10-02 23:31:14 +02:00
*/
2013-03-29 16:16:26 +01:00
function print_left_auguria_menu ( $db , $menu_array_before , $menu_array_after , & $tabMenu , & $menu , $noout = 0 , $forcemainmenu = '' , $forceleftmenu = '' )
2010-10-02 23:31:14 +02:00
{
2013-02-24 21:16:36 +01:00
global $user , $conf , $langs , $dolibarr_main_db_name , $mysoc ;
2013-03-05 15:42:26 +01:00
$newmenu = $menu ;
2013-02-24 21:16:36 +01:00
2013-03-29 16:16:26 +01:00
$mainmenu = ( $forcemainmenu ? $forcemainmenu : $_SESSION [ " mainmenu " ]);
$leftmenu = ( $forceleftmenu ? '' : ( empty ( $_SESSION [ " leftmenu " ]) ? 'none' : $_SESSION [ " leftmenu " ]));
2013-02-24 21:16:36 +01:00
// Show logo company
2013-03-29 16:16:26 +01:00
if ( empty ( $noout ) && ! empty ( $conf -> global -> MAIN_SHOW_LOGO ))
2013-02-24 21:16:36 +01:00
{
$mysoc -> logo_mini = $conf -> global -> MAIN_INFO_SOCIETE_LOGO_MINI ;
if ( ! empty ( $mysoc -> logo_mini ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/thumbs/' . $mysoc -> logo_mini ))
{
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode ( 'thumbs/' . $mysoc -> logo_mini );
print " \n " . '<!-- Show logo on menu -->' . " \n " ;
print '<div class="blockvmenuimpair">' . " \n " ;
print '<div class="menu_titre" id="menu_titre_logo"></div>' ;
print '<div class="menu_top" id="menu_top_logo"></div>' ;
print '<div class="menu_contenu" id="menu_contenu_logo">' ;
print '<center><img title="" src="' . $urllogo . '"></center>' . " \n " ;
print '</div>' ;
print '<div class="menu_end" id="menu_end_logo"></div>' ;
print '</div>' . " \n " ;
}
}
2013-04-15 13:11:29 +02:00
// We update newmenu with entries found into database
2013-02-24 21:16:36 +01:00
$menuArbo = new Menubase ( $db , 'auguria' );
$newmenu = $menuArbo -> menuLeftCharger ( $newmenu , $mainmenu , $leftmenu ,( $user -> societe_id ? 1 : 0 ), 'auguria' , $tabMenu );
2013-06-05 16:24:32 +02:00
// We update newmenu for special dynamic menus
if ( $conf -> banque -> enabled && $user -> rights -> banque -> lire && $mainmenu == 'bank' ) // Entry for each bank account
{
$sql = " SELECT rowid, label, courant, rappro, courant " ;
$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 );
if ( $resql )
{
$numr = $db -> num_rows ( $resql );
$i = 0 ;
2013-07-07 03:26:51 +02:00
2013-06-05 16:24:32 +02:00
if ( $numr > 0 ) $newmenu -> add ( '/compta/bank/index.php' , $langs -> trans ( " BankAccounts " ), 0 , $user -> rights -> banque -> lire );
2013-07-07 03:26:51 +02:00
2013-06-05 16:24:32 +02:00
while ( $i < $numr )
{
$objp = $db -> fetch_object ( $resql );
$newmenu -> add ( '/compta/bank/fiche.php?id=' . $objp -> rowid , $objp -> label , 1 , $user -> rights -> banque -> lire );
if ( $objp -> rappro && $objp -> courant != 2 && empty ( $objp -> clos )) // If not cash account and not closed and can be reconciliate
{
$newmenu -> add ( '/compta/bank/rappro.php?account=' . $objp -> rowid , $langs -> trans ( " Conciliate " ), 2 , $user -> rights -> banque -> consolidate );
}
$i ++ ;
}
}
else dol_print_error ( $db );
$db -> free ( $resql );
2013-04-15 13:11:29 +02:00
}
if ( $conf -> ftp -> enabled && $mainmenu == 'ftp' ) // Entry for FTP
{
2013-06-05 16:24:32 +02:00
$MAXFTP = 20 ;
$i = 1 ;
while ( $i <= $MAXFTP )
{
$paramkey = 'FTP_NAME_' . $i ;
//print $paramkey;
if ( ! empty ( $conf -> global -> $paramkey ))
{
$link = " /ftp/index.php?idmenu= " . $_SESSION [ " idmenu " ] . " &numero_ftp= " . $i ;
2013-07-07 03:26:51 +02:00
2013-06-05 16:24:32 +02:00
$newmenu -> add ( $link , dol_trunc ( $conf -> global -> $paramkey , 24 ));
}
$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;
$menu_array = $newmenu -> liste ;
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 );
//var_dump($menu_array);exit;
2013-03-30 14:27:13 +01:00
if ( ! is_array ( $menu_array )) return 0 ;
2013-02-24 21:16:36 +01:00
// Show menu
2013-03-29 16:16:26 +01:00
if ( empty ( $noout ))
{
2013-06-14 19:51:53 +02:00
$alt = 0 ; $blockvmenuopened = false ;
2013-04-01 16:02:16 +02:00
$num = count ( $menu_array );
for ( $i = 0 ; $i < $num ; $i ++ )
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
$showmenu = true ;
if ( ! empty ( $conf -> global -> MAIN_MENU_HIDE_UNAUTHORIZED ) && empty ( $menu_array [ $i ][ 'enabled' ])) $showmenu = false ;
$alt ++ ;
if ( empty ( $menu_array [ $i ][ 'level' ]) && $showmenu )
2013-02-24 21:16:36 +01:00
{
2013-06-14 19:51:53 +02:00
$blockvmenuopened = true ;
2013-04-01 16:02:16 +02:00
if (( $alt % 2 == 0 ))
{
print '<div class="blockvmenuimpair">' . " \n " ;
}
else
{
print '<div class="blockvmenupair">' . " \n " ;
}
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
// Place tabulation
$tabstring = '' ;
$tabul = ( $menu_array [ $i ][ 'level' ] - 1 );
if ( $tabul > 0 )
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
for ( $j = 0 ; $j < $tabul ; $j ++ )
{
$tabstring .= ' ' ;
}
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
// Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser.
$url = dol_buildpath ( $menu_array [ $i ][ 'url' ], 1 );
2013-06-05 16:24:32 +02:00
$url = preg_replace ( '/__LOGIN__/' , $user -> login , $url );
$url = preg_replace ( '/__USERID__/' , $user -> id , $url );
2013-02-24 21:16:36 +01:00
2013-04-01 16:02:16 +02:00
if ( ! preg_match ( '/mainmenu=/i' , $menu_array [ $i ][ 'url' ]))
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
if ( ! preg_match ( '/\?/' , $url )) $url .= '?' ;
else $url .= '&' ;
$url .= 'mainmenu=' . $mainmenu ;
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
2013-06-16 21:33:05 +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' ] . ' -->' . " \n " ;
2013-07-07 03:26:51 +02:00
2013-04-01 16:02:16 +02:00
// Menu niveau 0
if ( $menu_array [ $i ][ 'level' ] == 0 )
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
if ( $menu_array [ $i ][ 'enabled' ])
{
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>' ;
}
else if ( $showmenu )
{
print '<div class="menu_titre">' . $tabstring . '<font class="vmenudisabled">' . $menu_array [ $i ][ 'titre' ] . '</font></div>' . " \n " ;
}
if ( $showmenu )
print '<div class="menu_top"></div>' . " \n " ;
2013-02-24 21:16:36 +01:00
}
2013-04-01 16:02:16 +02:00
// Menu niveau > 0
if ( $menu_array [ $i ][ 'level' ] > 0 )
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
if ( $menu_array [ $i ][ 'enabled' ])
{
print '<div class="menu_contenu">' . $tabstring ;
if ( $menu_array [ $i ][ 'url' ]) print '<a class="vsmenu" href="' . $url . '"' . ( $menu_array [ $i ][ 'target' ] ? ' target="' . $menu_array [ $i ][ 'target' ] . '"' : '' ) . '>' ;
print $menu_array [ $i ][ 'titre' ];
if ( $menu_array [ $i ][ 'url' ]) print '</a>' ;
// If title is not pure text and contains a table, no carriage return added
if ( ! strstr ( $menu_array [ $i ][ 'titre' ], '<table' )) print '<br>' ;
print '</div>' . " \n " ;
}
else if ( $showmenu )
{
2013-04-01 20:15:52 +02:00
print '<div class="menu_contenu">' . $tabstring . '<font class="vsmenudisabled vsmenudisabledmargin">' . $menu_array [ $i ][ 'titre' ] . '</font><br></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
2013-04-01 16:02:16 +02:00
if ( empty ( $menu_array [ $i + 1 ][ 'level' ]))
2013-02-24 21:16:36 +01:00
{
2013-04-01 16:02:16 +02:00
if ( $showmenu )
print '<div class="menu_end"></div>' . " \n " ;
2013-06-14 19:51:53 +02:00
if ( $blockvmenuopened ) { print " </div> \n " ; $blockvmenuopened = false ; }
2013-02-24 21:16:36 +01:00
}
}
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
* @ param array & $menuentry Array for menu entry
* @ param array & $listofmodulesforexternal Array with list of modules allowed to external users
* @ 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);
if ( empty ( $menuentry [ 'enabled' ])) return 0 ; // Entry disabled by condition
if ( $type_user && $menuentry [ 'module' ])
{
$tmploops = explode ( '|' , $menuentry [ 'module' ]);
$found = 0 ;
foreach ( $tmploops as $tmploop )
{
2013-02-24 21:16:36 +01:00
if ( in_array ( $tmploop , $listofmodulesforexternal )) {
$found ++ ; break ;
}
2013-01-02 21:35:28 +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
2013-01-10 08:27:12 +01:00
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 ;
}
2010-10-02 23:31:14 +02:00
?>