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 Genera los datos para el envio de las notificaciones * @param string I de la categoría * @param int Id del elemento * @param string Id del Evento generado * @param array Parámetros adicionales * @return string */ function bxNotifications($category, $id, $event, $params = array()) { $bxf = bXFunctions::get(); if ($category == 'forum') { //Notificación de nuevo tema en foro if ($event == 'newtopic') { $forum = new bXForum($id); $info['name'] = $forum->name(); $info['url'] = $bxf->url() . "/topic.php?id={$params['topic']}"; //$info['desc']=$param['topic']; return $info; } //Notificación de nuevo mensaje en foro if ($event == 'postforum') { $forum = new bXForum($id); $info['name'] = $forum->name(); $info['url'] = $bxf->url() . "/topic.php?pid={$params['post']}#p{$params['post']}"; //$info['desc']=$param['topic']; return $info; } } //Notificación de nuevo mensaje en tema if ($category == 'topic') { $topic = new bXTopic($id); $info['name'] = $topic->title(); $info['url'] = $bxf->url() . "/topic.php?pid={$params['post']}#p{$params['post']}"; //$info['desc']=$param['topic']; return $info; } //Notificación de mensaje en cualquier foro if ($category == 'any_forum') { $forum = new bXForum($params['forum']); $info['name'] = $forum->name(); $info['url'] = $bxf->url() . "/topic.php?pid={$params['post']}#p{$params['post']}"; //$info['desc']=$param['topic']; return $info; } }
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(); }
public function object_data($event) { include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php'; switch ($event->event) { case 'reply': // Get topic $topic = new bXTopic($event->params); if ($topic->isNew()) { return null; } $ret = array('name' => $topic->title(), 'link' => $topic->permalink()); break; case 'newtopic': case 'forum-newpost': // Get forum $forum = new bXForum($event->params); if ($forum->isNew()) { return null; } $ret = array('name' => $forum->name(), 'link' => $forum->permalink()); break; } return $ret; }
$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; } }
$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; }
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 { $pages = null; } $tpl->append('topics', array('id' => $topic->id(), 'title' => $topic->title(), 'replies' => $topic->replies(), 'views' => $topic->views(), 'by' => sprintf(__('By: %s', 'bxpress'), $topic->posterName()), 'last' => $lastpost, 'popular' => $topic->replies() >= $forum->hotThreshold(), 'sticky' => $topic->sticky(), 'pages' => $pages, 'tpages' => $tpages, 'closed' => $topic->status(), 'poster' => array('uid' => $topic->poster, 'uname' => $poster->uname, 'name' => $poster->name, 'email' => $poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $poster->getVar('email'), 100), 'type' => $poster->isAdmin() ? 'admin' : ($forum->isModerator($topic->poster) ? 'moderator' : 'user')))); } // Datos del Foro $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false)); // Notificaciones de Common Utilities $notifications = RMNotifications::get(); $events = Bxpress_Notifications::get(); // New topics notifications $event = $events->event('newtopic')->parameters($forum->id())->permissions(array('users' => $forum->moderators(), 'groups' => array(XOOPS_GROUP_ADMIN))); $notifications->add_item($event); // New posts notification $event = $events->event('forum-newpost')->parameters($forum->id())->permissions(array('users' => $forum->moderators(), 'groups' => array(XOOPS_GROUP_ADMIN))); $notifications->add_item($event); // Assign output to a Smarty variable $tpl->assign('notifications', $notifications->render()); $tpl->assign('lang_pages', __('Pages:', 'bxpress')); $tpl->assign('lang_topic', __('Topics', 'bxpress')); $tpl->assign('lang_replies', __('Replies', 'bxpress')); $tpl->assign('lang_views', __('Views', 'bxpress'));
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())); } }
/** * @desc Visualiza lista de usuarios para determinar moderadores **/ function bx_moderators() { global $xoopsModule; $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('forums.php', __('No forum ID has been provided!', 'bxpress'), 1); die; } $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1); break; } RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/#moderadores'); xoops_cp_header(); //Lista de usuarios $form = new RMForm(sprintf(__('Forum "%s" Moderators', 'bxpress'), $forum->name()), 'formmdt', 'forums.php'); $form->addElement(new RMFormUser(__('Moderators', 'bxpress'), 'users', 1, $forum->moderators(), 30), true, 'checked'); $form->element('users')->setDescription(__('Choose from the list the moderators users', 'bxpress')); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Save Moderators', 'bxpress'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location.href=\'forums.php\';"'); $form->addElement($buttons); $form->addElement(new RMFormHidden('action', 'savemoderat')); $form->addElement(new RMFormHidden('id', $id)); $form->display(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('forum Moderators', 'bxpress')); xoops_cp_footer(); }
$pid = isset($_REQUEST['pid']) ? intval($_REQUEST['pid']) : 0; $post = new bXPost($pid); $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
$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