/**
 * Gets group options for view.
 *
 * @param array mixed $group					- Group information
 * @param bool &$result							- Whether any options were set
 * @return array mixed							- The resolved options
 */
function fetch_groupoptions(&$group, &$result)
{
    global $vbphrase, $show;
    $result = false;
    foreach (array('join', 'leave', 'edit', 'delete', 'manage', 'managemembers', 'transfergroup') as $groupoption) {
        switch ($groupoption) {
            case 'join':
                $allowedtojoin = can_join_group($group);
                $groupoptions['join'] = $allowedtojoin ? 'alt1' : '';
                $result = $allowedtojoin ? true : $result;
                break;
            case 'leave':
                $allowedtoleave = can_leave_group($group);
                if ($allowedtoleave) {
                    switch ($group['membertype']) {
                        case 'member':
                            $groupoptions['leavephrase'] = $vbphrase['leave_social_group'];
                            break;
                        case 'invited':
                            $groupoptions['leavephrase'] = $vbphrase['decline_join_invitation'];
                            break;
                        case 'moderated':
                            $groupoptions['leavephrase'] = $vbphrase['cancel_join_request'];
                            break;
                    }
                }
                $groupoptions['leave'] = $allowedtoleave ? 'alt1' : '';
                $result = $allowedtoleave ? true : $result;
                break;
            case 'edit':
                $allowedtoedit = can_edit_group($group);
                $groupoptions['edit'] = $allowedtoedit ? 'alt1' : '';
                $result = $allowedtoedit ? true : $result;
                break;
            case 'delete':
                $allowedtodelete = can_delete_group($group);
                $groupoptions['delete'] = $allowedtodelete ? 'alt1' : '';
                $result = $allowedtodelete ? true : $result;
                break;
            case 'manage':
                $allowedtomanage = fetch_socialgroup_modperm('caninvitemoderatemembers', $group);
                $groupoptions['manage'] = $allowedtomanage ? 'alt1' : '';
                $result = $allowedtomanage ? true : $result;
                break;
            case 'managemembers':
                $allowedtomanagemembers = fetch_socialgroup_modperm('canmanagemembers', $group);
                $groupoptions['managemembers'] = $allowedtomanagemembers ? 'alt1' : '';
                $result = $allowedtomanagemembers ? true : $result;
                break;
            case 'transfergroup':
                $allowedtotransfergroup = fetch_socialgroup_modperm('cantransfergroup', $group);
                $groupoptions['transfergroup'] = $allowedtotransfergroup ? 'alt1' : '';
                $result = $allowedtomanagemembers ? true : $result;
        }
    }
    return $groupoptions;
}
Exemple #2
0
    $templatename = 'socialgroups_pictures';
}
// #######################################################################
if ($_REQUEST['do'] == 'picture') {
    $vbulletin->input->clean_array_gpc('r', array('pictureid' => TYPE_UINT, 'pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'commentid' => TYPE_UINT, 'showignored' => TYPE_BOOL));
    if (!$vbulletin->userinfo['userid']) {
        print_no_permission();
    }
    if (!($permissions['albumpermissions'] & $vbulletin->bf_ugp_albumpermissions['canviewalbum']) or !($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums'] and $vbulletin->options['socnet_groups_albums_enabled'])) {
        print_no_permission();
    }
    if (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
        print_no_permission();
    }
    if ($group['membertype'] != 'member' and !can_moderate(0, 'caneditalbumpicture')) {
        if ($vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canjoingroups'] and can_join_group($group)) {
            standard_error(fetch_error('must_be_group_member_view_add_pictures_join_x', 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'do=join&groupid=' . $group['groupid']));
        } else {
            standard_error(fetch_error('must_be_group_member_view_add_pictures'));
        }
    }
    $pictureinfo = fetch_socialgroup_picture($vbulletin->GPC['pictureid'], $group['groupid']);
    if (!$pictureinfo) {
        standard_error(fetch_error('invalidid', $vbphrase['picture'], $vbulletin->options['contactuslink']));
    }
    $pictureinfo['adddate'] = vbdate($vbulletin->options['dateformat'], $pictureinfo['dateline'], true);
    $pictureinfo['addtime'] = vbdate($vbulletin->options['timeformat'], $pictureinfo['dateline']);
    $pictureinfo['caption_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($pictureinfo['caption'])));
    $navpictures_sql = $db->query_read_slave("\n\t\tSELECT socialgrouppicture.pictureid\n\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (socialgrouppicture.pictureid = picture.pictureid)\n\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON\n\t\t\t(socialgroupmember.userid = picture.userid AND socialgroupmember.groupid = {$group['groupid']} AND socialgroupmember.type = 'member')\n\t\tWHERE socialgrouppicture.groupid = {$group['groupid']}\n\t\tORDER BY socialgrouppicture.dateline DESC\n\t");
    $pic_location = fetch_picture_location_info($navpictures_sql, $pictureinfo['pictureid']);
    ($hook = vBulletinHook::fetch_hook('group_picture')) ? eval($hook) : false;