Exemplo n.º 1
0
 /**
  * Create full title of the topic
  *
  * the title is composed of [type_name] if type_id is greater than 0 plus topic_title
  *
  */
 function getFullTitle()
 {
     $topic_title = $this->getVar("topic_title");
     if (!$this->getVar("type_id")) {
         return $topic_title;
     }
     $type_handler =& xoops_getmodulehandler('type', 'newbb');
     if (!($type_obj =& $type_handler->get($this->getVar("type_id")))) {
         return $topic_title;
     }
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.topic.php";
     return newbb_getTopicTitle($topic_title, $type_obj->getVar("type_name"), $type_obj->getVar("type_color"));
 }
Exemplo n.º 2
0
 function renderTopics($xoopsTpl = null)
 {
     global $myts;
     $ret = array();
     //$this->parseVars();
     if ($this->noperm) {
         if (is_object($xoopsTpl)) {
             $xoopsTpl->assign_by_ref("topics", $ret);
             return;
         }
         return $ret;
     }
     $selects = array();
     $froms = array();
     $joins = array();
     $wheres = array();
     // topic fields
     $selects[] = 't.*';
     // post fields
     $selects[] = 'p.post_time as last_post_time, p.poster_name as last_poster_name, p.icon, p.post_id, p.uid';
     $froms[] = $this->handler->db->prefix("bb_topics") . ' AS t ';
     $joins[] = 'LEFT JOIN ' . $this->handler->db->prefix('bb_posts') . ' AS p ON p.post_id = t.topic_last_post_id';
     $wheres[] = "1 = 1";
     if (!empty($this->config['post_excerpt'])) {
         $selects[] = 'p.post_karma, p.require_reply, pt.post_text';
         $this->query["join"][] = 'LEFT JOIN ' . $this->handler->db->prefix('bb_posts_text') . ' AS pt ON pt.post_id = t.topic_last_post_id';
     }
     if (empty($this->query["sort"])) {
         $this->query["sort"][] = 't.topic_last_post_id DESC';
     }
     $GLOBALS['xoopsLogger']->startTime('XOOPS output module - render - topics - query');
     $sql = '    SELECT ' . implode(", ", $selects) . '     FROM ' . implode(", ", $froms) . '        ' . implode(" ", $joins) . '        ' . implode(" ", $this->query["join"]) . '     WHERE ' . implode(" AND ", $wheres) . '        AND ' . @implode(" AND ", @$this->query["where"]) . '     ORDER BY ' . implode(", ", $this->query["sort"]);
     if (!($result = $this->handler->db->query($sql, $this->config['topics_per_page'], @$this->vars["start"]))) {
         if (is_object($xoopsTpl)) {
             $xoopsTpl->assign_by_ref("topics", $ret);
             return;
         }
         return $ret;
     }
     $GLOBALS['xoopsLogger']->stopTime('XOOPS output module - render - topics - query');
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.render.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.session.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.time.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.read.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.topic.php";
     $sticky = 0;
     $topics = array();
     $posters = array();
     $reads = array();
     $types = array();
     $forums = array();
     $anonymous = $myts->htmlSpecialChars($GLOBALS["xoopsConfig"]['anonymous']);
     $GLOBALS['xoopsLogger']->startTime('XOOPS output module - render - topics - fetch');
     while ($myrow = $this->handler->db->fetchArray($result)) {
         if ($myrow['topic_sticky']) {
             $sticky++;
         }
         // ------------------------------------------------------
         // topic_icon: priority: sticky -> digest -> regular
         if ($myrow['topic_haspoll']) {
             if ($myrow['topic_sticky']) {
                 $topic_icon = newbb_displayImage("topic_sticky", _MD_TOPICSTICKY) . '<br />' . newbb_displayImage("poll", _MD_TOPICHASPOLL);
             } else {
                 $topic_icon = newbb_displayImage('poll', _MD_TOPICHASPOLL);
             }
         } elseif ($myrow['topic_sticky']) {
             $topic_icon = newbb_displayImage('topic_sticky', _MD_TOPICSTICKY);
         } elseif (!empty($myrow['icon'])) {
             $topic_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($myrow['icon']) . '" alt="" />';
         } else {
             $topic_icon = '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />';
         }
         // ------------------------------------------------------
         // rating_img
         $rating = number_format($myrow['rating'] / 2, 0);
         $rating_img = newbb_displayImage($rating < 1 ? 'blank' : 'rate' . $rating);
         // ------------------------------------------------------
         // topic_page_jump
         $topic_page_jump = '';
         $topic_page_jump_icon = '';
         $totalpages = ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']);
         if ($totalpages > 1) {
             $topic_page_jump .= '&nbsp;&nbsp;';
             $append = false;
             for ($i = 1; $i <= $totalpages; $i++) {
                 if ($i > 3 && $i < $totalpages) {
                     if (!$append) {
                         $topic_page_jump .= "...";
                         $append = true;
                     }
                 } else {
                     $topic_page_jump .= '[<a href="viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;start=' . ($i - 1) * $this->config['posts_per_page'] . '">' . $i . '</a>]';
                     $topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=" . $myrow['topic_id'] . "&amp;start=" . ($i - 1) * $this->config['posts_per_page'] . "#forumpost" . $myrow['post_id'] . "'>" . newbb_displayImage('document') . "</a>";
                 }
             }
         } else {
             $topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=" . $myrow['topic_id'] . "#forumpost" . $myrow['post_id'] . "'>" . newbb_displayImage('document') . "</a>";
         }
         // ------------------------------------------------------
         // => topic array
         $topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
         if ($myrow['topic_digest']) {
             $topic_title = "<span class='digest'>" . $topic_title . "</span>";
         }
         if (empty($this->config["post_excerpt"])) {
             $topic_excerpt = "";
         } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbb_isAdmin($myrow['forum_id'])) {
             $topic_excerpt = "";
         } else {
             $GLOBALS['xoopsLogger']->startTime('XOOPS output module - render - topics - fetch - substr ' . $myrow['topic_id']);
             $topic_excerpt = xoops_substr(newbb_html2text($myts->displayTarea($myrow['post_text'])), 0, $this->config["post_excerpt"]);
             $GLOBALS['xoopsLogger']->stopTime('XOOPS output module - render - topics - fetch - substr ' . $myrow['topic_id']);
             $topic_excerpt = str_replace("[", "&#91;", $myts->htmlSpecialChars($topic_excerpt));
         }
         $topics[$myrow['topic_id']] = array('topic_id' => $myrow['topic_id'], 'topic_icon' => $topic_icon, 'type_id' => $myrow['type_id'], 'topic_title' => $topic_title, 'topic_link' => 'viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;forum=' . $myrow['forum_id'], 'rating_img' => $rating_img, 'topic_page_jump' => $topic_page_jump, 'topic_page_jump_icon' => $topic_page_jump_icon, 'topic_replies' => $myrow['topic_replies'], 'topic_poster_uid' => $myrow['topic_poster'], 'topic_poster_name' => !empty($myrow['poster_name']) ? $myts->htmlSpecialChars($myrow['poster_name']) : $anonymous, 'topic_views' => $myrow['topic_views'], 'topic_time' => newbb_formatTimestamp($myrow['topic_time']), 'topic_last_posttime' => newbb_formatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? $myts->htmlSpecialChars($myrow['last_poster_name']) : $anonymous, 'topic_forum' => $myrow['forum_id'], 'topic_excerpt' => $topic_excerpt, 'stick' => empty($myrow['topic_sticky']), "stats" => array($myrow['topic_status'], $myrow['topic_digest'], $myrow['topic_replies']));
         /* users */
         $posters[$myrow['topic_poster']] = 1;
         $posters[$myrow['uid']] = 1;
         // reads
         if (!empty($this->config["read_mode"])) {
             $reads[$myrow['topic_id']] = $this->config["read_mode"] == 1 ? $myrow['last_post_time'] : $myrow["topic_last_post_id"];
         }
         // types
         if (!empty($myrow['type_id'])) {
             //$types[$myrow['type_id']] = 1;
         }
         // forums
         $forums[$myrow['forum_id']] = 1;
     }
     $GLOBALS['xoopsLogger']->stopTime('XOOPS output module - render - topics - fetch');
     $posters_name = newbb_getUnameFromIds(array_keys($posters), $this->config['show_realname'], true);
     $topic_isRead = newbb_isRead("topic", $reads);
     /*
     $type_list = array();
     if (count($types) > 0) {
     $type_handler =& xoops_getmodulehandler('type', 'newbb');
     $type_list = $type_handler->getAll(new Criteria("type_id", "(".implode(", ", array_keys($types)).")", "IN"), null, false);
     }
     */
     $type_list = $this->getTypes();
     $forum_handler =& xoops_getmodulehandler('forum', 'newbb');
     $forum_list = $forum_handler->getAll(new Criteria("forum_id", "(" . implode(", ", array_keys($forums)) . ")", "IN"), array("forum_name", "hot_threshold"), false);
     foreach (array_keys($topics) as $id) {
         $topics[$id]["topic_forum_link"] = '<a href="' . XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $topics[$id]["topic_forum"] . '">' . $forum_list[$topics[$id]["topic_forum"]]["forum_name"] . '</a>';
         if (!empty($topics[$id]["type_id"]) && isset($type_list[$topics[$id]["type_id"]])) {
             $topics[$id]["topic_title"] = newbb_getTopicTitle($topics[$id]["topic_title"], $type_list[$topics[$id]["type_id"]]["type_name"], $type_list[$topics[$id]["type_id"]]["type_color"]);
         }
         $topics[$id]["topic_poster"] = !empty($posters_name[$topics[$id]["topic_poster_uid"]]) ? $posters_name[$topics[$id]["topic_poster_uid"]] : $topics[$id]["topic_poster_name"];
         $topics[$id]["topic_last_poster"] = !empty($posters_name[$topics[$id]["topic_last_poster_uid"]]) ? $posters_name[$topics[$id]["topic_last_poster_uid"]] : $topics[$id]["topic_last_poster_name"];
         // ------------------------------------------------------
         // topic_folder: priority: newhot -> hot/new -> regular
         list($topic_status, $topic_digest, $topic_replies) = $topics[$id]["stats"];
         if ($topic_status == 1) {
             $topic_folder = 'topic_locked';
         } else {
             if ($topic_digest) {
                 $topic_folder = 'topic_digest';
             } elseif ($topic_replies >= $forum_list[$topics[$id]["topic_forum"]]["hot_threshold"]) {
                 $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot';
             } else {
                 $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic';
             }
         }
         $topics[$id]['topic_folder'] = newbb_displayImage($topic_folder);
         unset($topics[$id]["topic_poster_name"], $topics[$id]["topic_last_poster_name"], $topics[$id]["stats"]);
     }
     if (count($topics) > 0) {
         $sql = " SELECT DISTINCT topic_id FROM " . $this->handler->db->prefix("bb_posts") . " WHERE attachment != ''" . " AND topic_id IN (" . implode(',', array_keys($topics)) . ")";
         if ($result = $this->handler->db->query($sql)) {
             while (list($topic_id) = $this->handler->db->fetchRow($result)) {
                 $topics[$topic_id]['attachment'] = '&nbsp;' . newbb_displayImage('attachment', _MD_TOPICSHASATT);
             }
         }
     }
     if (is_object($xoopsTpl)) {
         $xoopsTpl->assign_by_ref("sticky", $sticky);
         $xoopsTpl->assign_by_ref("topics", $topics);
         return;
     }
     return array($topics, $sticky);
 }
Exemplo n.º 3
0
 function getAllTopics(&$forum, $criteria = null)
 {
     global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts, $xoopsUser, $viewall_forums;
     global $xoopsLogger;
     $xoopsLogger->startTime('XOOPS output module - forum - topic - init');
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.render.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.session.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.time.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.read.php";
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.topic.php";
     $criteria_vars = array("startdate", "start", "sort", "order", "type", "status", "excerpt");
     foreach ($criteria_vars as $var) {
         ${$var} = $criteria[$var];
     }
     $topic_lastread = newbb_getcookie('LT', true);
     if (is_object($forum)) {
         $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id');
         $hot_threshold = $forum->getVar('hot_threshold');
     } else {
         $hot_threshold = 10;
         if (is_array($forum) && count($forum) > 0) {
             $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')';
         } elseif (!empty($forum)) {
             $criteria_forum = ' AND t.forum_id =' . intval($forum);
         } else {
             $criteria_forum = '';
         }
     }
     $criteria_post = $startdate ? ' p.post_time > ' . $startdate : " 1 = 1 ";
     $criteria_topic = empty($type) ? '' : " AND t.type_id={$type}";
     $criteria_extra = '';
     $criteria_approve = ' AND t.approved = 1';
     $post_on = ' p.post_id = t.topic_last_post_id';
     $leftjoin = ' LEFT JOIN ' . $this->db->prefix('bb_posts') . ' p ON p.post_id = t.topic_last_post_id';
     $sort_array = array();
     switch ($status) {
         case 'digest':
             $criteria_extra = ' AND t.topic_digest = 1';
             break;
         case 'unreplied':
             $criteria_extra = ' AND t.topic_replies < 1';
             break;
         case 'unread':
             if (empty($xoopsModuleConfig["read_mode"])) {
             } elseif ($xoopsModuleConfig["read_mode"] == 2) {
                 $leftjoin .= ' LEFT JOIN ' . $this->db->prefix('bb_reads_topic') . ' r ON r.read_item = t.topic_id';
                 $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
             } elseif ($xoopsModuleConfig["read_mode"] == 1) {
                 $topics = array();
                 $topic_lastread = newbb_getcookie('LT', true);
                 if (count($topic_lastread) > 0) {
                     foreach ($topic_lastread as $id => $time) {
                         if ($time > $time_criterion) {
                             $topics[] = $id;
                         }
                     }
                 }
                 if (count($topics) > 0) {
                     $criteria_extra = ' AND t.topic_id NOT IN (' . implode(",", $topics) . ')';
                 }
                 if ($lastvisit = max($GLOBALS['last_visit'], $startdate)) {
                     $criteria_post = ' p.post_time > ' . max($GLOBALS['last_visit'], $startdate);
                 }
             }
             break;
         case 'pending':
             $post_on = ' p.topic_id = t.topic_id';
             $criteria_post .= ' AND p.pid = 0';
             $criteria_approve = ' AND t.approved = 0';
             break;
         case 'deleted':
             $criteria_approve = ' AND t.approved = -1';
             break;
         case 'all':
             // For viewall.php; do not display sticky topics at first
         // For viewall.php; do not display sticky topics at first
         case 'active':
             // same as "all"
             break;
         default:
             if ($startdate > 0) {
                 $criteria_post = ' (p.post_time > ' . $startdate . ' OR t.topic_sticky=1)';
             }
             $sort_array[] = 't.topic_sticky DESC';
             break;
     }
     $select = 't.*, ' . ' p.post_time as last_post_time, p.poster_name as last_poster_name, p.icon, p.post_id, p.uid';
     $from = $this->db->prefix("bb_topics") . ' t ' . $leftjoin;
     $where = $criteria_post . $criteria_topic . $criteria_forum . $criteria_extra . $criteria_approve;
     if ($excerpt) {
         $select .= ', p.post_karma, p.require_reply, pt.post_text';
         $from .= ' LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' pt ON pt.post_id = t.topic_last_post_id';
     }
     if ($sort == "u.uname") {
         $sort = "t.topic_poster";
     }
     $sort_array[] = trim($sort . ' ' . $order);
     $sortby = implode(", ", array_filter($sort_array));
     if (empty($sortby)) {
         $sortby = 't.topic_last_post_id DESC';
     }
     $xoopsLogger->stopTime('XOOPS output module - forum - topic - init');
     $sql = 'SELECT ' . $select . ' FROM ' . $from . ' WHERE ' . $where . ' ORDER BY ' . $sortby;
     $xoopsLogger->startTime('XOOPS output module - forum - topic - query');
     if (!($result = $this->db->query($sql, $xoopsModuleConfig['topics_per_page'], $start))) {
         redirect_header('index.php', 2, _MD_ERROROCCURED);
         exit;
     }
     $xoopsLogger->stopTime('XOOPS output module - forum - topic - query');
     $sticky = 0;
     $topics = array();
     $posters = array();
     $reads = array();
     $types = array();
     $xoopsLogger->startTime('XOOPS output module - forum - topic - display');
     $xoopsLogger->startTime('XOOPS output module - forum - topic - display - assign');
     while ($myrow = $this->db->fetchArray($result)) {
         //$xoopsLogger->startTime( 'XOOPS output module - forum - topic - display - assign '. $myrow['topic_id']);
         if ($myrow['topic_sticky']) {
             $sticky++;
         }
         // ------------------------------------------------------
         // topic_icon: priority: sticky -> digest -> regular
         if ($myrow['topic_haspoll']) {
             if ($myrow['topic_sticky']) {
                 $topic_icon = newbb_displayImage('topic_sticky', _MD_TOPICSTICKY) . '<br />' . newbb_displayImage('poll', _MD_TOPICHASPOLL);
             } else {
                 $topic_icon = newbb_displayImage('poll', _MD_TOPICHASPOLL);
             }
         } elseif ($myrow['topic_sticky']) {
             $topic_icon = newbb_displayImage('topic_sticky', _MD_TOPICSTICKY);
         } elseif (!empty($myrow['icon'])) {
             $topic_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($myrow['icon']) . '" alt="" />';
         } else {
             $topic_icon = '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />';
         }
         // ------------------------------------------------------
         // rating_img
         $rating = number_format($myrow['rating'] / 2, 0);
         $rating_img = newbb_displayImage($rating < 1 ? 'blank' : 'rate' . $rating);
         // ------------------------------------------------------
         // topic_page_jump
         $topic_page_jump = '';
         $topic_page_jump_icon = '';
         $totalpages = ceil(($myrow['topic_replies'] + 1) / $xoopsModuleConfig['posts_per_page']);
         if ($totalpages > 1) {
             $topic_page_jump .= '&nbsp;&nbsp;';
             $append = false;
             for ($i = 1; $i <= $totalpages; $i++) {
                 if ($i > 3 && $i < $totalpages) {
                     if (!$append) {
                         $topic_page_jump .= "...";
                         $append = true;
                     }
                 } else {
                     $topic_page_jump .= '[<a href="viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;start=' . ($i - 1) * $xoopsModuleConfig['posts_per_page'] . '">' . $i . '</a>]';
                     $topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=" . $myrow['topic_id'] . "&amp;start=" . ($i - 1) * $xoopsModuleConfig['posts_per_page'] . "#forumpost" . $myrow['post_id'] . "'>" . newbb_displayImage('document') . "</a>";
                 }
             }
         } else {
             $topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=" . $myrow['topic_id'] . "#forumpost" . $myrow['post_id'] . "'>" . newbb_displayImage('document') . "</a>";
         }
         // ------------------------------------------------------
         // => topic array
         if (!empty($viewall_forums[$myrow['forum_id']])) {
             $forum_link = '<a href="' . XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $myrow['forum_id'] . '">' . $viewall_forums[$myrow['forum_id']]['forum_name'] . '</a>';
         } else {
             $forum_link = '';
         }
         $topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
         if ($myrow['topic_digest']) {
             $topic_title = "<span class='digest'>" . $topic_title . "</span>";
         }
         if ($excerpt == 0) {
             $topic_excerpt = "";
         } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbb_isAdmin($forum)) {
             $topic_excerpt = "";
         } else {
             $topic_excerpt = xoops_substr(newbb_html2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt);
             $topic_excerpt = str_replace("[", "&#91;", $myts->htmlSpecialChars($topic_excerpt));
         }
         $topics[$myrow['topic_id']] = array('topic_id' => $myrow['topic_id'], 'topic_icon' => $topic_icon, 'type_id' => $myrow['type_id'], 'topic_title' => $topic_title, 'topic_link' => 'viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;forum=' . $myrow['forum_id'], 'rating_img' => $rating_img, 'topic_page_jump' => $topic_page_jump, 'topic_page_jump_icon' => $topic_page_jump_icon, 'topic_replies' => $myrow['topic_replies'], 'topic_poster_uid' => $myrow['topic_poster'], 'topic_poster_name' => $myts->htmlSpecialChars($myrow['poster_name'] ? $myrow['poster_name'] : $xoopsConfig['anonymous']), 'topic_views' => $myrow['topic_views'], 'topic_time' => newbb_formatTimestamp($myrow['topic_time']), 'topic_last_posttime' => newbb_formatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], 'topic_last_poster_name' => $myts->htmlSpecialChars($myrow['last_poster_name'] ? $myrow['last_poster_name'] : $xoopsConfig['anonymous']), 'topic_forum_link' => $forum_link, 'topic_excerpt' => $topic_excerpt, 'stick' => empty($myrow['topic_sticky']), "stats" => array($myrow['topic_status'], $myrow['topic_digest'], $myrow['topic_replies']));
         /* users */
         $posters[$myrow['topic_poster']] = 1;
         $posters[$myrow['uid']] = 1;
         // reads
         if (!empty($xoopsModuleConfig["read_mode"])) {
             $reads[$myrow['topic_id']] = $xoopsModuleConfig["read_mode"] == 1 ? $myrow['last_post_time'] : $myrow["topic_last_post_id"];
         }
         // types
         if (!empty($myrow['type_id'])) {
             $types[$myrow['type_id']] = 1;
         }
         //$xoopsLogger->stopTime( 'XOOPS output module - forum - topic - display - assign '. $myrow['topic_id']);
     }
     $xoopsLogger->stopTime('XOOPS output module - forum - topic - display - assign');
     $posters_name = newbb_getUnameFromIds(array_keys($posters), $xoopsModuleConfig['show_realname'], true);
     $topic_isRead = newbb_isRead("topic", $reads);
     $types_obj = array();
     if (count($types) > 0) {
         $type_handler =& xoops_getmodulehandler('type', 'newbb');
         $types_obj = $type_handler->getAll(new Criteria("type_id", "(" . implode(", ", array_keys($types)) . ")", "IN"));
     }
     foreach (array_keys($topics) as $id) {
         if (!empty($topics[$id]["type_id"]) && isset($types_obj[$topics[$id]["type_id"]])) {
             $topics[$id]["topic_title"] = newbb_getTopicTitle($topics[$id]["topic_title"], $types_obj[$topics[$id]["type_id"]]->getVar("type_name"), $types_obj[$topics[$id]["type_id"]]->getVar("type_color"));
         }
         $topics[$id]["topic_poster"] = !empty($posters_name[$topics[$id]["topic_poster_uid"]]) ? $posters_name[$topics[$id]["topic_poster_uid"]] : $topics[$id]["topic_poster_name"];
         $topics[$id]["topic_last_poster"] = !empty($posters_name[$topics[$id]["topic_last_poster_uid"]]) ? $posters_name[$topics[$id]["topic_last_poster_uid"]] : $topics[$id]["topic_last_poster_name"];
         // ------------------------------------------------------
         // topic_folder: priority: newhot -> hot/new -> regular
         list($topic_status, $topic_digest, $topic_replies) = $topics[$id]["stats"];
         if ($topic_status == 1) {
             $topic_folder = 'topic_locked';
         } else {
             if ($topic_digest) {
                 $topic_folder = 'topic_digest';
             } elseif ($topic_replies >= $hot_threshold) {
                 $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot';
             } else {
                 $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic';
             }
         }
         $topics[$id]['topic_folder'] = newbb_displayImage($topic_folder);
         unset($topics[$id]["topic_poster_name"], $topics[$id]["topic_last_poster_name"], $topics[$id]["stats"]);
     }
     unset($types_obj);
     $xoopsLogger->stopTime('XOOPS output module - forum - topic - display');
     $xoopsLogger->startTime('XOOPS output module - forum - topic - attach');
     if (count($topics) > 0) {
         $sql = " SELECT DISTINCT topic_id FROM " . $this->db->prefix("bb_posts") . " WHERE attachment != ''" . " AND topic_id IN (" . implode(',', array_keys($topics)) . ")";
         if ($result = $this->db->query($sql)) {
             while (list($topic_id) = $this->db->fetchRow($result)) {
                 $topics[$topic_id]['attachment'] = '&nbsp;' . newbb_displayImage('attachment', _MD_TOPICSHASATT);
             }
         }
     }
     $xoopsLogger->stopTime('XOOPS output module - forum - topic - attach');
     return array($topics, $sticky);
 }
Exemplo n.º 4
0
$xoopsLogger->startTime('XOOPS output module - forum - type');
$query_type = $query_array;
unset($query_type["type"]);
$page_query_type = implode("&amp;", array_values($query_type));
unset($query_type);
$type_handler =& xoops_getmodulehandler('type', 'newbb');
$type_options = null;
if ($types = $type_handler->getByForum($forum_id)) {
    $type_options[] = array("title" => _ALL, "link" => "viewforum.php?{$page_query_type}");
    foreach ($types as $key => $item) {
        $type_options[] = array("title" => $item["type_name"], "link" => "viewforum.php?{$page_query_type}&amp;type={$key}");
    }
}
if ($type > 0) {
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.topic.php";
    $xoopsTpl->assign('forum_topictype', newbb_getTopicTitle("", $types[$type]["type_name"], $types[$type]["type_color"]));
}
$xoopsTpl->assign_by_ref('type_options', $type_options);
$xoopsLogger->stopTime('XOOPS output module - forum - type');
$query_status = $query_array;
unset($query_status["status"]);
$page_query_status = implode("&amp;", array_values($query_status));
unset($query_status);
$xoopsTpl->assign('newpost_link', "viewpost.php?status=new&amp;forum=" . $forum_obj->getVar('forum_id'));
$xoopsTpl->assign('all_link', "viewforum.php?{$page_query_status}");
$xoopsTpl->assign('digest_link', "viewforum.php?{$page_query_status}&amp;status=digest");
$xoopsTpl->assign('unreplied_link', "viewforum.php?{$page_query_status}&amp;status=unreplied");
$xoopsTpl->assign('unread_link', "viewforum.php?{$page_query_status}&amp;status=unread");
switch ($status) {
    case 'digest':
        $current_status = _MD_DIGEST;