function og_subgroups_can_edit_hierarchy in Subgroups for Organic groups 6
Access handler to check if the current user can edit the hierarchy of a given group, or group type
Parameters
$group: The group node object, or group type
Return value
TRUE if the user can edit the hierarchy of the given group, or group type, otherwise FALSE
2 calls to og_subgroups_can_edit_hierarchy()
- og_subgroups_add_group_select_form in includes/
form.inc - Add form components to select group parents on the group node form
- og_subgroups_og_create_links in ./
og_subgroups.module - Implementation of hook_og_create_links()
File
- ./
og_subgroups.module, line 340 - Maintains a hierarchy of groups created by the orgainc groups module.
Code
function og_subgroups_can_edit_hierarchy($group) {
og_subgroups_include('tree');
// Either a group node or type can be passed in
$type = is_object($group) ? $group->type : $group;
// Check that this is a group type
if (og_is_group_type($type)) {
// Check basic user permissions
if (user_access('edit groups hierarchy')) {
// Check that the user is a group admin, if we have a group yet
if ($group->nid && !og_is_group_admin($group)) {
return FALSE;
}
// Check that this type has hierarchy enabled
if (og_subgroups_is_subgroup_type($type)) {
return TRUE;
}
else {
if ($group->nid && og_subgroups_get_group_tree($group)) {
return TRUE;
}
}
}
}
return FALSE;
}