function admin_addpanelaction($panel, $action, $showpanel = true)
{
    global $fpadminpanelactions;
    if (admin_panelexists($panel)) {
        $fpadminpanelactions[$panel][$action] = $showpanel;
    }
}
Beispiel #2
0
function main()
{
    // general setup
    global $panel, $action, $lang, $smarty, $fp_admin, $fp_admin_action;
    $panels = admin_getpanels();
    $panel = isset($_GET['p']) ? $_GET['p'] : $panels[0];
    define('ADMIN_PANEL', $panel);
    $smarty->assign('panel', $panel);
    if (!admin_panelexists($panel)) {
        trigger_error('Requested panel does not exists!', E_USER_ERROR);
    }
    $panelprefix = "admin.{$panel}";
    $panelpath = ADMIN_DIR . "panels/{$panel}/{$panelprefix}.php";
    $fp_admin = null;
    if (file_exists($panelpath)) {
        include $panelpath;
        $panelclass = "admin_{$panel}";
        if (!class_exists($panelclass)) {
            trigger_error("No class defined for requested panel", E_USER_ERROR);
        }
        $fp_admin = new $panelclass($smarty);
    }
    /* check if user is loggedin */
    if (!user_loggedin()) {
        utils_redirect("login.php");
        die;
    }
    $action = isset($_GET['action']) ? $_GET['action'] : 'default';
    if (!$fp_admin) {
        return;
    }
    $fp_admin_action = $fp_admin->get_action($action);
    define('ADMIN_PANEL_ACTION', $action);
    $smarty->assign('action', $action);
    $panel_url = BLOG_BASEURL . "admin.php?p={$panel}";
    $action_url = $panel_url . "&action={$action}";
    $smarty->assign('panel_url', $panel_url);
    $smarty->assign('action_url', $action_url);
    if (!empty($_POST)) {
        check_admin_referer("admin_{$panel}_{$action}");
    }
    $smarty->assign('success', sess_remove("success_{$panel}"));
    $retval = $fp_admin_action->exec();
    if ($retval > 0) {
        // if has REDIRECT option
        // clear postdata by a redirect
        sess_add("success_{$panel}", $smarty->get_template_vars('success'));
        $smarty->get_template_vars('success');
        $to_action = $retval > 1 ? '&action=' . $action : '';
        $with_mod = isset($_GET['mod']) ? '&mod=' . $_GET['mod'] : '';
        $with_arguments = '';
        if ($retval == PANEL_REDIRECT_CURRENT) {
            foreach ($fp_admin_action->args as $mandatory_argument) {
                $with_arguments .= '&' . $mandatory_argument . '=' . $_REQUEST[$mandatory_argument];
            }
        }
        $url = "admin.php?p={$panel}{$to_action}{$with_mod}{$with_arguments}";
        utils_redirect($url);
    }
    $smarty->register_modifier('action_link', 'admin_filter_action');
    $smarty->register_modifier('cmd_link', 'admin_filter_command');
}