示例#1
0
/**
* @desc Activa o desactiva una categoría
**/
function activeCatego($act = 0)
{
    global $xoopsSecurity;
    $cats = RMHttpRequest::request('ids', 'array', array());
    //Verificamos si se ha proporcionado una categoría
    if (empty($cats)) {
        RMUris::redirect_with_message(__('You must select at least one category', 'bxpress'), './categories.php', RMMSG_WARN);
        die;
    }
    if (!$xoopsSecurity->check()) {
        RMUris::redirect_with_message(__('Session token expired!', 'bxpress'), 'categories.php', RMMSG_ERROR);
        die;
    }
    $errors = '';
    foreach ($cats as $k) {
        //Verificamos que la categoría sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category ID %s is not valid!', 'bxpress'), '<strong>' . $k . '</strong>') . '<br />';
            continue;
        }
        //Verificamos que categoría exista
        $cat = new bXCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(_AS_BB_ERRCATNOEXIST, $k);
            continue;
        }
        $cat->setStatus($act);
        if (!$cat->save()) {
            $errors .= sprintf(_AS_BB_ERRCATNOSAVE, $k);
        }
    }
    if ($errors != '') {
        RMUris::redirect_with_message(__('Errors ocurred while trying to change status', 'bxpress') . $errors, './categories.php', RMMSG_ERROR);
        die;
    } else {
        RMUris::redirect_with_message(__('Database updated successfully!', 'bxpress'), './categories.php', RMMSG_SUCCESS);
        die;
    }
}
示例#2
0
/**
* @desc Activa o desactiva una categoría
**/
function activeCatego($act = 0)
{
    global $xoopsSecurity;
    $cats = rmc_server_var($_REQUEST, 'ids', array());
    //Verificamos si se ha proporcionado una categoría
    if (empty($cats)) {
        redirectMsg('./categos.php', __('You must select at least one category', 'bxpress'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('categos.php', __('Session token expired!', 'bxpress'), 1);
        die;
    }
    $errors = '';
    foreach ($cats as $k) {
        //Verificamos que la categoría sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category ID %s is not valid!', 'bxpress'), '<strong>' . $k . '</strong>') . '<br />';
            continue;
        }
        //Verificamos que categoría exista
        $cat = new bXCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(_AS_BB_ERRCATNOEXIST, $k);
            continue;
        }
        $cat->setStatus($act);
        if (!$cat->save()) {
            $errors .= sprintf(_AS_BB_ERRCATNOSAVE, $k);
        }
    }
    if ($errors != '') {
        redirectMsg('./categos.php', _AS_BB_ERRACTION . $errors, 1);
        die;
    } else {
        redirectMsg('./categos.php', _AS_BB_DBOK, 0);
        die;
    }
}