Example #1
0
     $mygroups = fetch_socialgroup_random_groups();
 }
 // Get groupids to be displayed
 $groupids = array();
 if (!empty($updatedgroups)) {
     foreach ((array) $updatedgroups as $group) {
         $groupids[] = $group['groupid'];
     }
 }
 if (!empty($mygroups)) {
     foreach ((array) $mygroups as $group) {
         $groupids[] = $group['groupid'];
     }
 }
 // Cache group members info
 cache_group_members($groupids);
 unset($groupids);
 // Display groups that the current user created
 //	if ($owngroup = fetch_owner_socialgroup($vbulletin->userinfo['userid'], $vbulletin->GPC['owngrouppage']))
 //	{
 //		$owngroup = prepare_socialgroup($owngroup);
 //		($hook = vBulletinHook::fetch_hook('group_newgroup_bit')) ? eval($hook) : false;
 //		$templater = vB_Template::create('socialgroups_owngroup_bit');
 //			$templater->register('owngroup', $owngroup);
 //			$templater->register('template_hook', $template_hook);
 //		$owngroup = $templater->render();
 //	}
 $updatedgroupbits = '';
 foreach ($updatedgroups as $group) {
     $group = prepare_socialgroup($group, true);
     $group['canjoin'] = can_join_group($group);
/**
 * 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;
}
Example #3
0
     $mygroups = fetch_socialgroup_random_groups();
 }
 // Get groupids to be displayed
 $groupids = array();
 if (!empty($updatedgroups)) {
     foreach ((array) $updatedgroups as $group) {
         $groupids[] = $group['groupid'];
     }
 }
 if (!empty($mygroups)) {
     foreach ((array) $mygroups as $group) {
         $groupids[] = $group['groupid'];
     }
 }
 // Cache group members info
 cache_group_members(array_unique($groupids));
 unset($groupids);
 $updatedgroupbits = '';
 foreach ($updatedgroups as $group) {
     $group = prepare_socialgroup($group, true);
     $group['canjoin'] = can_join_group($group);
     $group['canleave'] = can_leave_group($group);
     $templater = vB_Template::create('socialgroups_updatedgroups_bit');
     $templater->register('group', $group);
     $templater->register('template_hook', $template_hook);
     $updatedgroupbits .= $templater->render();
 }
 unset($updatedgroups);
 // Render bits
 $mygroup_bits = '';
 foreach ($mygroups as $mygroup) {