Esempio n. 1
0
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**
 * @file
 * @brief user's bookmark
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
if (!isset($_GET['ac'])) {
    /*
     * find default module
     */
    $_GET['ac'] = find_default_module();
}
// Add bookmark
if (isset($_GET['bookmark_add'])) {
    $count = $cn->get_value("select count(*) from bookmark" . " where b_action=\$1 and login=\$2", array($_GET['ac'], $g_user->login));
    // Add bookmark only if absent
    if ($count == 0) {
        $cn->exec_sql("insert into bookmark(b_action,login) values(\$1,\$2)", array($_GET['ac'], $g_user->login));
    } else {
        $js = "error_message('" . _("Ce favori a déjà été ajouté") . "');";
        echo create_script($js);
    }
}
// remove bookmark
if (isset($_GET['bookmark_delete']) && isset($_GET['book'])) {
    $a_book = $_GET['book'];
Esempio n. 2
0
/**
 * 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\n\t    from profile_menu join profile_user using (p_id)\n\t    where\n\t    p_type_display='M' and\n\t    user_name=\$1 and pm_default=1", array($g_user->login));
    /*
     * Try to find the smallest order for module
     */
    if (empty($default_module)) {
        $default_module = $cn->get_array("select me_code\n\t    from profile_menu join profile_user using (p_id)\n\t    where\n\t    p_type_display='M' and\n\t    user_name=\$1 order by p_order limit 1", array($g_user->login));
        // if no default try to find the default menu
        if (empty($default_module)) {
            $default_module = $cn->get_array("select me_code\n\t\t\t from profile_menu join profile_user using (p_id)\n\t\t\t   where\n\t\t\t   p_type_display='E' and\n\t\t\t   user_name=\$1 and pm_default=1 ", array($g_user->login));
            /*
             * Try to find a default menu by order
             */
            if (empty($default_module)) {
                $default_module = $cn->get_array("select me_code\n\t\t\t\tfrom profile_menu join profile_user using (p_id)\n\t\t\t\twhere\n\t\t\t\tuser_name=\$1 and p_order=(select min(p_order) from profile_menu join profile_user using (p_id)\n\t\t\t\twhere user_name=\$2) limit 1", array($g_user->login, $g_user->login));
            }
            /*
             * if nothing found, there is no profile for this user => exit
             */
            if (empty($default_module)) {
                /* 
                 * If administrateur, then we insert a default profile (1)
                 * for him
                 */
                if ($g_user->admin == 1) {
                    $cn->exec_sql('insert into profile_user(user_name,p_id) values ($1,1) ', array($g_user->login));
                    return find_default_module();
                }
                echo_warning(_("Utilisateur n'a pas de profil, votre administrateur doit en configurer un dans CFGSEC"));
                exit;
            }
        }
        return $default_module[0]['me_code'];
    }
    if (count($default_module) > 1) {
        // return the first module found
        return $default_module[0]['me_code'];
    } elseif (count($default_module) == 1) {
        return $default_module[0]['me_code'];
    }
}
Esempio n. 3
0
            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();
    if ($user_profile == "") {
        throw new Exception(_('Aucun profil utilisateur'));
    }
    $menu_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 code= upper($1)  and p_id=$2', array($default, $user_profile));
    $_GET['ac'] = $default;
    $_POST['ac'] = $default;
    $_REQUEST['ac'] = $default;
    show_module($menu_id);
    $all[0] = $default;
    show_menu($menu_id);