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; }
die; } if ($ok) { if (!$xoopsSecurity->check()) { redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Session token expired!', 'bxpress')); die; } if ($post->id() == bXFunctions::getFirstId($topic->id())) { $ret = $topic->delete(); $wtopic = true; } else { $ret = $post->delete(); $wtopic = false; } if ($ret) { redirect_header($wtopic ? 'forum.php?id=' . $forum->id() : 'topic.php?id=' . $topic->id(), 1, $wtopic ? __('Topic deleted successfully!', 'bxpress') : __('Post deleted successfully!', 'bxpress')); } else { redirect_header('topic.php?pid=' . $id, 1, ($wtopic ? __('The topic could not be deleted!', 'bxpress') : __('The post could not be deleted!', 'bxpress')) . '<br />' . ($wtopic ? $topic->errors() : $post->errors())); } } else { include 'header.php'; //include '../../header.php'; $myts =& MyTextSanitizer::getInstance(); $hiddens['ok'] = 1; $hiddens['id'] = $id; $buttons['sbt']['value'] = __('Delete', 'bxpress'); $buttons['sbt']['type'] = 'submit'; $buttons['cancel']['value'] = __('Cancel', 'bxpress'); $buttons['cancel']['type'] = 'button'; $buttons['cancel']['extra'] = 'onclick="window.location=\'topic.php?pid=' . $id . '#p' . $id . '\';"'; $text = __('Dou you really wish to delete specified post?', 'bxpress');
$topic->addView(); $topic->save(); $_SESSION['topics_viewed'] = array(); $_SESSION['topics_viewed'][] = $topic->id(); } else { if (!in_array($topic->id(), $_SESSION['topics_viewed'])) { $topic->addView(); $topic->save(); $_SESSION['topics_viewed'][] = $topic->id(); } } $xoopsOption['template_main'] = "bxpress-topic.tpl"; $xoopsOption['module_subpage'] = "topics"; include 'header.php'; bXFunctions::makeHeader(); $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false)); $tpl->assign('topic', array('id' => $topic->id(), 'title' => $topic->title(), 'closed' => $topic->status(), 'sticky' => $topic->sticky(), 'approved' => $topic->approved())); if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'reply')) { if ($topic->status()) { $canreply = $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : 0; } else { $canreply = true; } if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'topic')) { $tpl->assign('lang_newtopic', __('New Topic', 'bxpress')); $tpl->assign('can_topic', 1); } $tpl->assign('can_reply', $canreply); $tpl->assign('lang_reply', __('Reply', 'bxpress')); $tpl->assign('lang_approved', __('Approved', 'bxpress')); $tpl->assign('lang_noapproved', __('Not approved', 'bxpress'));
public function forumList($varname = 'forums', $assign = true) { global $db, $tpl; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mod_bxpress_forums") . " WHERE active='1' ORDER BY cat,`order`"; $result = $db->query($sql); $forums = array(); while ($row = $db->fetchArray($result)) { $forum = new bXForum(); $forum->assignVars($row); $forums[] = array('id' => $forum->id(), 'title' => $forum->name()); } if ($assign) { $tpl->assign($varname, $forums); } else { return $forums; } }
public function forumList($varname = 'forums') { global $db, $tpl; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("bxpress_forums") . " WHERE active='1' ORDER BY cat,`order`"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $forum = new bXForum(); $forum->assignVars($row); $tpl->append($varname, array('id' => $forum->id(), 'title' => $forum->name())); } }
RMUris::redirect_with_message(__('This forum is closed and you don\'t have permissions to view it', 'bxpress'), BX_URL, RMMSG_WARN); } /** * Comprobamos que el usuario actual tenga permisos * de acceso al foro */ if (!$forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : array(0, XOOPS_GROUP_ANONYMOUS), BXPRESS_PERM_VIEW)) { RMUris::redirect_with_message(__('You are not allowed to view this forum!', 'bxpress'), BX_URL, RMMSG_WARN); die; } /** * Cargamos los temas */ $tbl1 = $db->prefix("mod_bxpress_topics"); $tbl2 = $db->prefix("mod_bxpress_forumtopics"); $sql = "SELECT COUNT(*) FROM {$tbl1} WHERE id_forum='" . $forum->id() . "' AND approved='1'"; list($num) = $db->fetchRow($db->queryF($sql)); $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = $xoopsModuleConfig['topicperpage'] > 0 ? $xoopsModuleConfig['topicperpage'] : 15; if ($page > 0) { $page -= 1; } $start = $page * $limit; $tpages = (int) ($num / $limit); if ($num % $limit > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $rest = $pactual - $tpages; $pactual = $pactual - $rest + 1;
/** * @desc Almacena los datos de un foro */ function bx_save_forum($edit = 0) { global $xoopsSecurity, $xoopsModuleConfig, $xoopsConfig; $q = $edit ? 'action=edit' : 'action=new'; $prefix = 1; foreach ($_POST as $k => $v) { if (substr($k, 0, 5) == 'perm_') { $permissions[substr($k, 5)] = $v; } else { ${$k} = $v; } if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $q .= '&' . $k . '=' . $v; } if (!$xoopsSecurity->check()) { RMUris::redirect_with_message(__('Session token expired', 'bxpress'), 'forums.php?' . $q, RMMSG_ERROR); } if ($edit) { $id = RMHttpRequest::request('id', 'integer', 0); if ($id <= 0) { RMUris::redirect_with_message(__('Specified id is not valid!', 'bxpress'), 'forums.php', RMMSG_ERROR); } $forum = new bXForum($id); if ($forum->isNew()) { RMUris::redirect_with_message(__('Specified forum does not exists!', 'bxpress'), 'forums.php', RMMSG_ERROR); } } else { $forum = new bXForum(); } $forum->setVar('name', $name); $forum->setVar('desc', $desc); $forum->setVar('image', $image); if (!$edit) { $forum->setVar('topics', 0); $forum->setVar('posts', 0); $forum->setVar('last_post_id', 0); $forum->setVar('subforums', 0); } $forum->setVar('cat', $cat); $forum->setActive($active); $forum->setSignature($sig); $forum->setPrefix($prefix); $forum->setHotThreshold($hot_threshold); $forum->setOrder($order); $forum->setAttachments($attachments); $forum->setMaxSize($attach_maxkb); $forum->setExtensions(explode('|', $attach_ext)); $forum->setPermissions($permissions); // Check if forum exists $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_bxpress_forums") . " WHERE name='{$name}' AND cat={$cat}"; if ($edit) { $sql .= " AND id_forum != " . $forum->id(); } list($exists) = $db->fetchRow($db->query($sql)); if ($exists) { RMUris::redirect_with_message(sprintf(__('Another forum with name "%s" already exists in this category.', 'bxpress'), $name), 'forums.php?' . $q, RMMSG_ERROR); } if ($forum->save()) { if ($parent > 0) { $pf = new bXForum($parent); if (!$pf->isNew()) { $pf->setSubforums($pf->subforums() + 1); $pf->save(); } } if (!$edit) { //Redireccionamos a ventana de selección de moderadores redirectMsg('forums.php?action=moderators&id=' . $forum->id(), __('Forum saved successfully! Redirecting to moderators assignment...', 'bxpress'), 0); } else { redirectMsg('forums.php', __('Changes saved successfully!', 'bxpress'), 0); } } else { redirectMsg('forums.php?' . $q, __('Forum could not be saved!', 'bxpress') . $forum->errors(), 1); } }
} if ($forum->isNew()) { redirect_header('./', 2, __('Specified forum does not exists!', 'bxpress')); die; } if (!$forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, $fid > 0 ? 'topic' : 'reply')) { redirect_header($retlink, 2, __('You do not have permission to do this!', 'bxpress')); die; } switch ($op) { case 'post': foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check()) { redirect_header('./' . ($create ? 'forum.php?id=' . $forum->id() : 'topic.php?id=' . $topic->id()), 2, __('Session token expired!', 'bxpress')); die; } $myts =& MyTextSanitizer::getInstance(); if ($create) { $topic = new bXTopic(); $topic->setApproved($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'approve')); $topic->setDate(time()); $topic->setForum($forum->id()); $topic->setPoster($xoopsUser ? $xoopsUser->uid() : 0); $topic->setPosterName($xoopsUser ? $xoopsUser->uname() : $name); $topic->setRating(0); $topic->setReplies(0); $topic->setStatus(0); if ($xoopsUser && $xoopsModuleConfig['sticky']) { $csticky = $xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts'];
$forum = new bXForum($post->forum()); $topic = new bXTopic($post->topic()); $form = new RMForm(__('Report Post', 'bxpress'), 'formrep', 'report.php'); $form->styles('width: 30%;', 'odd'); $form->addElement(new RMFormEditor(__('Your reasons to report this post', 'bxpress'), 'report', '90%', '300px', '', 'textarea'), true); $form->addElement(new RMFormHidden('op', 'savereport')); $form->addElement(new RMFormHidden('pid', $pid)); $form->addElement(new RMFormHidden('id', $topic->id())); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', _SUBMIT, 'submit'); $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="history.go(-1);"'); $form->addElement($buttons); $tpl->assign('report_contents', $form->render()); $tpl->assign('forumtitle', $forum->name()); $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()) {
die; } /** * Comprobamos que el usuario actual tenga permisos * de acceso al foro */ if (!$forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : array(0, XOOPS_GROUP_ANONYMOUS), BXPRESS_PERM_VIEW) && !$xoopsUser->isAdmin()) { redirect_header(BB_URL, 2, __('You are not allowed to view this forum!', 'bxpress')); die; } /** * Cargamos los temas */ $tbl1 = $db->prefix("bxpress_topics"); $tbl2 = $db->prefix("bxpress_forumtopics"); $sql = "SELECT COUNT(*) FROM {$tbl1} WHERE id_forum='" . $forum->id() . "' AND approved='1'"; list($num) = $db->fetchRow($db->queryF($sql)); $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = $xoopsModuleConfig['topicperpage'] > 0 ? $xoopsModuleConfig['topicperpage'] : 15; if ($page > 0) { $page -= 1; } $start = $page * $limit; $tpages = (int) ($num / $limit); if ($num % $limit > 0) { $tpages++; } $pactual = $page + 1; if ($pactual > $tpages) { $rest = $pactual - $tpages; $pactual = $pactual - $rest + 1;
/** * @desc Almacena los datos de un foro */ function bx_save_forum($edit = 0) { global $xoopsSecurity, $xoopsModuleConfig, $xoopsConfig; $q = $edit ? 'action=edit' : 'action=new'; $prefix = 1; foreach ($_POST as $k => $v) { if (substr($k, 0, 5) == 'perm_') { $permissions[substr($k, 5)] = $v; } else { ${$k} = $v; } if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $q = '&' . $k . '=' . $v; } if (!$xoopsSecurity->check()) { redirectMsg('forums.php?' . $q, __('Session token expired', 'bxpress'), 1); die; } if ($edit) { $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('forums.php', __('Specified id is not valid!', 'bxpress'), 1); die; } $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1); die; } } else { $forum = new bXForum(); } $forum->setName($name); $forum->setDescription($desc); if (!$edit) { $forum->setTopics(0); $forum->setPosts(0); $forum->setPostId(0); $forum->setSubforums(0); } $forum->setCategory($cat); $forum->setActive($active); $forum->setSignature($sig); $forum->setPrefix($prefix); $forum->setHotThreshold($hot_threshold); $forum->setOrder($order); $forum->setAttachments($attachments); $forum->setMaxSize($attach_maxkb); $forum->setExtensions(explode('|', $attach_ext)); $forum->setFriendName(TextCleaner::getInstance()->sweetstring($name)); $forum->setPermissions($permissions); if ($forum->save()) { if ($parent > 0) { $pf = new bXForum($parent); if (!$pf->isNew()) { $pf->setSubforums($pf->subforums() + 1); $pf->save(); } } if (!$edit) { //Redireccionamos a ventana de selección de moderadores redirectMsg('forums.php?action=moderators&id=' . $forum->id(), __('Forum saved successfully! Redirecting to moderators assignment...', 'bxpress'), 0); } else { redirectMsg('forums.php', __('Changes saved successfully!', 'bxpress'), 0); } } else { redirectMsg('forums.php?' . $q, __('Forum could not be saved!', 'bxpress') . $forum->errors(), 1); } }
/** * @desc Eliminar temas */ function deleteTopics() { global $db, $xoopsModuleConfig, $bxpress, $forum, $xoopsUser, $xoopsSecurity; $ok = isset($_POST['ok']) ? $_POST['ok'] : 0; $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null; if (empty($topics) || is_array($topics) && empty($topics)) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Select at least one topic to delete!', 'bxpress')); die; } $topics = !is_array($topics) ? array($topics) : $topics; $lastpost = false; if (!$xoopsSecurity->check()) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Session token expired!', 'bxpress')); die; } foreach ($topics as $k) { $topic = new bXTopic($k); if ($topic->isNew()) { continue; } if ($topic->forum() != $forum->id()) { continue; } //Verificamos si el tema contiene el último mensaje del foro if (!$lastpost && array_key_exists($forum->lastPostId(), $topic->getPosts(0))) { $lastpost = true; } $topic->delete(); } //Actualizamos el último mensaje del foro if ($lastpost) { $forum = new bXForum($forum->id()); $post = $forum->getLastPost(); $forum->setPostId($post); $forum->save(); } redirect_header('moderate.php?id=' . $forum->id(), 1, __('Action completed!', 'bxpress')); }
$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); $poptops[] = array('id' => $topic->id(), 'title' => $topic->title(), 'date' => sprintf(__('Created on %s', 'bxpress'), bXFunctions::formatDate($row['date'])), 'replies' => $topic->replies(), 'link' => $topic->permalink(), 'forum' => array('id' => $forum->id(), 'name' => $forum->name(), 'link' => $forum->permalink())); } unset($post, $pt, $topic, $result, $row, $sql, $tbl1, $tbl2, $tbl3); RMTemplate::get()->add_style('dashboard.css', 'bxpress'); RMTemplate::get()->add_script('dashboard.js', 'bxpress'); RMTemplate::get()->add_help('Ayuda de bXpress', 'http://www.xoopsmexico.net/docs/bxpress-forums/dashboard/standalone/1/'); // Activity