private function getforumlist($parentid) { global $vbulletin, $counters, $lastpostarray; if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) { return; } // call fetch_last_post_array() first to get last post info for forums if (!is_array($lastpostarray)) { fetch_last_post_array($parentid); } foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) { $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"]; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums']) or !$vbulletin->forumcache["{$forumid}"]['displayorder'] or !($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['active'])) { continue; } else { $forum = $vbulletin->forumcache["{$forumid}"]; $is_category = !(bool) ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']); $forum['threadcount'] = $counters["{$forum['forumid']}"]['threadcount']; $forum['replycount'] = $counters["{$forum['forumid']}"]['replycount']; $forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum); $forum2 = array('forumid' => $forum['forumid'], 'title' => $forum['title'], 'description' => $forum['description'], 'title_clean' => $forum['title_clean'], 'description_clean' => $forum['description_clean'], 'parentid' => $forum['parentid'], 'threadcount' => $forum['threadcount'], 'replycount' => $forum['replycount'], 'is_category' => $is_category, 'is_link' => !empty($forum['link']), 'depth' => $forum['depth']); $children = explode(',', trim($forum['childlist'])); if (sizeof($children) > 2) { if ($subforums = $this->getforumlist($forumid)) { $forum2['subforums'] = $subforums; } } $forums[] = $forum2; } // if can view } // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid) return $forums; }
/** * Marks a forum as read using the appropriate method. * * @param array Array of data for the forum being marked * @param integer User ID this thread is being marked read for * @param integer Unix timestamp that the thread is being marked read * @param boolean Whether to automatically check if the parents' read times need to be updated * * @return array Returns an array of forums that were marked as read */ function mark_forum_read(&$foruminfo, $userid, $time, $check_parents = true) { global $vbulletin, $db; if (empty($foruminfo['forumid'])) { // sanity check -- wouldn't work anyway return array(); } $userid = intval($userid); $time = intval($time); $forums_marked = array($foruminfo['forumid']); if ($vbulletin->options['threadmarking'] AND $userid) { $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "forumread (forumid, userid, readtime) VALUES ($foruminfo[forumid], $userid, $time) "); if (!$check_parents) { return $forums_marked; } // check to see if any parent forums should be marked as read as well $parentarray = array_diff(explode(',', $foruminfo['parentlist']), array($foruminfo['forumid'], -1)); if (!empty($parentarray)) { // find the top most entry in the parent list -- we need its child list $top_parentid = end($parentarray); $top_foruminfo = $vbulletin->forumcache["$top_parentid"]; if (!$top_foruminfo['childlist']) { return $forums_marked; } // fetch the effective (including children) and raw last post times static $lastpostset = false, $rawlastpostinfo; if (!$lastpostset) { $lastpostset = true; require_once(DIR . '/includes/functions_forumlist.php'); cache_ordered_forums(1); $rawlastpostinfo = $vbulletin->forumcache; fetch_last_post_array(); } // determine the read time for all forums that we need to consider $readtimes = array(); $readtimes_query = $db->query_read_slave(" SELECT forumid, readtime FROM " . TABLE_PREFIX . "forumread WHERE userid = $userid AND forumid IN ($top_foruminfo[childlist]) "); while ($readtime = $db->fetch_array($readtimes_query)) { $readtimes["$readtime[forumid]"] = $readtime['readtime']; } $cutoff = (TIMENOW - ($vbulletin->options['markinglimit'] * 86400)); // now work through the parent, grandparent, etc of the forum we just marked // and mark it read only if all direct children are marked read foreach ($parentarray AS $parentid) { if (empty($vbulletin->forumcache["$parentid"])) { continue; } $markread = true; // now look through all the children and confirm they are all read if (is_array($vbulletin->iforumcache["$parentid"])) { foreach ($vbulletin->iforumcache["$parentid"] AS $childid) { if (max($cutoff, $readtimes["$childid"]) < $vbulletin->forumcache["$childid"]['lastpost']) { $markread = false; break; } } } // if all children are read, make sure all the threads in this forum are read too if ($markread) { $forumread = intval(max($readtimes["$parentid"], $cutoff)); $unread = $db->query_first(" SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "thread AS thread LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = $userid) WHERE thread.forumid = $parentid AND thread.visible = 1 AND thread.sticky IN (0,1) AND thread.lastpost > $forumread AND thread.open <> 10 AND (threadread.threadid IS NULL OR threadread.readtime < thread.lastpost) "); if ($unread['count'] > 0) { $markread = false; } } if ($markread) { // can mark as read $readtimes["$parentid"] = $time; $parents[] = "($parentid, $userid, $time)"; $forums_marked[] = $parentid; } else { // can't mark this as read, so we have no need to continue with further generations break; } } if ($parents) { $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "forumread (forumid, userid, readtime) VALUES " . implode(', ', $parents) ); } } } else { set_bbarray_cookie('forum_view', $foruminfo['forumid'], $time); } return $forums_marked; }
function construct_forum_bit($parentid, $depth = 0, $subsonly = 0) { global $vbulletin, $vbphrase, $show; global $imodcache, $lastpostarray, $counters, $inforum; // this function takes the constant MAXFORUMDEPTH as its guide for how // deep to recurse down forum lists. if MAXFORUMDEPTH is not defined, // it will assume a depth of 2. // call fetch_last_post_array() first to get last post info for forums if (!is_array($lastpostarray)) { fetch_last_post_array($parentid); } if (empty($vbulletin->iforumcache["{$parentid}"])) { return; } if (!defined('MAXFORUMDEPTH')) { define('MAXFORUMDEPTH', 2); } $forumbits = ''; $depth++; if ($parentid == -1) { $parent_is_category = false; } else { $parentforum = $vbulletin->forumcache[$parentid]; $parent_is_category = !(bool) ($parentforum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']); } foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) { // grab the appropriate forum from the $vbulletin->forumcache $forum = $vbulletin->forumcache["{$forumid}"]; //$lastpostforum = $vbulletin->forumcache["$lastpostarray[$forumid]"]; $lastpostforum = empty($lastpostarray[$forumid]) ? array() : $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; if (!$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) { continue; } $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"]; $lastpostforumperms = empty($lastpostarray[$forumid]) ? 0 : $vbulletin->userinfo['forumpermissions']["{$lastpostarray[$forumid]}"]; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums'])) { // no permission to view current forum continue; } if ($subsonly) { $childforumbits = construct_forum_bit($forum['forumid'], 1, $subsonly); } else { if ($depth < MAXFORUMDEPTH) { $childforumbits = construct_forum_bit($forum['forumid'], $depth, $subsonly); } else { $childforumbits = ''; } } // do stuff if we are not doing subscriptions only, or if we ARE doing subscriptions, // and the forum has a subscribedforumid if (!$subsonly or $subsonly and !empty($forum['subscribeforumid'])) { $GLOBALS['forumshown'] = true; // say that we have shown at least one forum if ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']) { // get appropriate suffix for template name $tempext = '_post'; } else { $tempext = '_nopost'; } if (!$vbulletin->options['showforumdescription']) { // blank forum description if set to not show $forum['description'] = ''; } // dates & thread title $lastpostinfo = empty($lastpostarray["{$forumid}"]) ? array() : $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; // compare last post time for this forum with the last post time specified by // the $lastpostarray, and if it's less, use the last post info from the forum // specified by $lastpostarray if (!empty($lastpostinfo) and $vbulletin->forumcache["{$lastpostarray[$forumid]}"]['lastpost'] > 0) { if (!($lastpostforumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($lastpostforumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and $lastpostinfo['lastposter'] != $vbulletin->userinfo['username']) { $forum['lastpostinfo'] = $vbphrase['private']; } else { $lastpostinfo['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $lastpostinfo['lastpost'], 1); $lastpostinfo['lastposttime'] = vbdate($vbulletin->options['timeformat'], $lastpostinfo['lastpost']); $lastpostinfo['trimthread'] = fetch_trimmed_title(fetch_censored_text($lastpostinfo['lastthread'])); if ($lastpostinfo['lastprefixid'] and $vbulletin->options['showprefixlastpost']) { $lastpostinfo['prefix'] = $vbulletin->options['showprefixlastpost'] == 2 ? $vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_rich"] : htmlspecialchars_uni($vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_plain"]); } else { $lastpostinfo['prefix'] = ''; } if ($vbulletin->forumcache["{$lastpostforum['forumid']}"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons'] and $icon = fetch_iconinfo($lastpostinfo['lasticonid'])) { $show['icon'] = true; } else { $show['icon'] = false; } $show['lastpostinfo'] = (!$lastpostforum['password'] or verify_forum_password($lastpostforum['forumid'], $lastpostforum['password'], false)); $pageinfo_lastpost = array('p' => $lastpostinfo['lastpostid']); $pageinfo_newpost = array('goto' => 'newpost'); $threadinfo = array('title' => $lastpostinfo['lastthread'], 'threadid' => $lastpostinfo['lastthreadid']); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown(fetch_lastposter_userinfo($lastpostinfo)); $templater = vB_Template::create('forumhome_lastpostby'); $templater->register('icon', $icon); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('lastpostinfo', $lastpostinfo); $templater->register('pageinfo_lastpost', $pageinfo_lastpost); $templater->register('pageinfo_newpost', $pageinfo_newpost); $templater->register('threadinfo', $threadinfo); $forum['lastpostinfo'] = $templater->render(); } } else { if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) { $forum['lastpostinfo'] = $vbphrase['private']; } else { $forum['lastpostinfo'] = $vbphrase['never']; } } // do light bulb $forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum); // add lock to lightbulb if necessary // from 3.6.9 & 3.7.0 we now show locks only if a user can not post AT ALL // previously it was just if they could not create new threads if ($vbulletin->options['showlocks'] and !$forum['link'] and (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostnew']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']))) { $forum['statusicon'] .= '_lock'; } // get posting permissions $forum['allowposting'] = true; if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting'])) { $forum['allowposting'] = false; } // get counters from the counters cache ( prepared by fetch_last_post_array() ) $forum['threadcount'] = $counters["{$forum['forumid']}"]['threadcount']; $forum['replycount'] = $counters["{$forum['forumid']}"]['replycount']; // get moderators ( this is why we needed cache_moderators() ) if ($vbulletin->options['showmoderatorcolumn']) { $clc = 0; $showmods = array(); $forum['moderators'] = array(); $listexploded = explode(',', $forum['parentlist']); foreach ($listexploded as $parentforumid) { if (!isset($imodcache["{$parentforumid}"]) or $parentforumid == -1) { continue; } foreach ($imodcache["{$parentforumid}"] as $moderator) { if (isset($showmods["{$moderator['userid']}"])) { continue; } ($hook = vBulletinHook::fetch_hook('forumbit_moderator')) ? eval($hook) : false; $clc++; $showmods["{$moderator['userid']}"] = true; $moderator['comma'] = $vbphrase['comma_space']; $forum['moderators'][$clc] = $moderator; } } // Last element if ($clc) { $forum['moderators'][$clc]['comma'] = ''; } } if ($forum['link']) { $forum['replycount'] = '-'; $forum['threadcount'] = '-'; $forum['lastpostinfo'] = '-'; } else { $forum['replycount'] = vb_number_format($forum['replycount']); $forum['threadcount'] = vb_number_format($forum['threadcount']); } $subforums = array(); if (($subsonly or $depth == MAXFORUMDEPTH) and $vbulletin->options['subforumdepth'] > 0) { $subforums = construct_subforum_bit($forumid); $clc = sizeof($subforums); // Last element if ($clc) { $subforums[$clc - 1]['comma'] = ''; } } $forum['browsers'] = 0; $children = explode(',', $forum['childlist']); foreach ($children as $childid) { $forum['browsers'] += isset($inforum["{$childid}"]) ? $inforum["{$childid}"] : 0; } if ($depth == 1 and $tempext == '_nopost') { global $vbcollapse; $collapseobj_forumid =& $vbcollapse["collapseobj_forumbit_{$forumid}"]; $collapseimg_forumid =& $vbcollapse["collapseimg_forumbit_{$forumid}"]; $show['collapsebutton'] = true; } else { $show['collapsebutton'] = false; } $show['forumsubscription'] = !empty($forum['subscribeforumid']); $show['forumdescription'] = $forum['description'] != '' ? true : false; $show['subforums'] = !empty($subforums) ? true : false; $show['browsers'] = ($vbulletin->options['displayloggedin'] and !$forum['link'] and $forum['browsers'] ? true : false); if ($show['subforums']) { $templater = vB_Template::create("forumhome_subforums"); $templater->register('subforums', $subforums); $forum['subforums'] = $templater->render(); } $perms = fetch_permissions($forumid, 0, array('userid' => 0, 'usergroupid' => 1), false); // VBIV-14011, Always skip Calendar Permissions $show['externalrss'] = ($vbulletin->options['externalrss'] and $perms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and $perms & $vbulletin->bf_ugp_forumpermissions['canviewothers']); // build the template for the current forum ($hook = vBulletinHook::fetch_hook('forumbit_display')) ? eval($hook) : false; $templater = vB_Template::create("forumhome_forumbit_level{$depth}{$tempext}"); $templater->register('childforumbits', $childforumbits); $templater->register('collapseimg_forumid', $collapseimg_forumid); $templater->register('collapseobj_forumid', $collapseobj_forumid); $templater->register('forum', $forum); $templater->register('forumid', $forumid); $templater->register('parent_is_category', $parent_is_category); $forumbits .= $templater->render(); } else { $forumbits .= $childforumbits; } } return $forumbits; }
// ############################### start subscribed forums ############################### // get only subscribed forums cache_ordered_forums(1, 0, $vbulletin->userinfo['userid']); $show['forums'] = false; foreach ($vbulletin->forumcache as $forumid => $forum) { if ($forum['subscribeforumid'] != '') { $show['forums'] = true; } } if ($show['forums']) { if ($vbulletin->options['showmoderatorcolumn']) { cache_moderators(); } else { cache_moderators($vbulletin->userinfo['userid']); } fetch_last_post_array(); $show['collapsable_forums'] = true; $forumbits = construct_forum_bit(-1, 0, 1); $forumhome_markread_script = vB_Template::create('forumhome_markread_script')->render(); if ($forumshown == 1) { $show['forums'] = true; } else { $show['forums'] = false; } } // ############################### start new subscribed to threads ############################### $show['threads'] = false; $numthreads = 0; // query thread ids if (!$vbulletin->options['threadmarking']) { if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) {
private function getforumlist($parentid) { global $vbulletin, $counters, $lastpostarray, $vbphrase; if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) { return; } // call fetch_last_post_array() first to get last post info for forums if (!is_array($lastpostarray)) { fetch_last_post_array($parentid); } foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) { $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"]; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums']) or !$vbulletin->forumcache["{$forumid}"]['displayorder'] or !($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['active'])) { continue; } else { $forum = $vbulletin->forumcache["{$forumid}"]; $is_category = !(bool) ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']); $is_link = $forum['link']; $forum['threadcount'] = $counters["{$forum['forumid']}"]['threadcount']; $forum['replycount'] = $counters["{$forum['forumid']}"]['replycount']; $lastpostinfo = empty($lastpostarray["{$forumid}"]) ? array() : $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; // compare last post time for this forum with the last post time specified by // the $lastpostarray, and if it's less, use the last post info from the forum // specified by $lastpostarray if (!empty($lastpostinfo) and $vbulletin->forumcache["{$lastpostarray[$forumid]}"]['lastpost'] > 0) { if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and $lastpostinfo['lastposter'] != $vbulletin->userinfo['username']) { $forum['lastpostinfo'] = ''; } else { if ($lastpostinfo['lastprefixid'] and $vbulletin->options['showprefixlastpost']) { $lastpostinfo['prefix'] = $vbulletin->options['showprefixlastpost'] == 2 ? $vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_rich"] : htmlspecialchars_uni($vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_plain"]); } else { $lastpostinfo['prefix'] = ''; } $lastpostinfo2 = array(); $lastpostinfo2['lastposter'] = $lastpostinfo['lastposter']; $lastpostinfo2['lastposterid'] = $lastpostinfo['lastposterid']; $lastpostinfo2['lastthread'] = $lastpostinfo['lastthread']; $lastpostinfo2['lastthreadid'] = $lastpostinfo['lastthreadid']; $lastpostinfo2['lastposttime'] = $lastpostinfo['lastpost']; $lastpostinfo2['prefix'] = $lastpostinfo['prefix']; $forum['lastpostinfo'] = $lastpostinfo2; } } $forum2 = array('forumid' => $forum['forumid'], 'title' => unhtmlspecialchars($forum['title']), 'description' => $forum['description'], 'title_clean' => $forum['title_clean'], 'description_clean' => $forum['description_clean'], 'parentid' => $forum['parentid'], 'threadcount' => $forum['threadcount'], 'replycount' => $forum['replycount'], 'is_category' => $is_category, 'depth' => $forum['depth'], 'subscribed' => array_key_exists($forum['forumid'], $this->subscribed_forums) ? 1 : 0); if (!empty($forum[link])) { $forum2['is_link'] = 1; $forum2['link'] = $forum['link']; } else { $forum2['is_link'] = 0; } if (!empty($forum['lastpostinfo'])) { $forum2['lastpostinfo'] = $forum['lastpostinfo']; } $children = explode(',', trim($forum['childlist'])); if (sizeof($children) > 2) { if ($subforums = $this->getforumlist($forumid)) { $forum2['subforums'] = $subforums; } } $forums[] = $forum2; } // if can view } // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid) return $forums; }
function fr_construct_forum_bit($parentid, $depth = 0, $subsonly = 0) { global $vbulletin, $vbphrase, $show; global $imodcache, $lastpostarray, $counters, $inforum; // Get exclude IDs $exclude_ids = @explode(',', $vbulletin->options['forumrunner_exclude']); if (in_array('-1', $exclude_ids)) { $exclude_ids = array(); } if (in_array($parentid, $exclude_ids)) { return; } // this function takes the constant MAXFORUMDEPTH as its guide for how // deep to recurse down forum lists. if MAXFORUMDEPTH is not defined, // it will assume a depth of 2. // call fetch_last_post_array() first to get last post info for forums if (!is_array($lastpostarray)) { fetch_last_post_array($parentid); } if (empty($vbulletin->iforumcache["{$parentid}"])) { return; } if (!defined('MAXFORUMDEPTH')) { define('MAXFORUMDEPTH', 2); } $forumbits = ''; $depth++; if ($parentid == -1) { $parent_is_category = false; } else { $parentforum = $vbulletin->forumcache[$parentid]; $parent_is_category = !(bool) ($parentforum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']); } foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) { if (in_array($forumid, $exclude_ids)) { continue; } // grab the appropriate forum from the $vbulletin->forumcache $forum = $vbulletin->forumcache["{$forumid}"]; //$lastpostforum = $vbulletin->forumcache["$lastpostarray[$forumid]"]; $lastpostforum = empty($lastpostarray[$forumid]) ? array() : $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; if (!$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) { continue; } $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"]; $lastpostforumperms = empty($lastpostarray[$forumid]) ? 0 : $vbulletin->userinfo['forumpermissions']["{$lastpostarray[$forumid]}"]; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums'])) { // no permission to view current forum continue; } if ($subsonly) { $childforumbits = fr_construct_forum_bit($forum['forumid'], 1, $subsonly); } else { if ($depth < MAXFORUMDEPTH) { $childforumbits = fr_construct_forum_bit($forum['forumid'], $depth, $subsonly); } else { $childforumbits = ''; } } // do stuff if we are not doing subscriptions only, or if we ARE doing subscriptions, // and the forum has a subscribedforumid if (!$subsonly or $subsonly and !empty($forum['subscribeforumid'])) { $GLOBALS['forumshown'] = true; // say that we have shown at least one forum if ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']) { // get appropriate suffix for template name $tempext = '_post'; } else { $tempext = '_nopost'; } if (!$vbulletin->options['showforumdescription']) { // blank forum description if set to not show $forum['description'] = ''; } // dates & thread title $lastpostinfo = empty($lastpostarray["{$forumid}"]) ? array() : $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; // compare last post time for this forum with the last post time specified by // the $lastpostarray, and if it's less, use the last post info from the forum // specified by $lastpostarray if (!empty($lastpostinfo) and $vbulletin->forumcache["{$lastpostarray[$forumid]}"]['lastpost'] > 0) { if (!($lastpostforumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($lastpostforumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and $lastpostinfo['lastposter'] != $vbulletin->userinfo['username']) { $forum['lastpostinfo'] = $vbphrase['private']; } else { $lastpostinfo['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $lastpostinfo['lastpost'], 1); $lastpostinfo['lastposttime'] = vbdate($vbulletin->options['timeformat'], $lastpostinfo['lastpost']); $lastpostinfo['trimthread'] = fetch_trimmed_title(fetch_censored_text($lastpostinfo['lastthread'])); if ($lastpostinfo['lastprefixid'] and $vbulletin->options['showprefixlastpost']) { $lastpostinfo['prefix'] = $vbulletin->options['showprefixlastpost'] == 2 ? $vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_rich"] : htmlspecialchars_uni($vbphrase["prefix_{$lastpostinfo['lastprefixid']}_title_plain"]); } else { $lastpostinfo['prefix'] = ''; } if ($vbulletin->forumcache["{$lastpostforum['forumid']}"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons'] and $icon = fetch_iconinfo($lastpostinfo['lasticonid'])) { $show['icon'] = true; } else { $show['icon'] = false; } $show['lastpostinfo'] = (!$lastpostforum['password'] or verify_forum_password($lastpostforum['forumid'], $lastpostforum['password'], false)); $pageinfo_lastpost = array('p' => $lastpostinfo['lastpostid']); $pageinfo_newpost = array('goto' => 'newpost'); $threadinfo = array('title' => $lastpostinfo['lastthread'], 'threadid' => $lastpostinfo['lastthreadid']); } } else { if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) { $forum['lastpostinfo'] = $vbphrase['private']; } else { $forum['lastpostinfo'] = $vbphrase['never']; } } // do light bulb $forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum); // add lock to lightbulb if necessary // from 3.6.9 & 3.7.0 we now show locks only if a user can not post AT ALL // previously it was just if they could not create new threads if ($vbulletin->options['showlocks'] and !$forum['link'] and (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostnew']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']))) { $forum['statusicon'] .= '_lock'; } // get counters from the counters cache ( prepared by fetch_last_post_array() ) $forum['threadcount'] = $counters["{$forum['forumid']}"]['threadcount']; $forum['replycount'] = $counters["{$forum['forumid']}"]['replycount']; // get moderators ( this is why we needed cache_moderators() ) if ($vbulletin->options['showmoderatorcolumn']) { $showmods = array(); $listexploded = explode(',', $forum['parentlist']); foreach ($listexploded as $parentforumid) { if (!isset($imodcache["{$parentforumid}"]) or $parentforumid == -1) { continue; } foreach ($imodcache["{$parentforumid}"] as $moderator) { if (isset($showmods["{$moderator['userid']}"])) { continue; } ($hook = vBulletinHook::fetch_hook('forumbit_moderator')) ? eval($hook) : false; $showmods["{$moderator['userid']}"] = true; if (!isset($forum['moderators'])) { $forum['moderators'] = ''; } } } if (!isset($forum['moderators'])) { $forum['moderators'] = ''; } } if ($forum['link']) { $forum['replycount'] = '-'; $forum['threadcount'] = '-'; $forum['lastpostinfo'] = '-'; } else { $forum['replycount'] = vb_number_format($forum['replycount']); $forum['threadcount'] = vb_number_format($forum['threadcount']); } if (($subsonly or $depth == MAXFORUMDEPTH) and $vbulletin->options['subforumdepth'] > 0) { //$forum['subforums'] = construct_subforum_bit($forumid, ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'] ) ); $forum['subforums'] = ''; } else { $forum['subforums'] = ''; } $forum['browsers'] = 0; $children = explode(',', $forum['childlist']); foreach ($children as $childid) { $forum['browsers'] += isset($inforum["{$childid}"]) ? $inforum["{$childid}"] : 0; } if ($depth == 1 and $tempext == '_nopost') { global $vbcollapse; $collapseobj_forumid =& $vbcollapse["collapseobj_forumbit_{$forumid}"]; $collapseimg_forumid =& $vbcollapse["collapseimg_forumbit_{$forumid}"]; $show['collapsebutton'] = true; } else { $show['collapsebutton'] = false; } $show['forumsubscription'] = $subsonly ? true : false; $show['forumdescription'] = $forum['description'] != '' ? true : false; $show['subforums'] = $forum['subforums'] != '' ? true : false; $show['browsers'] = ($vbulletin->options['displayloggedin'] and !$forum['link'] and $forum['browsers'] ? true : false); // FRNR Start // If this forum has a password, check to see if we have // the proper cookie. If so, don't prompt for one $password = 0; if ($forum['password']) { $pw_ok = verify_forum_password($forum['forumid'], $forum['password'], false); if (!$pw_ok) { $password = 1; } } $new = array('id' => $forum['forumid'], 'new' => $forum['statusicon'] == 'new' ? true : false, 'name' => prepare_utf8_string(strip_tags($forum['title'])), 'password' => $password); $icon = fr_get_forum_icon($forum['forumid'], $forum['statusicon'] == 'new' ? true : false); if ($icon) { $new['icon'] = $icon; } if ($forum['link'] != '') { $link = fr_fix_url($forum['link']); if (is_int($link)) { $new['id'] = $link; } else { $new['link'] = $link; } $linkicon = fr_get_forum_icon($forum['forumid'], false, true); if ($linkicon) { $new['icon'] = $linkicon; } } if ($forum['description'] != '') { $desc = prepare_utf8_string(strip_tags($forum['description'])); if (strlen($desc) > 0) { $new['desc'] = $desc; } } $out[] = $new; // FRNR End } else { $forumbits .= $childforumbits; } } return $out; }
function ListForums($who, $forumid) { global $db, $vbulletin, $server, $structtypes, $lastpostarray; $result = RegisterService($who); if ($result['Code'] != 0) { $retval['Result'] = $result; return $retval; } $userid = $vbulletin->userinfo['userid']; //$xml = new XMLexporter($vbulletin); // ### GET FORUMS & MODERATOR iCACHES ######################## cache_ordered_forums(1, 1); if (empty($vbulletin->iforumcache)) { $forums = $vbulletin->db->query_read_slave("\r\n SELECT forumid, title, link, parentid, displayorder, title_clean, description, description_clean,\r\n (options & " . $vbulletin->bf_misc_forumoptions['cancontainthreads'] . ") AS cancontainthreads\r\n FROM " . TABLE_PREFIX . "forum AS forum\r\n WHERE displayorder <> 0 AND\r\n password = '' AND\r\n (options & " . $vbulletin->bf_misc_forumoptions['active'] . ")\r\n ORDER BY displayorder\r\n "); $vbulletin->iforumcache = array(); while ($forum = $vbulletin->db->fetch_array($forums)) { $vbulletin->iforumcache["{$forum['parentid']}"]["{$forum['displayorder']}"]["{$forum['forumid']}"] = $forum; } unset($forum); $vbulletin->db->free_result($forums); } // define max depth for forums display based on $vbulletin->options[forumhomedepth] define('MAXFORUMDEPTH', 1); if (is_array($vbulletin->iforumcache["{$forumid}"])) { $childarray = $vbulletin->iforumcache["{$forumid}"]; } else { $childarray = array($vbulletin->iforumcache["{$forumid}"]); } if (!is_array($lastpostarray)) { fetch_last_post_array(); } // add the current forum info // get the current location title $current = $db->query_first("SELECT title FROM " . TABLE_PREFIX . "forum AS forum WHERE (forumid = {$forumid})"); if (strlen($current['title']) == 0) { $current['title'] = 'INDEX'; } $forum = fetch_foruminfo($forumid); $lastpostinfo = $vbulletin->forumcache["{$lastpostarray[$forumid]}"]; $isnew = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum); $curforum['ForumID'] = $forumid; $curforum['Title'] = $current['title']; $curforum['IsNew'] = $isnew == "new"; $curforum['IsCurrent'] = true; $forumlist = array(); foreach ($childarray as $subforumid) { // hack out the forum id $forum = fetch_foruminfo($subforumid); if (!$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) { continue; } $forumperms = $vbulletin->userinfo['forumpermissions']["{$subforumid}"]; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$subforumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$subforumid}"]['showprivate'] and !$vbulletin->options['showprivateforums'])) { // no permission to view current forum continue; } $lastpostinfo = $vbulletin->forumcache["{$lastpostarray[$subforumid]}"]; $isnew = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum); $tempforum['ForumID'] = $forum['forumid']; $tempforum['Title'] = $forum['title']; $tempforum['IsNew'] = $isnew == "new"; $tempforum['IsCurrent'] = false; array_push($forumlist, $tempforum); unset($tempforum); } $result['RemoteUser'] = ConsumeArray($vbulletin->userinfo, $structtypes['RemoteUser']); $retval['Result'] = $result; $retval['CurrentForum'] = $curforum; $retval['ForumList'] = $forumlist; return $retval; }