Exemplo n.º 1
0
 /**
  * Create from the user id
  *
  * @param int $id
  * @return vB_Legacy_User
  */
 public static function createFromId($id, $extra_flags = 0)
 {
     $user = new vB_Legacy_User();
     if ($id == 0) {
         $user->initGuest();
     } else {
         $user->record = fetch_userinfo($id, $extra_flags);
     }
     return $user;
 }
Exemplo n.º 2
0
	/**
	 * vBCms_Rssfeed::makeRss()
	 * This is the function that processes the request. All the parameters
	 * we need are in vbulletin->GPC. The variables we look for are
	 * 'type' => TYPE_UINT,
	 * 'count' => TYPE_UINT,
	 * 'id' => TYPE_UINT,
	 * 'grouped' => TYPE_UINT,
	 * 'days' => TYPE_UINT, (date limit)
	 * 'detail' => TYPE_STR, (can be any extra info)
	 * 'name' => TYPE_STR
	 * We need at least the type, but the others may or may not be needed by
	 * a particular feed
	 *
	 * @param vB_Legacy_User
	 */
	public static function makeRss()
	{
		global $vbulletin;
		
		$user = vB_Legacy_User::createFromId(0);

		if (!intval($vbulletin->options['externalcache']) OR $vbulletin->options['externalcache'] > 1440)
		{
			$externalcache = 60;
		}
		else
		{
			$externalcache = $vbulletin->options['externalcache'];
		}

		$cachehash = md5(
			$vbulletin->GPC['days'] . '|' .
			$vbulletin->GPC['type'] . '|' .
			$vbulletin->GPC['count'] . '|' .
			$vbulletin->GPC['grouped'] . '|' .
			$vbulletin->GPC['detail'] . '|' .
			$vbulletin->GPC['name']
		);

		$result = vB_Cache::instance()->read($cachehash, true, false);

		if (!$result)
		{

			switch($vbulletin->GPC['type'])
			{
				case 'newposts':
					$result = self::getNewPosts($user);
					break;
				case 'newblogs':
					$result = self::getNewBlogs($user);
					break;
				case 'newcontent':
						$result = self::getNewContent($user);
					break;
				default:
					$result = '';
			} // switch
			vB_Cache::instance()->write($cachehash ,
				$result, $externalcache);
		}
		header('Content-Type: text/xml' . (vB_Template_Runtime::fetchStyleVar('charset') != '' ? '; charset=' .  vB_Template_Runtime::fetchStyleVar('charset') : ''));

		echo $result ;
	}
Exemplo n.º 3
0
 /**
  * Enter description here...
  *
  * @return unknown
  */
 public function render($current_user, $criteria, $template_name = '')
 {
     require_once DIR . "/includes/functions_socialgroup.php";
     require_once DIR . "/includes/class_groupmessage.php";
     $user = vB_Legacy_User::createFromIdCached($this->discussion->getUserId());
     $item = $this->discussion->getInfo($current_user->get_field('userid'));
     $item = array_merge($item, $user->get_record());
     $item['issearch'] = true;
     $group = $this->discussion->getSocialGroup();
     if ($group->has_modperm('canviewdeleted', $current_user)) {
         $dellog = $this->discussion->getDeletionLogArray();
         $item['del_username'] = $dellog['username'];
         $item['del_userid'] = $dellog['userid'];
         $item['del_reason'] = $dellog['reason'];
     }
     //I'm not sure what these are for, but they exist in the template so we should
     //make sure they are set.  The main message display code does not appear to
     //set them.
     global $show;
     $show['group'] = false;
     global $vbulletin;
     $factory = new vB_Group_Bit_Factory($vbulletin);
     $bit = $factory->create($item, $this->discussion->getSocialGroup()->get_record());
     //unfortunately the bit render can set the $show['inlinemod'] variable which we are
     //currently using across all templates to handle the inline mod settings.  We should
     //probably rely on something a little less global but that's not in the cards right now.
     //make sure that we honor the starting value and restore it when we are done.
     $inlinemod = $show['inlinemod'];
     $bit->show_moderation_tools($inlinemod);
     $text = $bit->construct();
     $show['inlinemod'] = $inlinemod;
     //todo this is ugly and invalid html.  We need to get the message_list
     //id out of here and convert the css to use a class for that formatting
     //but lets wait until we figure out what the new look and feel is going
     //do to or for us.
     return $text;
 }
Exemplo n.º 4
0
 /**
  * Process the actual deletes
  *
  * @param boolean $is_hard_delete
  * @param vB_Legacy_User $user
  * @param string $reason
  * @param boolean $keepattachments
  */
 protected function delete_internal($is_hard_delete, $user, $reason, $keepattachments)
 {
     global $vbulletin;
     $thread = $this->get_field('thread');
     $forum = $thread->get_field('forum');
     $postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
     $postman->set_existing($this->record);
     $postman->delete($forum->get_countposts(), $thread->get_field('threadid'), $is_hard_delete, array('userid' => $user->get_field('userid'), 'username' => $user->get_field('username'), 'reason' => $reason, 'keepattachments' => $keepattachments));
     unset($postman);
     build_thread_counters($threadinfo['threadid']);
     if ($forum->get_field('lastthreadid') != $thread->get_field('threadid')) {
         $forum->decrement_replycount();
     } else {
         // this thread is the one being displayed as the thread with the last post...
         // need to get the lastpost datestamp and lastposter name from the thread.
         build_forum_counters($thread->get_field('forumid'));
     }
 }
Exemplo n.º 5
0
 /**
  * Enter description here...
  *
  * @param boolean $is_hard_delete
  * @param vB_Legacy_User $user
  * @param String $reason
  * @param boolean $keepattachments
  */
 protected function delete_internal($is_hard_delete, $user, $reason, $keepattachments)
 {
     global $vbulletin;
     $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
     $threadman->set_existing($this->record);
     $forum = $this->get_forum();
     $threadman->delete($forum->get_field['replycount'], $is_hard_delete, array('userid' => $user->get_field('userid'), 'username' => $user->get_field('username'), 'reason' => $reason, 'keepattachments' => $keepattachments));
     unset($threadman);
     if ($forum->get_field('lastthreadid') != $this->get_field('threadid')) {
         $forum->decrement_threadcount();
     } else {
         // this thread is the one being displayed as the thread with the last post...
         // so get a new thread to display.
         build_forum_counters($this->get_field('forumid'));
     }
 }
Exemplo n.º 6
0
	/**
	 * Contructor
	 */
	public function __construct()
	{
		$this->record = $GLOBALS ['vbulletin']->userinfo;
		parent::__construct();
	}
Exemplo n.º 7
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,'?') ? '&' : '?';
					$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;

		}
	}
Exemplo n.º 8
0
	public function render($current_user, $criteria, $template_name = '')
	{
		require_once(DIR . "/includes/functions_socialgroup.php");
		require_once(DIR . "/includes/class_groupmessage.php");
		global $vbulletin;

		$user = vB_Legacy_User::createFromIdCached($this->message->getPostUserId(), FETCH_USERINFO_AVATAR);
		$item = $this->message->getInfo();
		if (strlen($template_name))
		{
			if ($record = vB::$vbulletin->db->query_first("SELECT gm.*, gr.groupid,
			disc.discussionid, starter.postuserid AS poststarterid, starter.postusername AS poststarter,
			disc.firstpostid, starter.title AS firsttitle, gr.groupid, gr.name AS groupname
			 FROM " . TABLE_PREFIX .
				"groupmessage AS gm\n INNER JOIN " . TABLE_PREFIX .
				"discussion AS disc ON disc.discussionid = gm.discussionid\n INNER JOIN " . TABLE_PREFIX .
				"socialgroup AS gr ON gr.groupid = disc.groupid\n INNER JOIN " . TABLE_PREFIX .
				"groupmessage AS starter ON starter.gmid = disc.firstpostid\n WHERE gm.gmid = " . $item['gmid'] ))
			{
				$item = array_merge($item, $record);
			}

			if (!$this->bbcode_parser)
			{
				$this->bbcode_parser = new vB_BbCodeParser(vB::$vbulletin, fetch_tag_list());
			}
			$item['previewtext'] = fetch_censored_text($this->bbcode_parser->get_preview($item['pagetext'], 200));
			$template = vB_Template::create($template_name);
			$template->register('item', $item);
			$template->register('dateformat', $vbulletin->options['dateformat']);
			$template->register('timeformat', $vbulletin->options['default_timeformat']);
			return $template->render();
		}

		$item = array_merge($item, $user->get_record());
		$item['hascustom'] = $item['hascustomavatar'];
		$item['issearch'] = true;

		$group = $this->message->getDiscussion()->getSocialGroup();
		if ($group->has_modperm('canviewdeleted', $current_user))
		{
			$dellog = $this->message->getDeletionLogArray();
			$item['del_username'] = $dellog['username'];
			$item['del_userid'] = $dellog['userid'];
			$item['del_reason'] = $dellog['reason'];
		}

		//I'm not sure what these are for, but they exist in the template so we should
		//make sure they are set.  The main message display code does not appear to
		//set them.
		global $show;
		$show['group'] = false;
		$show['discussion'] = false;

		//If we want to create our own template, then we need

		$factory = new vB_Group_Bit_Factory($vbulletin);
		//this gets lookup up by the bit anyway.  Not sure why we need to pass it.
		$group = array();
		$bit = $factory->create($item, $group);

		//unfortunately the bit render can set the $show['inlinemod'] variable which we are
		//currently using across all templates to handle the inline mod settings.  We should
		//probably rely on something a little less global but that's not in the cards right now.
		//make sure that we honor the starting value and restore it when we are done.
		$inlinemod =  $show['inlinemod'];
		$bit->show_moderation_tools($inlinemod);
		$text = $bit->construct();
		$show['inlinemod'] = $inlinemod;

		//todo this is ugly and invalid html.  We need to get the message_list
		//id out of here and convert the css to use a class for that formatting
		//but lets wait until we figure out what the new look and feel is going
		//do to or for us.
		return $text;
	}
Exemplo n.º 9
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;
	}