Esempio n. 1
0
 // Build message bits for all items
 $messagebits = '';
 while ($item = $collection->fetch_item()) {
     if (!$do_discussions) {
         $discussion = fetch_socialdiscussioninfo($item['discussionid']);
         $group = fetch_socialgroupinfo($discussion['groupid']);
     } else {
         $group = fetch_socialgroupinfo($item['groupid']);
     }
     // add group name to message
     $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
     // force items to be visible
     if ('new' != $type) {
         $item['state'] = 'visible';
     }
     $bit =& $bitfactory->create($item, $group);
     $messagebits .= $bit->construct();
 }
 unset($bitfactory, $bit);
 // Set counts for view
 list($first, $last, $messageshown, $messagetotal) = array_values($collection->fetch_counts());
 // Legacy for templates
 $show['havemessages'] = (bool) $messagetotal;
 // Get actual resolved page number in case input was normalised
 $pagenumber = $show['pagenumber'] = $collection->fetch_pagenumber();
 $quantity = $collection->fetch_quantity();
 unset($collection_factory, $collection);
 // Add filters to pagenav
 $pagenavbits = array($do_discussions ? "do=viewdiscussions" : "do=viewgms");
 if ($perpage != ($do_discussions ? $vbulletin->options['sgd_perpage'] : $vbulletin->options['gm_perpage'])) {
     $pagenavbits[] = "pp={$perpage}";
Esempio n. 2
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;
 }
Esempio n. 3
0
     require_once DIR . '/includes/class_groupmessage.php';
     // create message collection
     $collection_factory = new vB_Group_Collection_Factory($vbulletin, $group);
     $collection = $collection_factory->create($messageinfo['gmid'] ? 'message' : 'recentmessage', $discussion['discussionid'], false, false, false, true);
     if ($messageinfo['gmid']) {
         $collection->filter_id($messageinfo['gmid']);
     } else {
         $collection->set_dateline($vbulletin->GPC['lastcomment'], $gmid);
     }
     // add hook for manipulating query
     $collection->set_query_hook('group_message_post_ajax');
     // create bit factory for rendering messages
     $bitfactory = new vB_Group_Bit_Factory($vbulletin, 'message');
     // build response for each message
     while ($message = $collection->fetch_item()) {
         $bit = $bitfactory->create($message, $group);
         if ($vbulletin->GPC['hideinlinemod']) {
             $bit->show_moderation_tools(false);
         }
         $xml->add_tag('message', process_replacement_vars($bit->construct()), array('gmid' => $message['gmid'], 'visible' => $message['state'] == 'visible' ? 1 : 0, 'bgclass' => $bgclass, 'quickedit' => 1));
     }
     unset($bitfactory, $bit, $collection_factory, $collection);
     exec_sg_mark_as_read('discussion', $discussion['discussionid'], $vbulletin->userinfo['username']);
     // send notifications
     if (!$messageinfo and $discussion['subscribers'] and !fetch_group_auto_moderation($group)) {
         exec_send_sg_notification($discussion['discussionid'], $gmid, $postusername = false);
     }
     $xml->add_tag('time', TIMENOW);
     $xml->close_group();
     $xml->print_xml(true);
 } else {
Esempio n. 4
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;
	}