if (!$eventinfo['singleday'] and gmdate('w', $eventinfo['dateline_from_user']) != gmdate('w', $eventinfo['dateline_from'] + $eventinfo['utc'] * 3600)) { $show['adjustedday'] = true; $eventinfo['timezone'] = str_replace(' ', ' ', $vbphrase[fetch_timezone($eventinfo['utc'])]); } else { $show['adjustedday'] = false; } $show['ignoredst'] = ($eventinfo['dst'] and !$eventinfo['singleday']) ? true : false; $show['postedby'] = !empty($eventinfo['userid']) ? true : false; $show['singleday'] = !empty($eventinfo['singleday']) ? true : false; if (($show['candeleteevent'] or $show['canmoveevent'] or $show['caneditevent']) and !$show['holiday']) { $show['eventoptions'] = true; } //we already have the avatar info, no need to refetch. fetch_avatar_from_userinfo($eventinfo); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown($eventinfo); // $avatar = fetch_avatar_url($eventinfo['userid']); // $eventinfo['avatarurl'] = $avatar[0]; ($hook = vBulletinHook::fetch_hook('calendar_getday_event')) ? eval($hook) : false; $templater = vB_Template::create('calendar_showeventsbit'); $templater->register('calendarinfo', $calendarinfo); $templater->register('customfields', $customfields); $templater->register('date1', $date1); $templater->register('date2', $date2); $templater->register('eventdate', $eventdate); $templater->register('eventinfo', $eventinfo); $templater->register('gobutton', $gobutton); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('recurcriteria', $recurcriteria); $templater->register('spacer_close', $spacer_close); $templater->register('spacer_open', $spacer_open);
{ $thread['hiddencount']++; } $show['moderated'] = ($thread['hiddencount'] > 0 AND can_moderate($forumid, 'canmoderateposts')) ? true : false; $show['deletedthread'] = ($thread['deletedcount'] > 0 AND $canseedelnotice) ? true : false; $pageinfo_lastpage = array(); if ($show['pagenavmore']) { $pageinfo_lastpage['page'] = $thread['totalpages']; } $pageinfo_newpost = array('goto' => 'newpost'); $pageinfo_lastpost = array('p' => $thread['lastpostid']); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown(fetch_lastposter_userinfo($thread)); $templater = vB_Template::create('threadbit'); $templater->register('pageinfo', $pageinfo); $templater->register('pageinfo_lastpage', $pageinfo_lastpage); $templater->register('pageinfo_lastpost', $pageinfo_lastpost); $templater->register('pageinfo_newpost', $pageinfo_newpost); $templater->register('subscribethread', $subscribethread); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('thread', $thread); $templater->register('threadid', $threadid); $threadbit .= $templater->render(); } } $db->free_result($threads); unset($thread, $counter);
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; }
$show['privateentry'] = $bloginfo['private']; $perform_floodcheck = (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) and $vbulletin->options['emailfloodtime'] and $vbulletin->userinfo['userid']); $show['registeruserid'] = true; $bloguserid = $bloginfo['userid']; $blogheader = parse_blog_description($bloginfo); $sidebar =& build_user_sidebar($bloginfo); $ad_location['ad_blog_showentry_before'] = vB_Template::create('ad_blog_showentry_before')->render(); $ad_location['ad_blog_showentry_after'] = vB_Template::create('ad_blog_showentry_after')->render(); // navbar and output $navbits[fetch_seo_url('blog', $bloginfo, null, 'userid', 'blog_title')] = $bloginfo['blog_title']; $navbits[fetch_seo_url('entry', $bloginfo)] = $bloginfo['title']; // prepare the member action drop-down menu if ($bloginfo['userid'] != $bloginfo['postedby_userid']) { $memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($bloginfo['postedby_userid'])); } else { $memberaction_dropdown = construct_memberaction_dropdown($bloginfo); } ($hook = vBulletinHook::fetch_hook('blog_entry_complete')) ? eval($hook) : false; $templater = vB_Template::create('blog_show_entry'); $templater->register('pageinfo_ip', array('do' => 'viewip')); $templater->register('pageinfo_sf', array('do' => 'sendtofriend')); $templater->register('blogheader', $blogheader); $templater->register('ad_location', $ad_location); $templater->register('allow_ajax_qc', $allow_ajax_qc); $templater->register('blog', $blog); $templater->register('bloginfo', $bloginfo); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('blogtextinfo', $blogtextinfo); $templater->register('bookmarksites', $bookmarksites); $templater->register('editorid', $editorid); $templater->register('effective_lastcomment', $effective_lastcomment);
/** * Template method. Calls all the appropriate methods to build a post and then evaluates the template. * * @param array Post information * * @return string HTML for the post */ function construct_postbit(&$post) { global $ad_location; $this->post =& $post; $thread =& $this->thread; $forum =& $this->forum; // make sure we can display this post if ($this->is_displayable() == false) { return ''; } global $show, $vbphrase; global $spacer_open, $spacer_close; global $bgclass, $altbgclass; exec_switch_bg(); $template_hook = array(); ($hook = vBulletinHook::fetch_hook('postbit_display_start')) ? eval($hook) : false; // put together each part of the post $this->prep_post_start(); $this->process_date_status(); $this->process_edit_info(); $this->process_icon(); $this->process_ip(); if (!empty($this->post['userid'])) { $this->process_registered_user(); $this->process_im_icons(); } else { $this->process_unregistered_user(); } $this->bbcode_parser->containerid = $this->post['postid']; $this->parse_bbcode(); $this->process_attachments(); // finish prepping the post $this->prep_post_end(); $pageinfo_post = array( 'p' => $post['postid'] ); if ($this->templatename != 'postbit') { $pageinfo_post['viewfull'] = 1; } // execute hook ($hook = vBulletinHook::fetch_hook('postbit_display_complete')) ? eval($hook) : false; $show['last_ad'] = $show['first_ad'] = $show['first_adsense'] = false; if ($post['isfirstshown']) { //this does not appear to be an ad slot, rather it appears to be some shim html //that needs to be rendered if the firstpost google ad is included. $template = vB_Template::create('ad_showthread_firstpost_sig'); $template->register('adsense_pub_id', $this->registry->adsense_pub_id); $template->register('adsense_host_id', $this->registry->adsense_host_id); $ad_location['ad_showthread_firstpost_sig'] = $template->render(); $template = vB_Template::create('ad_showthread_firstpost_start'); $template->register('adsense_pub_id', $this->registry->adsense_pub_id); $template->register('adsense_host_id', $this->registry->adsense_host_id); $ad_location['ad_showthread_firstpost_start'] = trim($template->render(true)); $ad_location['ad_showthread_firstpost_sig'] = vB_Template::create('ad_showthread_firstpost_sig')->render(); if ($ad_location['ad_showthread_firstpost_start']) { $show['first_ad'] = true; } if ($ad_location['thread_first_post_content'] = trim(vB_Template::create('ad_thread_first_post_content')->render(true))) { if (preg_match('#^<div id="ad_thread_first_post_content">.+</div>$#si', $ad_location['thread_first_post_content'])) { $show['first_ad'] = true; } else { $ad_location['thread_first_post_content'] = ''; } } } else if ( $post['islastshown'] AND $ad_location['thread_last_post_content'] = trim(vB_Template::create('ad_thread_last_post_content')->render(true)) ) { if (preg_match('#^<div id="ad_thread_last_post_content">.+</div>$#si', $ad_location['thread_last_post_content'])) { $show['last_ad'] = true; } else { $ad_location['thread_last_post_content'] = ''; } } // prepare the member action drop-down menu // pass the local template hook so that each drop-down gets its own hook (per-postbit) $memberaction_dropdown = construct_memberaction_dropdown($post, $template_hook); // evaluate template $postid =& $post['postid']; $templater = vB_Template::create($this->template_prefix . $this->templatename); if ($this->add_promote_links AND $this->registry->products['vbcms']) { if (!isset($this->registry->userinfo['permissions']['cms'])) { bootstrap_framework(); vBCMS_Permissions::getUserPerms(); } if ($this->registry->userinfo['permissions']['cms']['canpublish'][0] != -1) { $templater->register('promote_sectionid', $this->registry->userinfo['permissions']['cms']['canpublish'][0]); $templater->register('articletypeid', vB_Types::instance()->getContentTypeID('vBCms_Article')); $promote_url = vB_Route::create('vBCms_Route_Content', '1/addcontent/')->getCurrentURL(); $promote_url .= (strrpos($promote_url, '?') ? '&' : '?') . 'contenttypeid=' . vB_Types::instance()->getContentTypeID('vBCms_Article') . "&postid=" . $post['postid'] . '&parentid=1'; $templater->register('promote_url', $promote_url); } } $templater->register('ad_location', $ad_location); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('pageinfo_post', $pageinfo_post); $templater->register('post', $post); $templater->register('postid', $postid); $templater->register('template_hook', $template_hook); $templater->register('thread', $thread); $postbit = $templater->render(); $templater = vB_Template::create('postbit_wrapper'); $templater->register('post', $post); $templater->register('postbit', $postbit); $templater->register('spacer_close', $spacer_close); $templater->register('spacer_open', $spacer_open); $retval = $templater->render(); return $retval; }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData($view); } ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_start')) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); if ($this->editing) { $view->pagetext = $this->content->getPageText(); } else { $rendered = $this->content->getRendered($this->data_saved); $view->pagetext = $rendered['pages'][$this->parameters['page']]; if ($this->content->canDownload()) { $view->attachments = $rendered['attachments']; $view->showattachments = empty($rendered['viewinfo']) ? 0 : 1 ; if (!empty($rendered['viewinfo'])) { foreach ($rendered['viewinfo'] as $key => $viewbit) { $view->$key = $viewbit; } } } $view->parenttitle = $this->content->getParentTitle(); $view->showattachments = empty($view->attachments) ? 0 : 1 ; if (!empty($viewinfo)) { foreach ($viewinfo as $key => $viewbit) { $view->$key = $viewbit; } } $view->pagelist = $rendered['pagelist']; $view->nodesegment = $this->content->getUrlSegment(); $view->current_page = $this->parameters['page']; if ($this->content->canDownload()) { $show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']); } } // Only break pages for the page view if ((self::VIEW_PAGE == $viewtype) OR (self::VIEW_PREVIEW == $viewtype)) { if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getContentId(), $this->content); $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; // promoted threadid if ($promoted_threadid = $this->content->getThreadId()) { if ($promoted_threadid = verify_id('thread', $promoted_threadid, false)) { // get threadinfo $threadinfo = fetch_threadinfo($promoted_threadid); $forumperms = fetch_permissions($threadinfo['forumid']); $view->threadinfo = $threadinfo; // check permissions if ($threadinfo['visible'] != 1) { $promoted_threadid = false; } else if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != vB::$vbulletin->userinfo['userid'] OR vB::$vbulletin->userinfo['userid'] == 0) )) { $promoted_threadid = false; } else { // check forum password $foruminfo = fetch_foruminfo($threadinfo['forumid']); if ($foruminfo['password'] AND !verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false)) { $promoted_threadid = false; } } $view->promoted_threadid = $promoted_threadid; } } // get pagelist for navigation $view->postitle = $this->content->getPostTitle(); $view->poststarter = $this->content->getPostStarter(); $view->postauthor = $this->content->getPostAuthor(); $view->postid = ($this->content->getPostId()); $view->threadid = $this->content->getThreadId(); $view->blogpostid = ($this->content->getBlogPostId()); $view->post_started = ($this->content->getPostStarted()); $view->post_posted = ($this->content->getPostPosted()); $view->promoted_blogid = $this->content->getBlogId(); //make links to original post and/or blog if appropriate if ($view->promoted_blogid) { $view->blog_url = fetch_seo_url('blog', array('userid' => $this->content->getPostStarter(), 'blog_title' => $this->content->getPostTitle())); } else if ($view->threadid) { $threadinfo = vB::$vbulletin->db->query_first("SELECT threadid, title FROM " . TABLE_PREFIX . "thread where threadid = " . $view->threadid); if ($threadinfo) { $post_url = fetch_seo_url('thread', $threadinfo); $post_url .= (strpos($post_url, '?' ) ? '&p=' : '?p=') . $view->postid . '#post' . $view->postid; $view->post_url = $post_url; } } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); // facebook options if (is_facebookenabled()) { // display the like button for this article? $view->fblikebutton = construct_fblikebutton(); } //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = $this->content->getPreviewText(); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; if (count($view->pagelist) > 1) { $view->preview_chopped = 1; } } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->promoted_blogid = $this->content->getBlogId(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->postid = ($this->content->getPostId()); $view->blogpostid = $this->content->getBlogPostId(); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); $view->post_started = $this->content->getPostStarted(); $view->post_posted = $this->content->getPostPosted(); //We need to check rights. If this user doesn't have download rights we hide the image. if ($this->content->canDownload()) { if ($view->previewimage= $this->content->getPreviewImage()) { $view->imagewidth= $this->content->getImageWidth(); $view->imageheight= $this->content->getImageHeight(); } if ($view->previewvideo= $this->content->getPreviewVideo()) { $view->haspreviewvideo = true; } } else { $view->previewimage = false; $view->previewvideo = false; } if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } } //If this was promoted from a blog or post, we need to verify the permissions. if (intval($view->blogpostid)) { $view->can_view_post = (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) ? 0 : 1 ; } else if (intval($view->postid)) { $user = new vB_Legacy_CurrentUser(); if ($post = vB_Legacy_Post::create_from_id($view->postid)) { $view->can_view_post = $post->can_view($user) ? 1 : 0; } } $view->poststarter = array('userid' => $this->content->getPostStarter(), 'username' => $this->content->getPostAuthor()); $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_end')) ? eval($hook) : false; $this->content->cacheNow(); return $view; }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; if (empty($this->config)) { $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->config = $this->content->getConfig(); } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); $this->config = $this->content->getConfig(); } else { $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); } if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); } ($hook = vBulletinHook::fetch_hook($this->startpopulatehook)) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $view->previewtext = $this->config['previewtext']; if ((self::VIEW_PREVIEW != $viewtype) OR !$view->showpreviewonly) { $view->pagetext = $this->config['pagetext']; } $view->previewimage = $this->config['preview_image']; $view->nodeid = $this->content->getNodeId(); parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); $view->pagetext = $this->config['pagetext']; if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getNodeId(), $this->content); if ($taggable) { $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; } else { $view->showtags = false; } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = isset($this->config['previewtext']) ? $this->config['previewtext'] : substr(strip_tags( $this->config['pagetext'], '<br />'), 0, $this->config['previewlength']); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook($this->endpopulatehook)) ? eval($hook) : false; if (method_exists($this->content, 'cacheNow')) { $this->content->cacheNow(); } return $view; }
function do_get_forum() { global $vbulletin, $db, $show, $vbphrase, $foruminfo; $canpost = true; $vbulletin->input->clean_array_gpc('r', array('fid' => TYPE_INT, 'previewtype' => TYPE_INT)); $previewtype = $vbulletin->GPC['previewtype']; if (!$previewtype) { $previewtype = 1; } if (empty($foruminfo['forumid'])) { $forumid = -1; } else { $vbulletin->input->clean_array_gpc('r', array('password' => TYPE_STR)); // Check the forum password if ($vbulletin->GPC['password'] && $foruminfo['password'] == $vbulletin->GPC['password']) { // Set a temp cookie for guests if (!$vbulletin->userinfo['userid']) { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password'])); } else { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password']), 1); } } $perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT); $pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT); $daysprune = $vbulletin->input->clean_gpc('r', 'daysprune', TYPE_INT); $sortfield = $vbulletin->input->clean_gpc('r', 'sortfield', TYPE_STR); // get permission to view forum $_permsgetter_ = 'forumdisplay'; $forumperms = fetch_permissions($foruminfo['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) { json_error(ERR_NO_PERMISSION); } // Check for forum password! if (!verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false)) { json_error(ERR_NEED_PASSWORD, RV_NEED_FORUM_PASSWORD); } // Can we post in this forum? if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostnew'])) { $canpost = false; } $forumid = $foruminfo['forumid']; } // Can forum contain threads? $announcements_out = array(); // These $_REQUEST values will get used in the sort template so they are assigned to normal variables $perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT); $pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT); $daysprune = $vbulletin->input->clean_gpc('r', 'daysprune', TYPE_INT); $sortfield = $vbulletin->input->clean_gpc('r', 'sortfield', TYPE_STR); // get permission to view forum $_permsgetter_ = 'forumdisplay'; $forumperms = fetch_permissions($foruminfo['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) { json_error(ERR_NO_PERMISSION); } // disable thread preview if we can't view threads if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) { $vbulletin->options['threadpreview'] = 0; } // check if there is a forum password and if so, ensure the user has it set verify_forum_password($foruminfo['forumid'], $foruminfo['password']); // verify that we are at the canonical SEO url // and redirect to this if not //verify_seo_url('forum', $foruminfo, array('pagenumber' => $_REQUEST['pagenumber'])); // get vbulletin->iforumcache - for use by makeforumjump and forums list // fetch the forum even if they are invisible since its needed // for the title but we'll unset that further down // also fetch subscription info for $show['subscribed'] variable cache_ordered_forums(1, 1, $vbulletin->userinfo['userid']); $show['newthreadlink'] = iif(!$show['search_engine'] and $foruminfo['allowposting'], true, false); $show['threadicons'] = iif($foruminfo['allowicons'], true, false); $show['threadratings'] = iif($foruminfo['allowratings'], true, false); $show['subscribed_to_forum'] = $vbulletin->forumcache["{$foruminfo['forumid']}"]['subscribeforumid'] != '' ? true : false; if (!$daysprune) { if ($vbulletin->userinfo['daysprune']) { $daysprune = $vbulletin->userinfo['daysprune']; } else { $daysprune = iif($foruminfo['daysprune'], $foruminfo['daysprune'], 30); } } $daysprune = -1; // FRNR // ### GET FORUMS, PERMISSIONS, MODERATOR iCACHES ######################## cache_moderators(); // draw nav bar $navbits = array(); $navbits[$vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q']] = $vbphrase['forum']; $parentlist = array_reverse(explode(',', substr($foruminfo['parentlist'], 0, -3))); foreach ($parentlist as $forumID) { $forumTitle = $vbulletin->forumcache["{$forumID}"]['title']; $navbits[fetch_seo_url('forum', array('forumid' => $forumID, 'title' => $forumTitle))] = $forumTitle; } // pop the last element off the end of the $nav array so that we can show it without a link array_pop($navbits); $navbits[''] = $foruminfo['title']; $navbits = construct_navbits($navbits); $navbar = render_navbar_template($navbits); $moderatorslist = ''; $listexploded = explode(',', $foruminfo['parentlist']); $showmods = array(); $show['moderators'] = false; $totalmods = 0; foreach ($listexploded as $parentforumid) { if (!$imodcache["{$parentforumid}"] or $parentforumid == -1) { continue; } foreach ($imodcache["{$parentforumid}"] as $moderator) { if ($showmods["{$moderator['userid']}"] === true) { continue; } $showmods["{$moderator['userid']}"] = true; $show['comma_leader'] = $moderatorslist != ''; $show['moderators'] = true; $totalmods++; } } // ### BUILD FORUMS LIST ################################################# // get an array of child forum ids for this forum $foruminfo['childlist'] = explode(',', $foruminfo['childlist']); // define max depth for forums display based on $vbulletin->options[forumhomedepth] define('MAXFORUMDEPTH', $vbulletin->options['forumdisplaydepth']); if (($vbulletin->options['showforumusers'] == 1 or $vbulletin->options['showforumusers'] == 2 or $vbulletin->options['showforumusers'] > 2 and $vbulletin->userinfo['userid']) and !$show['search_engine']) { $datecut = TIMENOW - $vbulletin->options['cookietimeout']; $forumusers = $db->query_read_slave("\n \t\tSELECT user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid,\n \t\t\tsession.userid, session.inforum, session.lastactivity, session.badlocation,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\tFROM " . TABLE_PREFIX . "session AS session\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)\n \t\tWHERE session.lastactivity > {$datecut}\n \t\tORDER BY" . iif($vbulletin->options['showforumusers'] == 1 or $vbulletin->options['showforumusers'] == 3, " username ASC,") . " lastactivity DESC\n \t"); $numberregistered = 0; $numberguest = 0; $doneuser = array(); if ($vbulletin->userinfo['userid']) { // fakes the user being in this forum $loggedin = array('userid' => $vbulletin->userinfo['userid'], 'username' => $vbulletin->userinfo['username'], 'invisible' => $vbulletin->userinfo['invisible'], 'invisiblemark' => $vbulletin->userinfo['invisiblemark'], 'inforum' => $foruminfo['forumid'], 'lastactivity' => TIMENOW, 'musername' => $vbulletin->userinfo['musername']); $numberregistered = 1; fetch_online_status($loggedin); $show['comma_leader'] = false; $doneuser["{$vbulletin->userinfo['userid']}"] = 1; } $inforum = array(); // this require the query to have lastactivity ordered by DESC so that the latest location will be the first encountered. while ($loggedin = $db->fetch_array($forumusers)) { if ($loggedin['badlocation']) { continue; } if (empty($doneuser["{$loggedin['userid']}"])) { if (in_array($loggedin['inforum'], $foruminfo['childlist']) and $loggedin['inforum'] != -1) { if (!$loggedin['userid']) { // this is a guest $numberguest++; $inforum["{$loggedin['inforum']}"]++; } else { $numberregistered++; $inforum["{$loggedin['inforum']}"]++; if (fetch_online_status($loggedin)) { fetch_musername($loggedin); $show['comma_leader'] = $activeusers != ''; } } } if ($loggedin['userid']) { $doneuser["{$loggedin['userid']}"] = 1; } } } if (!$vbulletin->userinfo['userid']) { $numberguest = $numberguest == 0 ? 1 : $numberguest; } $totalonline = $numberregistered + $numberguest; unset($joingroupid, $key, $datecut, $invisibleuser, $userinfo, $userid, $loggedin, $index, $value, $forumusers, $parentarray); $show['activeusers'] = true; } else { $show['activeusers'] = false; } // ############################################################################# // get read status for this forum and children $unreadchildforums = 0; foreach ($foruminfo['childlist'] as $val) { if ($val == -1 or $val == $foruminfo['forumid']) { continue; } if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $lastread_child = max($vbulletin->forumcache["{$val}"]['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { $lastread_child = max(intval(fetch_bbarray_cookie('forum_view', $val)), $vbulletin->userinfo['lastvisit']); } if ($vbulletin->forumcache["{$val}"]['lastpost'] > $lastread_child) { $unreadchildforums = 1; break; } } $forumbits = fr_construct_forum_bit($forumid); // admin tools $show['post_queue'] = can_moderate($foruminfo['forumid'], 'canmoderateposts'); $show['attachment_queue'] = can_moderate($foruminfo['forumid'], 'canmoderateattachments'); $show['mass_move'] = can_moderate($foruminfo['forumid'], 'canmassmove'); $show['mass_prune'] = can_moderate($foruminfo['forumid'], 'canmassprune'); $show['post_new_announcement'] = can_moderate($foruminfo['forumid'], 'canannounce'); $show['addmoderator'] = $permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']; $show['adminoptions'] = ($show['post_queue'] or $show['attachment_queue'] or $show['mass_move'] or $show['mass_prune'] or $show['addmoderator'] or $show['post_new_announcement']); $navpopup = array('id' => 'forumdisplay_navpopup', 'title' => $foruminfo['title_clean'], 'link' => fetch_seo_url('forum', $foruminfo)); construct_quick_nav($navpopup); ///////////////////////////////// if ($foruminfo['cancontainthreads']) { ///////////////////////////////// if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $foruminfo['forumread'] = $vbulletin->forumcache["{$foruminfo['forumid']}"]['forumread']; $lastread = max($foruminfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { $bbforumview = intval(fetch_bbarray_cookie('forum_view', $foruminfo['forumid'])); $lastread = max($bbforumview, $vbulletin->userinfo['lastvisit']); } // Inline Moderation $show['movethread'] = can_moderate($forumid, 'canmanagethreads') ? true : false; $show['deletethread'] = (can_moderate($forumid, 'candeleteposts') or can_moderate($forumid, 'canremoveposts')) ? true : false; $show['approvethread'] = can_moderate($forumid, 'canmoderateposts') ? true : false; $show['openthread'] = can_moderate($forumid, 'canopenclose') ? true : false; $show['inlinemod'] = ($show['movethread'] or $show['deletethread'] or $show['approvethread'] or $show['openthread']) ? true : false; $show['spamctrls'] = ($show['inlinemod'] and $show['deletethread']); $url = $show['inlinemod'] ? SCRIPTPATH : ''; // fetch popup menu if ($show['popups'] and $show['inlinemod']) { } else { $threadadmin_imod_thread_menu = ''; } // get announcements $announcebits = ''; if ($show['threadicons'] and $show['inlinemod']) { $announcecolspan = 6; } else { if (!$show['threadicons'] and !$show['inlinemod']) { $announcecolspan = 4; } else { $announcecolspan = 5; } } $mindate = TIMENOW - 2592000; // 30 days $hook_query_fields = $hook_query_joins = $hook_query_where = ''; $announcements = $db->query_read_slave("\n \t\tSELECT\n \t\t\tannouncement.announcementid, startdate, title, announcement.views,\n \t\t\tuser.username, user.userid, user.usertitle, user.customtitle, user.usergroupid,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\t\t" . ($vbulletin->userinfo['userid'] ? ", NOT ISNULL(announcementread.announcementid) AS readannounce" : "") . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "announcement AS announcement\n \t\t" . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "announcementread AS announcementread ON (announcementread.announcementid = announcement.announcementid AND announcementread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = announcement.userid)\n \t\t{$hook_query_joins}\n \t\tWHERE startdate <= " . TIMENOW . "\n \t\t\tAND enddate >= " . TIMENOW . "\n \t\t\tAND " . fetch_forum_clause_sql($foruminfo['forumid'], 'forumid') . "\n \t\t\t{$hook_query_where}\n \t\tORDER BY startdate DESC, announcement.announcementid DESC\n \t\t" . iif($vbulletin->options['oneannounce'], "LIMIT 1")); while ($announcement = $db->fetch_array($announcements)) { fetch_musername($announcement); $announcement['title'] = fetch_censored_text($announcement['title']); $announcement['postdate'] = vbdate($vbulletin->options['dateformat'], $announcement['startdate']); if ($announcement['readannounce'] or $announcement['startdate'] <= $mindate) { $announcement['statusicon'] = 'old'; } else { $announcement['statusicon'] = 'new'; } $announcement['views'] = vb_number_format($announcement['views']); $announcementidlink = iif(!$vbulletin->options['oneannounce'], "&a={$announcement['announcementid']}"); // FRNR START if ($pagenumber == 1) { $avatarurl = ''; $userinfoavatar = fetch_userinfo($announcement['userid'], FETCH_USERINFO_AVATAR); fetch_avatar_from_userinfo($userinfoavatar, true, false); if ($userinfoavatar['avatarurl'] != '') { $avatarurl = process_avatarurl($userinfoavatar['avatarurl']); } unset($userinfoavatar); $tmp = array('thread_id' => $foruminfo['forumid'], 'announcement' => 1, 'new_posts' => $announcement['readannounce'] ? 0 : 1, 'thread_title' => prepare_utf8_string(strip_tags($announcement['title'])), 'thread_preview' => prepare_utf8_string(preview_chop(html_entity_decode($announcement['pagetext']), FR_PREVIEW_LEN)), 'post_userid' => $announcement['userid'], 'post_lastposttime' => prepare_utf8_string(date_trunc($announcement['postdate'])), 'post_username' => prepare_utf8_string(strip_tags($announcement['username']))); if ($avatarurl != '') { $tmp['avatarurl'] = $avatarurl; } $announcements_out[] = $tmp; } // FRNR END } // display threads if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) { $limitothers = "AND postuserid = " . $vbulletin->userinfo['userid'] . " AND " . $vbulletin->userinfo['userid'] . " <> 0"; } else { $limitothers = ''; } if (can_moderate($foruminfo['forumid'])) { $redirectjoin = "LEFT JOIN " . TABLE_PREFIX . "threadredirect AS threadredirect ON(thread.open = 10 AND thread.threadid = threadredirect.threadid)"; } else { $redirectjoin = ''; } // filter out deletion notices if can't be seen if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] or can_moderate($foruminfo['forumid'])) { $canseedelnotice = true; $deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND deletionlog.type = 'thread')"; } else { $canseedelnotice = false; $deljoin = ''; } // remove threads from users on the global ignore list if user is not a moderator if ($Coventry = fetch_coventry('string') and !can_moderate($foruminfo['forumid'])) { $globalignore = "AND postuserid NOT IN ({$Coventry}) "; } else { $globalignore = ''; } // look at thread limiting options $stickyids = ''; $stickycount = 0; if ($daysprune != -1) { if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) { $tachyjoin = "LEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON " . "(tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ")"; $datecut = " AND (thread.lastpost >= " . (TIMENOW - $daysprune * 86400) . " OR tachythreadpost.lastpost >= " . (TIMENOW - $daysprune * 86400) . ")"; } else { $datecut = "AND lastpost >= " . (TIMENOW - $daysprune * 86400); $tachyjoin = ""; } $show['noposts'] = false; } else { $tachyjoin = ""; $datecut = ""; $show['noposts'] = true; } // complete form fields on page $daysprunesel = iif($daysprune == -1, 'all', $daysprune); $daysprunesel = array($daysprunesel => 'selected="selected"'); $vbulletin->input->clean_array_gpc('r', array('sortorder' => TYPE_NOHTML, 'prefixid' => TYPE_NOHTML)); // prefix options $prefix_options = fetch_prefix_html($foruminfo['forumid'], $vbulletin->GPC['prefixid']); $prefix_selected = array('anythread', 'anythread' => '', 'none' => ''); if ($vbulletin->GPC['prefixid']) { //no prefix id if ($vbulletin->GPC['prefixid'] == '-1') { $prefix_filter = "AND thread.prefixid = ''"; $prefix_selected['none'] = ' selected="selected"'; } else { if ($vbulletin->GPC['prefixid'] == '-2') { $prefix_filter = "AND thread.prefixid <> ''"; $prefix_selected['anyprefix'] = ' selected="selected"'; } else { $prefix_filter = "AND thread.prefixid = '" . $db->escape_string($vbulletin->GPC['prefixid']) . "'"; } } } else { $prefix_filter = ''; $prefix_selected['anythread'] = ' selected="selected"'; } // default sorting methods if (empty($sortfield)) { $sortfield = $foruminfo['defaultsortfield']; } if (empty($vbulletin->GPC['sortorder'])) { $vbulletin->GPC['sortorder'] = $foruminfo['defaultsortorder']; } // look at sorting options: if ('asc' != ($sortorder = $vbulletin->GPC['sortorder'])) { $sqlsortorder = 'DESC'; $order = array('desc' => 'checked="checked"'); $vbulletin->GPC['sortorder'] = 'desc'; } else { $sqlsortorder = ''; $order = array('asc' => 'checked="checked"'); } $sqlsortfield2 = ''; switch ($sortfield) { case 'title': $sqlsortfield = 'thread.title'; break; case 'lastpost': $sqlsortfield = 'lastpost'; break; case 'replycount': case 'views': $sqlsortfield = 'views'; case 'postusername': $sqlsortfield = $sortfield; break; case 'voteavg': if ($foruminfo['allowratings']) { $sqlsortfield = 'voteavg'; $sqlsortfield2 = 'votenum'; break; } case 'dateline': $sqlsortfield = 'thread.dateline'; break; // else, use last post // else, use last post default: $handled = false; if (!$handled) { $sqlsortfield = 'lastpost'; $sortfield = 'lastpost'; } } $sort = array($sortfield => 'selected="selected"'); $visiblethreads = " AND visible = 1"; /*if (!can_moderate($forumid, 'canmoderateposts')) { if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'])) { $visiblethreads = " AND visible = 1 "; } else { $visiblethreads = " AND visible IN (1,2)"; } } else { $visiblethreads = " AND visible IN (0,1,2)"; }*/ $hook_query_fields = $hook_query_joins = $hook_query_where = ''; # Include visible IN (0,1,2) in order to hit upon the 4 column index $threadscount = $db->query_first_slave("\n \t\tSELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > {$lastread} AND open <> 10, 1, 0)) AS newthread\n \t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "thread AS thread\n \t\t{$tachyjoin}\n \t\t{$hook_query_joins}\n \t\tWHERE forumid = {$foruminfo['forumid']}\n \t\t\tAND sticky = 0\n \t\t\t{$prefix_filter}\n \t\t\t{$visiblethreads}\n \t\t\t{$globalignore}\n \t\t\t{$limitothers}\n \t\t\t{$datecut}\n \t\t\t{$hook_query_where}\n \t"); $totalthreads = $threadscount['threads']; $newthreads = $threadscount['newthread']; // set defaults sanitize_pageresults($totalthreads, $pagenumber, $perpage, 200, $vbulletin->options['maxthreads']); // get number of sticky threads for the first page // on the first page there will be the sticky threads PLUS the $perpage other normal threads // not quite a bug, but a deliberate feature! if ($pagenumber == 1) { $stickies = $db->query_read_slave("\n \t\t\tSELECT thread.threadid, lastpost, open\n \t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n \t\t\tWHERE forumid = {$foruminfo['forumid']}\n \t\t\t\tAND sticky = 1\n \t\t\t\t{$prefix_filter}\n \t\t\t\t{$visiblethreads}\n \t\t\t\t{$limitothers}\n \t\t\t\t{$globalignore}\n \t\t"); while ($thissticky = $db->fetch_array($stickies)) { $stickycount++; if ($thissticky['lastpost'] >= $lastread and $thissticky['open'] != 10) { $newthreads++; } $stickyids .= ",{$thissticky['threadid']}"; } $db->free_result($stickies); unset($thissticky, $stickies); } $limitlower = ($pagenumber - 1) * $perpage; $limitupper = $pagenumber * $perpage; if ($limitupper > $totalthreads) { $limitupper = $totalthreads; if ($limitlower > $totalthreads) { $limitlower = $totalthreads - $perpage - 1; } } if ($limitlower < 0) { $limitlower = 0; } if ($foruminfo['allowratings']) { $vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']); $votequery = "\n \t\t\tIF(votenum >= " . $vbulletin->options['showvotes'] . ", votenum, 0) AS votenum,\n \t\t\tIF(votenum >= " . $vbulletin->options['showvotes'] . " AND votenum > 0, votetotal / votenum, 0) AS voteavg,\n \t\t"; } else { $votequery = ''; } if ($previewtype == 1) { $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,"; $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)"; } else { $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,"; $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.lastpostid)"; } if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) { $tachyjoin = "\n \t\t\tLEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON\n \t\t\t\t(tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ")\n \t\t\tLEFT JOIN " . TABLE_PREFIX . "tachythreadcounter AS tachythreadcounter ON\n \t\t\t\t(tachythreadcounter.threadid = thread.threadid AND tachythreadcounter.userid = " . $vbulletin->userinfo['userid'] . ")\n \t\t"; $tachy_columns = "\n \t\t\tIF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost,\n \t\t\tIF(tachythreadpost.userid IS NULL, thread.lastposter, tachythreadpost.lastposter) AS lastposter,\n \t\t\tIF(tachythreadpost.userid IS NULL, thread.lastposterid, tachythreadpost.lastposterid) AS lastposterid,\n \t\t\tIF(tachythreadpost.userid IS NULL, thread.lastpostid, tachythreadpost.lastpostid) AS lastpostid,\n \t\t\tIF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount) AS replycount,\n \t\t\tIF(thread.views<=IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount), IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount)+1, thread.views) AS views\n \t\t"; } else { $tachyjoin = ''; $tachy_columns = 'thread.lastpost, thread.lastposter, thread.lastposterid, thread.lastpostid, thread.replycount, IF(thread.views<=thread.replycount, thread.replycount+1, thread.views) AS views'; } $hook_query_fields = $hook_query_joins = $hook_query_where = ''; $getthreadids = $db->query_read_slave("\n \t\tSELECT " . iif($sortfield == 'voteavg', $votequery) . " thread.threadid,\n \t\t\t{$tachy_columns}\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "thread AS thread\n \t\t{$tachyjoin}\n \t\t{$hook_query_joins}\n \t\tWHERE forumid = {$foruminfo['forumid']}\n \t\t\tAND sticky = 0\n \t\t\t{$prefix_filter}\n \t\t\t{$visiblethreads}\n \t\t\t{$globalignore}\n \t\t\t{$limitothers}\n \t\t\t{$datecut}\n \t\t\t{$hook_query_where}\n \t\tORDER BY sticky DESC, {$sqlsortfield} {$sqlsortorder}" . (!empty($sqlsortfield2) ? ", {$sqlsortfield2} {$sqlsortorder}" : '') . "\n \t\tLIMIT {$limitlower}, {$perpage}\n \t"); $ids = ''; while ($thread = $db->fetch_array($getthreadids)) { $ids .= ',' . $thread['threadid']; } $ids .= $stickyids; $db->free_result($getthreadids); unset($thread, $getthreadids); $hook_query_fields = $hook_query_joins = $hook_query_where = ''; $threads = $db->query_read_slave("\n \t\tSELECT {$votequery} {$previewfield}\n \t\t\tthread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, postusername, postuserid, thread.iconid AS threadiconid,\n \t\t\tthread.dateline, notes, thread.visible, sticky, votetotal, thread.attach, {$tachy_columns},\n \t\t\tthread.prefixid, thread.taglist, hiddencount, deletedcount,\n \t\t\tuser.usergroupid, user.homepage, user.options AS useroptions, IF(userlist.friend = 'yes', 1, 0) AS isfriend\n \t\t\t" . (($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid']) ? ", NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed" : "") . "\n \t\t\t" . ($deljoin ? ", deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason" : "") . "\n \t\t\t" . (($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) ? ", threadread.readtime AS threadread" : "") . "\n \t\t\t" . ($redirectjoin ? ", threadredirect.expires" : "") . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "thread AS thread\n \t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = thread.lastposterid)\n \t\t\tLEFT JOIN " . TABLE_PREFIX . "userlist AS userlist ON (userlist.relationid = user.userid AND userlist.type = 'buddy' AND userlist.userid = " . $vbulletin->userinfo['userid'] . ")\n \t\t\t{$deljoin}\n \t\t\t" . (($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = " . $vbulletin->userinfo['userid'] . " AND canview = 1)" : "") . "\n \t\t\t" . (($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "\n \t\t\t{$previewjoin}\n \t\t\t{$tachyjoin}\n \t\t\t{$redirectjoin}\n \t\t\t{$hook_query_joins}\n \t\tWHERE thread.threadid IN (0{$ids}) {$hook_query_where}\n \t\tORDER BY sticky DESC, {$sqlsortfield} {$sqlsortorder}" . (!empty($sqlsortfield2) ? ", {$sqlsortfield2} {$sqlsortorder}" : '') . "\n \t"); unset($limitothers, $delthreadlimit, $deljoin, $datecut, $votequery, $sqlsortfield, $sqlsortorder, $threadids, $sqlsortfield2); // Get Dot Threads $dotthreads = fetch_dot_threads_array($ids); if ($vbulletin->options['showdots'] and $vbulletin->userinfo['userid']) { $show['dotthreads'] = true; } else { $show['dotthreads'] = false; } unset($ids); $pageinfo = array(); if ($vbulletin->GPC['prefixid']) { $pageinfo['prefixid'] = $vbulletin->GPC['prefixid']; } if ($vbulletin->GPC['daysprune']) { $pageinfo['daysprune'] = $daysprune; } $show['fetchseo'] = true; $oppositesort = $vbulletin->GPC['sortorder'] == 'asc' ? 'desc' : 'asc'; $pageinfo_voteavg = $pageinfo + array('sort' => 'voteavg', 'order' => 'voteavg' == $sortfield ? $oppositesort : 'desc'); $pageinfo_title = $pageinfo + array('sort' => 'title', 'order' => 'title' == $sortfield ? $oppositesort : 'asc'); $pageinfo_postusername = $pageinfo + array('sort' => 'postusername', 'order' => 'postusername' == $sortfield ? $oppositesort : 'asc'); $pageinfo_flastpost = $pageinfo + array('sort' => 'lastpost', 'order' => 'lastpost' == $sortfield ? $oppositesort : 'asc'); $pageinfo_replycount = $pageinfo + array('sort' => 'replycount', 'order' => 'replycount' == $sortfield ? $oppositesort : 'desc'); $pageinfo_views = $pageinfo + array('sort' => 'views', 'order' => 'views' == $sortfield ? $oppositesort : 'desc'); $pageinfo_sort = $pageinfo + array(sort => $sortfield, 'order' => $oppositesort, 'pp' => $perpage, 'page' => $pagenumber); if ($totalthreads > 0 or $stickyids) { if ($totalthreads > 0) { $limitlower++; } // check to see if there are any threads to display. If there are, do so, otherwise, show message if ($vbulletin->options['threadpreview'] > 0) { // Get Buddy List $buddy = array(); if (trim($vbulletin->userinfo['buddylist'])) { $buddylist = preg_split('/( )+/', trim($vbulletin->userinfo['buddylist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($buddylist as $buddyuserid) { $buddy["{$buddyuserid}"] = 1; } } DEVDEBUG('buddies: ' . implode(', ', array_keys($buddy))); // Get Ignore Users $ignore = array(); if (trim($vbulletin->userinfo['ignorelist'])) { $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($ignorelist as $ignoreuserid) { if (!$buddy["{$ignoreuserid}"]) { $ignore["{$ignoreuserid}"] = 1; } } } DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore))); } $show['threads'] = true; $threadbits = ''; $threadbits_sticky = ''; $counter = 0; $toread = 0; while ($thread = $db->fetch_array($threads)) { // AND $counter++ < $perpage) // build thread data $thread = process_thread_array($thread, $lastread, $foruminfo['allowicons']); $realthreadid = $thread['realthreadid']; if ($thread['sticky']) { $threadbit =& $threadbits_sticky; } else { $threadbit =& $threadbits; } // Soft Deleted Thread if ($thread['visible'] == 2) { $thread['deletedcount']++; $show['threadtitle'] = (can_moderate($forumid) or $vbulletin->userinfo['userid'] != 0 and $vbulletin->userinfo['userid'] == $thread['postuserid']) ? true : false; $show['deletereason'] = !empty($thread['del_reason']) ? true : false; $show['viewthread'] = can_moderate($forumid) ? true : false; $show['managethread'] = (can_moderate($forumid, 'candeleteposts') or can_moderate($forumid, 'canremoveposts')) ? true : false; $show['moderated'] = ($thread['hiddencount'] > 0 and can_moderate($forumid, 'canmoderateposts')) ? true : false; $show['deletedthread'] = $canseedelnotice; } else { if (!$thread['visible']) { $thread['hiddencount']++; } $show['moderated'] = ($thread['hiddencount'] > 0 and can_moderate($forumid, 'canmoderateposts')) ? true : false; $show['deletedthread'] = ($thread['deletedcount'] > 0 and $canseedelnotice) ? true : false; $pageinfo_lastpage = array(); if ($show['pagenavmore']) { $pageinfo_lastpage['page'] = $thread['totalpages']; } $pageinfo_newpost = array('goto' => 'newpost'); $pageinfo_lastpost = array('p' => $thread['lastpostid']); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown(fetch_lastposter_userinfo($thread)); } // FRNR Start $avatarurl = ''; if ($thread['lastpost_userid'] > 0) { $userinfoavatar = fetch_userinfo($thread['lastpost_userid'], FETCH_USERINFO_AVATAR); fetch_avatar_from_userinfo($userinfoavatar, true, false); if ($userinfoavatar['avatarurl'] != '') { $avatarurl = process_avatarurl($userinfoavatar['avatarurl']); } unset($userinfoavatar); } $tmp = array('thread_id' => $thread['threadid'], 'new_posts' => $show['gotonewpost'] ? 1 : 0, 'forum_id' => $thread['forumid'], 'total_posts' => $thread['totalposts'] ? $thread['totalposts'] : 0, 'thread_title' => prepare_utf8_string(strip_tags($thread['threadtitle'])), 'thread_preview' => prepare_utf8_string(preview_chop(html_entity_decode($thread['preview']), FR_PREVIEW_LEN)), 'post_userid' => $thread['lastpost_userid'], 'post_lastposttime' => prepare_utf8_string(date_trunc($thread['lastpostdate']) . ' ' . $thread['lastposttime']), 'post_username' => prepare_utf8_string(strip_tags($thread['lastpost_username']))); if ($avatarurl != '') { $tmp['avatarurl'] = $avatarurl; } if ($thread['prefixid']) { $tmp['prefix'] = prepare_utf8_string(strip_tags($vbphrase["prefix_{$thread['prefixid']}_title_plain"])); } if ($thread['attach']) { $tmp['attach'] = true; } if ($thread['pollid']) { $tmp['poll'] = true; } if ($thread['open'] == 10) { // Special case for redirect threads $tmp = array_merge($tmp, array('post_userid' => $thread['postuserid'], 'post_username' => prepare_utf8_string(strip_tags($thread['postusername'])), 'poll' => false)); } if ($thread['sticky']) { $thread_data_sticky[] = $tmp; } else { $thread_data[] = $tmp; } // FRNR Stop } $db->free_result($threads); unset($thread, $counter); $pageinfo_pagenav = array(); if (!empty($vbulletin->GPC['perpage'])) { $pageinfo_pagenav['pp'] = $perpage; } if (!empty($vbulletin->GPC['prefixid'])) { $pageinfo_pagenav['prefixid'] = $vbulletin->GPC['prefixid']; } if (!empty($vbulletin->GPC['sortfield'])) { $pageinfo_pagenav['sort'] = $sortfield; } if (!empty($vbulletin->GPC['sortorder'])) { $pageinfo_pagenav['order'] = $vbulletin->GPC['sortorder']; } if (!empty($vbulletin->GPC['daysprune'])) { $pageinfo_pagenav['daysprune'] = $daysprune; } $pagenav = construct_page_nav($pagenumber, $perpage, $totalthreads, 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f={$foruminfo['forumid']}", '', '', 'forum', $foruminfo, $pageinfo_pagenav); } unset($threads, $dotthreads); // get colspan for bottom bar $foruminfo['bottomcolspan'] = 5; if ($foruminfo['allowicons']) { $foruminfo['bottomcolspan']++; } if ($show['inlinemod']) { $foruminfo['bottomcolspan']++; } $show['threadslist'] = true; ///////////////////////////////// } else { $show['threadslist'] = false; $canpost = false; // FRNR } ///////////////////////////////// if (!$vbulletin->GPC['prefixid'] and $newthreads < 1 and $unreadchildforums < 1) { mark_forum_read($foruminfo, $vbulletin->userinfo['userid'], TIMENOW); } // FNRN Below $out = array(); if (is_array($thread_data) && count($thread_data) > 0) { $out['threads'] = $thread_data; } else { $out['threads'] = array(); } if (is_array($thread_data_sticky) && count($thread_data_sticky) > 0) { $out['threads_sticky'] = $thread_data_sticky; $out['total_sticky_threads'] = count($thread_data_sticky); } else { $out['threads_sticky'] = array(); $out['total_sticky_threads'] = 0; } // Announcements become #1 on the threads if (is_array($announcements_out) && count($announcements_out) == 1) { array_unshift($out['threads'], $announcements_out[0]); $totalthreads++; } $out['total_threads'] = $totalthreads ? $totalthreads : 0; if ($forumbits) { $out['forums'] = $forumbits; } else { $out['forums'] = array(); } $out['canpost'] = $canpost ? 1 : 0; $out['canattach'] = ($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid']); // Get thread prefixes for this forum (if any) $prefix_out = array(); if ($prefixsets = fetch_prefix_array($forumid)) { foreach ($prefixsets as $prefixsetid => $prefixes) { $optgroup_options = ''; foreach ($prefixes as $prefixid => $prefix) { if ($permcheck and !can_use_prefix($prefixid, $prefix['restrictions'])) { continue; } $optionvalue = $prefixid; $optiontitle = htmlspecialchars_uni($vbphrase["prefix_{$prefixid}_title_plain"]); $prefix_out[] = array('prefixid' => $prefixid, 'prefixcaption' => prepare_utf8_string($optiontitle)); } } } if ($foruminfo['options'] & $vbulletin->bf_misc_forumoptions['prefixrequired']) { $out['prefixrequired'] = true; } else { $out['prefixrequired'] = false; } $out['prefixes'] = $prefix_out; return $out; }
public function render($current_user, $criteria, $template = '') { //ensure that the phrases used by events are in the phrase list. $phrase = new vB_Legacy_Phrase(); $phrase->add_phrase_groups(array('calendar', 'holiday', 'timezone', 'posting', 'user')); global $show, $bgclass; //a bunch of crap set by fetch_event_date_time that we send to the template global $date1, $date2, $time1, $time2, $recurcriteria, $eventdate; //a bunch of crap set by fetch_event_date_time that I can't find any use of. //leaving it in for now in case I missed some use of globals. global $titlecolor, $allday, $calendarinfo; $eventinfo = $this->event->get_record(); $calendarinfo = $this->event->get_calendar()->get_record(); //event['dst'] means "don't adjust event time for dst" $offset = $current_user->getTimezoneOffset(!$eventinfo['dst']); $eventinfo['dateline_from_user'] = $eventinfo['dateline_from'] + $offset * 3600; $eventinfo['dateline_to_user'] = $eventinfo['dateline_to'] + $offset * 3600; $eventinfo = fetch_event_date_time($eventinfo); fetch_musername($eventinfo); if (!$eventinfo['holidayid']) { $bgclass = 'alt2'; //Custom fields are a little weird. By default we don't show a blank value, but //the conditional is in the template so its possible that the user by change that. //We don't show the text block unless we have at least one set field, but again //the user can change that. I'm not sure why somebody would want to do these //things but its not worth altering the behavior. It does mean that we can't //rely on either field_text being blank when there are no set fields $custom_fields = $this->event->get_custom_fields(); $custom_field_text = $this->render_custom_fields($custom_fields); $show['customfields'] = $this->have_set_customfield($custom_fields); $show['holiday'] = false; $show['caneditevent'] = $this->event->can_edit($current_user); $show['subscribed'] = !empty($eventinfo['subscribed']) ? true : false; $show['subscribelink'] = ($eventinfo['subscribed'] or $this->event->can_subscribe($current_user)); } else { $custom_field_text = ''; $show['holiday'] = true; $show['caneditevent'] = false; $show['subscribed'] = false; $show['subscribelink'] = false; } exec_switch_bg(); if (!$eventinfo['singleday'] and gmdate('w', $eventinfo['dateline_from_user']) != gmdate('w', $eventinfo['dateline_from'] + $eventinfo['utc'] * 3600)) { $show['adjustedday'] = true; $eventinfo['timezone'] = str_replace(' ', ' ', $vbphrase[fetch_timezone($eventinfo['utc'])]); } else { $show['adjustedday'] = false; } $show['ignoredst'] = ($eventinfo['dst'] and !$eventinfo['singleday']) ? true : false; $show['postedby'] = !empty($eventinfo['userid']) ? true : false; $show['singleday'] = !empty($eventinfo['singleday']) ? true : false; if (($show['candeleteevent'] or $show['canmoveevent'] or $show['caneditevent']) and !$show['holiday']) { $show['eventoptions'] = true; } $eventinfo = array_merge($eventinfo, convert_bits_to_array($eventinfo['options'], vB::$vbulletin->bf_misc_useroptions)); $eventinfo = array_merge($eventinfo, convert_bits_to_array($eventinfo['adminoptions'], vB::$vbulletin->bf_misc_adminoptions)); cache_permissions($eventinfo, false); //we already have the avatar info, no need to refetch. fetch_avatar_from_userinfo($eventinfo); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown($eventinfo); ($hook = vBulletinHook::fetch_hook('calendar_getday_event')) ? eval($hook) : false; //some globals registered for the template's sake global $gobutton, $spacer_open, $spacer_close; $templater = vB_Template::create('calendar_showeventsbit'); $templater->register('calendarinfo', $calendarinfo); $templater->register('customfields', $custom_field_text); $templater->register('date1', $date1); $templater->register('date2', $date2); $templater->register('time1', $time1); $templater->register('time2', $time2); $templater->register('eventdate', $eventdate); $templater->register('eventinfo', $eventinfo); $templater->register('gobutton', $gobutton); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('recurcriteria', $recurcriteria); $templater->register('spacer_close', $spacer_close); $templater->register('spacer_open', $spacer_open); return $templater->render(); }
/** * Template method that does all the work to display an issue note, including processing the template * * @return string Templated note output */ function construct() { global $vbulletin; ($hook = vBulletinHook::fetch_hook('blog_entry_display_start')) ? eval($hook) : false; // preparation for display... $this->prepare_start(); if ($this->blog['userid']) { $this->process_registered_user(); } else { $this->process_unregistered_user(); } $this->process_date_status(); $this->process_display(); $this->process_text(); $this->process_attachments(); $this->prepare_end(); // actual display... $blog =& $this->blog; $status =& $this->status; global $show, $vbphrase; global $spacer_open, $spacer_close; global $bgclass, $altbgclass; exec_switch_bg(); $show['readmore'] = $this->readmore; $show['ignoreduser'] = ($this->ignored_users[$this->blog['userid']]); // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown($blog); //set up the ad for the first blog entry global $ad_location; if ($this->is_first) { $ad_location['bloglist_first_entry'] = vB_Template::create('ad_bloglist_first_entry')->render(); } ($hook = vBulletinHook::fetch_hook('blog_entry_display_complete')) ? eval($hook) : false; $templater = vB_Template::create($this->template); $templater->register('blog', $blog); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('status', $status); $templater->register('is_first', $this->is_first); $templater->register('ad_location', $ad_location); if ($vbulletin->products['vbcms']) { if (! isset(vB::$vbulletin->userinfo['permissions']['cms'])) { require_once DIR . '/packages/vbcms/permissions.php'; vBCMS_Permissions::getUserPerms(); } if (count(vB::$vbulletin->userinfo['permissions']['cms']['canpublish'])) { $templater->register('promote_sectionid', vB::$vbulletin->userinfo['permissions']['cms']['canpublish'][0]); $templater->register('articletypeid', vB_Types::instance()->getContentTypeID('vBCms_Article')); $promote_url = vB_Route::create('vBCms_Route_Content', '1/addcontent/')->getCurrentURL(); $promote_url .= (strrpos($promote_url, '?') ? '&' : '?') . 'contenttypeid=' . vB_Types::instance()->getContentTypeID('vBCms_Article') . "&blogid=" . $blog['blogid'] . '&parentid=1'; $templater->register('promote_url', $promote_url); } } $output = $templater->render(($this->registry->GPC['ajax'])); return $output; }