function forums_data($data) { global $xoopsUser; if (empty($data)) { return; } $forums = array(); foreach ($data as $forum) { $isModerator = $xoopsUser && ($xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid())); if (!$forum->active && !$isModerator) { continue; } $last = new bXPost($forum->lastPostId()); $lastpost = array(); if (!$last->isNew()) { if (!isset($posters[$last->uid])) { $posters[$last->uid] = new RMUser($last->uid); } $user = $posters[$last->uid]; $lastpost['date'] = bXFunctions::formatDate($last->date()); $lastpost['by'] = sprintf(__('by %s', 'bxpress'), $last->uname()); $lastpost['id'] = $last->id(); $lastpost['topic'] = $last->topic(); $lastpost['user'] = array('uname' => $user->uname, 'name' => $user->name != '' ? $user->name : $user->uname, 'avatar' => $user ? RMEvents::get()->run_event('rmcommon.get.avatar', $user->getVar('email'), 50) : ''); if ($xoopsUser) { $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new']; } else { $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new']; } } $category = new bXCategory($forum->cat); $forums[] = array('id' => $forum->id(), 'name' => $forum->name(), 'desc' => $forum->description(), 'topics' => $forum->topics(), 'posts' => $forum->posts(), 'link' => $forum->makeLink(), 'last' => $lastpost, 'image' => $forum->image, 'active' => $forum->active, 'category' => array('title' => $category->title)); } return $forums; }
function bxpress_recents_show($options) { $util = RMUtilities::get(); $tc = TextCleaner::getInstance(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $xoopsModuleConfig = $util->module_config('exmbb'); $mc = RMUtilities::module_config('bxpress'); $tbl1 = $db->prefix('bxpress_posts'); $tbl2 = $db->prefix('bxpress_topics'); $tbl3 = $db->prefix('bxpress_posts_text'); $tbl4 = $db->prefix('bxpress_forums'); $sql = "SELECT MAX(id_post) AS id FROM {$tbl1} WHERE approved=1 GROUP BY id_topic ORDER BY MAX(id_post) DESC LIMIT 0,{$options['0']}"; $result = $db->queryF($sql); $topics = array(); $block = array(); include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php'; $post = new bXPost(); $forum = new bXForum(); $tf = new RMTimeFormatter(0, '%T%-%d%-%Y% at %h%:%i%'); while ($row = $db->fetchArray($result)) { $post = new bXPost($row['id']); $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); $ret = array(); $ret['id'] = $topic->id(); $ret['post'] = $post->id(); $ret['link'] = $post->permalink(); if ($options[2]) { $ret['date'] = $tf->format($post->date()); } if ($options[3]) { $ret['poster'] = sprintf(__('Posted by: %s', 'bxpress'), "<a href='" . $post->permalink() . "'>" . $post->uname() . "</a>"); } $ret['title'] = $topic->title(); if ($options[4]) { $ret['text'] = $tc->clean_disabled_tags($post->text()); } $ret['forum'] = array('id' => $forum->id(), 'name' => $forum->name(), 'link' => $forum->permalink()); $topics[] = $ret; } // Opciones $block['showdates'] = $options[2]; $block['showuname'] = $options[3]; $block['showtext'] = $options[4]; $block['topics'] = $topics; $block['lang_topic'] = __('Topic', 'bxpress'); $block['lang_date'] = __('Date', 'bxpress'); $block['lang_poster'] = __('Poster', 'bxpress'); return $block; }
/** * @desc Realiza una búsqueda en el módulo desde EXM */ function bxpressSearch($queryarray, $andor, $limit, $offset, $userid = 0) { global $myts, $module; $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbl1 = $db->prefix("mod_bxpress_topics"); $tbl2 = $db->prefix("mod_bxpress_posts_text"); $tbl3 = $db->prefix("mod_bxpress_posts"); if ($userid <= 0) { $sql = "SELECT a.*,b.*,c.* FROM {$tbl1} a, {$tbl2} b, {$tbl3} c "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? '' : " {$andor} ") . " (\n \t (a.title LIKE '%{$k}%' AND a.id_topic=c.id_topic) OR \n \t (b.post_text LIKE '%{$k}%' AND b.post_id=c.id_post))"; } $sql .= $sql1 != '' ? "WHERE {$sql1}" : ''; $sql .= $userid > 0 ? "GROUP BY c.id_topic" : " GROUP BY c.id_topic"; $sql .= " ORDER BY c.post_time DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql); } else { $sql = "SELECT a.*, b.*, c.post_text FROM {$tbl3} a, {$tbl1} b, {$tbl2} c WHERE a.uid='{$userid}' AND b.id_topic=a.id_topic \n AND c.post_id=a.id_post "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? 'AND ' : " {$andor} ") . "\n b.title LIKE '%{$k}%' AND c.post_text LIKE '%{$k}%'"; } $sql .= $sql1; $sql .= "ORDER BY a.post_time DESC\n LIMIT {$offset}, {$limit}"; $result = $db->query($sql); } include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php'; $tc = TextCleaner::getInstance(); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); $rtn = array(); $rtn['image'] = 'images/forum16.png'; $rtn['link'] = $post->permalink(); $rtn['title'] = $row['title']; $rtn['time'] = $row['post_time']; $rtn['uid'] = $row['uid']; $rtn['desc'] = substr($tc->clean_disabled_tags($row['post_text']), 0, 150) . '...'; $ret[] = $rtn; } return $ret; }
function showReports() { global $xoopsModule, $xoopsConfig, $xoopsSecurity; //Indica la lista a mostrar $show = isset($_REQUEST['show']) ? intval($_REQUEST['show']) : '0'; //$show = 0 Muestra todos los reportes //$show = 1 Muestra los reportes revisados //$show = 2 Muestra los reportes no revisados define('RMCSUBLOCATION', $show == 0 ? 'allreps' : ($show == 1 ? 'reviews' : 'noreviewd')); $db = XoopsDatabaseFactory::getDatabaseConnection(); //Lista de Todos los reportes $sql = "SELECT * FROM " . $db->prefix('mod_bxpress_report') . ($show ? $show == 1 ? " WHERE zapped=1" : " WHERE zapped=0 " : '') . " ORDER BY report_time DESC"; $result = $db->queryF($sql); $reports = array(); $tf = new RMTimeFormatter(0, '%T% %d%, %Y% %h%:%i%:%s%'); while ($rows = $db->fetchArray($result)) { $report = new bXReport(); $report->assignVars($rows); $user = new XoopsUser($report->user()); $post = new bXPost($report->post()); $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); if ($report->zappedBy() > 0) { $zuser = new XoopsUser($report->zappedBy()); } $reports[] = array('id' => $report->id(), 'post' => array('link' => $post->permalink(), 'id' => $report->post()), 'user' => $user->uname(), 'uid' => $user->uid(), 'date' => $tf->format($report->time()), 'report' => $report->report(), 'forum' => array('link' => $forum->permalink(), 'name' => $forum->name()), 'topic' => array('link' => $topic->permalink(), 'title' => $topic->title()), 'zapped' => $report->zapped(), 'zappedby' => $report->zappedby() > 0 ? array('uid' => $zuser->uid(), 'name' => $zuser->uname()) : '', 'zappedtime' => $report->zappedtime() > 0 ? $tf->format($report->zappedtime()) : ''); } RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('admin.js', 'bxpress'); RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/introduccion/standalone/1/'); RMTemplate::get()->assign('xoops_pagetitle', __('Reports Management', 'bxpress')); $bc = RMBreadCrumb::get(); $bc->add_crumb(__('Reports management', 'bxpress')); xoops_cp_header(); include RMTemplate::get()->get_template('admin/forums-reports.php', 'module', 'bxpress'); xoops_cp_footer(); }
// Permisos $edit = $forum->isAllowed($groups, 'edit'); $delete = $forum->isAllowed($groups, 'delete'); $report = $forum->isAllowed($groups, 'reply'); $moderator = $xoopsUser ? $forum->isModerator($xoopsUser->uid()) : false; $admin = $xoopsUser ? $xoopsUser->isAdmin() : false; $tbl1 = $db->prefix("mod_bxpress_posts"); $tbl2 = $db->prefix("mod_bxpress_posts_text"); $tbl3 = $db->prefix("mod_bxpress_likes"); $sql = "SELECT\n posts.*,\n texts.*,\n (SELECT COUNT(*) FROM {$tbl1} WHERE parent=posts.id_post) as replies,\n GROUP_CONCAT(tlikes.uid ORDER BY " . ($xoopsUser ? "tlikes.uid=" . $xoopsUser->uid() . ' DESC' : 'tlikes.uid') . ") as liked\n FROM\n {$tbl1} posts\n LEFT JOIN {$tbl3} tlikes ON tlikes.post=posts.id_post\n INNER JOIN {$tbl2} texts ON texts.post_id=posts.id_post\n WHERE\n posts.id_topic='" . $topic->id() . "'\n AND\n texts.post_id=posts.id_post\n GROUP BY\n posts.id_post\n ORDER BY\n posts.post_time ASC,\n posts.parent ASC\n LIMIT\n {$start},{$limit}"; $result = $db->query($sql); $users = array(); $posts_ids = array(); $posts = array(); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); // Permisos de edición y eliminación $canedit = $moderator || $admin ? true : $edit && $post->isOwner(); $candelete = $moderator || $admin ? true : $delete && $post->isOwner(); //Permiso de visualizar mensaje $canshow = $moderator || $admin ? true : false; // Datos del usuario if ($post->user() > 0) { if (!isset($users[$post->user()])) { $users[$post->user()] = new XoopsUser($post->user()); } $bbUser = $users[$post->user()]; $userData = array(); $userData['id'] = $bbUser->uid(); $userData['uname'] = $bbUser->uname();
public function getPosts($object = true, $id_as_key = true) { $result = $this->db->query("SELECT * FROM " . $this->db->prefix("mod_bxpress_posts") . " WHERE id_topic='" . $this->id() . "'"); $ret = array(); while ($row = $this->db->fetchArray($result)) { if ($object) { $attach = new bXPost(); $attach->assignVars($row); if ($id_as_key) { $ret[$row['id_post']] = $attach; } else { $ret[] = $attach; } } else { if ($id_as_key) { $ret[$row['id_post']] = $row; } else { $ret[] = $row; } } } return $ret; }
$rss_channel['title'] = $xoopsModule->name(); $rss_channel['link'] = XOOPS_URL . ($config->urlmode ? $config->htbase : '/modules/bxpress'); $rss_channel['description'] = __('All recent messages posted on forum', 'bxpress'); $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss'); $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['category'] = 'Forum'; $rss_channel['generator'] = 'Common Utilities'; $rss_channel['language'] = RMCLANG; $sql = "SELECT * FROM {$tbl1} WHERE approved=1 ORDER BY post_time DESC LIMIT 0,50"; $result = $db->queryF($sql); $topics = array(); $block = array(); $post = new bXPost(); $forum = new bXForum(); $tf = new RMTimeFormatter(0, '%T%-%d%-%Y% at %h%:%i%'); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); $item = array(); $item['title'] = sprintf(__('Posted on: %s :: %s'), $topic->title(), $forum->name()); $item['link'] = $post->permalink(); $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($post->text(), ENT_QUOTES)); $item['pubdate'] = formatTimestamp($post->date(), 'rss'); $item['guid'] = $post->permalink(); $rss_items[] = $item; } break; }
$nav->target_url($forum->permalink() . '&pag={PAGE_NUM}'); $tpl->assign('itemsNavPage', $nav->render(false)); } $sql = str_replace("COUNT(*)", '*', $sql); $sql .= " ORDER BY sticky DESC,"; $sql .= $xoopsModuleConfig['order_post'] ? " last_post " : " date "; $sql .= " DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); /** * Posters cache */ $posters = array(); while ($row = $db->fetchArray($result)) { $topic = new bXTopic(); $topic->assignVars($row); $last = new bXPost($topic->lastPost()); if (!isset($posters[$topic->poster])) { $posters[$topic->poster] = new RMUser($topic->poster); } if (!isset($posters[$last->uid])) { $posters[$last->uid] = new RMUser($last->uid); } $poster = $posters[$topic->poster]; $last_poster = $posters[$last->uid]; $lastpost = array(); if (!$last->isNew()) { $lastpost['date'] = formatTimeStamp($last->date(), __('M d, Y')); $lastpost['time'] = $last->date(); $lastpost['id'] = $last->id(); $lastpost['poster'] = array('uid' => $last->uid, 'uname' => $last->poster_name, 'name' => $last_poster->name != '' ? $last_poster->name : $last_poster->uname, 'email' => $last_poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $last_poster->getVar('email'), 50), 'link' => XOOPS_URL . '/userinfo.php?uid=' . $last_poster->uid); if ($xoopsUser) {
} else { $sql1 .= " (a.title LIKE '%{$search}%' OR b.post_text LIKE '%{$search}%') "; } } $sql2 .= ($sql1 ? " AND " : '') . " c.approved=1 AND a.id_topic=c.id_topic AND b.post_id=c.id_post AND d.id_forum=c.id_forum "; $sql2 .= $themes ? $themes == 1 ? " AND a.date>" . (time() - $xoopsModuleConfig['time_topics'] * 3600) : ($themes == 2 ? " AND a.replies=0" : '') : ''; $sql2 .= " ORDER BY a.sticky DESC, a.date DESC LIMIT {$start},{$limit}"; } $result = $db->queryF($sql . $sql1 . $sql2); while ($rows = $db->fetchArray($result)) { $date = bXFunctions::formatDate($rows['date']); $lastpost = array(); $firstpost = array(); if (!$search && $themes == 0) { $firstpost = bXFunctions::getFirstId($rows['id_topic']); $last = new bXPost($rows['last_post']); $lastpost['date'] = bXFunctions::formatDate($last->date()); $lastpost['by'] = sprintf(__('By: %s', 'bxpress'), $last->uname()); $lastpost['id'] = $last->id(); if ($xoopsUser) { $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new']; } else { $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new']; } } $tpl->append('posts', array('id' => $rows['id_topic'], 'title' => $rows['title'], 'sticky' => $rows['sticky'], 'user' => $rows['poster_name'], 'replies' => $rows['replies'], 'views' => $rows['views'], 'closed' => $rows['status'], 'date' => $date, 'by' => sprintf(__('By: %s', 'bxpress'), $rows['poster_name']), 'forum' => $rows['name'], 'id_post' => $rows['id_post'], 'post_text' => TextCleaner::getInstance()->truncate($rows['post_text'], 100), 'last' => $lastpost, 'firstpost' => $firstpost)); } $tpl->assign('lang_search', __('Search:', 'bxpress')); $tpl->assign('lang_recenttopics', __('Recent topics', 'bxpress')); $tpl->assign('lang_alltopics', __('All topics', 'bxpress')); $tpl->assign('lang_anunswered', __('Unanswered topics', 'bxpress'));
$sql = "SELECT post_time FROM " . $db->prefix("mod_bxpress_posts") . ' ORDER BY post_time ASC LIMIT 0, 1'; list($daysnum) = $db->fetchRow($db->query($sql)); $daysnum = time() - $daysnum; $daysnum = ceil($daysnum / 86400); //Lista de Mensajes recientes $tbl1 = $db->prefix('mod_bxpress_posts'); $tbl2 = $db->prefix('mod_bxpress_topics'); $tbl3 = $db->prefix('mod_bxpress_posts_text'); $tbl4 = $db->prefix('mod_bxpress_forums'); $sql = "SELECT a.*, b.*, c.post_text, d.* \n FROM {$tbl1} a, {$tbl2} b, {$tbl3} c, {$tbl4} d \n WHERE b.id_topic = a.id_topic AND c.post_id=a.id_post AND d.id_forum=b.id_forum\n GROUP BY a.id_topic \n ORDER BY a.post_time DESC \n LIMIT 0,5"; $result = $db->query($sql); $posts = array(); $topics = array(); $topic = new bXTopic(); $forum = new bXForum(); $pt = new bXPost(); while ($row = $db->fetchArray($result)) { //print_r($row); $pt->assignVars($row); $post = array('id' => $row['last_post'], 'date' => sprintf(__('Last post on %s', 'bxpress'), bXFunctions::formatDate($row['post_time'])), 'by' => sprintf(__('By %s', 'bxpress'), $row['poster_name']), 'link' => $pt->permalink(), 'uid' => $row['uid']); $topic->assignVars($row); $forum->assignVars($row); $topics[] = array('id' => $row['id_topic'], 'title' => $row['title'], 'post' => $post, 'link' => $topic->permalink(), 'forum' => array('id' => $forum->id(), 'name' => $forum->name(), 'link' => $forum->permalink())); } $sql = "SELECT * FROM {$tbl2} ORDER BY replies DESC LIMIT 0,5"; $result = $db->query($sql); $poptops = array(); $topic = new bXTopic(); while ($row = $db->fetchArray($result)) { $topic->assignVars($row); $forum->assignVars($row);
$tpl->assign('topictitle', $topic->title()); $tpl->assign('forumid', $forum->id()); $tpl->assign('topicid', $topic->id()); $tpl->assign('report', __('Report Post', 'bxpress')); include 'footer.php'; } elseif ($op == 'savereport') { foreach ($_POST as $k => $v) { ${$k} = $v; } //Verificamos que el mensaje sea válido if ($pid <= 0) { redirect_header('./topic.php?id=' . $id, 1, __('Sepecified post is not valid!', 'bxpress')); die; } //Comprobamos que el mensaje exista $post = new bXPost($pid); if ($post->isNew()) { redirect_header('./topic.php?id=' . $id, 1, __('Specified post does not exists!', 'bxpress')); die; } if (!$xoopsSecurity->check()) { redirect_header('./topic.php?pid=' . $pid . '#p' . $pid, 2, __('Session token expired!', 'bxpress')); die; } $rep = new bXReport(); $rep->setPost($pid); $rep->setUser($xoopsUser->uid()); $rep->setIp($_SERVER['REMOTE_ADDR']); $rep->setTime(time()); $rep->setReport($report); if ($rep->save()) {
$form = new RMForm(__('Edit Topic', 'bxpress'), 'frmTopic', 'edit.php'); $first_id = bXFunctions::getFirstId($topic->id()); if ($id == $first_id) { $form->addElement(new RMFormText(__('Topic Subject:', 'bxpress'), 'subject', 50, 255, $topic->title()), true); // Sticky if ($xoopsUser && $xoopsModuleConfig['sticky']) { $sticky = $xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts'] && $topic->poster() == $xoopsUser->uid(); if ($sticky) { $form->addElement(new RMFormYesNo(__('Sticky Topic', 'bxpress'), 'sticky', $topic->sticky())); } } } // Si se especifico una acotación entonces la cargamos $idq = isset($_GET['quote']) ? intval($_GET['quote']) : 0; if ($idq > 0) { $post = new bXPost($idq); if ($post->isNew()) { break; } $quote = "[quote=" . $post->uname() . "]" . $post->getVar('post_text', 'e') . "[/quote]\n\n"; } $form->addElement(new RMFormEditor(__('Post', 'bxpress'), 'msg', '90%', '300px', $rmc_config['editor_type'] == 'tiny' ? $post->getVar('post_text') : $post->getVar('post_text', 'e')), true); $form->addElement(new RMFormHidden('op', 'post')); $form->addElement(new RMFormHidden('id', $id)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', __('Save Changes', 'bxpress'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location = \'topic.php?pid=' . $post->id() . '#p' . $post->id() . '\'";'); $form->addElement($ele); // Adjuntar Archivos if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) { $forma = new RMForm('<a name="attachments"></a>' . __('Attached Files', 'bxpress'), 'frmAttach', 'edit.php');
$start = ($pactual - 1) * $limit; } if ($tpages > 0) { $nav = new RMPageNav($num, $limit, $pactual); $nav->target_url($forum->permalink() . '&pag={PAGE_NUM}'); $tpl->assign('itemsNavPage', $nav->render(false)); } $sql = str_replace("COUNT(*)", '*', $sql); $sql .= " ORDER BY sticky DESC,"; $sql .= $xoopsModuleConfig['order_post'] ? " last_post " : " date "; $sql .= " DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $topic = new bXTopic(); $topic->assignVars($row); $last = new bXPost($topic->lastPost()); $lastpost = array(); if (!$last->isNew()) { $lastpost['date'] = formatTimeStamp($last->date(), 'c'); $lastpost['by'] = sprintf(__('By: %s', 'bxpress'), $last->uname()); $lastpost['id'] = $last->id(); if ($xoopsUser) { $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new']; } else { $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new']; } } $tpages = ceil($topic->replies() / $xoopsModuleConfig['perpage']); if ($tpages > 1) { $pages = bXFunctions::paginateIndex($tpages); } else {
/** * @desc Aprueba o no un mensaje editado **/ function approvedPosts($app = 0) { global $xoopsUser, $xoopsSecurity; $posts = isset($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0; //Verifica que el mensaje sea válido if ($posts <= 0) { redirect_header('./topic.php?id=' . $posts, 1, __('Topic not valid!', 'bxpress')); die; } //Comprueba que el mensaje exista $post = new bXPost($posts); if ($post->isNew()) { redirect_header('./topic.php?id=' . $posts, 1, __('Post doesn\'t exists!', 'bxpress')); die; } //Comprueba si usuario es moderador del foro $forum = new bXForum($post->forum()); if (!$forum->isModerator($xoopsUser->uid()) || !$xoopsUser->isAdmin()) { redirect_header('./topic.php?id=' . $posts, 1, __('You don\'t have permission to do this action!', 'bxpress')); die; } if (!$xoopsSecurity->check()) { redirect_header('./topic.php?id=' . $posts, 2, __('Session token expired!', 'bxpress')); die; } $post->setApproved($app); if ($post->editText()) { $post->setText($post->editText()); } $post->setEditText(''); $post->save(); redirect_header('./topic.php?id=' . $post->topic(), 1, __('Operation completed!', 'bxpress')); }
// -------------------------------------------------------------- // bXpress Forums // An simple forums module for XOOPS and Common Utilities // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- include '../../mainfile.php'; $ok = isset($_POST['ok']) ? $_POST['ok'] : 0; // Id del Post $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($id <= 0) { redirect_header('./', 2, __('Please specify a post id to delete!', 'bxpress')); die; } $post = new bXPost($id); if ($post->isNew()) { redirect_header('./', 2, __('Specified post does not exists!', 'bxpress')); die; } $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); // Verificamos que el usuario tenga permiso if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'delete')) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress')); die; } // Verificamos si el usuario tiene permiso de eliminación para el post if ($xoopsUser->uid() != $post->user() && (!$xoopsUser->isAdmin() && !$forum->isModerator($xoopsUser->uid()))) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress')); die;
$form->addElement(new RMFormEditor(__('Post', 'bxpress'), 'msg', 'auto', '400px', isset($quote) ? $quote : ''), true); // Adjuntar Archivos if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) { $ele = new RMFormFile(__('Attach file', 'bxpress'), 'attach', 45, $xoopsModuleConfig['maxfilesize'] * 1024); $ele->setDescription(sprintf(__('Allowed file types: %s', 'bxpress'), implode(',', $forum->extensions()))); $form->addElement($ele); $form->setExtra('enctype="multipart/form-data"'); } $form->addElement(new RMFormHidden('op', 'post')); $form->addElement(new RMFormHidden($fid > 0 ? 'fid' : 'tid', $fid > 0 ? $fid : $tid)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', __('Send', 'bxpress'), 'submit'); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1)";'); $form->addElement($ele); $tpl->assign('topic_form', $form->render()); /** * @desc Cargamos los mensajes realizados en este tema */ if ($mc['numpost'] > 0 && !$create) { $sql = "SELECT * FROM " . $db->prefix("bxpress_posts") . " WHERE id_topic='" . $topic->id() . "' ORDER BY post_time DESC LIMIT 0, {$mc['numpost']}"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); $tpl->append('posts', array('id' => $post->id(), 'text' => $post->text(), 'time' => date($xoopsConfig['datestring'], $post->date()), 'uname' => $post->uname())); } } $tpl->assign('lang_topicreview', __('Topic review (newest first)', 'bxpress')); include 'footer.php'; break; }
{ global $xoopsSecurity; echo json_encode(array('message' => $message, 'data' => $data, 'error' => $error, 'token' => $token ? $xoopsSecurity->createToken(0, 'BXTOKEN') : '')); exit; } if (!$xoopsUser) { exit; } /* * Get parameters */ $id = RMHttpRequest::post('id', 'integer', 0); if (!$xoopsSecurity->check(true, false, 'BXTOKEN')) { response_json(1, __('Please refresh the page in order to register your likes.', 'bxpress'), array(), false); } $post = new bXPost($id); if ($post->isNew()) { response_json(1, __('The specified post does not exists! Verify it!', 'bxpress'), array(), true); } $sql = "SELECT COUNT(*) FROM " . $xoopsDB->prefix("mod_bxpress_likes") . " WHERE uid=" . $xoopsUser->uid() . " AND post=" . $post->id(); list($exists) = $xoopsDB->fetchRow($xoopsDB->query($sql)); if ($exists > 0) { $action = 'unlike'; } else { $action = 'like'; } if ('like' == $action) { // Add to likes table $sql = "INSERT INTO " . $xoopsDB->prefix("mod_bxpress_likes") . " (post,uid,time) VALUES (" . $post->id() . "," . $xoopsUser->uid() . "," . time() . ")"; if (!$xoopsDB->queryF($sql)) { response_json(1, __('We could not register your like for this post. Please try again.', 'bxpress'), array(), true);