Example #1
0
    from v_menu_profile where code= upper($1)  and p_id=$2', array($AC, $user_profile));
    try {
        if (count($amenu_id) != 1) {
            // if AC is a simple code and this menu can be accessed
            // we should find the first menu which used it and change the
            // request AC to it
            $pm_id = $cn->get_array('select pm_id from profile_menu ' . ' where lower(me_code)=lower($1) and p_id=$2', array($AC, $user_profile));
            if (count($pm_id) > 0) {
                show_menu($pm_id[0]['pm_id']);
            } else {
                throw new Exception(_('Erreur menu'), 10);
            }
        }
        $module_id = $cn->get_value('select case when pm_id_v3 = 0 then (case when pm_id_v2 = 0 then pm_id_v1 else pm_id_v2 end) else pm_id_v3 end 
            from v_menu_profile where p_id=$1 and upper(code)=upper($2)', array($user_profile, $AC));
        $g_user->audit();
        // Show module and highligt selected one
        show_module($module_id);
        show_menu($amenu_id[0]['pm_id_v3']);
        show_menu($amenu_id[0]['pm_id_v2']);
        show_menu($amenu_id[0]['pm_id_v1']);
    } catch (Exception $e) {
        if ($e->getCode() == 10) {
            alert(_('Accès menu impossible'));
        } else {
            alert($e->getTraceAsString());
        }
    }
} else {
    $default = find_default_module();
    $user_profile = $g_user->get_profile();