Beispiel #1
0
function hqth_get_avatar($userid)
{
    global $vbulletin;
    require_once DIR . '/includes/functions_user.php';
    $avatar = fetch_avatar_url($userid);
    if ($avatar == '') {
        $milano = $vbulletin->db->query_first("SELECT yahoo FROM " . TABLE_PREFIX . "user WHERE userid=" . $userid);
        if ($milano['yahoo'] != '') {
            $link = 'http://img.msg.yahoo.com/avatar.php?yids=' . $milano['yahoo'];
        } else {
            $link = 'images/avatars/noavatar.gif';
        }
    } else {
        $link = $avatar[0];
    }
    return $link;
}
     }
     $output .= '</tr>';
 }
 $output .= '</table>';
 if ($totalavatars > 0) {
     print_description_row($output);
 }
 if ($nouseavatarchecked) {
     print_description_row($vbphrase['user_has_no_avatar']);
 } else {
     print_yes_row($vbphrase['delete_avatar'], 'avatarid', $vbphrase['yes'], '', -1);
 }
 print_table_break();
 print_table_header($vbphrase['custom_avatar']);
 require_once DIR . '/includes/functions_user.php';
 $userinfo['avatarurl'] = fetch_avatar_url($userinfo['userid']);
 if (empty($userinfo['avatarurl']) or $userinfo['avatarid'] != 0) {
     $userinfo['avatarurl'] = '<img src="' . vB::getDatastore()->getOption('bburl') . '/' . $vbulletin->options['cleargifurl'] . '" alt="" border="0" />';
 } else {
     $userinfo['avatarurl'] = "<img src=\"../" . $userinfo['avatarurl'][0] . "\" " . $userinfo['avatarurl'][1] . " alt=\"\" border=\"0\" />";
 }
 if (!empty($avatarchecked[0])) {
     print_label_row($vbphrase['custom_avatar'], $userinfo['avatarurl']);
 }
 print_yes_row(!empty($avatarchecked[0]) ? $vbphrase['use_current_avatar'] : $vbphrase['add_new_custom_avatar'], 'avatarid', $vbphrase['yes'], $avatarchecked[0], 0);
 cache_permissions($userinfo, false);
 // 	if ($userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar'] AND ($userinfo['permissions']['avatarmaxwidth'] > 0 OR $userinfo['permissions']['avatarmaxheight'] > 0))
 // 	{
 // 		print_yes_no_row($vbphrase['resize_image_to_users_maximum_allowed_size'], 'resize');
 // 	}
 print_input_row($vbphrase['enter_image_url_gcpuser'], 'avatarurl', 'http://');
Beispiel #3
0
	public function render($current_user, $criteria, $template_name = '')
	{
		global $show;
		global $vbulletin;

		require_once(DIR . '/includes/class_bbcode.php');
		require_once(DIR . '/includes/class_bbcode_blog.php');
		require_once (DIR . '/includes/functions.php');
		require_once (DIR . '/includes/blog_functions.php');
		require_once (DIR . '/includes/functions_user.php');

		if (!$this->record)
		{
			return "";
		}

		if (!strlen($template_name)) {
			$template_name = 'blog_search_results_result';
		}

		if (! $this->bbcode_parser )
		{
			$this->bbcode_parser = new vB_BbCodeParser_Blog($vbulletin, fetch_tag_list('', true));
		}
		$blog = $this->record;
		$blog['previewtext']  = htmlspecialchars_uni(fetch_censored_text(
			fetch_trimmed_title(strip_bbcode($blog['pagetext'], true, true, true, true),
					$this->preview_length)
		));

		$canmoderation = (can_moderate_blog('canmoderatecomments') OR $vbulletin->userinfo['userid'] == $blog['userid']);
		$blog['trackbacks_total'] = $blog['trackback_visible'] + ($canmoderation ? $blog['trackback_moderation'] : 0);
		$blog['comments_total'] = $blog['comments_visible'] + ($canmoderation ? $blog['comments_moderation'] : 0);
		$blog['lastcommenter_encoded'] = urlencode($blog['lastcommenter']);
		$blog['lastposttime'] = vbdate($vbulletin->options['timeformat'], $blog['lastcomment']);
		$blog['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $blog['lastcomment'], true);
		$blog['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $blog['lastcomment'], true);
		$show['blogtitle'] = $blog['blogtitle'];

		$templater = vB_Template::create($template_name);
		$templater->register('blog', $blog);
		$templater->register('dateline', $blog['dateline']);
		$templater->register('dateformat', $vbulletin->options['dateformat']);
		$templater->register('timeformat', $vbulletin->options['default_timeformat']);

		if ($vbulletin->options['avatarenabled'] AND (intval($blog['userid'])))

		{
			$avatar = fetch_avatar_url($blog['userid']);
		}

		if (!isset($avatar) OR (count($avatar) < 2))
		{
			$avatar = false;
		}

		//to make the link to the poster
		$blogposter = array('userid' => $blog['postedby_userid'], 'username' => $blog['postedby_username']);

		$templater->register('blogposter', $blogposter);
		$templater->register('avatar', $avatar);
		return $templater->render();
	}
Beispiel #4
0
	/**
	 * function to return the rendered html for this result
	 *
	 * @param string $current_user
	 * @param object $criteria
	 * @return
	 */

	public function render($current_user, $criteria, $template_name = '')
	{
		global $vbulletin;
		global $show;
		include_once DIR . '/vb/search/searchtools.php';
		include_once DIR . '/includes/functions_user.php';

		if (!strlen($template_name))
		{
			$template_name = strtolower($this->package) . '_searchresult_' .  strtolower($this->class);
		}
		$view = new vB_View($template_name);
		$view->title = $this->record['title'];
		$view->html_title =  $this->record['html_title'];
		$view->categories = $this->record['categories'];
		$view->published = $this->record['publishdate'] >= TIMENOW ?
		 true : false ;
		$view->publishdate = $this->record['publishdate'];
		$view->previewtext = $this->record['previewtext'];
		$view->pagetext = $this->record['pagetext'];
		$view->parent_html_title = $this->record['parent_html_title'];
		$view->dateformat = $vbulletin->options['dateformat'];
		$view->parenttitle = $this->record['parenttitle'];
		$view->timeformat = $vbulletin->options['default_timeformat'];
		$view->parentnode = $this->record['parentnode'];
		$view->username = $this->record['username'];
		$view->user = array(
			'username' => $this->record['username'],
			'userid' => $this->record['userid']);
		$view->page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL();

		if (vB::$vbulletin->options['avatarenabled'])
		{
			$view->avatar = fetch_avatar_url($this->record['userid']);
		}

		//When we can we'll return the view, but right now the calling objects
		//want strings.

		// Create the standard vB templater
		$templater = new vB_Templater_vB();

		// Register the templater to be used for XHTML
		vB_View::registerTemplater(vB_View::OT_XHTML, $templater);
		return $view->render();

	}
Beispiel #5
0
	/** This function gets the article information based on the defined criteria
	*
	 * @return	array
	 */
	protected function getContent()
	{
		// First, compose the sql
		$sql = "SELECT node.contenttypeid, node.url, node.publishdate, node.userid,
		node.setpublish, node.publicpreview, info.title, user.username, node.showuser,
		node.nodeid, node.contenttypeid, thread.replycount FROM "
		. TABLE_PREFIX . "cms_node AS node
		INNER JOIN "	. TABLE_PREFIX . "contenttype AS type on type.contenttypeid = node.contenttypeid
		INNER JOIN "	. TABLE_PREFIX . "cms_nodeinfo AS info on info.nodeid = node.nodeid "
		. ( (($this->config['categories'] != '') AND ($this->config['categories'] != '0')) ?
			" INNER JOIN " . TABLE_PREFIX .
		"cms_nodecategory nc ON nc.nodeid = node.nodeid " : '') .	"
		LEFT JOIN "	. TABLE_PREFIX . "user AS user ON user.userid = node.userid
		LEFT JOIN "	. TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid
		WHERE type.isaggregator = '0' AND " . vBCMS_Permissions::getPermissionString() ;
	
		if (($this->config['categories'] != '') AND ($this->config['categories'] != '0') )
		{
			$sql .= "\n AND nc.categoryid IN (" . $this->config['categories'] . ")\n";
		}

		if (($this->config['sections'] != '') AND ($this->config['sections'] != '0'))
		{

			$sql .= "\n AND node.parentnode IN (" . $this->config['sections'] . ")\n";
		}

		if (isset($this->config['days']) AND (intval($this->config['days'])) )
		{
			$sql .= "\n AND node.publishdate > " . (TIMENOW - (86400 * $this->config['days'])) . "\n";
		}

		$sql .= "\n ORDER BY node.publishdate DESC LIMIT " . $this->config['count'];
		$items = array();
	
		//Execute
		if ($rst = vB::$db->query_read($sql))
		{
			$current_record = array('contentid' => -1);
			//now build the results array
			while($item = vB::$db->fetch_array($rst))
			{
				$item['categories'] = array();
				$item['tags'] = array();
				$class = vB_Types::instance()->getContentTypeClass($item['contenttypeid']);
				$package = vB_Types::instance()->getContentTypePackage($item['contenttypeid']);
				$node = vBCms_Content::create($package, $class, $item['nodeid']);
				$item['pagetext'] = $item['previewtext'] = '';
					
				//get the avatar
				if (vB::$vbulletin->options['avatarenabled'])
				{
					$item['avatar'] = fetch_avatar_url($item['userid']);
				}
				
				if (method_exists($node, 'getPageText'))
				{
					$item['pagetext'] = fetch_censored_text($node->getPageText());
				}
				
				if (method_exists($node, 'getPreviewText'))
				{
					$item['previewtext'] = fetch_censored_text($node->getPreviewText());
				}
				else if (!empty($item['pagetext']))
				{
					$item['previewtext'] = vB_Search_Searchtools::getSummary($item['pagetext'], 200);
				}
				
				if (method_exists($node, 'getPreviewImage'))
				{
					$item['pagetext'] = fetch_censored_text($node->getPageText());
				}
								
				$items[$item['nodeid']]  = $item;
			}

			//Let's get the tags and the categories
			// we can do that with one query each.
			if (count($articles))
			{
				//first let's get categories
				$nodeids = implode(', ', array_keys($item));
				$sql = "SELECT nc.nodeid, nc.categoryid, category.category FROM " . TABLE_PREFIX . "cms_nodecategory AS nc
				INNER JOIN "	. TABLE_PREFIX . "cms_category AS category ON category.categoryid = nc.categoryid
				WHERE nc.nodeid IN ($nodeids)";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$route_info = $record['categoryid'] .
							($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');
						$record['route_info'] = $route_info;
						$record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();

						$items[$record['nodeid']]['categories'][$record['categoryid']] = $record;
					}
				}

				//next tags;
				$sql = "SELECT tag.tagid, node.nodeid, tag.tagtext FROM " .
				TABLE_PREFIX . "cms_node AS node INNER JOIN " .	TABLE_PREFIX .
				"tagcontent AS tc ON (tc.contentid = node.contentid AND  tc.contenttypeid = node.contenttypeid)
				INNER JOIN " .	TABLE_PREFIX .
				"tag AS tag ON tag.tagid = tc.tagid
				 WHERE node.nodeid IN ($nodeids) ";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$items[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext'];
					}
				}
			}
		}
		return $items;
	}
Beispiel #6
0
     $ump_avatar = "images/misc/unknown.gif";
 }
 $user_most_refunds = $db->fetch_array($db->query_read("SELECT * from " . TABLE_PREFIX . "user order by market_refund DESC limit 0,1"));
 $umr_name = "" . stripslashes($user_most_refunds[username]) . "";
 $umr_avatar = fetch_avatar_url($vbulletin->userinfo[$user_most_refunds[userid]]);
 if (!is_array($umr_avatar)) {
     $umr_avatar = "images/misc/unknown.gif";
 }
 $moststeals = $db->fetch_array($db->query_read("SELECT userid, COUNT(userid) FROM " . TABLE_PREFIX . "market_transactions\r\n    where marketid >= 7 AND marketid <= 9 GROUP BY userid ORDER BY COUNT( userid ) DESC LIMIT 0 , 1"));
 if (!$moststeals) {
     $moststeals[userid] = 1;
     $moststeals['COUNT(userid)'] = 0;
 }
 $steal_username = $db->fetch_array($db->query_read("SELECT * FROM " . TABLE_PREFIX . "user where userid='{$moststeals['userid']}'"));
 $steal_username = "" . stripslashes($steal_username[username]) . "";
 $steal_avatar = fetch_avatar_url($vbulletin->userinfo[$steal_username[userid]]);
 if (!is_array($steal_avatar)) {
     $steal_avatar = "images/misc/unknown.gif";
 }
 $templater = vB_Template::create('market_home');
 $templater->register('popular_name', $popular_name[name]);
 $templater->register('popular_id', $popular_name[marketid]);
 $templater->register('popular_amount', $popular_name[amount]);
 $templater->register('popular_image', $popimage);
 $templater->register('popular_count', $mostpopular['COUNT(marketid)']);
 $templater->register('popular_desc', $popular_desc);
 $templater->register('refund_name', $refund_name[name]);
 $templater->register('refund_id', $refund_name[marketid]);
 $templater->register('refund_amount', $refund_name[amount]);
 $templater->register('refund_image', $refundimage);
 $templater->register('refund_count', $mostrefunded['COUNT(marketid)']);
Beispiel #7
0
	/**
	 * This function composes and executes the SQL query to generate the
	 * blog data.
	 *
	 * @return	array
	 */
	private function getComments()
	{
		require_once DIR . "/includes/functions_user.php";

		if (!isset($this->config['days']) OR (! intval($this->config['days'])) )
		{
			$this->config['days'] = 7;
		}

		if (!isset($this->config['count']) OR (! intval($this->config['count'])) )
		{
			$this->config['count'] = 10;
		}

		if (!isset($this->config['messagemaxchars']) OR (! intval($this->config['messagemaxchars'])) )
		{
			$this->config['messagemaxchars'] = 200;
		}

		//handle authors
		$useridsql = empty($this->config['postuserid']) ? '' : " AND(blog.userid IN (" .
			implode(',', array_keys($this->config['postuserid']))
			. "))";

		$useridsql .= empty($this->config['commentuserid']) ? '' : " AND(blog_text.userid IN (" .
			implode(',', array_keys($this->config['commentuserid']))
			. "))";

		//categories
		if (empty($this->config['categories']))
		{
			$catjoin = '';
			$categorysql = '';
		}
		else
		{
			$catjoin = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid)";
			$categorysql = " AND cu.blogcategoryid IN (" . implode(',', array_keys($this->config['categories'])) . ")";
		}

		//and tags
		if (empty($this->config['taglist']))
		{
			$tagjoin = '';
			$tagsql = '';
		}
		else
		{
			$tagjoin = "LEFT JOIN " . TABLE_PREFIX . "tagcontent AS tc ON (tc.contentid = blog.blogid AND
				tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") . ")";
			$tagsql = " AND tc.tagid IN (" . implode(',', array_keys($this->config['taglist'])) . ")";
		}

		$datecutoffsql = "AND (blog.dateline > " . (TIMENOW - (86400 * $this->config['days']) ).  ")" ;

		require_once(DIR . '/includes/blog_functions_shared.php');

		prepare_blog_category_permissions(vB::$vbulletin->userinfo);

		if (!(vB::$vbulletin->userinfo['permissions']['vbblog_general_permissions'] & vB::$vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']))
		{
			$sql_and[] = "blog.userid = " . vB::$vbulletin->userinfo['userid'];
		}

		$state = array('visible');
		if (can_moderate_blog('canmoderateentries'))
		{
			$state[] = 'moderation';
		}

		$sql_and[] = "blog.state IN('" . implode("', '", $state) . "')";
		$sql_and[] = "blog.dateline <= " . TIMENOW;
		$sql_and[] = "blog.pending = 0";

		$sql_join = array();
		$sql_or = array();
		if (!can_moderate_blog())
		{
			if (vB::$vbulletin->userinfo['userid'])
			{
				$sql_or[] = "blog.userid = " . vB::$vbulletin->userinfo['userid'];
				$sql_or[] = "(options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)";
				$sql_or[] = "(options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)";
				$sql_or[] = "(options_member & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))";
				$sql_and[] = "(" . implode(" OR ", $sql_or) . ")";

				$sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')";
				$sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')";

				$sql_and[] = "
					(blog.userid = " . vB::$vbulletin->userinfo['userid'] . "
						OR
					~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private'] . "
						OR
					(options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL))";
			}
			else
			{
				$sql_and[] = "options_guest & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
				$sql_and[] = "~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private'];

			}
		}

		$globalignore = '';
		if (trim(vB::$vbulletin->options['globalignore']) != '')
		{
			require_once(DIR . '/includes/functions_bigthree.php');
			if ($Coventry = fetch_coventry('string'))
			{
				$globalignore = "AND blog.userid NOT IN ($Coventry) ";
			}
		}

		$sql = "SELECT blog.blogid, blog.comments_visible as replycount, blog.title, blog.lastcomment, blog.lastcommenter, blog.postedby_userid, blog.postedby_username, blog.dateline,
			blog_text.blogtextid, blog_text.pagetext AS message, blog.ratingnum, blog.ratingtotal, blog.rating, blog.views, blog.postedby_userid AS userid, blog.postedby_username AS username,
			blog_user.title as blogtitle, blog_user.description as blogdescription, blog.trackback_visible,
			user.*
			" . (vB::$vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
			FROM " . TABLE_PREFIX . "blog AS blog
			INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON ((blog_text.blogid = blog.blogid) AND (blog_text.blogtextid <> blog.firstblogtextid))
			INNER JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)
			LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog_text.userid = user.userid) " .
            implode("\r\n\t ", $sql_join) . "
			$catjoin
			$tagjoin
			" . (vB::$vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
			WHERE 1=1
			$useridsql
			$categorysql
			$tagsql
			$datecutoffsql
			$globalignore
			AND " . implode("\r\n\tAND ", $sql_and) . "
			ORDER BY blog_text.dateline DESC
			LIMIT 0," . $this->config['count'] ;

		$results = vB::$db->query_read($sql);
		$array = array();
		$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		while ($blogcomment = vB::$db->fetch_array($results))
		{
			$blogcomment['title'] = fetch_trimmed_title($blogcomment['title'], $this->config['blogentries_titlemaxchars']);

			$urlinfo = array('blogid' => $blogcomment['blogid'], 'blog_title' => $blogcomment['title']);
			$blogcomment['url'] = fetch_seo_url('entry', $urlinfo, array('bt' => $blogcomment['blogtextid']))
				. "#comment" . $blogcomment['blogtextid'] ;

			$blogcomment['blogtitle'] = $blogcomment['blogtitle'] ? $blogcomment['blogtitle'] : $blogcomment['username'];

			$blogcomment['date'] = vbdate(vB::$vbulletin->options['dateformat'], $blogcomment['dateline'], true);
			$blogcomment['time'] = vbdate(vB::$vbulletin->options['timeformat'], $blogcomment['dateline']);

			$thread['lastpostdate'] = vbdate(vB::$vbulletin->options['dateformat'], $thread['lastcomment'], true);
			$thread['lastposttime'] = vbdate(vB::$vbulletin->options['timeformat'], $thread['lastcomment']);

			$blogcomment['message'] = $this->getSummary($blogcomment['message'], $this->config['messagemaxchars']);

			//get the avatar
			if (vB::$vbulletin->options['avatarenabled'])
			{
				$blogcomment['avatar'] = fetch_avatar_url($blogcomment['userid']);
			}
			else
			{
				$blogcomment['avatar'] = 0;
			}

			$blogcomment['tags'] = array();
			$array[$blogcomment['blogtextid']] = $blogcomment;
		}

		//let's get the tags;
		if (!empty($array))
		{
			$sql = "SELECT tag.tagid, tc.contentid, tag.tagtext
			FROM " . TABLE_PREFIX . "tagcontent AS tc INNER JOIN " .	TABLE_PREFIX .
			"tag AS tag ON tag.tagid = tc.tagid
				 WHERE tc.contentid IN (" . implode(',', array_keys($array)) . ") AND
				tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") ;
			if ($rst = vB::$db->query_read($sql))
			{
				while ($record = vB::$db->fetch_array($rst))
				{
					$array[$record['contentid']]['tags'][$record['tagid']] = $record['tagtext'];
				}
			}
		}
		return $array;

	}
Beispiel #8
0
	public function render($current_user, $criteria, $template_name = '')
	{
		require_once(DIR . '/includes/functions_forumdisplay.php');
		require_once(DIR . '/includes/functions_user.php');
		global $vbulletin;
		global $show;

		if (!strlen($template_name)) {
			$template_name = 'search_threadbit';
		}


		$show['forumlink'] = true;

		// threadbit_deleted conditionals
		$show['threadtitle'] = true;
		$show['viewthread'] = true;
		$show['managethread'] = true;

		//thread isn't a great name for this, but it stays consistant with
		//previous use and what will be expected in the hook.
		$thread = $this->thread->get_record();
		$this->set_replydata($thread['threadid'], $current_user);

		// get info from thread
		$thread['postid'] = $thread['threadid'];
		$thread['threadtitle'] = $thread['title'];
		$thread['threadiconid'] = $thread['iconid'];
		$thread['postdateline'] = $thread['lastpost'];
		$thread['threadtitle'] = $thread['title'];

		$thread['issubscribed'] = $this->thread->is_subscribed($current_user);
		$thread['threadread'] = $this->thread->get_lastread($current_user);

		/*
			This used to be precalculated by forum, but it doesn't look expensive enough to want to
			bother with that.  If that turns out to be wrong we'll need to do some kind of
			caching.
		*/
		$forum = $this->thread->get_forum();
		if (!$current_user->hasForumPermission($forum->get_field('forumid'), 'canviewthreads'))
		{
			unset($thread['preview']);
		}

		//set the correct status
		if ($this->replydata['mylastpost'] > 0)
		{
			$post_statusicon[] = 'dot';
		}

		if (!$thread['open'])
		{
			$post_statusicon[] = 'lock';
		}

		if ($this->replydata['lastread'] < $thread['lastpost'])
		{
			$post_statusicon[] = 'new';
		}

		if (! count($post_statusicon))
		{
				$post_statusicon[] = 'old';
		}
		$post_statusicon = implode('_', $post_statusicon);


		$show['deletereason'] = false;

		if ($thread['visible'] == 2)
		{
			$log = $this->thread->get_deletion_log_array();
			$thread['del_username'] = $log['username'];
			$thread['del_userid'] = $log['userid'];
			$thread['del_reason'] = $log['reason'];

			$thread['deletedcount']++;
			$show['deletereason'] = !empty($thread['del_reason']);
		}
		else if ($thread['visible'] == 0)
		{
			$thread['hiddencount']++;
		}

		$thread['highlight'] = $criteria->get_highlights();

		$show['moderated'] = ($thread['hiddencount'] > 0 AND
			$current_user->canModerateForum($thread['forumid'], 'canmoderateposts'));

		$show['deletedthread'] = ($thread['deletedcount'] > 0 AND
			($current_user->canModerateForum($thread['forumid']) OR
			$current_user->hasForumPermission($thread['forumid'], 'canseedelnotice')));

		$show['disabled'] = !$this->can_inline_mod($current_user);

		$lastread = $forum->get_last_read_by_current_user($current_user);
		$thread = process_thread_array($thread, $lastread);
		($hook = vBulletinHook::fetch_hook('search_results_threadbit')) ? eval($hook) : false;

		$pageinfo = $pageinfo_lastpost = $pageinfo_firstpost = $pageinfo_lastpage = array();
		if ($show['pagenavmore'])
		{
			$pageinfo_lastpage['page'] = $thread['totalpages'];
		}
		$pageinfo_lastpost['p'] = $thread['lastpostid'];
		$pageinfo_newpost['goto'] = 'newpost';

		$pageinfo_thread = array();
		if (!empty($thread['highlight']))
		{
			$pageinfo_thread['highlight'] = urlencode(implode(' ', $thread['highlight']));
			$pageinfo_newpost['highlight'] = urlencode(implode(' ', $thread['highlight']));
			$pageinfo_lastpost['highlight'] = urlencode(implode(' ', $thread['highlight']));
			$pageinfo_firstpost['highlight'] = urlencode(implode(' ', $thread['highlight']));
		}
		
		if ($vbulletin->options['avatarenabled'])
		{
			$thread['lastpost_avatar'] = fetch_avatar_url($thread['lastposterid']);
			$thread['post_avatar'] = fetch_avatar_url($thread['postuserid']);
		}
					
		if ($vbulletin->options['avatarenabled'])
		{
			$thread['lastpost_avatar'] = fetch_avatar_url($thread['lastposterid']);
			$thread['post_avatar'] = fetch_avatar_url($thread['postuserid']);
		}

 		$template = vB_Template::create($template_name);
		$template->register('post_statusicon', $post_statusicon);
		$template->register('pageinfo_firstpost', $pageinfo_firstpost);
		$template->register('pageinfo_lastpost', $pageinfo_lastpost);
		$template->register('pageinfo_lastpage', $pageinfo_lastpage);
		$template->register('pageinfo_newpost', $pageinfo_newpost);
		$template->register('pageinfo', $pageinfo_thread);
		$template->register('dateformat', $vbulletin->options['dateformat']);
		$template->register('timeformat', $vbulletin->options['default_timeformat']);
		$template->register('postdateline', $thread['lastpost']);
		$userinfo = array('userid' => $thread['postuserid'], 'username' => $thread['postusername'] );
		$template->register('userinfo', $userinfo);
		$template->register('show', $show);
		$template->register('thread', $thread);




		return $template->render();
	}
Beispiel #9
0
	public function render($current_user, $criteria, $template_name = '')
	{
		require_once (DIR . '/includes/functions_user.php');
		require_once (DIR . '/includes/functions.php');
		if (!$this->record)
		{
			return "";
		}

		if (!strlen($template_name)) {
			$template_name = 'blog_comment_search_result';
		}

		global $vbulletin, $show;

		$urlinfo = array('blogid' => $this->record['blogid'], 'blog_title' => $this->record['title']);
		$this->record['page_url'] = fetch_seo_url('entry', $urlinfo, array('bt' => $this->record['blogtextid'])) . "#comment" . $this->record['blogtextid'] ;
		$comment = $this->record;
		$canmoderation = (can_moderate_blog('canmoderatecomments') OR $vbulletin->userinfo['userid'] == $blog['userid']);

		$comment['comment_date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline'], true);
		$comment['comment_time'] = vbdate($vbulletin->options['timeformat'], $comment['dateline']);

		if (! $this->bbcode_parser )
		{
			$this->bbcode_parser = new vB_BbCodeParser_Blog($vbulletin, fetch_tag_list('', true));
		}
		$can_use_html = vB::$vbulletin->userinfo['permissions']['vbblog_entry_permissions']
			& vB::$vbulletin->bf_ugp_vbblog_entry_permissions['blog_allowhtml'];
		$comment['comment_summary'] =
			fetch_censored_text($this->bbcode_parser->get_preview($comment['comment_pagetext'],
			$this->preview_length, $can_use_html));
		$templater = vB_Template::create($template_name);
		$templater->register('commentinfo', $comment);
		$templater->register('dateline', $this->message['dateline']);
		$templater->register('dateformat', $vbulletin->options['dateformat']);
		$templater->register('timeformat', $vbulletin->options['default_timeformat']);

		if ($vbulletin->options['avatarenabled'] AND (intval($comment['comment_userid'])))
		{
			$avatar = fetch_avatar_url($comment['comment_userid']);
		}

		if (!isset($avatar) OR (count($avatar) < 2))
		{
			$avatar = false;
		}

		$templater->register('avatar', $avatar);
		$text = $templater->render();

		return $text;
	}
Beispiel #10
0
	private function renderResult($config, $results, $criteria, $current_user)
	{
		require_once DIR . "/includes/functions_user.php";
		//None of the search result renderers do this right. Instead
		// we need two templates- one for the header and one for each row
		if (count($results))
		{
			//Here we have something of a dilemma. We need to verify permissions
			// for each post. That requires that we instantiate the object, so we've got
			// two sql calls per object. We could reduce that by instantiating an array, but we
			// still make a second query to get the thread. So I guess we'll just brute-force it.
			$views =	'' ;
			$current_user = new vB_Legacy_CurrentUser();
			$count = 0;
			foreach ($results as $result)
			{
				// title comes in encoded already and gets encoded again in the view
				$result['title'] = unhtmlspecialchars($result['title']);
				$post = vB_Legacy_Post::create_from_id($result['postid']);
				if (!empty($post) AND is_object($post) AND $post->can_view($current_user))
				{
					$view = new vB_View($config['inner_template']);
					$user = vB_Legacy_User::createFromId($post->get_field('userid'));

					if (vB::$vbulletin->options['avatarenabled'])
					{
						$avatar = fetch_avatar_url($result['userid']);
					}

					$view->avatar = $avatar;
					$view->record = $result;
					$view->node_url = vB_Route::create('vBCms_Route_Content', $result['nodeid'] .
						($result['url'] != '' ? '-' . $result['url'] : '') )->getCurrentURL();
					$view->node_title = htmlspecialchars_uni($result['title']);

					// Comment url
					$join_char = strpos($view->node_url,'?') ? '&amp;' : '?';
					$view->comment_url = $view->node_url . $join_char . "commentid=" . $post->get_field('postid') . "#post" . $post->get_field('postid');

					$view->post = $this->addVariables($post);
					$thread = $post->get_thread();
					$view->threadinfo = array('threadid' => $thread->get_field('threadid'),
						 'title' => $thread->get_field('title'));
					$view->dateformat = $vbulletin->options['dateformat'];
					$view->timeformat = $vbulletin->options['default_timeformat'];
					$view->dateline =  $post->get_field('dateline');

					$views .= $view->render();
					$count++;
					if ($count >= intval($config['count']))
					{
						break;
					}

				}
			}
			return $views;

		}
	}
Beispiel #11
0
         $thread['notification'] = $vbphrase['n_a'];
 }
 ($hook = vBulletinHook::fetch_hook('threadbit_display')) ? eval($hook) : 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));
 // The code block needs to be here to register $show['avatar']
 if (defined('VB_API') and VB_API === true) {
     // We need to fetch avatar url
     if (intval($thread['postuserid']) and $vbulletin->options['avatarenabled']) {
         $avatar = fetch_avatar_url($thread['postuserid']);
     }
     if (!isset($avatar)) {
         $avatar = false;
     }
 }
 $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);
 if (defined('VB_API') and VB_API === true) {
Beispiel #12
0
function do_get_profile()
{
    global $vbulletin, $db, $show, $vbphrase, $permissions, $imodcache;
    $vbulletin->input->clean_array_gpc('r', array('userid' => TYPE_UINT));
    if (!$vbulletin->userinfo['userid'] && !$vbulletin->GPC['userid']) {
        json_error(ERR_INVALID_LOGGEDIN, RV_NOT_LOGGED_IN);
    }
    if (!($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) or !($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canviewmembers'])) {
        json_error(ERR_NO_PERMISSION);
    }
    if (!$vbulletin->GPC['userid']) {
        $vbulletin->GPC['userid'] = $vbulletin->userinfo['userid'];
    }
    $fetch_userinfo_options = FETCH_USERINFO_AVATAR | FETCH_USERINFO_LOCATION | FETCH_USERINFO_PROFILEPIC | FETCH_USERINFO_SIGPIC | FETCH_USERINFO_USERCSS | FETCH_USERINFO_ISFRIEND;
    $userinfo = verify_id('user', $vbulletin->GPC['userid'], 1, $fetch_userinfo_options);
    if ($userinfo['usergroupid'] == 4 and !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) {
        json_error(ERR_NO_PERMISSION);
    }
    $posts = $userinfo['posts'];
    $joindate = vbdate($vbulletin->options['dateformat'], $userinfo['joindate']);
    $out = array('username' => html_entity_decode($userinfo['username']), 'online' => fetch_online_status($userinfo, false), 'avatar_upload' => $vbulletin->options['avatarenabled'] && $permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar'], 'posts' => $posts, 'joindate' => $joindate);
    $avatarurl_info = fetch_avatar_url($userinfo['userid']);
    if ($avatarurl_info) {
        $out['avatarurl'] = process_avatarurl($avatarurl_info[0]);
    }
    cache_moderators();
    $canbanuser = ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or can_moderate(0, 'canbanusers'));
    if ($canbanuser) {
        $out['ban'] = true;
    }
    $groups = array();
    // About
    $out_group = array('name' => 'about', 'values' => array(array('name' => prepare_utf8_string($vbphrase['posts']), 'value' => strval(vb_number_format($userinfo['posts']))), array('name' => prepare_utf8_string($vbphrase['join_date']), 'value' => vbdate($vbulletin->options['dateformat'], $userinfo['joindate']))));
    if (function_exists('itrader_user')) {
        itrader_user($userinfo);
        $out_group['values'][] = array('name' => 'iTrader', 'value' => vb_number_format($userinfo['tradescore']) . ', ' . $userinfo['tradepcnt'] . '%');
        $out += array('itrader_score' => vb_number_format($userinfo['tradescore']), 'itrader_percent' => $userinfo['tradepcnt'] . '%');
    }
    $groups[] = $out_group;
    $profileobj = new vB_UserProfile($vbulletin, $userinfo);
    $blockfactory = new vB_ProfileBlockFactory($vbulletin, $profileobj);
    $profileblock =& $blockfactory->fetch('ProfileFields');
    $profileblock->build_field_data(false);
    $profile = $profileblock->categories[0];
    // Additional information
    if (count($profile)) {
        $out_group = array('name' => 'additional');
        foreach ($profile as $profilefield) {
            $field_value = $userinfo["field{$profilefield['profilefieldid']}"];
            fetch_profilefield_display($profilefield, $field_value);
            if (!strlen(trim($field_value))) {
                continue;
            }
            $out_group['values'][] = array('name' => prepare_utf8_string($profilefield['title']), 'value' => prepare_utf8_string($profilefield['value']));
        }
        if (count($out_group['values'])) {
            $groups[] = $out_group;
        }
    }
    $out['groups'] = $groups;
    return $out;
}
Beispiel #13
0
	public function render($current_user, $criteria, $template_name = '')
	{
		global $vbulletin, $vbphrase, $show;
		require_once (DIR . '/includes/functions_forumdisplay.php');
		require_once (DIR . '/includes/functions_misc.php');
		require_once(DIR . '/includes/functions_user.php');

		fetch_phrase_group('search');


		if (!strlen($template_name)) {
			$template_name = 'search_results_postbit';
		}

		/*
			Post is not a good name for this array, however its what it used to be called
			(when it wasn't such a bad name) and changing it makes it certain that a lot of
			hooks are going to break.
		*/
		$post = array();
		$thread = $this->post->get_thread();

		$forum = $thread->get_forum();
		$this->set_replydata($this->post->get_field('threadid'), $this->post->get_field('postid'), $current_user);

		if ($this->replydata['mylastpost'] > 0)
		{
			$post_statusicon[] = 'dot';
		}

		if (!$thread->get_field('open'))
		{
			$post_statusicon[] = 'lock';
		}

		if ($this->replydata['lastread'] < $thread->get_field('lastpost'))
		{
			$post_statusicon[] = 'new';
		}

		if (! count($post_statusicon))
		{
			$post_statusicon[] = 'old';
		}

		$post_statusicon = implode('_', $post_statusicon);

		$post['postid'] = $this->post->get_field('postid');
		$post['postdateline'] = $this->post->get_field('dateline');
		$post['posttitle'] = vB_Search_Searchtools::stripHtmlTags(htmlspecialchars_decode($this->post->get_display_title()));
		$post['pagetext'] = nl2br($this->post->get_summary(200));
		$post['visible'] = $this->post->get_field('visible');
		$post['attach'] = $this->post->get_field('attach');

		$post['highlight'] = $criteria->get_highlights();
		$post['userid'] = $this->post->get_field('userid');
		$post['username'] = $this->post->get_field('userid') == 0 ?
			$this->post->get_field('username') : $this->post->get_user()->get_field('username');

		$post['threadid'] = $thread->get_field('threadid');
		$post['threadtitle'] = $thread->get_field('title');
		$post['threadiconid'] = $thread->get_field('iconid');
		$post['replycount'] = $thread->get_field('replycount');
		$post['views'] = $thread->get_field('views') > 0 ?
			$thread->get_field('views') : $thread->get_field('replycount') + 1;
		$post['firstpostid'] = $thread->get_field('firstpostid');
		$post['prefixid'] = $thread->get_field('prefixid');
		$post['taglist'] = $thread->get_field('taglist');
		$post['pollid'] = $thread->get_field('pollid');
		$post['sticky'] = $thread->get_field('sticky');
		$post['open'] = $thread->get_field('open');
		$post['lastpost'] = $thread->get_field('lastpost');
		$post['forumid'] = $thread->get_field('forumid');
		$post['thread_visible'] = $thread->get_field('visible');

		$post['forumtitle'] = $forum->get_field('title');

		$post['posticonid'] = $this->post->get_field('iconid');
		$post['allowicons'] = $forum->allow_icons();
		$post['posticonpath'] = $this->post->get_icon_path();
		$post['posticontitle'] = $this->post->get_icon_title();
		$post['posticon'] = $post ['allowicons'] and $post ['posticonpath'];

		$lastread = $forum->get_last_read_by_current_user($current_user);

		$show['deleted'] = false;
		if ($current_user->isModerator())
		{
			$log = $this->post->get_deletion_log_array();
			if ($log['userid'])
			{
				$post['del_phrase'] = $vbphrase['message_deleted_by_x'];
			}
			else
			{
				$log = $thread->get_deletion_log_array();
				if (!$log['userid'])
				{
					$post['del_phrase'] = $vbphrase['thread_deleted_by_x'];
					$log = false;
				}
			}

			if ($log)
			{
				$post['del_username'] = $log['username'];
				$post['del_userid'] = $log['userid'];
				$post['del_reason'] = $log['reason'];
				$show['deleted'] = true;
			}
		}
		$post['prefixid'] = $thread->get_field('prefixid');
		if ($post['prefixid'])
		{
			$post['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_$post[prefixid]_title_plain"]);
			$post['prefix_rich'] = $vbphrase["prefix_$post[prefixid]_title_rich"];
		}
		else
		{
			$post['prefix_plain_html'] = '';
			$post['prefix_rich'] = '';
		}

		$show['disabled'] = !$this->can_inline_mod($current_user);

		$post = process_thread_array($post, $lastread, $post['allowicons']);
		($hook = vBulletinHook::fetch_hook('search_results_postbit')) ? eval($hook) : false;

		$template = vB_Template::create($template_name);
		$template->register('post', $post);
		$template->register('userinfo', fetch_userinfo($this->post->get_field('userid')));
		$template->register('threadinfo', $thread->get_record());
		$template->register('lastpostdate', vbdate($vbulletin->options['dateformat'], $thread->get_field('lastpost'), true));
		$template->register('lastpostdatetime', vbdate($vbulletin->options['timeformat'], $thread->get_field('lastpost')));
		$template->register('dateformat', $vbulletin->options['dateformat']);
		$template->register('timeformat',$vbulletin->options['default_timeformat']);
		$template->register('dateline', $this->post->get_field('dateline'));

		if ($vbulletin->options['avatarenabled'])
		{
			$template->register('avatar', fetch_avatar_url($this->post->get_field('userid')));
		}


		$template->register('dateline', $this->post->get_field('dateline'));


		$pageinfo_thread = array();
		$pageinfo_post = array('p' => $post['postid']);
		if (!empty($post['highlight']))
		{
			$pageinfo_post['highlight'] = urlencode(implode(' ', $post['highlight']));
			$pageinfo_thread['highlight'] = urlencode(implode(' ', $post['highlight']));
		}

		$template->register('pageinfo_post', $pageinfo_post);
		$template->register('pageinfo_thread', $pageinfo_thread);
		$template->register('post_statusicon', $post_statusicon);

		return $template->render();
	}
Beispiel #14
0
	/**
	 * function to return the rendered html for this result
	 *
	 * @param string $current_user
	 * @param object $criteria
	 * @return
	 */
	public function render($current_user, $criteria, $template_name = '')
	{
		global $vbulletin;
		global $show;
		require_once DIR . '/vb/search/searchtools.php';
		require_once DIR . "/includes/functions_user.php";
		require_once DIR . "/includes/functions.php";

		if (!strlen($template_name))
		{
			$template_name = 'vbcms_searchresult_article_general';
		}
		$template = vB_Template::create($template_name);

		$template->register('title', vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ? $this->record['title'] : htmlspecialchars_uni($this->record['title']));
		$template->register('html_title', vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ? $this->record['html_title'] : htmlspecialchars_uni($this->record['html_title']));

		// Bug 35855: due to a different bug, 35413, users are able to save articles with
		// invalid seo url aliases. this causes the getCurrentUrl to throw a vB_Exception_Router
		// exception when attempting to build article URL's for search. so, to prevent
		// the search from blowing up on these articles results, we will trap these exceptions,
		// and generate the url without the alias in that case
		try
		{
			$page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'] .
				($this->record['url'] == '' ? '' : '-' . $this->record['url'] ))->getCurrentURL();
		}
		catch (vB_Exception_Router $e)
		{
			$page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL();
		}
		$template->register('page_url', $page_url);
		$this->record['page_url'] = $page_url;
		try
		{
			$parent_url = vB_Route::create('vBCms_Route_Content', $this->record['parentid'] .
				($this->record['parenttitle'] == '' ? '' : '-' . $this->record['parenttitle'] )	)->getCurrentURL();
		}
		catch (vB_Exception_Router $e)
		{
			$parent_url = vB_Route::create('vBCms_Route_Content', $this->record['parentid'])->getCurrentURL();
		}
		$template->register('parent_url', $parent_url);

		$template->register('lastcomment_url', $page_url . "#new_comment");
		$template->register('username', $this->record['username']);
		$template->register('description', $this->record['description']);
		$template->register('parenttitle' , htmlspecialchars_uni($this->record['parenttitle']) );
		$template->register('parentid' , $this->record['parentid'] );
		$template->register('threadid' , $this->record['threadid'] );
		$template->register('postauthor' , $this->record['postauthor'] );
		$template->register('poststarter' , $this->record['poststarter'] );
		$template->register('blogpostid' , $this->record['blogpostid'] );
		$template->register('parentnode' , $this->record['parentnode'] );
		$template->register('postid' , $this->record['postid'] );
		$template->register('post_started' , $this->record['post_started'] );
		$template->register('post_posted' , $this->record['post_posted'] );
		$can_use_html = vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ;
		$template->register('previewtext', $this->getPreviewText($this->record));
		$template->register('pagetext',
			 $can_use_html ? fetch_censored_text($this->record['pagetext']) :
			 fetch_censored_text(htmlspecialchars_uni($this->record['pagetext'])));
		$template->register('publish_phrase', ($this->record['publishdate'] ?
			$vbphrase['page_published'] : $vbphrase['page_unpublished']) );
		$template->register('author_phrase', 'author');
		$template->register('published', ($this->record['publishdate'] ?
			true : false));
		$template->register('categories', $this->categories);
		$template->register('tags', $this->tags);
		$template->register('replycount', ($this->record['replycount'] ?
			$this->record['replycount'] : '0'));
		$template->register('article', $this->record);
		$template->register('publishdate', vbdate($vbulletin->options['dateformat'], $this->record['publishdate'], true));
		$template->register('publishtime', vbdate($vbulletin->options['timeformat'], $this->record['publishdate']));
		$template->register('lastpostdate', vbdate($vbulletin->options['dateformat'], $this->record['lastpost'], true));
		$template->register('lastpostdatetime', vbdate($vbulletin->options['timeformat'], $this->record['lastpost']));
		$template->register('lastposter', $this->record['lastposter']);
		$template->register('lastposterinfo', array('userid'=>$this->record['lastposterid'], 'username'=>$this->record['lastposter']));
		$template->register('dateformat', $vbulletin->options['dateformat']);
		$template->register('timeformat', $vbulletin->options['default_timeformat']);
		$user = vB_Legacy_User::createFromId($this->record['userid']);

		//get the avatar
		if (intval($this->record['userid']))
		{
			$avatar = fetch_avatar_url($this->record['userid']);
		}

		if (!isset($avatar) OR (count($avatar) < 2))
		{
			$avatar = false;
		}
		$template->register('avatar', $avatar);
		$result = $template->render();

		return $result;
	}
Beispiel #15
0
	/** This function gets the article information based on the defined criteria
	*
	 * @return	array
	 */
	protected function getContent()
	{

		// First, compose the sql
		$sql = "SELECT article.pagetext, article.previewimage, article.imagewidth,
		article.imageheight, article.previewvideo, article.htmlstate, node.url, node.publishdate, node.userid,
		node.setpublish, node.publicpreview, info.title, user.username, node.showuser,
		node.nodeid, node.contenttypeid, thread.replycount FROM "
		. TABLE_PREFIX . "cms_article AS article INNER JOIN "
		. TABLE_PREFIX . "cms_node AS node ON (node.contentid = article.contentid
		AND node.contenttypeid = " . vb_Types::instance()->getContentTypeID("vBCms_Article") .
		") INNER JOIN "	. TABLE_PREFIX . "cms_nodeinfo AS info on info.nodeid = node.nodeid "
		. ( (($this->config['categories'] != '') AND ($this->config['categories'] != '0')) ?
			" INNER JOIN " . TABLE_PREFIX .
		"cms_nodecategory nc ON nc.nodeid = node.nodeid " : '') .	"
		LEFT JOIN "	. TABLE_PREFIX . "user AS user ON user.userid = node.userid
		LEFT JOIN "	. TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid
		WHERE " . vBCMS_Permissions::getPermissionString() ;

		if (($this->config['categories'] != '') AND ($this->config['categories'] != '0') )
		{
			$sql .= "\n AND nc.categoryid IN (" . $this->config['categories'] . ")\n";
		}

		if (($this->config['sections'] != '') AND ($this->config['sections'] != '0'))
		{

			$sql .= "\n AND node.parentnode IN (" . $this->config['sections'] . ")\n";
		}

		if (isset($this->config['days']) AND (intval($this->config['days'])) )
		{
			$sql .= "\n AND node.publishdate > " . (TIMENOW - (86400 * $this->config['days'])) . "\n";
		}

		$sql .= "\n ORDER BY node.publishdate DESC LIMIT " . $this->config['count'];
		$articles = array();

		//Execute
		if ($rst = vB::$db->query_read($sql))
		{
			$current_record = array('contentid' => -1);
			$contenttypeid = vb_Types::instance()->getContentTypeId($this->package . '_' . $this->view_class);
			//now build the results array
			$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin,  vBCms_BBCode_HTML::fetchCmsTags());
			while($article = vB::$db->fetch_array($rst))
			{
				$article['categories'] = array();
				$article['tags'] = array();
				$allow_html = vBCMS_Permissions::canUseHtml($article['nodeid'], $contenttypeid, $article['userid']);
				$pagetext = $bbcode_parser->get_preview(fetch_censored_text($article['pagetext']),
					vB::$vbulletin->options['default_cms_previewlength'], $allow_html);
				$article['previewtext'] = strip_bbcode($pagetext);

				//get the avatar
				if (vB::$vbulletin->options['avatarenabled'])
				{
					$article['avatar'] = fetch_avatar_url($article['userid']);
				}

				$articles[$article['nodeid']]  = $article;
			}

			//Let's get the tags and the categories
			// we can do that with one query each.
			if (count($articles))
			{
				//first let's get categories
				$nodeids = implode(', ', array_keys($articles));
				$sql = "SELECT nc.nodeid, nc.categoryid, category.category FROM " . TABLE_PREFIX . "cms_nodecategory AS nc
				INNER JOIN "	. TABLE_PREFIX . "cms_category AS category ON category.categoryid = nc.categoryid
				WHERE nc.nodeid IN ($nodeids)";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$route_info = $record['categoryid'] .
							($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');
						$record['route_info'] = $route_info;
						$record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();

						$articles[$record['nodeid']]['categories'][$record['categoryid']] = $record;
					}
				}

				//next tags;
				$sql = "SELECT tag.tagid, node.nodeid, tag.tagtext FROM " .
				TABLE_PREFIX . "cms_node AS node INNER JOIN " .	TABLE_PREFIX .
				"tagcontent AS tc ON (tc.contentid = node.contentid AND  tc.contenttypeid = node.contenttypeid)
				INNER JOIN " .	TABLE_PREFIX .
				"tag AS tag ON tag.tagid = tc.tagid
				 WHERE node.nodeid IN ($nodeids) ";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$articles[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext'];
					}
				}
			}
		}
		return $articles;
	}