/**
 * Takes information regardign a group, and prepares the information within it
 * for display
 *
 * @param	array	Group Array
 * @param	bool	Whether to fetch group members and avatars
 *
 * @return	array	Group Array with prepared information
 *
 */
function prepare_socialgroup($group, $fetchmembers = false)
{
    global $vbulletin;
    if (!is_array($group)) {
        return array();
    }
    if ($fetchmembers) {
        $membersinfo = cache_group_members();
        $group['membersinfo'] = $membersinfo[$group['groupid']];
    }
    $group['joindate'] = !empty($group['joindate']) ? vbdate($vbulletin->options['dateformat'], $group['joindate'], true) : '';
    $group['createtime'] = !empty($group['createdate']) ? vbdate($vbulletin->options['timeformat'], $group['createdate'], true) : '';
    $group['createdate'] = !empty($group['createdate']) ? vbdate($vbulletin->options['dateformat'], $group['createdate'], true) : '';
    $group['lastupdatetime'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['timeformat'], $group['lastupdate'], true) : '';
    $group['lastupdatedate'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['dateformat'], $group['lastupdate'], true) : '';
    $group['visible'] = vb_number_format($group['visible']);
    $group['moderation'] = vb_number_format($group['moderation']);
    $group['members'] = vb_number_format($group['members']);
    $group['moderatedmembers'] = vb_number_format($group['moderatedmembers']);
    $group['categoryname'] = htmlspecialchars_uni($group['categoryname']);
    $group['discussions'] = vb_number_format($group['discussions']);
    $group['lastdiscussion'] = fetch_word_wrapped_string(fetch_censored_text($group['lastdiscussion']));
    $group['trimdiscussion'] = fetch_trimmed_title($group['lastdiscussion']);
    if (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
        // albums disabled in this group - force 0 pictures
        $group['picturecount'] = 0;
    }
    $group['rawpicturecount'] = $group['picturecount'];
    $group['picturecount'] = vb_number_format($group['picturecount']);
    $group['rawname'] = $group['name'];
    $group['rawdescription'] = $group['description'];
    $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
    if ($group['description']) {
        $group['shortdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 185)));
    } else {
        $group['shortdescription'] = $group['name'];
    }
    $group['mediumdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 1000)));
    $group['description'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($group['description'])));
    $group['is_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
    $group['is_automoderated'] = ($group['options'] & $vbulletin->bf_misc_socialgroupoptions['owner_mod_queue'] and $vbulletin->options['sg_allow_owner_mod_queue'] and !$vbulletin->options['social_moderation']);
    $group['canviewcontent'] = (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view']) or !$vbulletin->options['sg_allow_join_to_view'] or $group['membertype'] == 'member' or can_moderate(0, 'canmoderategroupmessages') or can_moderate(0, 'canremovegroupmessages') or can_moderate(0, 'candeletegroupmessages') or fetch_socialgroup_perm('canalwayspostmessage') or fetch_socialgroup_perm('canalwascreatediscussion'));
    $group['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $group['lastpost'], true);
    $group['lastposttime'] = vbdate($vbulletin->options['timeformat'], $group['lastpost']);
    $group['lastposterid'] = $group['canviewcontent'] ? $group['lastposterid'] : 0;
    $group['lastposter'] = $group['canviewcontent'] ? $group['lastposter'] : '';
    // check read marking
    //remove notice and make readtime determination a bit more clear
    if (!empty($group['readtime'])) {
        $readtime = $group['readtime'];
    } else {
        $readtime = fetch_bbarray_cookie('group_marking', $group['groupid']);
        if (!$readtime) {
            $readtime = $vbulletin->userinfo['lastvisit'];
        }
    }
    // get thumb url
    $group['iconurl'] = fetch_socialgroupicon_url($group, true);
    // check if social group is moderated to join
    $group['membermoderated'] = 'moderated' == $group['type'];
    // posts older than markinglimit days won't be highlighted as new
    $oldtime = TIMENOW - $vbulletin->options['markinglimit'] * 24 * 60 * 60;
    $readtime = max((int) $readtime, $oldtime);
    $group['readtime'] = $readtime;
    $group['is_read'] = $readtime >= $group['lastpost'];
    // Legacy Hook 'group_prepareinfo' Removed //
    return $group;
}
Esempio n. 2
0
    // Get group options
    $show['groupoptions'] = false;
    $groupoptions = fetch_groupoptions($group, $show['groupoptions']);
}
// #######################################################################
if ($_REQUEST['do'] == 'view') {
    $show['groupinfo'] = (!$vbulletin->GPC['pagenumber'] and !$vbulletin->GPC['perpage'] and !$vbulletin->GPC['searchtext']);
    if ($show['groupinfo']) {
        // first page -- main group page
        $navbits = array('group.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['social_groups'], 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'cat=' . $group['socialgroupcategoryid'] => $group['categoryname'], '' => $group['name']);
    } else {
        $navbits = array('group.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['social_groups'], 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'cat=' . $group['socialgroupcategoryid'] => $group['categoryname'], 'group.php?' . $vbulletin->session->vars['sessionurl'] . "groupid={$group['groupid']}" => $group['name'], '' => $vbphrase['group_discussions']);
    }
    if ($show['groupinfo']) {
        // Show group icon
        $groupiconurl = fetch_socialgroupicon_url($group);
        // Show members
        $groupmemberids = $vbulletin->db->query_read_slave("\n\t\t\tSELECT userfield.*, usertextfield.*, user.*, UNIX_TIMESTAMP(passworddate) AS passworddate,\n\t\t\t\tIF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid\n\t\t\t\t" . ($vbulletin->options['avatarenabled'] ? ', avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, customavatar.width as avwidth, customavatar.height as avheight, customavatar.filedata_thumb' : '') . ', customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight' . ", user.icq AS icq, user.aim AS aim, user.yahoo AS yahoo, user.msn AS msn, user.skype AS skype\n\t\t\tFROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = socialgroupmember.userid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON (user.userid = userfield.userid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid = user.userid)\n\t\t\t" . ($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) " : '') . "LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid) " . "WHERE socialgroupmember.groupid = " . $group['groupid'] . " AND socialgroupmember.type = 'member'\n\t\t\tORDER BY user.lastactivity DESC\n\t\t\tLIMIT 10\n\t\t");
        $members_shown = $vbulletin->db->num_rows($groupmemberids);
        while ($groupmember = $vbulletin->db->fetch_array($groupmemberids)) {
            $width = 0;
            $height = 0;
            fetch_avatar_from_userinfo($groupmember, true);
            fetch_musername($groupmember);
            $user = $groupmember;
            ($hook = vBulletinHook::fetch_hook('group_memberbit')) ? eval($hook) : false;
            eval('$short_member_list_bits .= "' . fetch_template('memberinfo_tiny') . '";');
        }
        $vbulletin->db->free_result($groupmemberids);
        // find recent pictures
        $show['pictures_block'] = ($group['canviewcontent'] and $group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'] and $permissions['albumpermissions'] & $vbulletin->bf_ugp_albumpermissions['canviewalbum'] and ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums'] and $vbulletin->options['socnet_groups_albums_enabled']));
Esempio n. 3
0
	// Create dm for icon and ensure icon filedata is set but thumbdata is empty, so that thumbs are rebuilt by the dm
	while ($icon = $vbulletin->db->fetch_array($result))
	{
		// some transaltion for group info
		$icon['icondateline'] = $icon['dateline'];

		echo construct_phrase($vbphrase['processing_x'], "$vbphrase[socialgroup_icon] $icon[groupid]<br />\n");
		vbflush();

		$filedata = false;

		if ($vbulletin->options['usefilegroupicon'])
		{
			$iconpath = fetch_socialgroupicon_url($icon, false, true, true);
			$thumbpath = fetch_socialgroupicon_url($group, true, true, true);
			$filedata = @file_get_contents($iconpath);
		}
		else
		{
			$filedata = $icon['filedata'];
		}

		if ($filedata)
		{
			$icondm = datamanager_init('SocialGroupIcon', $vbulletin, ERRTYPE_CP);
			$icondm->set_existing($icon);
			$icondm->set('thumbnail_filedata', false);
			$icondm->set('filedata', $filedata);
			$icondm->set_info('thumbnail_quality', $vbulletin->GPC['quality']);
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,\n\t\t\tdisc.discussionid, starter.postuserid AS poststarterid, starter.postusername AS poststarter,\n\t\t\tdisc.firstpostid, starter.title AS firsttitle, gr.groupid, gr.name AS groupname\n\t\t\t" . (vB::$vbulletin->options['avatarenabled'] ? ", avatar.avatarpath, user.userid, user.username,\n\t\t\t\tcustomavatar.userid AS hascustomavatar, customavatar.dateline AS avatardateline,\n\t\t\t\tcustomavatar.width AS avwidth,customavatar.height AS avheight, user.avatarrevision" : "") . " 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\t\t\t\t" . (vB::$vbulletin->options['avatarenabled'] ? "\nLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid =starter.postuserid) \nLEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON (avatar.avatarid = user.avatarid) \nLEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\t\tWHERE 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['timeformat']);
         if ($vbulletin->options['sg_enablesocialgroupicons']) {
             $template->register('socialgroupicon_url', fetch_socialgroupicon_url($item['groupid'], true));
         }
         if (vB::$vbulletin->options['avatarenabled']) {
             $template->register('avatar', fetch_avatar_from_record($item, true));
         }
         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;
 }