Create a new GroupPermission entity for the provided $groupId, $path and $allowed setting.

@param int $groupId The group id
@param string $path The plugin controller action path.
@param bool|int $allowed The access level.
@return GroupPermission
772803
public function newEntityFor($groupId, $path, $allowed)
    {
        if (empty($this->_actionMap)) {
            $this->_actionMap = guardian()->getActionMap();
        }

        return $this->newEntity([
            'group_id' => $groupId,
            'path' => $path,
            'allowed' => $allowed,
            'plugin' => $this->_actionMap[$path]['plugin'],
            'controller' => $this->_actionMap[$path]['controller'],
            'action' => $this->_actionMap[$path]['action']
        ]);
    }
342118
public IdentityOperationResult createMembership(String userId, String groupId) {
    checkAuthorization(Permissions.CREATE, Resources.GROUP_MEMBERSHIP, groupId);
    UserEntity user = findUserById(userId);
    GroupEntity group = findGroupById(groupId);
    MembershipEntity membership = new MembershipEntity();
    membership.setUser(user);
    membership.setGroup(group);
    getDbEntityManager().insert(membership);
    createDefaultMembershipAuthorizations(userId, groupId);
    return new IdentityOperationResult(null, IdentityOperationResult.OPERATION_CREATE);
  }
596391
protected static function createPermission($name, $slug, $path)
    {
        $permissionModel = config('admin.database.permissions_model');

        $permissionModel::create([
            'name'      => $name,
            'slug'      => $slug,
            'http_path' => '/'.trim($path, '/'),
        ]);
    }
1229375
public static function createGlobalPermissions($globalPermissions, $id)
    {
        $query = [];

        if ($globalPermissions) {
            // Create global permissions
            foreach ($globalPermissions as $globalPermissionKey => $globalPermissionValue){
                if($globalPermissionValue) {
                    $query[] = array(
                        'groupID' => $id,
                        'app' => 'global',
                        'key' => $globalPermissionKey,
                        'value' => true,
                        'ids' => null,
                        'hasAll' => false,
                    );
                }
            }
        }
        return $query;
    }
1338367
public function moveUserGroup($groupPath, Request $request)
    {
        $userGroupLocation = $this->locationService->loadLocation(
            $this->extractLocationIdFromPath($groupPath)
        );

        $userGroup = $this->userService->loadUserGroup(
            $userGroupLocation->contentId
        );

        $locationPath = $this->requestParser->parseHref(
            $request->headers->get('Destination'),
            'groupPath'
        );

        try {
            $destinationGroupLocation = $this->locationService->loadLocation(
                $this->extractLocationIdFromPath($locationPath)
            );
        } catch (ApiExceptions\NotFoundException $e) {
            throw new Exceptions\ForbiddenException($e->getMessage());
        }

        try {
            $destinationGroup = $this->userService->loadUserGroup($destinationGroupLocation->contentId);
        } catch (ApiExceptions\NotFoundException $e) {
            throw new Exceptions\ForbiddenException($e->getMessage());
        }

        $this->userService->moveUserGroup($userGroup, $destinationGroup);

        return new Values\ResourceCreated(
            $this->router->generate(
                'ezpublish_rest_loadUserGroup',
                array(
                    'groupPath' => trim($destinationGroupLocation->pathString, '/') . '/' . $userGroupLocation->id,
                )
            )
        );
    }
590646
public function getDriveByGroup($groupId)
    {
        $groupLocator = "/groups/$groupId";
        $driveLocator = '/drive';
        $endpoint     = "$groupLocator$driveLocator";

        $response = $this
            ->graph
            ->createRequest('GET', $endpoint)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200) {
            throw new \Exception();
        }

        $drive = $response->getResponseAsObject(Model\Drive::class);

        return new DriveProxy($this->graph, $drive);
    }
992725
function resolveCommandPath(string $groupID, string $command) {
        $paths = array();
        
        foreach($this->commandsDirectories as $dir) {
            $paths[] = $dir.'/'.\mb_strtolower($groupID);
        }
        
        $paths[] = __DIR__.'/Commands/'.\mb_strtolower($groupID);
        $filename = '/'.\mb_strtolower($command).'.php';
        
        foreach($paths as $path) {
            $file = $path.$filename;
            if(\file_exists($file)) {
                return \realpath($file);
            }
        }
        
        throw new \InvalidArgumentException('Unable to resolve command path');
    }
252281
public function findUsersByGroupsForPaginate(PaginateFinderConfiguration $configuration, $groupId)
    {
        $qa = $this->createAggregationQuery();
        $qa->match(array('groups.$id' => new \MongoId($groupId)));

        $order = $configuration->getOrder();
        if (!empty($order)) {
            $qa->sort($order);
        }

        $qa->skip($configuration->getSkip());
        $qa->limit($configuration->getLimit());

        return $this->hydrateAggregateQuery($qa);
    }
90461
public function deleteUserGroup($groupPath)
    {
        $userGroupLocation = $this->locationService->loadLocation(
            $this->extractLocationIdFromPath($groupPath)
        );

        $userGroup = $this->userService->loadUserGroup(
            $userGroupLocation->contentId
        );

        // Load one user to see if user group is empty or not
        $users = $this->userService->loadUsersOfUserGroup($userGroup, 0, 1);
        if (!empty($users)) {
            throw new Exceptions\ForbiddenException('Non-empty user groups cannot be deleted');
        }

        $this->userService->deleteUserGroup($userGroup);

        return new Values\NoContent();
    }
389589
public function getGroupMember($groupId, $memberId)
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('groups/%d/members/%d', $groupId, $memberId))
		);
	}
924968
public function filePermission($path, $mode = self::CHMOD_775)
    {
        $results = array();
        $success = 0;
        if(file_exists($path)) {
            if(!is_writable($path))
                chmod($path, $mode);

            if(!is_readable($path))
                chmod($path, $mode);

            if(is_readable($path) && is_writable($path))
                $status = 1;
        }

        $results = array(
            'path' => $path,
            'mode' => $mode,
            'success' => $success
        );

        return Json::encode($results);
    }
250225
public Set<Integer> selectGroupIdsWithPermissionOnProjectBut(DbSession session, long projectId, String permission) {
    return mapper(session).selectGroupIdsWithPermissionOnProjectBut(projectId, permission);
  }
349068
public function getGroup ($groupID)
    {
        $groups = $this->getAllGroups();
        
        foreach ($groups as $group) {
            if ($group->getID() == $groupID) {
                return $group;
            }
        }
        
        return null;
    }
421634
public function setGroupId( $groupId )
    {
        $this->groupId = (int) $groupId ?: null;

        if ( $this->group && $this->group->id != $this->groupId )
        {
            $this->group = null;
        }

        return $this;
    }
1217196
public static function createPermissions($permissions, $id)
    {
        $query = [];

        if($permissions) {
            // create other permissions
            foreach($permissions as $appName => $app){
                foreach ($app as $permissionType => $permission){
                    if($permissionType == 'defaultPermissionsValues') {
                        foreach ($permission as $key){
                            $query[] = array(
                                'groupID' => $id,
                                'app' => $appName,
                                'key' => $key,
                                'value' => true,
                                'ids' => null,
                                'hasAll' => false,
                            );
                        }
                    }else if ($permissionType == 'customPermissionsValues') {
                        foreach($permission as $key => $object){
                            if (is_array($object)) {

                                if(count($object)) {
                                    $IDs = array();
                                    $c = 0;
                                    foreach($object as $value){
                                        $class = "App\\Models\\".$appName;
                                        $model = new $class();
                                        $IDs['ID'.$c] = $value[$model->getKeyName()];
                                        $c++;
                                    }
                                    $query[] = array(
                                        'groupID' => $id,
                                        'app' => $appName,
                                        'key' => $key,
                                        'value' => true,
                                        'ids' => json_encode($IDs),
                                        'hasAll' => false,
                                    );
                                }
                            }else{
                                if ($object) {
                                    $query[] = array(
                                        'groupID' => $id,
                                        'app' => $appName,
                                        'key' => $key,
                                        'value' => true,
                                        'ids' => null,
                                        'hasAll' => false,
                                    );
                                }
                            }
                        }
                    }else if ($permissionType == 'categoriesValues') {
                        if ($app['hasAll']) {
                            $query[] = array(
                                'groupID' => $id,
                                'app' => $appName,
                                'key' => 'categories',
                                'value' => true,
                                'ids' => null,
                                'hasAll' => true,
                            );
                        }else{
                            $IDs = array();
                            $c=0;
                            foreach ($permission as $category){
                                $IDs['ID'.$c] = $category['categoryID'];
                                $c++;
                            }
                            if (count($IDs)) {
                                $query[] = array(
                                    'groupID' => $id,
                                    'app' => $appName,
                                    'key' => 'categories',
                                    'value' => true,
                                    'ids' => json_encode($IDs),
                                    'hasAll' => false,
                                );
                            }
                        }
                    }
                }
            }
        }

        return $query;
    }
227764
public function mkdir($path, $permission = null, $recursive = false)
    {
        $fullPath = $this->concatPaths($path);

        if (file_exists($fullPath) && is_dir($path)) {
            return true;
        }

        $defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();

        if (!isset($permission)) {
            $permission = (string) $defaultPermissions['dir'];
            $permission = base_convert($permission, 8, 10);
        }

        try {
            $result = mkdir($fullPath, $permission, true);

            if (!empty($defaultPermissions['user'])) {
                $this->getPermissionUtils()->chown($fullPath);
            }

            if (!empty($defaultPermissions['group'])) {
                $this->getPermissionUtils()->chgrp($fullPath);
            }
        } catch (\Exception $e) {
            $GLOBALS['log']->critical('Permission denied: unable to create the folder on the server - '.$fullPath);
        }

        return isset($result) ? $result : false;
    }
579668
static public function create($groupId, $siteId, Site $site = null)
    {
        $instance = new self();

        $instance->group_id = $groupId;
        $instance->site_id = $siteId;

        return $instance;
    }