function search_resources() { global $xoopsConfig, $xoopsUser, $page, $xoopsTpl; $keyword = rmc_server_var($_GET, 'keyword', ''); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1"; list($num) = $db->fetchRow($db->query($sql)); $page = rmc_server_var($_GET, 'page', 1); $limit = 15; $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url(RDFunctions::make_link('search') . '?keyword=' . $keyword . '&page={PAGE_NUM}'); $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1 LIMIT {$start}, {$limit}"; $result = $db->query($sql); $resources = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => TextCleaner::truncate($res->getVar('description'), 100), 'link' => $res->permalink(), 'created' => $res->getVar('created'), 'owner' => $res->getVar('owner'), 'uname' => $res->getVar('owname'), 'reads' => $res->getVar('reads')); } RDFunctions::breadcrumb(); RMBreadCrumb::get()->add_crumb(__('Browsing recent Documents', 'docs')); RMTemplate::get()->add_style('docs.css', 'docs'); include 'header.php'; $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Search results for "%s"', 'docs'), $keyword)); include RMEvents::get()->run_event('docs.template.search', RMTemplate::get()->get_template('rd_search.php', 'module', 'docs')); include 'footer.php'; }
/** * Shows a list of existing resources in RapidDocs */ function resources_list() { global $xoopsUser, $xoopsModule; $db = XoopsDatabaseFactory::getDatabaseConnection(); //Navegador de páginas $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources'); list($num) = $db->fetchRow($db->queryF($sql)); $page = rmc_server_var($_REQUEST, 'page', 1); $limit = 20; $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url('javascript:;" onclick="docsAjax.getSectionsList({PAGE_NUM});'); //Fin navegador de páginas $sql = "SELECT * FROM " . $db->prefix('rd_resources'); if ($xoopsUser->isAdmin()) { $sql .= " ORDER BY `created` DESC LIMIT {$start},{$limit}"; } else { $sql .= " WHERE public=1 OR (public=0 AND owner=" . $xoopsUser->uid() . ") ORDER BY `created` DESC LIMIT {$start},{$limit}"; } $result = $db->queryF($sql); $resources = array(); while ($rows = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($rows); $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title')); } include RMTemplate::get()->get_template('ajax/rd_sections_list.php', 'module', 'docs'); }
/** * Este archivo permite controlar el bloque o los bloques * Bloques Existentes: * * 1. Publicaciones Recientes * 2. Publicaciones Populares (Mas Leídas) * 3. Publicaciones Mejor Votadas */ function rd_block_resources($options) { global $xoopsModule; include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); $mc = RMUtilities::module_config('docs'); $sql = "SELECT * FROM " . $db->prefix("rd_resources") . ' WHERE public=1 AND approved=1'; switch ($options[0]) { case 'recents': $sql .= " ORDER BY created DESC"; break; case 'popular': $sql .= " ORDER BY `reads` DESC"; break; } $sql .= " LIMIT 0, " . ($options[1] > 0 ? $options[1] : 5); $result = $db->query($sql); $block = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $ret = array(); $ret['id'] = $res->id(); $ret['title'] = $res->getVar('title'); if ($options[2]) { $ret['desc'] = $options[3] == 0 ? $res->getVar('description') : TextCleaner::truncate($res->getVar('description'), $options[3]); } $ret['link'] = $res->permalink(); $ret['author'] = sprintf(__('Created by %s', 'docs'), '<strong>' . $res->getVar('owname') . '</strong>'); $ret['reads'] = sprintf(__('Viewed %s times', 'docs'), '<strong>' . $res->getVar('reads') . '</strong>'); $block['resources'][] = $ret; } RMTemplate::get()->add_style('blocks.css', 'docs'); return $block; }
/** * @desc Realiza una búsqueda en el módulo desde EXM */ function ahelpSearch($queryarray, $andor, $limit, $offset, $userid) { global $myts; include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdsection.class.php"; include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdresource.class.php"; $mc = RMUtilities::module_config('docs'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbl1 = $db->prefix("rd_resources"); $tbl2 = $db->prefix("rd_sections"); $sql = "SELECT a.id_res,a.title,a.description,a.created,a.modified,a.public,a.nameid,a.owner,a.owname,a.approved,b.id_sec,b.title AS stitle,b.content,b.id_res AS sid_res,\n\tb.nameid AS snameid,b.uid,b.uname,b.created AS screated FROM {$tbl1} a, {$tbl2} b "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? '' : " {$andor} ") . " (a.id_res=b.id_res) AND (\n \t (b.title LIKE '%{$k}%' AND b.id_res=a.id_res) OR \n \t (b.content LIKE '%{$k}%' AND b.id_res=a.id_res))"; } $sql .= $sql1 != '' ? "WHERE {$sql1}" : ''; $sql .= " AND approved=1 AND public=1 ORDER BY a.modified DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql); $ret = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $sec = new RDSection(); $sec->assignVars($row); $sec->assignVar('title', $row['stitle']); $sec->assignVar('id_res', $row['sid_res']); $sec->assignVar('nameid', $row['snameid']); $sec->assignVar('created', $row['screated']); $rtn = array(); $rtn['image'] = 'images/result.png'; $rtn['link'] = $sec->permalink(); $rtn['title'] = $sec->getVar('title'); $rtn['time'] = $sec->getVar('created'); $rtn['uid'] = $sec->getVar('uid'); $rtn['desc'] = TextCleaner::getInstance()->truncate($sec->getVar('content'), 150); $ret[] = $rtn; } return $ret; }
/** * @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); } }
/** * @desc Almacena información perteneciente a una publicación **/ function savePublish() { global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $xoopsConfig; $config_handler =& xoops_gethandler('config'); $xconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); foreach ($_POST as $k => $v) { ${$k} = $v; } if ($xoopsModuleConfig['permalinks']) { $purl = RDFunctions::url() . '/publish/'; } else { $purl = RDFunctions::url() . '?page=publish&action=publish'; } if (!$xoopsSecurity->check()) { redirect_header($prul, 1, __('Session token expired!', 'docs')); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); //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) { redirect_header($purl, 1, __('Already exists a Document with same name!', 'docs')); die; } $res = new RDResource(); //Genera $nameid Nombre identificador $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->setVar('created', time()); $res->setVar('modified', time()); $res->setVar('editors', $editors); $res->setVar('groups', $groups); $res->setVar('public', 1); $res->setVar('quick', $quick); $res->setVar('nameid', $nameid); $res->setVar('owner', $xoopsUser->uid()); $res->setVar('owname', $xoopsUser->uname()); $res->setVar('approved', $xoopsModuleConfig['approved']); $res->setVar('single', $single); if (!$res->save()) { redirect_header($prul, 1, __('Document could not be created!', 'docs')); } else { //Si no se aprobó la publicación enviamos correo al administrador if (!$xoopsModuleConfig['approved']) { $mailer = new RMMailer('text/plain'); $mailer->add_user($xconfig['from'], $xconfig['fromname'], 'to'); $mailer->set_subject(__('New Document created at RapidDocs is waiting for approval', 'rmcommon')); $mailer->assign('to_name', $xconfig['fromname']); $mailer->assign('link_to_resource', XOOPS_URL . '/modules/docs/admin/resources.php?action=edit&id=' . $res->id()); $mailer->template(RMTemplate::get()->get_template('mail/resource_for_approval.php', 'module', 'docs')); if (!$mailer->send()) { redirect_header(RDFunctions::url(), 1, __('Your Document has been created, however the email to administrator could no be sent.', 'docs')); die; } redirect_header(RDFunctions::url(), 1, __('Your Document has been created and is pending for approval. We will sent an email when you can access to it and add content.', 'docs')); die; } if ($xoopsModuleConfig['permalinks']) { $purl = RDFunctions::url() . '/list/' . $res->id() . '/'; } else { $purl = RDFunctions::url() . '?page=edit&action=list&id=' . $res->id(); } redirect_header($purl, 1, __('Document created successfully!', 'docs')); die; } }
/** * @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); } }
/** * @desc Muestra el contenido completo de una sección */ function showSection(RDResource &$res, RDSection &$section) { global $xoopsUser, $xoopsModuleConfig, $xoopsOption, $xoopsTpl, $xoopsConfig, $standalone; include 'header.php'; $xoopsTpl->assign('xoops_pagetitle', $section->getVar('title')); // Resource data $resource = array('id' => $res->id(), 'title' => $res->getVar('title'), 'link' => $res->permalink(), 'reads' => $res->getVar('reads')); $res->add_read($res); // Navegación de Secciones $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("rd_sections") . " WHERE id_res='" . $res->id() . "' AND parent = '0' ORDER BY `order`"; $result = $db->query($sql); $i = 1; $number = 1; $located = false; // Check if current position has been located while ($row = $db->fetchArray($result)) { $sec = new RDSection(); $sec->assignVars($row); if ($sec->id() == $section->id()) { $number = $i; $located = true; } if ($sec->id() == $section->id() && isset($sprev)) { $prev_section = array('id' => $sprev->id(), 'title' => $sprev->getVar('title'), 'link' => $sprev->permalink()); } if ($number == $i - 1 && $located) { $next_section = array('id' => $sec->id(), 'title' => $sec->getVar('title'), 'link' => $sec->permalink()); break; } $i++; $sprev = $sec; } $GLOBALS['rd_section_number'] = $number; $sections = RDFunctions::get_section_tree($section->id(), $res, $number, true); array_walk($sections, 'rd_insert_edit'); // Check last modification date $last_modification = 0; foreach ($sections as $sec) { if ($sec['modified'] > $last_modification) { $last_modification = $sec['modified']; $last_author = array('id' => $sec['author'], 'name' => $sec['author_name']); } } // Event $sections = RMEvents::get()->run_event('docs.show.section', $sections, $res, $section); RMTemplate::get()->add_style('docs.css', 'docs'); RMTemplate::get()->add_jquery(); RMTemplate::get()->add_script(XOOPS_URL . '/modules/docs/include/js/docs.js'); // URLs if ($xoopsModuleConfig['permalinks']) { /** * @todo Generate friendly links */ if (RMFunctions::plugin_installed('topdf')) { $pdf_book_url = RDFunctions::url() . '/pdfbook/' . $section->id() . '/'; $pdf_section_url = RDFunctions::url() . '/pdfsection/' . $section->id() . '/'; } $print_book_url = RDFunctions::url() . '/printbook/' . $section->id() . '/'; $print_section_url = RDFunctions::url() . '/printsection/' . $section->id() . '/'; if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) { $publish_url = RDFunctions::url() . '/publish/'; } } else { if (RMFunctions::plugin_installed('topdf')) { $pdf_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=pdfbook'; $pdf_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=pdfsection'; } $print_book_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=printbook'; $print_section_url = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $section->id() . '&action=printsection'; if (RDFunctions::new_resource_allowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) { $publish_url = RDFunctions::url() . '/?action=publish'; } } // Comments RMFunctions::get_comments('docs', 'res=' . $res->id() . '&id=' . $section->id(), 'module', 0); RMFunctions::comments_form('docs', 'res=' . $res->id() . '&id=' . $section->id(), 'module', RDPATH . '/class/mywordscontroller.php'); RDFunctions::breadcrumb(); RMBreadCrumb::get()->add_crumb($res->getVar('title'), $res->permalink()); RMBreadCrumb::get()->add_crumb($section->getVar('title'), $section->permalink()); include RMEvents::get()->run_event('docs.section.template', RMTemplate::get()->get_template('rd_section.php', 'module', 'docs')); if ($standalone) { RDFunctions::standalone(); } include 'footer.php'; }
$resume_data['sections'] = $num; list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_figures"))); $resume_data['figures'] = $num; list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("rd_references"))); $resume_data['notes'] = $num; // No published resoruces $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE public=0 ORDER BY created DESC LIMIT 0,5"; $result = $db->query($sql); $nopublished = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $nopublished[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => $res->getVar('created'), 'desc' => TextCleaner::getInstance()->truncate($res->getVar('description'), 60)); } // No published resoruces $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE approved=0 ORDER BY created DESC LIMIT 0,5"; $result = $db->query($sql); $noapproved = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $noapproved[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => $res->getVar('created'), 'desc' => TextCleaner::getInstance()->truncate($res->getVar('description'), 60)); } xoops_cp_header(); RMTemplate::get()->add_style('admin.css', 'docs'); RMTemplate::get()->add_style('dashboard.css', 'docs'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.gcharts.js'); RMTemplate::get()->add_head('<script type="text/javascript">var xoops_url="' . XOOPS_URL . '";</script>'); RMTemplate::get()->add_script('../include/js/dashboard.js'); include RMTemplate::get()->get_template('admin/rd_index.php', 'module', 'docs'); xoops_cp_footer();
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; } }
/** * @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); } }
// http://www.redmexico.com.mx // http://www.exmsystem.net // -------------------------------------------- // @author BitC3R0 <*****@*****.**> // @license: GPL v2 define('AH_LOCATION', 'rate'); include '../../mainfile.php'; $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $rate = isset($_GET['rate']) ? intval($_GET['rate']) : 0; $ret = isset($_GET['ret']) ? $_GET['ret'] : ''; $mc =& $xoopsModuleConfig; if ($id <= 0) { redirect_header(XOOPS_URL . '/modules/ahelp/', 2, _MS_AH_NOID); die; } $res = new RDResource($id); if ($res->isNew()) { redirect_header(XOOPS_URL . '/modules/ahelp/', 2, _MS_AH_NOID); die; } $retlink = $ret != '' ? urldecode($ret) : XOOPS_URL . '/modules/ahelp/' . ($mc['access'] ? 'content/' . $res->id() . '/' . $res->nameId() : 'content.php?id=' . $res->id()); if ($rate <= 0 || $rate > 5) { redirect_header($retlink, 2, _MS_AH_NORATE); die; } $db->queryF("DELETE FROM " . $db->prefix("pa_votedata") . " WHERE date<'" . (time() - 86400) . "'"); $ip = $_SERVER['REMOTE_ADDR']; $sql = "SELECT COUNT(*) FROM " . $db->prefix("pa_votedata") . " WHERE "; if ($xoopsUser) { $sql .= "uid='" . $xoopsUser->uid() . "' AND date>'" . (time() - 86400) . "' AND res='" . $res->id() . "'"; } else {
/** * 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> » " . __('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(); }
/** * @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); } }
/** * @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')); } } }
} // 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';
// $Id$ // -------------------------------------------------------------- // RapidDocs // Documentation system for Xoops. // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (isset($special) && ($special == 'references' || $special == 'figures')) { $xoopsOption['module_subpage'] = 'content'; } else { $xoopsOption['module_subpage'] = 'resource'; } // Check if Document exist $res = new RDResource($id); if ($res->isNew()) { // Error 404 - When resrouce does not exists RDFunctions::error_404(); } if ($res->getVar('single')) { define('RD_LOCATION', 'resource_content'); } include 'header.php'; //Verificamos si la publicacion esta aprobada if (!$res->getVar('approved')) { redirect_header(RDURL, 1, __('Sorry, this Document does not exists!', 'docs')); die; } //Verifica si el usuario cuenta con permisos para ver la publicación $allowed = $res->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS);
/** * Get resources index according to given options */ public function resources_index($type = 'all', $display = 1, $cols = 3, $limit = 15) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("rd_resources"); if ($type == 'featured') { $sql .= " WHERE public=1 AND approved=1 AND featured=1 ORDER BY created DESC"; } elseif ($type == 'all') { $sql .= " WHERE public=1 AND approved=1 ORDER BY created DESC"; } $sql .= " LIMIT 0,{$limit}"; $result = $db->query($sql); $resources = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => $res->getVar('description'), 'link' => $res->permalink()); } ob_start(); include RMEvents::get()->run_event('docs.template.resources.index', RMTemplate::get()->get_template('rd_resindex.php', 'module', 'docs')); $ret = ob_get_clean(); return $ret; }
/** * Get the permalink for this section */ public function permalink($edit = 0) { global $standalone; $config = RMUtilities::module_config('docs'); $res = new RDResource($this->getVar('id_res')); if ($res->getVar('single') && defined('RD_LOCATION') && RD_LOCATION == 'resource_content') { return "#" . $this->getVar('nameid'); } if ($config['permalinks']) { if ($this->getVar('parent') > 0) { $sec = new RDSection($this->getVar('parent')); $perma = $sec->permalink() . '#' . ($edit ? '<span>' . $this->getVar('nameid') . '</span>' : $this->getVar('nameid')); } else { $perma = ($config['subdomain'] != '' ? $config['subdomain'] : XOOPS_URL) . $config['htpath'] . '/' . $res->getVar('nameid') . '/' . ($edit ? '<span>' . $this->getVar('nameid') . '</span>' : $this->getVar('nameid')) . '/'; $perma .= $standalone ? 'standalone/1/' : ''; } } else { if ($this->getVar('parent') > 0) { $sec = new RDSection($this->getVar('parent')); $perma = $sec->permalink() . '#' . $this->getVar('nameid'); } else { $perma = XOOPS_URL . '/modules/docs/index.php?page=content&id=' . $this->id(); $perma .= $standalone ? '&standalone=1' : ''; } } return $perma; }
function showFormEdits() { global $xoopsModule, $xoopsConfig; $id = rmc_server_var($_GET, 'id', 0); if ($id <= 0) { redirectMsg('edits.php', __('You have not specified any waiting section!', 'docs'), 1); die; } $edit = new RDEdit($id); if ($edit->isNew()) { redirectMsg('edits.php', __('Specified content does not exists!', 'docs'), 1); die; } $sec = new RDSection($edit->getVar('id_sec')); if ($sec->isNew()) { redirectMsg('edits.php', __('This waiting content does not have any section assigned!', 'docs'), 1); die; } $res = new RDResource($sec->getVar('id_res')); $form = new RMForm(__('Editing Waiting Content', 'docs'), 'frmsec', 'edits.php'); $form->addElement(new RMFormLabel(__('Belong to', 'docs'), $res->getVar('title'))); $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 200, $edit->getVar('title')), true); $form->addElement(new RMFormEditor(__('Contenido', 'docs'), 'content', '90%', '300px', $edit->getVar('content', 'e')), true); // Arbol de Secciones $ele = new RMFormSelect(__('Parent Section', 'docs'), 'parent'); $ele->addOption(0, __('Select section...', 'docs')); $tree = array(); RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $tree, false); foreach ($tree as $k) { $ele->addOption($k['id'], str_repeat('—', $k['jump']) . ' ' . $k['title'], $edit->getVar('parent') == $k['id'] ? 1 : 0); } $form->addElement($ele); $form->addElement(new RMFormText(__('Display order', 'docs'), 'order', 5, 5, $edit->getVar('order')), true); // Usuario $form->addElement(new RMFormUser(__('Owner', 'docs'), 'uid', 0, array($edit->getVar('uid')), 30)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Save Now', 'docs'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'edits.php\';"'); $form->addElement($buttons); $form->addElement(new RMFormHidden('action', 'save')); $form->addElement(new RMFormHidden('id', $edit->id())); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./edits.php'>" . __('Waiting Content', 'docs') . "</a> » " . sprintf(__('Editing %s', 'docs'), $edit->getVar('title'))); xoops_cp_header(); RMTemplate::get()->assign('xoops_pagetitle', __('Editing Waiting Content', 'docs')); $form->display(); xoops_cp_footer(); }
/** * @desc Permite la edición de figuras **/ function rd_figures_form($edit = 0) { global $xoopsModule, $xoopsConfig; xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . $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(); }