$forum_selection_since = newbb_sinceSelectBox($since); $xoopsTpl->assign_by_ref('forum_selection_since', $forum_selection_since); $query_sort = $query_array; unset($query_sort["sort"], $query_sort["order"]); $page_query_sort = implode("&", array_values($query_sort)); unset($query_sort); $xoopsTpl->assign('h_topic_link', "viewforum.php?{$page_query_sort}&sort=t.topic_title&order=" . ($sort == "t.topic_title" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_reply_link', "viewforum.php?{$page_query_sort}&sort=t.topic_replies&order=" . ($sort == "t.topic_replies" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_poster_link', "viewforum.php?{$page_query_sort}&sort=u.uname&order=" . ($sort == "u.uname" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_views_link', "viewforum.php?{$page_query_sort}&sort=t.topic_views&order=" . ($sort == "t.topic_views" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_rating_link', "viewforum.php?{$page_query_sort}&sort=t.topic_ratings&order=" . ($sort == "t.topic_ratings" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_date_link', "viewforum.php?{$page_query_sort}&sort=p.post_time&order=" . ($sort == "p.post_time" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('h_publish_link', "viewforum.php?{$page_query_sort}&sort=t.topic_time&order=" . ($sort == "t.topic_time" && $order == "DESC" ? "ASC" : "DESC")); $xoopsTpl->assign('forum_since', $since); // For $since in search.php $startdate = empty($since) ? 0 : time() - newbb_getSinceTime($since); $start = !empty($_GET['start']) ? intval($_GET['start']) : 0; $criteria_vars = array("startdate", "start", "sort", "order", "type", "status", "excerpt"); foreach ($criteria_vars as $var) { $criteria_topic[$var] = @${$var}; } $criteria_topic["excerpt"] = $xoopsModuleConfig['post_excerpt']; list($allTopics, $sticky) = $forum_handler->getAllTopics($forum_obj, $criteria_topic); $xoopsTpl->assign_by_ref('topics', $allTopics); $xoopsTpl->assign('sticky', $sticky); $xoopsTpl->assign('rating_enable', $xoopsModuleConfig['rating_enabled']); $xoopsTpl->assign('img_newposts', newbb_displayImage('topic_new', _MD_NEWPOSTS)); $xoopsTpl->assign('img_hotnewposts', newbb_displayImage('topic_hot_new', _MD_MORETHAN)); $xoopsTpl->assign('img_folder', newbb_displayImage('topic', _MD_NONEWPOSTS)); $xoopsTpl->assign('img_hotfolder', newbb_displayImage('topic_hot', _MD_MORETHAN2)); $xoopsTpl->assign('img_locked', newbb_displayImage('topic_locked', _MD_TOPICLOCKED));
//$query = trim($query); if (!$uname_required && strlen($query) < $xoopsConfigSearch['keyword_min']) { redirect_header('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); exit; } $queries = array($myts->addSlashes($query)); } // entries must be lowercase $allowed = array('p.post_time desc', 't.topic_title', 't.topic_views', 't.topic_replies', 'f.forum_name', 'u.uname'); $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); $next_search['sortby'] = $sortby; $sortby = in_array(strtolower($sortby), $allowed) ? $sortby : 'p.post_time DESC'; $searchin = isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? $_GET['searchin'] : 'both'); $next_search['searchin'] = $searchin; if (!empty($since)) { $subquery = ' AND p.post_time >= ' . (time() - newbb_getSinceTime($since)); } if ($uname_required && (!$uid || count($uid) < 1)) { $result = false; } else { $results =& newbb_search($queries, $andor, $limit, $start, $uid, $forum, $sortby, $searchin, $subquery); } if (count($results) < 1) { $xoopsTpl->assign("lang_nomatch", _SR_NOMATCH); } else { foreach ($results as $row) { $xoopsTpl->append('results', array('forum_name' => $myts->htmlSpecialChars($row['forum_name']), 'forum_link' => $row['forum_link'], 'link' => $row['link'], 'title' => $row['title'], 'poster' => $row['poster'], 'post_time' => formatTimestamp($row['time'], "m"))); } unset($results); if (count($next_search) > 0) { $items = array();
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 parseVar($var, $val) { switch ($var) { case "forum": $forum_handler = xoops_getmodulehandler('forum', 'newbb'); // Get accessible forums $access_forums = $forum_handler->getIdsByPermission(); // Filter specified forums if any if (!empty($val) && ($_forums = @explode("|", $val))) { $access_forums = array_intersect($access_forums, array_map("intval", $_forums)); } if (empty($access_forums)) { $this->noperm = true; } elseif (count($access_forums) == 1) { $this->query["where"][] = "t.forum_id = " . $access_forums[0]; } else { $this->query["where"][] = "t.forum_id IN ( " . implode(", ", $access_forums) . " )"; } break; case "uid": if (!empty($val)) { $this->query["where"][] = "t.topic_poster = " . $val; } break; case "since": if (!empty($val)) { $this->query["where"][] = "p.post_time = " . (time() - newbb_getSinceTime($val)); } break; case "type": if (!empty($val)) { $this->query["where"][] = "t.type_id = " . $val; } break; case "status": $this->_parseStatus($val); break; case "sort": if ($sort = $this->getSort($val, "sort")) { $this->query["sort"][] = $sort . (empty($this->vars["order"]) ? " DESC" : " ASC"); } break; default: break; } }
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; }