Exemplo n.º 1
0
    $options = array('--filename' => $res->getVar('title') . '.pdf', '--header-left' => $res->getVar('title'), '--header-right' => $xoopsConfig['sitename'], '--header-line' => '1');
    header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    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'));
Exemplo n.º 2
0
 /**
  * Get all figures list according to given parameters
  * @param int Resource ID
  * @param Referenced var to return results count
  * @param string Search keyword
  * @param int Start results
  * @param int Results number limit
  * @return array
  */
 public function figures($res = 0, &$count, $search = '', $start = 0, $limit = 15)
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_figures') . ($res > 0 ? " WHERE id_res='{$res}'" : '');
     if ($search != '') {
         $sql .= ($res > 0 ? " AND " : " WHERE ") . " (desc LIKE '%{$k}%' OR content LIKE '%{$k}%')";
     }
     if ($res > 0) {
         $res = new RDResource($res);
     }
     list($num) = $db->fetchRow($db->query($sql));
     $limit = $limit <= 0 ? 15 : $limit;
     $count = $num;
     //Fin de navegador de páginas
     $sql = str_replace("COUNT(*)", "*", $sql);
     $sql .= " ORDER BY id_fig DESC LIMIT {$start},{$limit}";
     $result = $db->query($sql);
     $figures = array();
     while ($rows = $db->fetchArray($result)) {
         $ref = new RDFigure();
         $ref->assignVars($rows);
         if ($res->isNew()) {
             $res = new RDResource($ref->resource());
         }
         $figures[] = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'desc' => $ref->getVar('desc'), 'content' => substr(TextCleaner::getInstance()->clean_disabled_tags($ref->getVar('content')), 0, 50) . "...", 'resource' => $res->getVar('title'));
     }
     return $figures;
 }
Exemplo n.º 3
0
/**
* @desc Almacena toda la información referente a la sección
**/
function saveSection($edit = 0, $ret = 0)
{
    global $xoopsUser, $xoopsModuleConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    //Verifica si se proporcionó una publicación para la sección
    if ($res <= 0) {
        redirect_header(RDURL, 1, __('Operation not allowed!', 'docs'));
        die;
    }
    //Verifica si la publicación existe
    $res = new RDResource($res);
    if ($res->isNew()) {
        redirect_header(RDURL, 1, __('Operation not allowed!', 'docs'));
        die;
    }
    //Verificamos si es una publicación aprobada
    if (!$res->getVar('approved')) {
        redirect_header(RDURL, 2, __('This Document has not been approved yet!', 'docs'));
        die;
    }
    // TODO: Crear el link correcto de retorno
    if ($xoopsModuleConfig['permalinks']) {
        $retlink = RDFunctions::url() . '/list/' . $res->getVar('nameid') . '/';
    } else {
        $retlink = RDFunctions::url() . '?page=edit&action=list&res=' . $res->id();
    }
    //Verificamos si el usuario tiene permisos de edicion
    if (!$xoopsUser->uid() == $res->getVar('owner') && !$res->isEditor($xoopsUser->uid()) && !$xoopsUser->isAdmin()) {
        redirect_header(RDURL, 2, __('You can not edit this content!', 'docs'));
        die;
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    if ($edit) {
        //Verifica si la sección es válida
        if ($id == '') {
            redirect_header($retlink, 1, __('Specified section is not valid!', 'docs'));
            die;
        }
        //Comprueba si la sección es existente
        $sec = new RDSection($id);
        if ($sec->isNew()) {
            redirect_header($retlink, 1, __('Specified section does not exists!', 'docs'));
            die;
        }
        //Comprueba que el título de la sección no exista
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='{$res}' AND id_sec<>" . $sec->id();
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirect_header($sec->editlink(), 1, __('Already exists another section with same title!', 'docs'));
            die;
        }
        /**
         * Comprobamos si debemos almacenar las ediciones en la
         * tabla temporal o directamente en la tabla de secciones
         */
        if (!$res->getVar('editor_approve') && !$xoopsUser->isAdmin()) {
            $sec = new RDEdit(null, $id_sec);
        }
    } else {
        //Comprueba que el título de la sección no exista
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='" . $res->id() . "'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirect_header(ah_make_link('publish/' . $res->nameId() . '/'), 1, _MS_AH_ERRTITLE);
            die;
        }
        $sec = new RDSection();
    }
    //Genera $nameid Nombre identificador
    if ($title != $sec->getVar('title')) {
        $found = false;
        $i = 0;
        do {
            $nameid = TextCleaner::getInstance()->sweetstring($title) . ($found ? $i : '');
            $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE nameid = '{$nameid}'";
            list($num) = $db->fetchRow($db->queryF($sql));
            if ($num > 0) {
                $found = true;
                $i++;
            } else {
                $found = false;
            }
        } while ($found == true);
    }
    if (!$res->getVar('editor_approve') && !$xoopsUser->isAdmin() && !($res->getVar('owner') == $xoopsUser->uid())) {
        $sec->setVar('id_sec', $id);
    }
    $sec->setVar('title', $title);
    $sec->setVar('content', $content);
    $sec->setVar('order', $order);
    $sec->setVar('id_res', $res->id());
    isset($nameid) ? $sec->setVar('nameid', $nameid) : '';
    $sec->setVar('parent', $parent);
    $sec->setVar('uid', $xoopsUser->uid());
    $sec->setVar('uname', $xoopsUser->uname());
    if ($edit) {
        $sec->setVar('modified', time());
    } else {
        $sec->setVar('created', time());
        $sec->setVar('modified', time());
    }
    // Metas
    if ($edit) {
        $sec->clear_metas();
    }
    // Clear all metas
    // Initialize metas array if not exists
    if (!isset($metas)) {
        $metas = array();
    }
    // Get meta key if "select" is visible
    if (isset($meta_name_sel) && $meta_name_sel != '') {
        $meta_name = $meta_name_sel;
    }
    // Add meta to metas array
    if (isset($meta_name) && $meta_name != '') {
        array_push($metas, array('key' => $meta_name, 'value' => $meta_value));
    }
    // Assign metas
    foreach ($metas as $value) {
        $sec->add_meta($value['key'], $value['value']);
    }
    RMEvents::get()->run_event('docs.saving.section', $sec);
    if (!$sec->save()) {
        redirect_header($sec->editlink(), 3, __('Section could not be saved!', 'docs'));
    } else {
        if ($edit) {
            $sec = new RDSection($sec->getVar('id_sec'));
        }
        if ($return == 1) {
            redirect_header($sec->permalink(), 1, __('Database updated successfully!', 'docs'));
        } elseif ($return == 2) {
            redirect_header($sec->editlink(), 1, __('Database updated successfully!', 'docs'));
        } else {
            redirect_header($retlink, 1, __('Database updated successfully!', 'docs'));
        }
    }
}
Exemplo n.º 4
0
}
// Sections list
if ($params[0] == 'list') {
    $id = $params[1];
    include 'edit.php';
    die;
}
// Explore
if ($params[0] == 'explore' || $params[0] == 'search') {
    $action = $params[0];
    if (isset($params[3])) {
        $page = $params[3];
    }
    $by = isset($params[1]) ? $params[1] : '';
    include 'search.php';
    die;
}
// Section
if (count($params) >= 2) {
    $res = new RDResource($params[0]);
    if (!$res->isNew()) {
        $res = $res->id();
        $id = $params[1];
        include 'content.php';
        die;
    }
}
// Once all verifications has been passed then the resource
// param is present, then we will show it
$id = $params[0];
require 'resource.php';
Exemplo n.º 5
0
/**
* @desc Almacena toda la información referente a la figura
**/
function saveFigures($edit = 0)
{
    global $xoopsSecurity;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = 'id=' . $id . '&pag=' . $pag . '&search=' . $search;
    if (!$xoopsSecurity->check()) {
        redirectMsg('./figures.php?' . $ruta, __('Session token expired!', 'docs'), 1);
        die;
    }
    //Comprobar publicacion valida
    if ($id <= 0) {
        redirectMsg('./figures.php?' . $ruta, __('No Document has been selected!', 'docs'), 1);
        die;
    }
    //Comprobar publicación existente existente
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('./figures.php?' . $ruta, __('Specified Document does not exists!'), 1);
        die;
    }
    if ($edit) {
        //Comprueba que la figura sea válida
        if ($id_fig <= 0) {
            redirectMsg('./figures.php?' . $ruta, __('No figure has been selected!', 'docs'), 1);
            die;
        }
        //Comprueba  si existe la figura
        $fig = new RDFigure($id_fig);
        if ($fig->isNew()) {
            redirectMsg('./figures.php?' . $ruta, __('Specified figure does not exists!', 'docs'), 1);
            die;
        }
    } else {
        $fig = new RDFigure();
    }
    $fig->setVar('id_res', $id);
    $fig->setVar('attrs', $attrs);
    $fig->setVar('desc', $desc);
    $fig->setVar('content', $content);
    $fig->setVar('title', $title);
    if (!$fig->save()) {
        redirectMsg('./figures.php?action=new&' . $ruta, __('Database could not be updated!', 'docs'), 1);
    } else {
        redirectMsg('./figures.php?' . $ruta, __('Database updated successfully!', 'docs'), 0);
    }
}
Exemplo n.º 6
0
/**
* @desc Elimina la información de una sección
**/
function rd_delete_sections()
{
    global $xoopsModule;
    $id = rmc_server_var($_GET, 'id', 0);
    $id_sec = rmc_server_var($_GET, 'sec', 0);
    // Check if a Document id has been provided
    if ($id <= 0) {
        redirectMsg('resources.php', __('You have not specify a Document id', 'docs'), 1);
        die;
    }
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('The specified Document does not exists!', 'docs');
        die;
    }
    // Check if a section id has been provided
    if ($id_sec <= 0) {
        redirectMsg('./sections.php?id=' . $id, __('You have not specified a section ID to delete!', 'docs'), 1);
        die;
    }
    $sec = new RDSection($id_sec);
    if ($sec->isNew()) {
        redirectMsg('./sections.php?id=' . $id, __('Specified section does not exists!', 'docs'), 1);
        die;
    }
    if (!$sec->delete()) {
        redirectMsg('./sections.php?id=' . $id, __('Errors ocurred while trying to delete sections!', 'docs') . '<br />' . $sec->errors(), 1);
        die;
    } else {
        redirectMsg('./sections.php?id=' . $id, __('Sections deleted successfully!', 'docs'), 0);
    }
}
Exemplo n.º 7
0
 public function get_item_url($params, $com)
 {
     static $cresources;
     static $csections;
     $params = urldecode($params);
     parse_str($params);
     if (!isset($res) || $res <= 0) {
         return __('Unknow element', 'docs');
     }
     include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdsection.class.php';
     if (isset($id) && $id > 0) {
         if (isset($csections[$id])) {
             $ret = $csections[$id]->permalink() . '#comment-' . $com->id();
             return $ret;
         }
         $sec = new RDSection($id);
         if ($sec->isNew()) {
             return '';
         }
         $ret = $sec->permalink() . '#comment-' . $com->id();
         $csections[$id] = $sec;
         return $ret;
     } else {
         if (isset($cresources[$res])) {
             $ret = $cresources[$res]->permalink() . '#comment-' . $com->id();
             return $ret;
         }
         $resoruce = new RDResource($res);
         if ($resoruce->isNew()) {
             return '';
         }
         $ret = $resoruce->permalink() . '#comment-' . $com->id();
         $cresources[$res] = $resoruce;
         return $ret;
     }
 }
Exemplo n.º 8
0
/**
* @desc Almacena toda la información referente a la referencia
**/
function saveReferences($edit = 0)
{
    global $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = '?id=' . $id . '&page=' . $page . '&limit=' . $limit . '&search=' . $search;
    if (!$xoopsSecurity->check()) {
        redirectMsg('./references.php' . $ruta, __('Session token expired!', 'docs'), 1);
        die;
    }
    //Comprobar publicacion valida
    if ($id <= 0) {
        redirectMsg('./references.php' . $ruta, __('Document ID not provided!', 'docs'), 1);
        die;
    }
    //Comprobar publicación existente existente
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('./references.php' . $ruta, __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    if ($edit) {
        if ($id_ref <= 0) {
            redirectMsg('./references.php' . $ruta, __('Note id not provided!', 'docs'), 1);
            die;
        }
        $ref = new RDReference($id_ref);
        if ($ref->isNew()) {
            redirectMsg('./references.php' . $ruta, __('Specified note does not exists!', 'docs'), 1);
            die;
        }
        //Comprobar si el título de la referencia en esa publicación existe
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . " WHERE title='{$title}' AND id_res='{$id}' AND id_ref<>'{$id_ref}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./references.php' . $ruta, __('Another note with same title already exists', 'docs'), 1);
            die;
        }
    } else {
        //Comprobar si el título de la referencia en esa publicación existe
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . " WHERE title='{$title}' AND id_res='{$id}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./references.php' . $ruta, __('Another note with same title already exists', 'docs'), 1);
            die;
        }
        $ref = new RDReference();
    }
    $ref->setVar('id_res', $id);
    $ref->setVar('title', $title);
    $ref->setVar('text', $reference);
    if ($ref->save()) {
        redirectMsg('./references.php' . $ruta, __('Note saved successfully', 'docs'), 0);
    } else {
        redirectMsg('./references.php' . $ruta, __('Errors ocurred while trying to save note', 'docs'), 1);
    }
}
Exemplo n.º 9
0
/**
* desc Edita Referencias
**/
function rd_edit_note()
{
    global $xoopsModule;
    RMTemplate::get()->assign('xoops_pagetitle', __('Editing Note', 'docs'));
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Editing Note', 'docs'));
    xoops_cp_header();
    $id = rmc_server_var($_GET, 'id', 0);
    $id_res = rmc_server_var($_GET, 'res', 0);
    if ($id_res <= 0) {
        redirectMsg('./notes.php', __('Document not specified', 'docs'), 1);
        die;
    }
    $res = new RDResource($id_res);
    if ($res->isNew()) {
        redirectMsg('./notes.php', __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    if ($id <= 0) {
        redirectMsg('./notes.php?res=' . $res, __('Note not specified', 'docs'), 1);
        die;
    }
    //Verifica que referencia exista
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        redirectMsg('./notes.php?res=' . $res, __('Specified note does not exists!', 'docs'), 1);
        die;
    }
    //Formulario
    $form = new RMForm(__('Edit Note', 'docs'), 'frmref', 'notes.php');
    $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 150, $ref->getVar('title')), true);
    $form->addElement(new RMFormTextArea(__('Content', 'docs'), 'reference', 5, 50, $ref->getVar('text', 'e')), true);
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', __('Save Changes', 'docs'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'notes.php?res=' . $res . '\';"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', 'saveedit'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('res', $id_res));
    $form->display();
    xoops_cp_footer();
}
Exemplo n.º 10
0
/**
* @desc Permite aprobar o no una publicación
**/
function approved_resources($app = 0)
{
    global $xoopsSecurity, $xoopsConfig, $xoopsModuleConfig;
    $resources = rmc_server_var($_POST, 'ids', array());
    $page = rmc_server_var($_POST, 'page', 1);
    if (!$xoopsSecurity->check()) {
        redirectMsg('./resources.php?page=' . $page, __('Session token expired!', 'docs'), 1);
        die;
    }
    //Verifica que se haya proporcionado una publicación
    if (!is_array($resources) || empty($resources)) {
        redirectMsg('./resources.php?page=' . $page, __('Select at least a Document!', 'docs'), 1);
        die;
    }
    $errors = '';
    foreach ($resources as $k) {
        //Comprueba si la publicación es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Document ID "%s" is not valid!', 'docs'), $k);
            continue;
        }
        //Comprueba si la publicación existe
        $res = new RDResource($k);
        if ($res->isNew()) {
            $errors .= sprintf(__('Document with ID "%s" does not exists!', 'docs'), $k);
            continue;
        }
        $approved = $res->getVar('approved');
        $res->setVar('approved', $app);
        if (!$res->save()) {
            $errors .= sprintf(__('Resoource "%s" could not be saved!', 'docs'), $k);
        } else {
            if ($app && !$approved) {
                $errors .= RDFunctions::mail_approved($res) != true ? __('Notification email could not be sent!', 'docs') . '<br />' : '';
            }
        }
    }
    if ($errors != '') {
        redirectMsg('./resources.php?page=' . $page, __('Errors ocurred while trying to update resources.') . '<br />' . $errors, 1);
    } else {
        redirectMsg('./resources.php?page=' . $page, __('Documents updated successfully!', 'docs'), 0);
    }
}
Exemplo n.º 11
0
/**
* @desc Permite la edición de figuras
**/
function rd_figures_form($edit = 0)
{
    global $xoopsModule, $xoopsConfig;
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . $edit ? __('Edit Figure', 'docs') : __('Create Figure'));
    xoops_cp_header();
    $id = rmc_server_var($_GET, 'id', 0);
    $id_res = rmc_server_var($_GET, 'res', 0);
    if ($id_res <= 0) {
        redirectMsg('resources.php', __('First select a Document to manage the figures.', 'docs'), 1);
    }
    $res = new RDResource($id_res);
    if ($res->isNew()) {
        redirectMsg('resources.php', __('Specified Document does not exists!', 'docs'), 1);
    }
    if ($edit) {
        if ($id <= 0) {
            redirectMsg('figures.php?res=' . $id_res, __('You have not specified a figure to edit!', 'docs'));
            break;
        }
        $fig = new RDFigure($id);
        if ($fig->isNew()) {
            redirectMsg('figures.php?res=' . $id_res, __('Specified figure does not exists!', 'docs'));
            break;
        }
    }
    $form = new RMForm($edit ? __('Editing Figure', 'docs') : __('Create Figure', 'docs'), 'frmfig', 'figures.php');
    $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 255, $edit ? $fig->getVar('title') : ''), true);
    $form->addElement(new RMFormText(__('Description', 'docs'), 'desc', 50, 255, $edit ? $fig->getVar('desc') : ''), true);
    $form->addElement(new RMFormEditor(__('Content', 'docs'), 'figure', '100%', '300px', $edit ? $fig->getVar('content', 'e') : ''), true);
    $form->addElement(new RMFormText(__('Attributes', 'docs'), 'attrs', 50, 150, $edit ? $fig->getVar('attrs') : ''));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Save Changes', 'docs') : __('Save Figure', 'docs'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'figures.php?res=' . $id_res . '\';"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form->addElement(new RMFormHidden('res', $id_res));
    $form->display();
    xoops_cp_footer();
}