Пример #1
0
function au_subgroups_add_parent($event, $type, $object)
{
    // if we have an input, then we're setting the parent
    $parent_guid = get_input('au_subgroups_parent_guid', false);
    if ($parent_guid !== false) {
        au_subgroups_set_parent_group($object->guid, $parent_guid);
    }
    $parent = get_entity($parent_guid);
    // a few things that can stop subgroup creation
    // - no subgroups allowed
    // - not an admin/group-admin and members disallowed
    if (elgg_instanceof($parent, 'group')) {
        if ($parent->subgroups_enable == 'no') {
            return FALSE;
        }
        if ($parent->subgroups_members_create_enable == 'no') {
            // only group admins can create subgroups
            if (!$parent->canEdit()) {
                return FALSE;
            }
        }
    }
}
Пример #2
0
 $parent = get_entity($parent_guid);
 $oldparent = au_subgroups_get_parent_group($subgroup);
 $child_groups = au_subgroups_get_all_children_guids($subgroup);
 //sanity check
 if (!elgg_instanceof($subgroup, 'group') || !elgg_instanceof($parent, 'group')) {
     register_error(elgg_echo('au_subgroups:error:invalid:group'));
     forward(REFERER);
 }
 // we need to have edit permissions all the way up
 if (!au_subgroups_can_move_subgroup($subgroup, $parent)) {
     register_error(elgg_echo('au_subgroups:error:permissions'));
     forward(REFERER);
 }
 // remove any existing parent relationships
 au_subgroups_remove_parent_group($subgroup->guid);
 au_subgroups_set_parent_group($subgroup->guid, $parent->guid);
 // determine the access_id of the new group, must be equal or more restrictive than the parent
 switch ($parent->access_id) {
     case ACCESS_PUBLIC:
         // only need to check that subgroup wasn't to old parent only
         if ($subgroup->access_id == $oldparent->group_acl) {
             $subgroup->access_id = $parent->group_acl;
         }
         break;
     case ACCESS_LOGGED_IN:
         // subgroup cannot be public
         if ($subgroup->access_id == ACCESS_PUBLIC) {
             $subgroup->access_id = ACCESS_LOGGED_IN;
         } elseif ($subgroup->access_id == $oldparent->group_acl) {
             $subgroup->access_id = $parent->group_acl;
         }