function spaces_groupmask in Spaces 5
Provides a mask to OG settings mapping
Parameters
$op: 'mask' - Fetch the available masks. 'check' - Checks the provided definition against available masks. 'labels' - Fetch an list of avaiable masks suitalble for the forms api.
$og_settings: An associative array to compare to the available masks. Used with the 'check' op
Return value
Depends on the $op. For 'mask' returns the available mask definitions. For 'check' returns the mask key is a match is found, otherwise FALSE. For 'labels' and options array that can be used in a form.
4 calls to spaces_groupmask()
- spaces::testSpaces in tests/
spaces.test - spaces_features_form in ./
spaces_admin.inc - Define form for controlling features
- spaces_group_after_build in ./
spaces.module - Overrides og_selective and og_directory options based on whether a group is public/private
- _spaces_form_alter_group in ./
spaces.module
File
- ./
spaces.module, line 947
Code
function spaces_groupmask($op = 'mask', $og_settings = array()) {
static $spacetype_mask;
if (!$spacetype_mask) {
$spacetype_mask = array(
'private' => array(
'label' => t('Private'),
'limit options' => array(
SPACES_PRIVATE,
),
'mask' => array(
'og_selective' => OG_CLOSED,
'og_directory' => OG_DIRECTORY_NEVER,
'og_register' => OG_REGISTRATION_ALWAYS,
'og_private' => defined(OG_PRIVATE_GROUPS_ALWAYS) ? OG_PRIVATE_GROUPS_ALWAYS : 1,
),
),
'controlled' => array(
'label' => t('Controlled'),
'mask' => array(
'og_selective' => variable_get('spaces_controlled_selective', OG_CLOSED),
'og_directory' => OG_DIRECTORY_ALWAYS,
'og_register' => OG_REGISTRATION_ALWAYS,
'og_private' => defined(OG_PRIVATE_GROUPS_NEVER) ? OG_PRIVATE_GROUPS_NEVER : 0,
),
),
'public' => array(
'label' => t('Public'),
'limit options' => array(
SPACES_PUBLIC,
),
'mask' => array(
'og_selective' => OG_OPEN,
'og_directory' => OG_DIRECTORY_ALWAYS,
'og_register' => OG_REGISTRATION_ALWAYS,
'og_private' => defined(OG_PRIVATE_GROUPS_NEVER) ? OG_PRIVATE_GROUPS_NEVER : 0,
),
),
);
}
switch ($op) {
case 'mask':
return $spacetype_mask;
case 'check':
foreach ($spacetype_mask as $key => $type) {
if ($og_settings == $type['mask']) {
return $key;
}
}
return false;
case 'labels':
$labels = array();
foreach ($spacetype_mask as $key => $type) {
$labels[$key] = $type['label'];
}
return $labels;
}
}