function commons_wikis_og_user_access_alter in Drupal Commons 7.3
Implements hook_og_user_access_alter().
File
- modules/
commons/ commons_wikis/ commons_wikis.module, line 57
Code
function commons_wikis_og_user_access_alter(&$temp_perm, $context) {
// Only alter if we're dealing with updating wiki content.
if ($context['string'] != 'update any wiki content') {
return;
}
$account = $context['account'];
$group = $context['group'];
$group_type = $context['group_type'];
$wrapper = entity_metadata_wrapper($group_type, $group);
$entity_id = $wrapper
->getIdentifier();
$group_content_restricted = (bool) (!isset($wrapper->field_og_subscribe_settings)) || isset($wrapper->field_og_subscribe_settings) && $wrapper->field_og_subscribe_settings
->value() != 'anyone';
$user_is_member = (bool) og_is_member($group_type, $entity_id, 'user', $account, array(
OG_STATE_ACTIVE,
));
// Allow group members to be able to edit any wiki content within the group.
// Also grant access to non-members if both the group and content is public.
if (user_access('edit any wiki content', $account) && (!$group_content_restricted || $user_is_member)) {
$temp_perm['update any wiki content'] = TRUE;
}
}