2010-04-06 12:56:25 +00:00

121 lines
2.3 KiB
PHP

<?php
require_once 'user/user.php';
require_once realpath(dirname(__FILE__)).'/menu_liens.php';
require_once realpath(dirname(__FILE__)).'/defineMenu.php';
function menu()
{
$menu = array();
$menu = defineMenu();
$html = '';
foreach($menu as $item)
{
$href = false;
//Gestion des permissions sur le menu
$displayMenu = true;
if( isset($item['perm']) )
{
$permStatut = false;
foreach($item['perm']['list'] as $perm)
{
$permStatut = $permStatut || hasPerm($perm);
}
if(!$permStatut)
{
if( !isset($item['perm']['hidden']) ||
$item['perm']['hidden']===false )
{
$displayMenu = true;
}
elseif( isset($item['perm']['hidden']) &&
$item['perm']['hidden']===true )
{
$displayMenu = false;
}
}
}
if($displayMenu)
{
$html.= '<h3><a href="#">'.$item['data'].'</a></h3>'."\n";
$html.= '<div>'."\n";
$html.= '<ul>'."\n";
foreach($item['children'] as $children)
{
$html.= menu_children($children);
}
$html.= '</ul>'."\n";
$html.= '</div>'."\n";
}
}
return $html;
}
function menu_children($children)
{
global $firephp;
//Génération du lien
$href = false;
if( $children['href']!='' && function_exists($children['href']) )
{
$href = $children['href']();
}
//Traitement des permissions
if( isset($children['perm']) )
{
$permStatut = false;
foreach($children['perm']['list'] as $perm)
{
$permStatut = $permStatut || hasPerm($perm);
}
if(!$permStatut)
{
if( !isset($children['perm']['hidden']) ||
$children['perm']['hidden']===false )
{
$href = '#';
}
elseif( isset($children['perm']['hidden']) &&
$children['perm']['hidden']===true )
{
$href = false;
}
}
}
//Traitement profil
if(isset($children['profil']))
{
if( ( !isset($children['profil']['hidden']) ||
$children['profil']['hidden']===false ) &&
hasProfil($children['profil']['name'])===false )
{
$href = '#';
}
elseif( isset($children['profil']['hidden']) &&
$children['profil']['hidden'] &&
hasProfil($children['profil']['name'])===false )
{
$href = false;
}
}
//Output
$html = '';
if($href!==false)
{
$html.= '<li><a href="'.$href.'">';
if($href=='#'){
$html.= '<font color="gray">'.
$children['data'].
'</font>';
}
else{ $html.= $children['data']; }
$html.= '</a></li>';
$html.= "\n";
}
return $html;
}