Beispiel #1
0
/**
* @desc Activa/desactiva las categorías especificadas
**/
function activeCategory($act = 0)
{
    global $xoopsSecurity;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : null;
    if (!$xoopsSecurity->check()) {
        redirectMsg('./categos.php', __('Session token expired!', 'works'), 1);
        die;
    }
    //Verificamos que nos hayan proporcionado una categoría
    if (!is_array($ids)) {
        redirectMsg('./categos.php', __('You must select a category to enable/disable', 'works'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la categoría es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category id "%s" is not valid!', 'works'), $k);
            continue;
        }
        //Verificamos si la categoría existe
        $cat = new PWCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(__('Specified category "%s" does not exists!', 'works'), $k);
            continue;
        }
        $cat->setActive($act);
        RMEvents::get()->run_event('works.activate.category', $cat);
        if (!$cat->save()) {
            $errors .= sprintf(__('Category "%s" could not be saved!', 'works'), $k);
        }
    }
    if ($errors != '') {
        redirectMsg('./categos.php', __('Errors ocurred while trying to save category', 'works') . $errors, 1);
        die;
    } else {
        redirectMsg('./categos.php', __('Database updated successfully!', 'works'), 0);
        die;
    }
}
Beispiel #2
0
// Author: BitC3R0 <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$xoopsOption['template_main'] = 'pw_catego.html';
$xoopsOption['module_subpage'] = 'category';
include 'header.php';
PWFunctions::makeHeader();
$mc =& $xoopsModuleConfig;
if ($id == '') {
    header('location: ' . PW_URL);
    die;
}
//Verificamos si la categoría existe
$cat = new PWCategory($id);
if ($cat->isNew()) {
    redirect_header(PW_URL . '/', 2, __('Specified category does not exists!', 'works'));
    die;
}
RMEvents::get()->run_event('works.starting.categories', $cat);
// Category
$tpl->assign('category', array('id' => $cat->id(), 'title' => $cat->name(), 'name' => $cat->nameId(), 'desc' => $cat->desc()));
//Barra de Navegación
$sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works') . " WHERE public=1 AND catego='" . $cat->id() . "'";
list($num) = $db->fetchRow($db->query($sql));
$limit = $mc['num_recent'];
$limit = $limit <= 0 ? 10 : $limit;
if (!isset($page)) {
    $page = rmc_server_var($_GET, 'page', 1);
}
$tpages = ceil($num / $limit);