function og_list_permissions in Organic groups 7.2
Same name and namespace in other branches
- 7 og.module \og_list_permissions()
Helper function to generate standard node permission list for a given type.
Parameters
$type: The machine-readable name of the node type.
Return value
array An array of permission names and descriptions.
1 call to og_list_permissions()
- og_og_permission in ./
og.module - Implements hook_og_permission().
File
- ./
og.module, line 3446 - Enable users to create and manage groups with roles and permissions.
Code
function og_list_permissions($type) {
$info = node_type_get_type($type);
$type = check_plain($info->type);
$perms = array();
// Check type is of group content.
if (og_is_group_content_type('node', $type)) {
// Build standard list of node permissions for this type.
$perms += array(
"create {$type} content" => array(
'title' => t('Create %type_name content', array(
'%type_name' => $info->name,
)),
),
"update own {$type} content" => array(
'title' => t('Edit own %type_name content', array(
'%type_name' => $info->name,
)),
),
"update any {$type} content" => array(
'title' => t('Edit any %type_name content', array(
'%type_name' => $info->name,
)),
),
"delete own {$type} content" => array(
'title' => t('Delete own %type_name content', array(
'%type_name' => $info->name,
)),
),
"delete any {$type} content" => array(
'title' => t('Delete any %type_name content', array(
'%type_name' => $info->name,
)),
),
);
if (!module_exists('entityreference_prepopulate')) {
// We allow the create permission only on members, as otherwise we would
// have to iterate over every single group to decide if the user has
// permissions for it.
$perms["create {$type} content"]['roles'] = array(
OG_AUTHENTICATED_ROLE,
);
}
// Add default permissions.
foreach ($perms as $key => $value) {
$perms[$key]['default role'] = array(
OG_AUTHENTICATED_ROLE,
);
}
}
return $perms;
}