} $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) { $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);
/** * @desc Mover temas de un foro a otro */ function moveTopics() { global $db, $xoopsModuleConfig, $xoopsSecurity, $forum, $xoopsUser, $xoopsOption, $xoopsConfig; $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null; $ok = isset($_POST['ok']) ? $_POST['ok'] : 0; $moveforum = rmc_server_var($_POST, 'moveforum', 0); if (empty($topics) || is_array($topics) && empty($topics)) { redirect_header('moderate.php?id=' . $moveforum, 2, __('Select at least a topic to moderate!', 'bxpress')); die; } $topics = !is_array($topics) ? array($topics) : $topics; if ($ok) { if (!$xoopsSecurity->check()) { redirect_header('moderate.php?id=' . $moveforum, 2, __('Session token expired!', 'bxpress')); die; } if ($moveforum <= 0) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Please select the target forum', 'bxpress')); die; } $mf = new bXForum($moveforum); if ($mf->isNew()) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Specified forum does not exists!', 'bxpress')); die; } $lastpost = false; foreach ($topics as $k) { $topic = new bXTopic($k); 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->setForum($moveforum); if ($topic->save()) { //Decrementa el número de temas $forum->setTopics($forum->topics() - 1 > 0 ? $forum->topics() - 1 : 0); $forum->setPosts($forum->posts() - ($topic->replies() + 1) > 0 ? $forum->posts() - ($topic->replies() + 1) : 0); $forum->save(); $mf->setPosts($mf->posts() + ($topic->replies() + 1)); $mf->addTopic(); $mf->save(); //Cambiamos el foro de los mensajes del tema if ($topic->getPosts()) { foreach ($topic->getPosts() as $k => $v) { $v->setForum($moveforum); $v->save(); } } } } //Actualizamos el último mensaje del foro if ($lastpost) { $post = $forum->getLastPost(); $forum->setPostId($post); $forum->save(); } //Actualizamos el último mensaje del foro al que fue movido el tema $post = $mf->getLastPost(); $post ? $mf->setPostId($post) : ''; $mf->save(); redirect_header('moderate.php?id=' . $forum->id(), 1, __('Topics has been relocated!', 'bxpress')); die; } else { global $xoopsTpl; $tpl = $xoopsTpl; $xoopsOption['template_main'] = "bxpress_moderateforms.html"; $xoopsOption['module_subpage'] = "moderate"; include 'header.php'; bXFunctions::makeHeader(); $form = new RMForm(__('Move Topics', 'bxpress'), 'frmMove', 'moderate.php'); $form->addElement(new RMFormHidden('id', $forum->id())); $form->addElement(new RMFormHidden('op', 'move')); $form->addElement(new RMFormHidden('ok', '1')); $i = 0; foreach ($topics as $k) { $form->addElement(new RMFormHidden('topics[' . $i . ']', $k)); ++$i; } $form->addElement(new RMFormSubTitle(' ', 1, '')); $form->addElement(new RMFormSubTitle(__('Select the forum where you wish to move selected topics', 'bxpress'), 1, 'even')); $ele = new RMFormSelect(__('Forum', 'bxpress'), 'moveforum'); $ele->addOption(0, '', 1); $tbl1 = $db->prefix("bxpress_categories"); $tbl2 = $db->prefix("bxpress_forums"); $sql = "SELECT b.*, a.title FROM {$tbl1} a, {$tbl2} b WHERE b.cat=a.id_cat AND b.active='1' AND id_forum<>" . $forum->id() . " ORDER BY a.order, b.order"; $result = $db->query($sql); $categories = array(); while ($row = $db->fetchArray($result)) { $cforum = array('id' => $row['id_forum'], 'name' => $row['name']); if (isset($categores[$row['cat']])) { $categories[$row['cat']]['forums'][] = $cforum; } else { $categories[$row['cat']]['title'] = $row['title']; $categories[$row['cat']]['forums'][] = $cforum; } } foreach ($categories as $cat) { $ele->addOption(0, $cat['title'], 0, true, 'color: #000; font-weight: bold; font-style: italic; border-bottom: 1px solid #c8c8c8;'); foreach ($cat['forums'] as $cforum) { $ele->addOption($cforum['id'], $cforum['name'], 0, false, 'padding-left: 10px;'); } } $form->addElement($ele, true, "noselect:0"); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', __('Move Topics Now!', 'bxpress'), 'submit'); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1);"'); $form->addElement($ele); $tpl->assign('moderate_form', $form->render()); include 'footer.php'; } }
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 { $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())); } // Datos del Foro $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false)); $tpl->assign('lang_pages', __('Pages:', 'bxpress')); $tpl->assign('lang_topic', __('Topics', 'bxpress')); $tpl->assign('lang_replies', __('Replies', 'bxpress')); $tpl->assign('lang_views', __('Views', 'bxpress')); $tpl->assign('lang_lastpost', __('Last Post', 'bxpress')); $tpl->assign('lang_nonew', __('No new posts', 'bxpress'));
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 // 30 Days $ago = strtotime("-30 days"); $sql = "SELECT id_post,post_time,id_forum FROM " . $db->prefix("mod_bxpress_posts") . " WHERE post_time>={$ago} ORDER BY post_time ASC"; $result = $db->query($sql); $posts = array(); $forums = array(); $p = ''; while ($row = $db->fetchArray($result)) { $ds = date("d-M-Y", $row['post_time']);