//return $xmlrss_handler->get($rss); } $rows = array(); $types = array(); while ($row = $xoopsDB->fetchArray($result)) { $users[$row['uid']] = 1; if ($row['type_id'] > 0) { $types[$row['type_id']] = 1; } $rows[] = $row; } if (count($rows) < 1) { newbb_trackback_response(1, _MD_ERROR); //return $xmlrss_handler->get($rss); } $users = newbb_getUnameFromIds(array_keys($users), $xoopsModuleConfig['show_realname']); if (count($types) > 0) { $type_handler =& xoops_getmodulehandler('type', 'newbb'); $type_list = $type_handler->getList(new Criteria("type_id", "(" . implode(", ", array_keys($types)) . ")", "IN")); } foreach ($rows as $topic) { if ($xoopsModuleConfig['enable_karma'] && $topic['post_karma'] > 0) { continue; } if ($xoopsModuleConfig['allow_require_reply'] && $topic['require_reply']) { continue; } if (!empty($users[$topic['uid']])) { $topic['uname'] = $users[$topic['uid']]; } else { $topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS["xoopsConfig"]["anonymous"]);
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 .= ' '; $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'] . '&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'] . "&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("[", "[", $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'] . '&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'] = ' ' . 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); }
function b_newbb_author_show($options) { global $xoopsConfig; global $access_forums; $myts =& MyTextSanitizer::getInstance(); $block = array(); $i = 0; $type = "topic"; $order = "count"; $extra_criteria = ""; $time_criteria = null; if (!empty($options[2])) { mod_loadFunctions("time", "newbb"); $time_criteria = time() - newbb_getSinceTime($options[2]); $extra_criteria = " AND topic_time > " . $time_criteria; } switch ($options[0]) { case 'topic': break; case 'digest': $extra_criteria = " AND topic_digest = 1"; if ($time_criteria) { $extra_criteria .= " AND digest_time > " . $time_criteria; } break; case 'sticky': $extra_criteria .= " AND topic_sticky = 1"; break; case 'post': default: $type = "post"; if ($time_criteria) { $extra_criteria = " AND post_time > " . $time_criteria; } break; } $newbbConfig = newbb_load_config(); if (!isset($access_forums)) { $perm_handler =& xoops_getmodulehandler('permission', 'newbb'); if (!($access_forums = $perm_handler->getForums())) { return $block; } } if (!empty($options[5])) { $allowedforums = array_filter(array_slice($options, 5), "b_newbb_array_filter"); // get allowed forums $allowed_forums = array_intersect($allowedforums, $access_forums); } else { $allowed_forums = $access_forums; } if (empty($allowed_forums)) { return false; } if ($type == "topic") { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_topics') . ' WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; } else { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_posts') . ' WHERE uid > 0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; } $result = $GLOBALS["xoopsDB"]->query($query, $options[1], 0); if (!$result) { //xoops_error($GLOBALS["xoopsDB"]->error()); return $block; } $author = array(); while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) { $author[$row["author"]]["count"] = $row["count"]; } if (count($author) < 1) { return $block; } mod_loadFunctions("user", "newbb"); $author_name = newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname']); foreach (array_keys($author) as $uid) { $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]); } $block['authors'] =& $author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; $block['indexNav'] = intval($options[4]); return $block; }
function &display($forums, $length_title_index = 30, $count_subforum = 1) { global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts; $posts = array(); $posts_obj = array(); foreach (array_keys($forums) as $id) { $posts[] = $forums[$id]["forum_last_post_id"]; } if (!empty($posts)) { $post_handler =& xoops_getmodulehandler('post', 'newbb'); $tags_post = array("uid", "topic_id", "post_time", "poster_name", "icon"); if (!empty($length_title_index)) { $tags_post[] = "subject"; } $posts = $post_handler->getAll(new Criteria("post_id", "(" . implode(", ", $posts) . ")", "IN"), $tags_post, false); } // Get topic/post stats per forum $stats_forum = array(); if (!empty($count_subforum)) { $stats_forum = $this->getSubforumStats(array_keys($forums)); } $users = array(); $reads = array(); $topics = array(); foreach (array_keys($forums) as $id) { $forum =& $forums[$id]; if (!$forum["forum_last_post_id"]) { continue; } if (!($post = @$posts[$forum["forum_last_post_id"]])) { $forum["forum_last_post_id"] = 0; continue; } $users[] = $post["uid"]; if ($moderators[$id] = $forum["forum_moderator"]) { $users = array_merge($users, $moderators[$id]); } // reads if (!empty($xoopsModuleConfig["read_mode"])) { $reads[$id] = $xoopsModuleConfig["read_mode"] == 1 ? $post['post_time'] : $post['post_id']; } } require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.user.php"; require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.time.php"; require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.render.php"; require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.read.php"; $forum_isread = newbb_isRead("forum", $reads); $users_linked = newbb_getUnameFromIds(array_unique($users), !empty($xoopsModuleConfig['show_realname']), true); $forums_array = array(); $name_anonymous = $myts->htmlSpecialChars($GLOBALS["xoopsConfig"]["anonymous"]); foreach (array_keys($forums) as $id) { $forum =& $forums[$id]; $_forum_data = array(); $_forum_data["forum_order"] = $forum['forum_order']; $_forum_data["forum_id"] = $id; $_forum_data["forum_cid"] = $forum['cat_id']; $_forum_data["forum_name"] = $forum['forum_name']; $_forum_data["forum_desc"] = $myts->displayTarea($forum['forum_desc']); $_forum_data["forum_topics"] = $forum["forum_topics"] + @$stats_forum[$id]["topics"]; $_forum_data["forum_posts"] = $forum["forum_posts"] + @$stats_forum[$id]["posts"]; //$_forum_data["forum_type"] = $forum['forum_type']; $forum_moderators = array(); if (!empty($moderators[$id])) { foreach (@$moderators[$id] as $moderator) { $forum_moderators[] = @$users_linked[$moderator]; } } $_forum_data["forum_moderators"] = implode(", ", $forum_moderators); if ($post_id = $forum["forum_last_post_id"]) { $post =& $posts[$post_id]; $_forum_data['forum_lastpost_id'] = $post_id; $_forum_data['forum_lastpost_time'] = newbb_formatTimestamp($post['post_time']); if (!empty($users_linked[$post["uid"]])) { $_forum_data["forum_lastpost_user"] = $users_linked[$post["uid"]]; } elseif ($poster_name = $post["poster_name"]) { $_forum_data["forum_lastpost_user"] = $poster_name; } else { $_forum_data["forum_lastpost_user"] = $name_anonymous; } if (!empty($length_title_index)) { $subject = $post["subject"]; if ($length_title_index < 255) { $subject = xoops_substr($subject, 0, $length_title_index); } $_forum_data['forum_lastpost_subject'] = $subject; } if ($icon = $post['icon']) { $_forum_data['forum_lastpost_icon'] = $icon; } else { $_forum_data['forum_lastpost_icon'] = 'icon1.gif'; } } $forum_folder = empty($forum_isread[$id]) ? 'forum_new' : 'forum'; $_forum_data['forum_folder'] = newbb_displayImage($forum_folder); $forums_array[$forum['parent_forum']][] = $_forum_data; } return $forums_array; }
function b_newbb_author_show($options) { global $xoopsConfig; global $newbbConfig, $access_forums; $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); $block = array(); $i = 0; $type = "topic"; $order = "count"; $extra_criteria = ""; $time_criteria = null; if (!empty($options[2])) { $time_criteria = time() - newbb_getSinceTime($options[2]); $extra_criteria = " AND topic_time>" . $time_criteria; } switch ($options[0]) { case 'topic': break; case 'digest': $extra_criteria = " AND topic_digest=1"; if ($time_criteria) { $extra_criteria .= " AND digest_time>" . $time_criteria; } break; case 'sticky': $extra_criteria .= " AND topic_sticky=1"; break; case 'post': default: $type = "post"; if ($time_criteria) { $extra_criteria = " AND post_time>" . $time_criteria; } break; } $forum_handler =& xoops_getmodulehandler('forum', 'newbb'); $module_handler =& xoops_gethandler('module'); $newbb = $module_handler->getByDirname('newbb'); if (!isset($newbbConfig)) { $config_handler =& xoops_gethandler('config'); $newbbConfig =& $config_handler->getConfigsByCat(0, $newbb->getVar('mid')); } if (!isset($access_forums)) { $access_forums = $forum_handler->getForums(0, 'access'); // get all accessible forums } if (!empty($options[5])) { $allowedforums = array_slice($options, 5); // get allowed forums $allowed_forums = array_intersect($allowedforums, array_keys($access_forums)); } else { $allowed_forums = array_keys($access_forums); } if ($type == "topic") { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count FROM ' . $db->prefix('bb_topics') . ' WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; } else { $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count FROM ' . $db->prefix('bb_posts') . ' WHERE uid>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; } $result = $db->query($query, $options[1], 0); if (!$result) { newbb_message("newbb block query error: " . $query); return false; } $author = array(); while ($row = $db->fetchArray($result)) { $author[$row["author"]]["count"] = $row["count"]; } if (count($author) < 1) { return false; } $author_name =& newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname']); foreach (array_keys($author) as $uid) { $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]); } $block['authors'] =& $author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; $block['indexNav'] = intval($options[4]); return $block; }