header("Pragma: no-cache"); $plugin->create_pdf_url($all ? $print_book_url : $print_section_url, $res->getVar('title') . '.pdf', $options); } // Sección $section = new RDSection($id, isset($res) ? $res : null); if ($section->isNew()) { RDfunctions::error_404(); } $res = new RDResource($section->getVar('id_res')); //Verificamos si es una publicación aprobada if ($res->isNew()) { RDFunctions::error_404(); } // Check if section is a top parent if ($section->getVar('parent') > 0) { $top = RDfunctions::super_parent($section->getVar('parent')); header('location: ' . html_entity_decode($top->permalink()) . '#' . $section->getVar('nameid')); die; } if (!$res->getVar('approved')) { redirect_header(RDURL, 0, __('This content is not available!', 'docs')); die; } // Comprobamos permisos if (!$res->isAllowed($xoopsUser ? $xoopsUser->groups() : XOOPS_GROUP_ANONYMOUS)) { redirect_header(RDURL, 0, __('You are not allowed to read this content!', 'docs')); die; } // Select correct operation $action = rmc_server_var($_GET, 'action', ''); switch ($action) {
/** * @desc Modifica el orden de las secciones **/ function changeOrderSections() { global $xoopsSecurity, $xoopsModuleConfig; $orders = rmc_server_var($_POST, 'orders', array()); $id = rmc_server_var($_POST, 'id', 0); if ($xoopsModuleConfig['permalinks']) { $url_ret = RDfunctions::url() . '/list/' . $id . '/'; } else { $url_ret = RDFunctions::url() . '?page=edit&action=list&id=' . $id; } if (!$xoopsSecurity->check()) { redirect_header($url_ret, 0, __('Session token expired!', 'docs')); die; } if (!is_array($orders) || empty($orders)) { redirect_header($url_ret, 1, __('Sorry, the data provided contains some errors!', 'docs'), 1); die; } $errors = ''; foreach ($orders as $k => $v) { if ($k <= 0) { continue; } //Comprueba si la sección es existente $sec = new RDSection($k); if ($sec->isNew()) { continue; } $sec->setVar('order', $v); if (!$sec->save()) { $errors .= sprintf(__('Order could not be saved for section %s', 'docs'), $sec->getVar('title')) . '<br />'; } } if ($errors != '') { redirect_header($url_ret, 1, __('Errors ocurred while trying to update orders') . '<br />' . $errors); } else { redirect_header($url_ret, 0, __('Sections updated successfully!', 'docs')); } }
$path = trim($path, '/'); } $params = explode("/", $path); } else { // If friendly urls are disabled $path = parse_url(RMFunctions::current_url()); if (isset($path['query'])) { parse_str($path['query']); } if (!isset($page) || $page == '') { require 'mainpage.php'; die; } $file = $page . '.php'; if (!file_exists(XOOPS_ROOT_PATH . '/modules/docs/' . $file)) { RDfunctions::error_404(); } if (!$xoopsModuleConfig['standalone'] && isset($standalone)) { unset($standalone); } include $file; die; } foreach ($params as $i => $p) { if ($p == 'standalone') { $standalone = $params[$i + 1]; $temp = array_slice($params, 0, $i); if ($i == count($params) - 1) { $temp = array_merge($temp, array_slice($params, $i + 1)); } $params = $temp;
/** * @desc Almacena la información de la publicación **/ function rd_save_resource($edit = 0) { global $xoopsModuleConfig, $xoopsUser, $xoopsSecurity; $nameid = ''; $q = ''; foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $q .= $q == '' ? "{$k}=" . urlencode($v) : "&{$k}=" . urlencode($v); } if ($action == 'save') { $q .= '&action=new'; } else { $q .= "&action=edit"; } if (!$xoopsSecurity->check()) { redirectMsg('resources.php?' . $q, __('Session token expired!', 'docs'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Comprueba si la publicación es válida if ($id <= 0) { redirectMsg('resources.php', __('You must provide a valid Document ID', 'docs'), 1); die; } //Comprueba si la publicación existe $res = new RDResource($id); if ($res->isNew()) { redirectMsg('resources.php', __('Specified Document does not exists!', 'docs'), 1); die; } //Comprueba que el título de publicación no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE title='{$title}' AND id_res<>'" . $id . "'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirectMsg('resources.php?' . $q, __('A Document with same title exists already!', 'docs'), 1); die; } } else { //Comprueba que el título de publicación no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE title='{$title}' "; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirectMsg('resources.php?' . $q, __('A Document with same title exists already!', 'docs'), 1); die; } $res = new RDResource(); } //Genera $nameid Nombre identificador if ($nameid == '' || $res->getVar('title') != $title) { $found = false; $i = 0; do { $nameid = TextCleaner::getInstance()->sweetstring($title) . ($found ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources') . " WHERE nameid = '{$nameid}'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { $found = true; $i++; } else { $found = false; } } while ($found == true); } $res->setVar('title', $title); $res->setVar('description', $desc); $res->isNew() ? $res->setVar('created', time()) : $res->setVar('modified', time()); $res->setVar('editors', $editors); $res->setVar('editor_approve', $approvededit); $res->setVar('groups', $groups); $res->setVar('public', $public); $res->setVar('quick', $quick); $res->setVar('nameid', $nameid); $res->setVar('show_index', $showindex); $res->setVar('featured', $featured); $res->setVar('approved', $approvedres); $res->setVar('single', $single); if ($res->isNew()) { $res->setVar('owner', $xoopsUser->uid()); $res->setVar('owname', $xoopsUser->uname()); } elseif ($owner != $res->getVar('owner')) { $xuser = new $xoopsUser($owner); $res->setVar('owner', $owner); $res->setVar('owname', $xuser->uname()); } if (!$res->save()) { redirectMsg('resources.php?' . $q, __('Document could not be saved!', 'docs') . '<br />' . $res->errors(), 1); die; } else { if (!$res->isNew()) { /** * Comprobamos si el recurso no estaba aprovado previamente * para enviar la notificación. * La notificación solo se envía si el dueño es distinto * al administrador actual. */ if (!$app && $app != $res->getVar('approved') && $xoopsUser->uid() != $res->getVar('owner')) { $errors = RDfunctions::mail_approved($res); redirectMsg('./resources.php?page=' . $page, $errors, 1); } } redirectMsg('./resources.php?limit=' . $limit . '&page=' . $page, __('Document saved successfully!', 'docs'), 0); } }