示例#1
0
/**
* @desc Almacena los camobios realizados en el orden de las categorías
**/
function updateOrderCatego()
{
    global $xoopsSecurity;
    $orders = isset($_POST['orders']) ? $_POST['orders'] : array();
    if (!$xoopsSecurity->check()) {
        RMUris::redirect_with_message(__('Token session expired. Try again.', 'bxpress'), 'categories.php', RMMSG_ERROR);
    }
    $errors = '';
    foreach ($orders as $k => $v) {
        //Verificamos que la categoría sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category ID is not valid: %s', 'bxpress'), $k);
            continue;
        }
        //Verificamos que categoría exista
        $cat = new bXCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(__('Category with ID %u does not exists.', 'bxpress'), $k);
            continue;
        }
        //Actualizamos el orden
        $cat->setOrder($v);
        if (!$cat->save()) {
            $errors .= sprintf(__('Category %s could not be saved.', 'bxpress'), $k);
        }
    }
    if ($errors != '') {
        RMUris::redirect_with_message(__('Errors ocurred while trying to update categories order', 'bxpress') . $errors, './categories.php', RMMSG_ERROR);
    } else {
        RMUris::redirect_with_message(__('Database updated successfully!', 'bxpress'), './categories.php', RMMSG_SUCCESS);
    }
}
示例#2
0
/**
* @desc Almacena los camobios realizados en el orden de las categorías
**/
function updateOrderCatego()
{
    global $util;
    $orders = isset($_POST['orders']) ? $_POST['orders'] : array();
    if (!$util->validateToken()) {
        redirectMsg('categos.php', _AS_BB_ERRTOKEN, 1);
        die;
    }
    foreach ($orders as $k => $v) {
        //Verificamos que la categoría sea válida
        if ($k <= 0) {
            $errors .= sprintf(_AS_BB_ERRCATNOVALID, $k);
            continue;
        }
        //Verificamos que categoría exista
        $cat = new bXCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(_AS_BB_ERRCATNOEXIST, $k);
            continue;
        }
        //Actualizamos el orden
        $cat->setOrder($v);
        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;
    }
}