/**
 * Fetches groups that the current user is a member of
 * If iconview is false, then the info for the listview will be fetched.
 *
 * @param boolean $iconview						Selects info for the icon view
 * @return array								Array of groupinfos
 */
function fetch_socialgroups_mygroups($iconview = true)
{
    global $vbulletin;
    $result = $vbulletin->db->query_read_slave("\n\t\tSELECT socialgroup.*, socialgroup.dateline AS createdate,\n\t\t\tsocialgroupmember.type AS membertype,\n\t\t\tgroupread.readtime" . ($iconview ? ",sgicon.dateline AS icondateline, sgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height" : ',socialgroupmember.dateline AS joindate, socialgroupmember.type AS membertype, sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid') . "\n\t\tFROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON (socialgroup.groupid = socialgroupmember.groupid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "groupread AS groupread ON (groupread.groupid = socialgroup.groupid\n\t\t\t\t\t\t\t\t\t\tAND groupread.userid = " . $vbulletin->userinfo['userid'] . ")" . ($iconview ? 'LEFT JOIN ' . TABLE_PREFIX . 'socialgroupicon AS sgicon ON sgicon.groupid = socialgroup.groupid' : 'INNER JOIN ' . TABLE_PREFIX . 'socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)') . "\n\t\tWHERE socialgroupmember.userid = " . $vbulletin->userinfo['userid'] . " AND socialgroupmember.type = 'member'\n\t\tORDER BY socialgroupmember.dateline DESC\n\t");
    $groups = array();
    while ($group = $vbulletin->db->fetch_array($result)) {
        $group = prepare_socialgroup($group);
        if (!$iconview) {
            $group['delete_group'] = can_delete_group($group);
            $group['edit_group'] = can_edit_group($group);
            $group['leave_group'] = can_leave_group($group);
            $group['group_options'] = ($group['delete_group'] or $group['edit_group'] or $group['leave_group']);
        }
        $groups[] = $group;
    }
    $vbulletin->db->free_result($result);
    return $groups;
}
Example #2
0
     $user =& $groupmember;
     ($hook = vBulletinHook::fetch_hook('group_memberbit')) ? eval($hook) : false;
     eval('$short_member_list_bits .= "' . fetch_template('memberinfo_tiny') . '";');
 }
 $navbits = array('group.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['social_groups'], '' => $group['name']);
 $show['groupoptions'] = false;
 $grouptypephrase = $vbphrase['group_desc_' . $group['type']];
 foreach (array('join', 'leave', 'edit', 'delete', 'manage', 'managemembers') as $groupoption) {
     switch ($groupoption) {
         case 'join':
             $allowedtojoin = can_join_group($group);
             $groupoptions['join'] = $allowedtojoin ? 'alt1' : '';
             $show['groupoptions'] = $allowedtojoin ? true : $show['groupoptions'];
             break;
         case 'leave':
             $allowedtoleave = can_leave_group($group);
             if ($allowedtoleave) {
                 switch ($group['membertype']) {
                     case 'member':
                         $leavephrase = $vbphrase['leave_social_group'];
                         break;
                     case 'invited':
                         $leavephrase = $vbphrase['decline_join_invitation'];
                         break;
                     case 'moderated':
                         $leavephrase = $vbphrase['cancel_join_request'];
                         break;
                 }
             }
             $groupoptions['leave'] = $allowedtoleave ? 'alt1' : '';
             $show['groupoptions'] = $allowedtoleave ? true : $show['groupoptions'];
Example #3
0
if ($_POST['do'] == 'doleave' or $_POST['do'] == 'dodelete' or $_POST['do'] == 'dojoin') {
    $vbulletin->input->clean_array_gpc('p', array('deny' => TYPE_NOHTML));
    // You either clicked no or you're a guest
    if ($vbulletin->GPC['deny']) {
        eval(print_standard_redirect('action_cancelled'));
    }
    if ($vbulletin->userinfo['userid'] == 0) {
        print_no_permission();
    }
    if ($vbulletin->url == $vbulletin->options['forumhome'] . '.php') {
        $vbulletin->url = 'group.php?' . $vbulletin->session->vars['sessionurl'] . "groupid={$group['groupid']}";
    }
}
// #######################################################################
if ($_POST['do'] == 'doleave') {
    if (!can_leave_group($group)) {
        if ($group['is_owner']) {
            standard_error(fetch_error('cannot_leave_group_if_owner'));
        } else {
            standard_error(fetch_error('invalidid', $vbphrase['social_group'], $vbulletin->options['contactuslink']));
        }
    }
    if (!empty($group['membertype'])) {
        $currentmemberentry = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "socialgroupmember WHERE userid = " . $vbulletin->userinfo['userid'] . " AND groupid = " . $vbulletin->GPC['groupid']);
        // remove us from the group if we're still in it
        if ($currentmemberentry) {
            $socialgroupmemberdm =& datamanager_init('SocialGroupMember', $vbulletin);
            $socialgroupmemberdm->set_existing($currentmemberentry);
            $socialgroupmemberdm->delete();
            unset($socialgroupmemberdm);
        }
/**
 * Fetches groups recently updated
 *
 * @return array								Array of groupinfos
 */
function fetch_socialgroups_updatedgroups()
{
	global $vbulletin;

	$result = $vbulletin->db->query_read_slave("
		SELECT socialgroup.*, socialgroup.dateline AS createdate,
			socialgroupmember.type AS membertype, socialgroupmember.dateline AS joindate,
			groupread.readtime
			,sgicon.dateline AS icondateline, sgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height
			,sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid
		FROM " . TABLE_PREFIX . "socialgroup AS socialgroup
		LEFT JOIN " . TABLE_PREFIX ."socialgroupmember AS socialgroupmember
			ON (socialgroup.groupid = socialgroupmember.groupid AND socialgroupmember.userid = " . $vbulletin->userinfo['userid'] . ")
		LEFT JOIN " . TABLE_PREFIX . "groupread AS groupread ON (groupread.groupid = socialgroup.groupid
										AND groupread.userid = " . $vbulletin->userinfo['userid'] . ")
		LEFT JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON sgicon.groupid = socialgroup.groupid
		INNER JOIN " . TABLE_PREFIX . "socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)
		ORDER BY socialgroup.lastupdate DESC
		LIMIT 0, 10
	");

	$groups = array();
	while ($group = $vbulletin->db->fetch_array($result))
	{
		$group['delete_group'] = can_delete_group($group);
		$group['edit_group'] = can_edit_group($group);
		$group['leave_group'] = can_leave_group($group);
		$group['group_options'] = ($group['delete_group'] OR $group['edit_group'] OR $group['leave_group']);

		$groups[] = $group;
	}
	$vbulletin->db->free_result($result);

	return $groups;
}
Example #5
0
/**
 * Fetches groups recently updated
 *
 * @return array								Array of groupinfos
 */
function fetch_socialgroups_updatedgroups()
{
    global $vbulletin;
    $hook_query_fields = $hook_query_joins = $hook_query_where = '';
    ($hook = vBulletinHook::fetch_hook('group_updatedgroups_query')) ? eval($hook) : false;
    $result = $vbulletin->db->query_read_slave("\n\t\tSELECT socialgroup.*, socialgroup.dateline AS createdate,\n\t\t\tsocialgroupmember.type AS membertype, socialgroupmember.dateline AS joindate,\n\t\t\tgroupread.readtime\n\t\t\t,sgicon.dateline AS icondateline, sgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height\n\t\t\t,sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid\n\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\t\tON (socialgroup.groupid = socialgroupmember.groupid AND socialgroupmember.userid = " . $vbulletin->userinfo['userid'] . ")\n\t\tLEFT JOIN " . TABLE_PREFIX . "groupread AS groupread ON (groupread.groupid = socialgroup.groupid\n\t\t\t\t\t\t\t\t\t\tAND groupread.userid = " . $vbulletin->userinfo['userid'] . ")\n\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON sgicon.groupid = socialgroup.groupid\n\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)\n\t\t{$hook_query_joins}\n\t\t{$hook_query_where}\n\t\tORDER BY socialgroup.lastupdate DESC\n\t\tLIMIT 0, 10\n\t");
    $groups = array();
    while ($group = $vbulletin->db->fetch_array($result)) {
        $group['delete_group'] = can_delete_group($group);
        $group['edit_group'] = can_edit_group($group);
        $group['leave_group'] = can_leave_group($group);
        $group['group_options'] = ($group['delete_group'] or $group['edit_group'] or $group['leave_group']);
        $groups[] = $group;
    }
    $vbulletin->db->free_result($result);
    return $groups;
}