示例#1
0
文件: blog.php 项目: Kheros/MMOver
 $lastentrycats = explode(',', $blog['categories']);
 $lastcommentcats = explode(',', $blog['categories_lastcomment']);
 $show['lastentry'] = array_intersect($vbulletin->userinfo['blogcategorypermissions']['cantview'], $lastentrycats) ? false : true;
 $show['lastcomment'] = array_intersect($vbulletin->userinfo['blogcategorypermissions']['cantview'], $lastcommentcats) ? false : true;
 if ($blogtype == 'all') {
     $blog['entrytitle'] = fetch_trimmed_title($blog['lastblogtitle'], 20);
     if ($blog['title']) {
         $blog['title'] = fetch_trimmed_title($blog['title'], 50);
     }
     $templater = vB_Template::create('blog_blog_row');
     $templater->register('blog', $blog);
     $templater->register('thread', $thread);
     $blogbits .= $templater->render();
 } else {
     fetch_musername($blog);
     fetch_avatar_html($blog);
     $blog['onlinestatus'] = 0;
     $blog['commentexcerpt'] = htmlspecialchars_uni(fetch_trimmed_title($blog['pagetext'], 50));
     // now decide if we can see the user or not
     if ($blog['lastactivity'] > TIMENOW - $vbulletin->options['cookietimeout'] and $blog['lastvisit'] != $blog['lastactivity']) {
         if ($blog['invisible']) {
             if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'] or $blog['userid'] == $vbulletin->userinfo['userid']) {
                 // user is online and invisible BUT bbuser can see them
                 $blog['onlinestatus'] = 2;
             }
         } else {
             // user is online and visible
             $blog['onlinestatus'] = 1;
         }
     }
     $blog['commentdate'] = vbdate($vbulletin->options['dateformat'], $blog['lastcomment'], true);
示例#2
0
/**
* Fetch the blogs sorted by rating in descending order
*
* @return	string	HTML for the latest blogs
*/
function &fetch_rated_blogs()
{
	global $vbulletin, $show, $vbphrase;

	$sql_and = array();
	$recentblogbits = '';

	if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']))
	{
		$sql_and[] = "bu.bloguserid = " . $vbulletin->userinfo['userid'];
	}
	if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']) AND $vbulletin->userinfo['userid'])
	{
		$sql_and[] = "bu.bloguserid <> " . $vbulletin->userinfo['userid'];
	}

	// get ignored users - just hide them on the latest list
	$ignore = array();
	if (trim($vbulletin->userinfo['ignorelist']))
	{
		$ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
		if (!empty($ignorelist))
		{
			$sql_and[] = "bu.bloguserid NOT IN (" . implode(", ", $ignorelist) . ")";
		}
	}

	if (trim($vbulletin->options['globalignore']) != '')
	{
		require_once(DIR . '/includes/functions_bigthree.php');
		if ($coventry = fetch_coventry('string') AND !can_moderate_blog())
		{
			$sql_and[] = "bu.bloguserid NOT IN ($coventry)";
		}
	}

	$sql_and[] = "bu.ratingnum >= " . intval($vbulletin->options['vbblog_ratinguser']);

	$sql_or = array();
	$sql_join = array();
	if (!can_moderate_blog())
	{
		if ($vbulletin->userinfo['userid'])
		{
			$sql_or[] = "bu.bloguserid IN (" . $vbulletin->userinfo['memberblogids'] . ")";
			$sql_or[] = "(options_ignore & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)";
			$sql_or[] = "(options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)";
			$sql_or[] = "(options_member & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . $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 = bu.bloguserid AND buddy.relationid = " . $vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')";
			$sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = bu.bloguserid AND ignored.relationid = " . $vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')";
		}
		else
		{
			$sql_and[] = "options_guest & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
		}
	}

	// Highest Rated
	$recentupdates = $vbulletin->db->query_read_slave("
		SELECT user.*, bu.ratingnum, bu.ratingtotal, bu.title,
			IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid, infractiongroupid, options_ignore, options_buddy, options_member, options_guest
			" . ($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_user AS bu " . ($index ? "USE INDEX ($index)" : "") . "
		LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = bu.bloguserid)
		" . (!empty($sql_join) ? implode("\r\n", $sql_join) : "") . "
		" . ($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 " . implode("\r\n\tAND ", $sql_and) . "
		ORDER BY bu.rating DESC
		LIMIT " .  intval($vbulletin->options['vbblog_maxratedblog']) . "
	");
	while ($updated = $vbulletin->db->fetch_array($recentupdates))
	{
		$updated = array_merge($updated, convert_bits_to_array($updated['options'], $vbulletin->bf_misc_useroptions));
		$updated = array_merge($updated, convert_bits_to_array($updated['adminoptions'], $vbulletin->bf_misc_adminoptions));
		fetch_musername($updated);
		fetch_avatar_html($updated);
		if ($updated['ratingnum'] > 0)
		{
			$updated['voteavg'] = vb_number_format($updated['ratingtotal'] / $updated['ratingnum'], 2);
			$updated['rating'] = intval(round($updated['ratingtotal'] / $updated['ratingnum']));
		}
		else
		{
			$updated['voteavg'] = 0;
			$updated['rating'] = 0;
		}
		$updated['title'] = $updated['title'] ? $updated['title'] : $updated['username'];

		$show['private'] = false;
		if (can_moderate() AND $vbulletin->userinfo['userid'] != $updated['userid'])
		{
			$membercanview = $updated['options_member'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
			$buddiescanview = $updated['options_buddy'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
			if (!$membercanview AND (!$updated['buddyid'] OR !$buddiescanview))
			{
				$show['private'] = true;
			}
		}

		$templater = vB_Template::create('blog_home_list_blog');
			$templater->register('updated', $updated);
		$recentblogbits .= $templater->render();
	}

	return $recentblogbits;
}
示例#3
0
/**
* Constructs the blog sidebar specific for a user's blog
*
* @param	array	userinfo array
* @param	integer	The month to show the calendar for
* @param	integer	The year to show the calendar for
* @param	boolean	Should posting rules be shown in the sidebar
*
* @return	string	HTML for sidebar
*/
function &build_user_sidebar(&$userinfo, $month = 0, $year = 0, $rules = false)
{
	global $vbulletin, $show, $vbphrase, $vbcollapse, $headinclude, $ad_location, $blogrssinfo;

	($hook = vBulletinHook::fetch_hook('blog_sidebar_user_start')) ? eval($hook) : false;

	$sidebar = array();

	$blockorder = $userinfo['sidebar'];
	$freeblocks = array();

	if ($userinfo['customblocks'] AND $userinfo['permissions']['vbblog_customblocks'] > 0)
	{
		if (count($userinfo['sidebar_customblocks']) != $userinfo['customblocks'])
		{
			$customblock = array();
			$customblocks = $vbulletin->db->query_read_slave("
				SELECT customblockid, pagetext, allowsmilie, title
				FROM " . TABLE_PREFIX . "blog_custom_block
				WHERE
					userid = " . $userinfo['userid'] . "
						AND
					type = 'block'
			");
			while ($blockholder = $vbulletin->db->fetch_array($customblocks))
			{
				$userinfo['sidebar_customblocks']["$blockholder[customblockid]"] = array(
					'pagetext'    => $blockholder['pagetext'],
					'title'       => $blockholder['title'],
					'allowsmilie' => $blockholder['allowsmilie'],
				);
			}
		}

		$blocktext = array();
		require_once(DIR . '/includes/class_bbcode_blog.php');
		$bbcode = new vB_BbCodeParser_Blog($vbulletin, fetch_tag_list());
		$bbcode->set_parse_userinfo($userinfo, $userinfo['permissions']);
		foreach ($userinfo['sidebar_customblocks'] AS $customblockid => $blockinfo)
		{
			$customblock["custom$customblockid"] = array(
				'message'   => $bbcode->parse(
					$blockinfo['pagetext'],
					'blog_entry',
					$blockinfo['allowsmilie'],
					false,
					$blockinfo['parsedtext'],
					$blockinfo['hasimages'],
					true
				),
				'title'     => $blockinfo['title'],
				'customblockid' => $customblockid,
			);

			if ($bbcode->cached['text'])
			{
				$blocktext["$customblockid"] = array(
					'parsedtext'  => $bbcode->cached['text'],
					'title'       => $blockinfo['title'],
					'allowsmilie' => $blockinfo['allowsmilie'],
					'hasimages'   => $bbcode->cached['has_images'],
				);
			}
		}
		unset($bbcode);

		if (!empty($blocktext))
		{
			$vbulletin->db->shutdown_query("
				REPLACE INTO " . TABLE_PREFIX . "blog_custom_block_parsed (userid, styleid, languageid, blocktext)
				VALUES ($userinfo[userid], " . (STYLEID) . ", " . (LANGUAGEID) . ", '" . $vbulletin->db->escape_string(serialize($blocktext)) . "')
			");
		}
	}

	if ($vbulletin->userinfo['permissions']['vbblog_customblocks'])
	{
		$show['editsidebar'] = true;
	}
	if ($vbulletin->userinfo['permissions']['vbblog_custompages'])
	{
		$show['editcustompage'] = true;
	}
	$useblock = array();
	foreach ($vbulletin->bf_misc_vbblogblockoptions AS $key => $value)
	{
		if ($vbulletin->options['vbblog_blocks'] & $value)
		{
			switch ($key)
			{
				case 'block_archive':
				case 'block_category':
				case 'block_comments':
				case 'block_entries':
				case 'block_visitors':
					$show['editsidebar'] = true;
					break;
				case 'block_search':
					if ($show['blog_search'])
					{
						$show['editsidebar'] = true;
					}
					break;
				case 'block_tagcloud':
					if ($vbulletin->options['vbblog_tagging'])
					{
						$show['editsidebar'] = true;
					}
					break;
				default:
					($hook = vBulletinHook::fetch_hook('blog_sidebar_user_block')) ? eval($hook) : false;
			}
			if (!isset($blockorder["$key"]))
			{
				$freeblocks["$key"] = 1;
				$useblock["$key"] = true;
			}
			else
			{
				$useblock["$key"] = $blockorder["$key"];
			}
		}
		else
		{
			if (preg_match('#^block_#', $key))
			{
				$useblock["$key"] = true;
				$blockorder["$key"] = 0;
			}
		}
	}
	if (!empty($freeblocks))
	{
		$blockorder = array_merge($blockorder, $freeblocks);
	}

	if ($useblock['block_archive'])
	{
		$month = ($month < 1 OR $month > 12) ? vbdate('n', TIMENOW, false, false) : $month;
		$year = ($year > 2037 OR $year < 1970) ? vbdate('Y', TIMENOW, false, false) : $year;
		$show['moveable'] = ($blockorder['block_archive']);
		$sidebar['calendar'] = construct_calendar($month, $year, $userinfo);
	}

	fetch_avatar_html($userinfo);
	fetch_profilepic_html($userinfo);

	$userinfo['joindate'] = vbdate($vbulletin->options['registereddateformat'], $userinfo['joindate']);
	$userinfo['posts'] = vb_number_format($userinfo['posts']);
	$userinfo['entries'] = vb_number_format($userinfo['entries']);

	// ########################## Get Recent Visitors #########################################
	if ($useblock['block_visitors'])
	{
		if ($vbulletin->options['profilemaxvisitors'] < 2)
		{
			$vbulletin->options['profilemaxvisitors'] = 2;
		}

		$hook_query_fields = $hook_query_joins = $hook_query_where = '';
		($hook = vBulletinHook::fetch_hook('blog_sidebar_user_visitors_query')) ? eval($hook) : false;

		// DISTINCT is nasty so add 5 to the limit as a fudge factor against pulling the same user twice (users can appear twice
		// due to stat tracking)
		$visitors_db = $vbulletin->db->query_read_slave("
			SELECT user.userid, user.username, user.usergroupid, user.displaygroupid, blog_visitor.visible
				$hook_query_fields
			FROM " . TABLE_PREFIX . "blog_visitor AS blog_visitor
			INNER JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = blog_visitor.visitorid)
			$hook_query_joins
			WHERE blog_visitor.userid = $userinfo[userid]
				" . (!($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) ? " AND (visible = 1 OR blog_visitor.visitorid = " . $vbulletin->userinfo['userid'] . ")" : "") . "
				$hook_query_where
			ORDER BY blog_visitor.dateline DESC
			LIMIT " . ($vbulletin->options['profilemaxvisitors'] + 5) . "
		");

		$visitors = array();
		while ($user = $vbulletin->db->fetch_array($visitors_db))
		{
			if (count($visitors) == $vbulletin->options['profilemaxvisitors'])
			{
				break;
			}
			$visitors["$user[username]"] = $user;
		}

		uksort($visitors, 'strnatcasecmp');

		if ($vbulletin->userinfo['buddylist'] = trim($vbulletin->userinfo['buddylist']))
		{
			$buddylist = preg_split('/\s+/', $vbulletin->userinfo['buddylist'], -1, PREG_SPLIT_NO_EMPTY);
		}
		else
		{
			$buddylist = array();
		}

		$visitorbits = '';
		$firstvisitor = true;
		foreach ($visitors AS $user)
		{
			fetch_musername($user);
			$user['invisiblemark'] = !$user['visible'] ? '*' : '';
			$user['buddymark'] = in_array($user['userid'], $buddylist) ? '+' : '';

			($hook = vBulletinHook::fetch_hook('blog_sidebar_user_visitors_loop')) ? eval($hook) : false;
			$templater = vB_Template::create('memberinfo_visitorbit');
				$templater->register('user', $user);
			$sidebar['visitorbits'] .=  $templater->render();
			$firstvisitor = false;
		}
		$sidebar['visitorcount'] = vb_number_format($vbulletin->db->num_rows($visitors_db));
	}

	//########################### Get Recent Comments #####################################
	if ($useblock['block_comments'])
	{
		$commentbits = '';
		$wheresql = array();
		$blogtextstate = array('visible');
		if (can_moderate_blog('canmoderatecomments') OR is_member_of_blog($vbulletin->userinfo, $userinfo))
		{
			$blogtextstate[] = 'moderation';
		}

		$blogstate = array('visible');
		if (can_moderate_blog('canmoderateentries') OR is_member_of_blog($vbulletin->userinfo, $userinfo))
		{
			$blogstate[] = 'moderation';
		}

		$wheresql = array(
			"blog.userid = $userinfo[userid]",
			"blog_text.blogtextid <> blog.firstblogtextid",
			"blog_text.state IN ('" . implode("','", $blogtextstate) . "')",
			"blog.state IN ('" . implode("','", $blogstate) . "')",
			"blog.dateline <= " . TIMENOW,
			"blog.pending = 0",
		);

		if (!empty($vbulletin->userinfo['blogcategorypermissions']['cantview']) AND $userinfo['userid'] != $vbulletin->userinfo['userid'])
		{
			$joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $vbulletin->userinfo['blogcategorypermissions']['cantview']) . "))";
			$wheresql[] = "cu.blogcategoryid IS NULL";
		}
		if (!can_moderate_blog() AND !is_member_of_blog($vbulletin->userinfo,  $userinfo) AND !$userinfo['buddyid'])
		{
			$wheresql[] = "~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'];
		}

		$hook_query_fields = $hook_query_joins = $hook_query_where = '';
		($hook = vBulletinHook::fetch_hook('blog_sidebar_user_comments_query')) ? eval($hook) : false;

		$comments = $vbulletin->db->query_read("
			SELECT blog.blogid, lastblogtextid AS blogtextid, blog_text.userid, blog_text.state, IF(blog_text.userid = 0, blog_text.username, user.username) AS username, blog.blogid, blog.title
			" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, user.avatarrevision, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
			$hook_query_fields
			FROM " . TABLE_PREFIX . "blog AS blog
			LEFT JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog.lastblogtextid = blog_text.blogtextid)
			LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog_text.userid = user.userid)
			" . ($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)" : "") . "
			$joinsql
			$hook_query_joins
			WHERE " . implode(" AND ", $wheresql) . "
			$hook_query_where
			ORDER BY blog.lastcomment DESC
			LIMIT 5
		");
		while ($comment = $vbulletin->db->fetch_array($comments))
		{
			$show['deleted'] = ($comment['state'] == 'deleted') ? true : false;
			$show['moderation'] = ($comment['state'] == 'moderation') ? true : false;

			if ($comment['hascustomavatar'] AND $vbulletin->options['avatarenabled'])
			{
				if ($vbulletin->options['usefileavatar'])
				{
					$comment['avatarurl'] = $vbulletin->options['avatarurl'] . '/avatar' . $comment['userid'] . '_' . $comment['avatarrevision'] . '.gif';
				}
				else
				{
					$comment['avatarurl'] = 'image.php?' . $vbulletin->session->vars['sessionurl'] . 'u=' . $comment['userid'] . '&amp;dateline=' . $comment['avatardateline'];
				}

				$comment['avwidthpx'] = intval($comment['avwidth']);
				$comment['avheightpx'] = intval($comment['avheight']);

				if ($comment['avwidth'] AND $comment['avheight'])
				{
					$comment['avwidth'] = 'width="' . $userinfo['avwidth'] . '"';
					$comment['avheight'] = 'height="' . $userinfo['avheight'] . '"';
				}
				else
				{
					$comment['avwidth'] = '';
					$comment['avheight'] = '';
				}
			}
			else
			{
				$comment['avatarurl'] = '';
			}

			($hook = vBulletinHook::fetch_hook('blog_sidebar_user_comments_loop')) ? eval($hook) : false;

			$templater = vB_Template::create('blog_sidebar_comment_link');
				$templater->register('comment', $comment);
				$templater->register('pageinfo', array('bt' => $comment['blogtextid']));
			$sidebar['commentbits'] .= $templater->render();
		}
	}

	//########################### Get Recent Entries #####################################
	if ($useblock['block_entries'])
	{
		$wheresql = array();
		$state = array('visible');

		if (can_moderate_blog('canmoderateentries') OR is_member_of_blog($vbulletin->userinfo, $userinfo))
		{
			$state[] = 'moderation';
		}

		if (is_member_of_blog($vbulletin->userinfo, $userinfo))
		{
			$state[] = 'draft';
		}
		else
		{
			$wheresql[] = "blog.dateline <= " . TIMENOW;
			$wheresql[] = "blog.pending = 0";
		}

		$wheresql[] = "blog.userid = $userinfo[userid]";
		$wheresql[] = "blog.state IN ('" . implode("','", $state) . "')";

		if (!empty($vbulletin->userinfo['blogcategorypermissions']['cantview']) AND $userinfo['userid'] != $vbulletin->userinfo['userid'])
		{
			$joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $vbulletin->userinfo['blogcategorypermissions']['cantview']) . "))";
			$wheresql[] = "cu.blogcategoryid IS NULL";
		}

		if (!can_moderate_blog() AND !is_member_of_blog($vbulletin->userinfo, $userinfo) AND !$userinfo['buddyid'])
		{
			$wheresql[] = "~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'];
		}

		$hook_query_fields = $hook_query_joins = $hook_query_where = '';
		($hook = vBulletinHook::fetch_hook('blog_sidebar_user_entries_query')) ? eval($hook) : false;

		// Recent Entries
		$entries = $vbulletin->db->query_read_slave("
			SELECT blog.blogid, blog.title, blog.dateline, blog.state, blog.pending
			" . ($deljoinsql ? ",blog_deletionlog.primaryid" : "") . "
			$hook_query_fields
			FROM " . TABLE_PREFIX . "blog AS blog
			$joinsql
			$hook_query_joins
			WHERE " . implode(" AND ", $wheresql) . "
			$hook_query_where
			ORDER BY blog.dateline DESC
			LIMIT 5
		");
		while ($entry = $vbulletin->db->fetch_array($entries))
		{
			if ($entry['dateline'] > TIMENOW OR $entry['pending'])
			{
				$status['phrase'] = $vbphrase['pending_blog_entry'];
				$status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/pending_small.gif";
				$show['status'] = true;
			}
			else if ($entry['state'] == 'deleted')
			{
				$status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/trashcan.gif";
				$status['phrase'] = $vbphrase['deleted_blog_entry'];
				$show['status'] = true;
			}
			else if ($entry['state'] == 'moderation')
			{
				$status['phrase'] = $vbphrase['moderated_blog_entry'];
				$status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/moderated.gif";
				$show['status'] = true;
			}
			else if ($entry['state'] == 'draft')
			{
				$status['phrase'] = $vbphrase['draft_blog_entry'];
				$status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/draft_small.gif";
				$show['status'] = true;
			}
			else
			{
				$show['status'] = false;
			}

			$entry['date'] = vbdate($vbulletin->options['dateformat'], $entry['dateline']);
			$entry['time'] = vbdate($vbulletin->options['timeformat'], $entry['dateline']);

			($hook = vBulletinHook::fetch_hook('blog_sidebar_user_entries_loop')) ? eval($hook) : false;

			$templater = vB_Template::create('blog_sidebar_entry_link');
				$templater->register('status', $status);
				$templater->register('entry', $entry);
				$templater->register('userinfo', $userinfo);
			$sidebar['entrybits'] .= $templater->render();
		}
	}

	if ($useblock['block_category'])
	{
		//########################### Get Category Bits #####################################
		$blog = array('userid' => $userinfo['userid'], 'title' => $userinfo['blog_title']);
		$categorybits = '';

		if (!empty($userinfo['categorycache']))
		{
			if (empty($userinfo['permissions']))
			{
				cache_permissions($userinfo, false);
			}

			$beenhere = $prevdepth = 0;
			foreach ($userinfo['categorycache'] AS $category)
			{
				$show['ul'] = $admincat = false;
				if (!$category['userid'])
				{
					if (!$vbulletin->blogcategorycache["{$category['blogcategoryid']}"])
					{
						continue;
					}
					$category['title'] = $vbphrase['category' . $category['blogcategoryid'] . '_title'];
					if (!($vbulletin->userinfo['blogcategorypermissions']["$category[blogcategoryid]"] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewcategory']) AND $userinfo['userid'] != $vbulletin->userinfo['userid'] )
					{
						continue;
					}
					$admincat = true;
				}
				else if (!($userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory']))
				{
					continue;
				}

				if (!$admincat AND $sidebar['globalcategorybits'] AND !$sidebar['localcategorybits'])
				{
					for ($x = $prevdepth; $x > 0; $x--)
					{
						$sidebar['globalcategorybits'] .= '</li></ul>';
					}
					$sidebar['globalcategorybits'] .= '</li>';
					$beenhere = $prevdepth = 0;
				}

				$indentbits = '';
				if ($category['depth'] == $prevdepth AND $beenhere)
				{
					$indentbits = '</li>';
				}
				else if ($category['depth'] > $prevdepth)
				{
					// Need an UL
					$show['ul'] = true;
				}
				else if ($category['depth'] < $prevdepth)
				{
					for ($x = ($prevdepth - $category['depth']); $x > 0; $x--)
					{
						$indentbits .= '</li></ul>';
					}
					$indentbits .= '</li>';
				}

				$show['catlink'] = ($vbulletin->GPC['blogcategoryid'] != $category['blogcategoryid']) ? true : false;
				if ($admincat)
				{
					$show['globalcats'] = true;

					$templater = vB_Template::create('blog_sidebar_category_link');
						$templater->register('category', $category);
						$templater->register('blog', $blog);
						$templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid']));
					$sidebar['globalcategorybits'] .= $templater->render();
				}
				else
				{
					$show['localcats'] = true;
					$templater = vB_Template::create('blog_sidebar_category_link');
						$templater->register('category', $category);
						$templater->register('blog', $blog);
						$templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid']));
					$sidebar['localcategorybits'] .= $templater->render();
				}

				$prevdepth = $category['depth'];
				$beenhere = true;
			}

			if ($sidebar['localcategorybits'])
			{
				for ($x = $prevdepth; $x > 0; $x--)
				{
					$sidebar['localcategorybits'] .= '</li></ul>';
				}
				$sidebar['localcategorybits'] .= '</li>';
			}
			else if ($sidebar['globalcategorybits'])
			{
				for ($x = $prevdepth; $x > 0; $x--)
				{
					$sidebar['globalcategorybits'] .= '</li></ul>';
				}
				$sidebar['globalcategorybits'] .= '</li>';
			}
		}

		if ($userinfo['uncatentries'])
		{
			$show['ul'] = false;
			$show['localcats'] = true;
			$blogcategoryid = -1;
			$category = array(
				'title'          => $vbphrase['uncategorized'],
				'entrycount'     => $userinfo['uncatentries'],
				'blogcategoryid' => $blogcategoryid,
			);
			$show['catlink'] = ($vbulletin->GPC['blogcategoryid'] != $blogcategoryid) ? true : false;

			$templater = vB_Template::create('blog_sidebar_category_link');
				$templater->register('category', $category);
				$templater->register('blog', $blog);
				$templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid']));
			$sidebar['localcategorybits'] .= $templater->render();
			$sidebar['localcategorybits'] .= '</li>';
		}

		$show['editcat'] = ($userinfo['userid'] == $vbulletin->userinfo['userid'] OR can_moderate_blog('caneditcategories'));
		$show['editcat_userid'] = ($userinfo['userid'] != $vbulletin->userinfo['userid']);
	}

	$show['subscribelink'] = ($vbulletin->userinfo['userid']);
	$show['blogsubscribed'] = $userinfo['blogsubscribed'];
	$show['pending'] = (is_member_of_blog($vbulletin->userinfo, $userinfo) AND $userinfo['blog_pending']);
	$show['draft'] = (is_member_of_blog($vbulletin->userinfo, $userinfo) AND $userinfo['blog_draft']);
	$show['approvecomments'] = (is_member_of_blog($vbulletin->userinfo, $userinfo) AND $userinfo['blog_comments_moderation']);

	if ($userinfo['blogid'])
	{
		$show['editentry'] = fetch_entry_perm('edit', $userinfo);

		$perform_floodcheck = (
			!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])
			AND $vbulletin->options['emailfloodtime']
			AND $vbulletin->userinfo['userid']
		);

		$show['emailentry'] = (
			$userinfo['state'] != 'visible'
				OR
			$userinfo['pending']
				OR
			!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canemail'])
				OR
			!$vbulletin->options['enableemail']
				OR
			(
				$perform_floodcheck
					AND
				($timepassed = TIMENOW - $vbulletin->userinfo['emailstamp']) < $vbulletin->options['emailfloodtime'])
			) ? false : true;
	}

	$show['emaillink'] = (
		$userinfo['showemail'] AND $vbulletin->options['displayemails'] AND (
			!$vbulletin->options['secureemail'] OR (
				$vbulletin->options['secureemail'] AND $vbulletin->options['enableemail']
			)
		) AND $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember']
	);
	$show['homepage'] = ($userinfo['homepage'] != '' AND $userinfo['homepage'] != 'http://');
	$show['pmlink'] = ($vbulletin->options['enablepms'] AND $vbulletin->userinfo['permissions']['pmquota'] AND ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']
 					OR ($userinfo['receivepm'] AND $vbulletin->perm_cache["{$userinfo['userid']}"]['pmquota'])
 				)) ? true : false;
 	$show['gotoblog'] = ($vbulletin->userinfo['userid'] AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']);
	$show['rssfeed'] = ($vbulletin->usergroupcache['1']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']) ? true : false;
	$show['categorylink'] = ($show['canpostitems'] AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory']);

	$usercsspermissions = array(
		'caneditfontfamily' => $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_caneditfontfamily'] ? true  : false,
		'caneditfontsize'   => $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_caneditfontsize'] ? true : false,
		'caneditcolors'     => $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_caneditcolors'] ? true : false,
		'caneditbgimage'    => ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums'] AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_caneditbgimage']) ? true : false,
		'caneditborders'    => $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_caneditborders'] ? true : false
	);
	$show['customizeblog'] = (in_array(true, $usercsspermissions) AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancustomizeblog']);

	if (
		$userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canhavegroupblog']
			OR
		$userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canjoingroupblog']
	)
	{
		$show['managegroupblog'] = true;
		$blogmembers = explode(',', $userinfo['memberids']);
		$show['groupblog'] = (count($blogmembers) > 1);
		$show['memberblog'] = (is_member_of_blog($vbulletin->userinfo, $userinfo) AND $userinfo['userid'] != $vbulletin->userinfo['userid']);
		$show['postgroupblog'] = (
			is_member_of_blog($vbulletin->userinfo, $userinfo)
				AND
			$vbulletin->userinfo['userid'] != $userinfo['userid']
				AND
			$userinfo['permissions']['vbblog_entry_permissions'] & $vbulletin->bf_ugp_vbblog_entry_permissions['blog_canpost']
				AND
			$userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']
		);
	}
	else
	{
		$show['groupblog'] = $show['managegroupblog'] = $show['postgroupblog'] = $show['memberblog'] = false;
	}

	$show['postblog'] = (
		$vbulletin->userinfo['userid']
			AND
		$vbulletin->userinfo['permissions']['vbblog_entry_permissions'] & $vbulletin->bf_ugp_vbblog_entry_permissions['blog_canpost']
			AND
		$vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']
	);

	$show['hidepostblogbutton'] = (THIS_SCRIPT == 'blog_post' AND in_array($_REQUEST['do'], array('editblog', 'newblog', 'comment')));

	if ($vbulletin->userinfo['userid'] AND !$userinfo['member_canviewmyblog'])
	{
		if (is_member_of_blog($vbulletin->userinfo, $userinfo))
		{
			$show['privateblog'] = true;
		}
		else if ($userinfo['buddyid'] AND $userinfo['buddy_canviewmyblog'])
		{
			$show['privateblog'] = $show['privateblog_contact'] = true;
		}
		else if (can_moderate_blog())
		{
			$show['privateblog'] = $show['privateblog_moderator'] = true;
		}
	}

	$userinfo['onlinestatus'] = 0;
	// now decide if we can see the user or not
	if ($userinfo['lastactivity'] > (TIMENOW - $vbulletin->options['cookietimeout']) AND $userinfo['lastvisit'] != $userinfo['lastactivity'])
	{
		if ($userinfo['invisible'])
		{
			if (($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) OR $vbulletin->userinfo['userid'] == $userinfo['userid'])
			{
				// user is online and invisible BUT bbuser can see them
				$userinfo['onlinestatus'] = 2;
			}
		}
		else
		{
			// user is online and visible
			$userinfo['onlinestatus'] = 1;
		}
	}

	if ($useblock['block_tagcloud'])
	{
		$sidebar['tagcloud'] = fetch_blog_tagcloud('usage', true, $userinfo['userid']);
	}
	if ($useblock['block_search'])
	{
		$sidebar['search'] = $show['blog_search'];
	}

	$blogrules = $rules ? construct_blog_rules($rules, $userinfo) : '';

	$customblockcount = 0;
	$moveableblocks = 0;
	foreach ($blockorder AS $blockname => $status)
	{
		switch($blockname)
		{
			case 'block_comments':
				$pageinfo = array('do' => 'comments');
				break;
			default:
				$pageinfo = array();
		}
		if ($status)
		{
			$show['moveable'] = true;
			if (preg_match('#^block_#', $blockname))
			{
				 $templater = vB_Template::create('blog_sidebar_user_' . $blockname);
					$templater->register('userinfo', $userinfo);
					$templater->register('sidebar', $sidebar);
					$templater->register('month', $month);
					$templater->register('year', $year);
					$templater->register('pageinfo', $pageinfo);
				$sidebar['user_customized_blocks'] .= $templater->render();
			}
			else if (!empty($customblock["$blockname"]) AND $customblockcount < $userinfo['permissions']['vbblog_customblocks']) // custom block
			{
				$collapseimg = $vbcollapse["collapseimg_blog_block_$blockname"];
				$collapseobj = $vbcollapse["collapseobj_blog_block_$blockname"];
				$block =& $customblock["$blockname"];
				$customblockcount++;
				$show['editblock'] = ($userinfo['userid'] == $vbulletin->userinfo['userid'] OR can_moderate_blog('caneditcustomblocks'));
				$templater = vB_Template::create('blog_sidebar_user_block_custom');
					$templater->register('block', $block);
					$templater->register('blockname', $blockname);
				$sidebar['user_customized_blocks'] .= $templater->render();
			}
			$moveableblocks++;
		}
		else if ($useblock["$blockname"])
		{
			$show['moveable'] = false;
				$templater = vB_Template::create('blog_sidebar_user_' . $blockname);
				$templater->register('userinfo', $userinfo);
				$templater->register('sidebar', $sidebar);
				$templater->register('month', $month);
				$templater->register('year', $year);
				$templater->register('pageinfo', $pageinfo);
			$sidebar["$blockname"] = $templater->render();
		}
	}

	if ($userinfo['permissions']['vbblog_custompages'] AND !empty($userinfo['custompages']['side']))
	{
		foreach ($userinfo['custompages']['side'] AS $page)
		{
			$templater = vB_Template::create('blog_sidebar_custompage_link');
				$templater->register('page', $page);
			$sidebar['custompages'] .= $templater->render();
		}
	}

	if ($moveableblocks > 1 AND $vbulletin->userinfo['userid'] == $userinfo['userid'])
	{
		$show['moveable_blocks'] = true;
	}

	$show['bloguserinfo'] = true;
	$blogrssinfo = array(
		'bloguserid' => $userinfo['bloguserid'],
		'blog_title' => $userinfo['blog_title'],
	);

	set_sidebar_ads($ad_location, $show);

	$headinclude .= construct_usercss_blog($userinfo, $show['blog_usercss_switch']);
	construct_usercss_switch_blog($show['blog_usercss_switch'], $blog_usercss_switch_phrase);

	($hook = vBulletinHook::fetch_hook('blog_sidebar_user_complete')) ? eval($hook) : false;

	$templater = vB_Template::create('blog_sidebar_user');
		$templater->register('ad_location', $ad_location);
		$templater->register('userinfo', $userinfo);
		$templater->register('sidebar', $sidebar);
		$templater->register('blogrules', $blogrules);
		$templater->register('pageinfo_markread', array('do' => 'markread', 'readhash' => $vbulletin->userinfo['logouthash']));
	return $templater->render();
}
示例#4
0
	/**
	* Process note as if a registered user posted
	*/
	function process_registered_user()
	{
		global $show, $vbphrase;

		fetch_musername($this->blog, 'displaygroupid');

		$this->blog['onlinestatus'] = 0;
		// now decide if we can see the user or not
		if ($this->blog['lastactivity'] > (TIMENOW - $this->registry->options['cookietimeout']) AND $this->blog['lastvisit'] != $this->blog['lastactivity'])
		{
			if ($this->blog['invisible'])
			{
				if (($this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canseehidden']) OR $this->blog['userid'] == $this->registry->userinfo['userid'])
				{
					// user is online and invisible BUT bbuser can see them
					$this->blog['onlinestatus'] = 2;
				}
			}
			else
			{
				// user is online and visible
				$this->blog['onlinestatus'] = 1;
			}
		}

		if (!isset($this->factory->perm_cache["{$this->blog['userid']}"]))
		{
			$this->factory->perm_cache["{$this->blog['userid']}"] = cache_permissions($this->blog, false);
		}
		else
		{
			$this->blog['permissions'] =& $this->factory->perm_cache["{$this->blog['userid']}"];
		}

		fetch_avatar_html($this->blog);
		fetch_profilepic_html($this->blog);

		$show['subscribelink'] = ($this->blog['userid'] != $this->registry->userinfo['userid'] AND $this->registry->userinfo['userid']);
		$show['blogsubscribed'] = $this->blog['blogsubscribed'];
		$show['entrysubscribed'] = $this->blog['entrysubscribed'];

		$show['emaillink'] = (
			$this->blog['showemail'] AND $this->registry->options['displayemails'] AND (
				!$this->registry->options['secureemail'] OR (
					$this->registry->options['secureemail'] AND $this->registry->options['enableemail']
				)
			) AND $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canemailmember']
		);
		$show['homepage'] = ($this->blog['homepage'] != '' AND $this->blog['homepage'] != 'http://');
		$show['pmlink'] = ($this->registry->options['enablepms'] AND $this->registry->userinfo['permissions']['pmquota'] AND ($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']
	 					OR ($this->blog['receivepm'] AND $this->factory->perm_cache["{$this->blog['userid']}"]['pmquota'])
	 				)) ? true : false;

	}