' . $p_string . ''; } function hi($p_string) { return '' . htmlspecialchars($p_string) . ''; } function hb($p_string) { return '' . htmlspecialchars($p_string) . ''; } function th($p_string, $p_extra='') { return '
| ' . $href[1] . ' | |
| ' . $href[1] . ' | |
| ' . $href[1] . ' | '; } else { $ret.='' . $href[1] . ' | '; } } $ret.="
$html
EOF;
exit();
}
}
/**
*
* @param int $selected module selected
*/
function show_module($selected)
{
global $g_user;
$cn = Dossier::connect();
$amodule = $cn->get_array("select
me_code,me_menu,me_url
from v_all_menu
where
user_name=$1
and p_type_display='M'
order by p_order", array($g_user->login));
if ($selected != -1)
{
require_once('template/module.php');
$file = $cn->get_array("select me_file,me_parameter from v_all_menu
where me_code=$1 and user_name=$2", array($selected,$g_user->login));
if ($file[0]['me_file'] != '')
{
if ($file[0]['me_parameter'] !== "")
{
// if there are paramter put them in superglobal
$array=compute_variable($file[0]['me_parameter']);
put_global($array);
}
require_once $file[0]['me_file'];
exit();
}
}
else
{
}
}
/**
* Find the default module or the first one
* @global $g_user $g_user
* @return default module (string)
*/
function find_default_module()
{
global $g_user;
$cn = Dossier::connect();
$default_module = $cn->get_array("select me_code
from profile_menu join profile_user using (p_id)
where
p_type_display='M' and
user_name=$1 and pm_default=1", array($g_user->login));
if (empty($default_module))
{
$default_module = $cn->get_array("select me_code
from profile_menu join profile_user using (p_id)
where
user_name=$1 and p_order=(select min(p_order) from profile_menu
where user_name=$2) limit 1", array($g_user->login, $g_user->login));
return $default_module[0]['me_code'];
}
if (count($default_module) > 1)
{
echo_error("Plusieurs modules sont le module par défaut", __LINE__, __FILE__);
}
elseif (count($default_module) == 1)
{
return $default_module[0]['me_code'];
}
}
/**
* show the module
* @global $g_user
* @param $module the $_REQUEST['ac'] exploded into an array
* @param $idx the index
*/
function show_menu($module, $idx)
{
global $g_user;
$cn = Dossier::connect();
$amenu = $cn->get_array("select
me_menu,me_code
from v_all_menu
where
me_code_dep=$1 and user_name=$2 order by p_order", array($module[$idx], $g_user->login));
if (!empty($amenu) && count($amenu) > 1)
{
require 'template/menu.php';
}
elseif (count($amenu) == 1)
{
echo '';
$module[$idx] = $amenu[0]['me_code'];
}
if (empty($amenu) || count($amenu) == 1)
{
/**
* @todo add security
* check if user can access this module
*/
$file = $cn->get_array("select me_file,me_parameter
from menu_ref
where
me_code=$1 and
(me_file is not null or trim(me_file) <>'')", array($module[$idx]));
if (count($file)==0)
{
echo "Configuration incorrecte pour ce module ".$module[$idx];
exit;
}
if ($file[0]['me_file'] != "")
{
if ($file[0]['me_parameter'] !== "")
{
// if there are paramter put them in superglobal
$array=compute_variable($file[0]['me_parameter']);
put_global($array);
}
echo '