Example #1
0
/**
* @desc Permite hacer publico o no un album
**/
function publicAlbums($pub = 0)
{
    global $xoopsSecurity;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $ok = isset($_POST['ok']) ? $_POST['ok'] : 0;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set';
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $ruta = "pag={$page}&limit={$limit}&sort={$sort}&mode={$mode}&search={$search}";
    //Verificamos si nos proporcionaron al menos un album para publicar
    if (!is_array($ids)) {
        redirectMsg('./sets.php?' . $ruta, __('Select one album at least!', 'galleries'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./sets.php?' . $ruta, __('Session token expired!', 'galleries'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si el album es válido
        if ($k <= 0) {
            $errors .= sprintf(__('"%u" is not a valid ID', 'galleries'), $k);
            continue;
        }
        //Verificamos si el album existe
        $set = new GSSet($k);
        if ($set->isNew()) {
            $errors .= sprintf(__('Album "%u" does not exists', 'galleries'), $k);
            continue;
        }
        $set->setPublic($pub);
        if (!$set->save()) {
            $errors .= sprintf(__('Error ocurred while trying to update album "%u"!', 'galleries'), $k);
        }
    }
    if ($erros != '') {
        redirectMsg('./sets.php?' . $ruta, __('Errors ocurred while trying to update albums', 'galleries') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('./sets.php?' . $ruta, __('Database updated successfully!', 'galleries'), 0);
        die;
    }
}
Example #2
0
/**
* @desc Almacena la información del album en la base de datos
**/
function saveSets($edit = 0)
{
    global $xoopsUser, $xoopsModuleConfig, $page, $id;
    $mc =& $xoopsModuleConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/' . $page : '?cp=sets&amp;pag=' . $pag);
    if ($edit) {
        //Verificamos que el album sea válido
        if ($id <= 0) {
            redirect_header($link, 1, __('Provided ID is not valid!', 'galleries'));
            die;
        }
        //Verificamos que el album exista
        $set = new GSSet($id);
        if ($set->isNew()) {
            redirect_header($link, 1, __('Specified album does not exists!', 'galleries'));
            die;
        }
    } else {
        $set = new GSSet();
    }
    $set->setTitle($title);
    $set->setPublic($public);
    $set->setOwner($xoopsUser->uid());
    $set->setUname($xoopsUser->uname());
    $set->setDate(time());
    if (!$set->save()) {
        redirect_header($link, 1, __('Album could not be saved. Please try again.', 'galleries'));
        die;
    } else {
        redirect_header($link, 1, __('Album saved successfully!', 'galleries'));
        die;
    }
}