Determines whether the specified group has a certain ACL permission

@param   string $sSearch The permission to check for
@param   mixed  $mGroup  The group to check for;  if numeric, fetches group, if object
uses that object

@return  boolean
978644
public function hasPermission($sSearch, $mGroup)
    {
        //  Fetch the correct ACL
        if (is_numeric($mGroup)) {

            $oGroup = $this->getById($mGroup);

            if (isset($oGroup->acl)) {
                $aAcl = $oGroup->acl;
                unset($oGroup);
            } else {
                return false;
            }

        } elseif (isset($mGroup->acl)) {
            $aAcl = $mGroup->acl;
        } else {
            return false;
        }

        if (!$aAcl) {
            return false;
        }

        // --------------------------------------------------------------------------

        // Super users or CLI users can do anything their heart's desire
        $oInput = Factory::service('Input');
        if (in_array('admin:superuser', $aAcl) || $oInput::isCli()) {
            return true;
        }

        // --------------------------------------------------------------------------

        /**
         * Test the ACL
         * We're going to use regular expressions here so we can allow for some
         * flexibility in the search, i.e admin:* would return true if the user has
         * access to any of admin.
         */

        $bHasPermission = false;

        /**
         * Replace :* with :.* - this is a common mistake when using the permission
         * system (i.e., assuming that star on it's own will match)
         */

        $sSearch = preg_replace('/:\*/', ':.*', $sSearch);

        foreach ($aAcl as $sPermission) {

            $sPattern = '/^' . $sSearch . '$/';
            $bMatch   = preg_match($sPattern, $sPermission);

            if ($bMatch) {
                $bHasPermission = true;
                break;
            }
        }

        return $bHasPermission;
    }
386610
protected function disallowSingleGroupPermission($permission, $object, $group)
	{
		// check to see if the permission exists
		$permObject = $this->permission->findByPermissionAndObject($permission, $object);
		
		if($permObject)
		{
			$gop = $this->groupObjectPermission->findPermission($group, $object, $permObject);
			
			if($gop)
			{
				$this->groupObjectPermission->delete($gop);
			}
		}
	}
490847
public function searchGroups($search, $by, $limit = 1, $num = 1000, $page = 1)
    {
        $groups = $this->indexGroups($num, $page)['data'];

        $filtered = array_filter(
            $groups,
            function ($group) use ($search, $by) {

                if (array_key_exists($by, $group)) {
                    if (strpos($group[$by], $search) !== false) {
                        return $group;
                    }
                    if ($group[$by] === $search) {
                        return $group;
                    }
                }

                return false;
            }
        );

        if ($limit == 1) {
            return array_shift($filtered);
        }

        return array_slice($filtered, 0, $limit);
    }
1338819
public function inGroup($group = null) {
    if (is_numeric($group)) {
      $group = Group::factory((int) $group);
    }
    if (!isset($group->guid)) {
      return false;
    }
    return ($group->inArray((array) $this->groups) || $group->is($this->group));
  }
966412
public function getRuleResultsByGroup($group)
    {
        $results = [];
        foreach ($this->getRuleResults() as $rule => $ruleResult) {
            if (in_array($group, $ruleResult->getGroups())) {
                $results[$rule] = $ruleResult;
            }
        }

        return $results;
    }
270856
public function checkPermission($permission)
    {
        $roleAttribute = "can_{$permission}";
        return isset($this->$roleAttribute) ? (bool)$this->$roleAttribute : false;
    }
425733
public function userCan($permission, $object, $user = null)
	{
		// if no user is specified, default to the Auth one
		if(is_null($user))
		{
			$user = app('auth')->user();
		}
		
		$adminGroups = $this->groupProvider()->findAdminGroups();
		
		if($adminGroups->count() > 0 && $user->inGroup($adminGroups))
			return true;
		
		// find the exact permission for the object
		$permObject = $this->permission->findByPermissionAndObject($permission, $object);
		
		// if the permission object doesn't exist, then they don't have access
		if(!$permObject)
			return false;
		
		// if the user has direct permission, allow
		$uop = $this->userObjectPermission->findPermission($user, $object, $permObject);
		
		if($uop)
			return true;
		
		// get all the groups that have that specific permission on the object
		$gop = $this->groupObjectPermission->findPermissions($object, $permObject);
		
		// if there are no groups, deny
		if(count($gop) == 0)
			return false;
		
		// get all the relevant groups
		$groups = array();
		foreach($gop as $onePermission)
		{
			$groups[] = $onePermission->getGroup();
		}
		
		// allow or deny based on whether the user is in those groups
		return $user->inGroup($groups);
	}
73873
protected void addGroupCondition(CmsSelectQuery select, TableAlias users, CmsUserSearchParameters searchParams) {

        CmsGroup group = searchParams.getGroup();
        if (group != null) {
            CmsUUID groupId = group.getId();
            TableAlias groupUsers = select.addTable(tabGroupUsers(), "groupusrs");
            select.addCondition(
                new CmsSimpleQueryFragment(groupUsers.column(colGroupUserGroupId()) + " = ? ", groupId.toString()));
            select.addCondition(
                new CmsSimpleQueryFragment(groupUsers.column(colGroupUserUserId()) + " = " + users.column(colId())));
            if (searchParams.isFilterByGroupOu()) {
                select.addCondition(new CmsSimpleQueryFragment(users.column(colOu()) + " = ? ", group.getOuFqn()));
            }
        }
        CmsGroup notGroup = searchParams.getNotGroup();
        if (notGroup != null) {
            CmsSimpleQueryFragment notGroupCondition = new CmsSimpleQueryFragment(
                "NOT EXISTS (SELECT "
                    + getGroupUserSubqueryColumns()
                    + " FROM "
                    + tabGroupUsers()
                    + " GU WHERE GU."
                    + colGroupUserUserId()
                    + " = "
                    + users.column(colId())
                    + " AND GU."
                    + colGroupUserGroupId()
                    + " = ?)",
                notGroup.getId().toString());
            select.addCondition(notGroupCondition);
        }

        Collection<CmsGroup> anyGroups = searchParams.getAnyGroups();
        if ((anyGroups != null) && !anyGroups.isEmpty()) {
            CmsCompositeQueryFragment groupClause = new CmsCompositeQueryFragment();
            groupClause.setSeparator(" OR ");
            for (CmsGroup grp : anyGroups) {
                groupClause.add(
                    new CmsSimpleQueryFragment("GU." + colGroupUserGroupId() + " = ?", grp.getId().toString()));
            }
            CmsCompositeQueryFragment existsClause = new CmsCompositeQueryFragment();
            existsClause.add(
                new CmsSimpleQueryFragment(
                    "EXISTS (SELECT "
                        + getGroupUserSubqueryColumns()
                        + " FROM "
                        + tabGroupUsers()
                        + " GU WHERE GU."
                        + colGroupUserUserId()
                        + " = "
                        + users.column(colId())
                        + " AND "));
            existsClause.add(groupClause);
            existsClause.add(new CmsSimpleQueryFragment(" ) "));
            select.addCondition(existsClause);
        }
        Collection<CmsGroup> notAnyGroups = searchParams.getNotAnyGroups();
        if ((notAnyGroups != null) && (!notAnyGroups.isEmpty())) {
            CmsCompositeQueryFragment groupClause = new CmsCompositeQueryFragment();
            groupClause.setPrefix("(");
            groupClause.setSuffix(")");
            groupClause.setSeparator(" OR ");
            for (CmsGroup grp : notAnyGroups) {
                groupClause.add(
                    new CmsSimpleQueryFragment("GU." + colGroupUserGroupId() + " = ?", grp.getId().toString()));
            }
            CmsCompositeQueryFragment notExistsClause = new CmsCompositeQueryFragment();
            notExistsClause.add(
                new CmsSimpleQueryFragment(
                    "NOT EXISTS (SELECT "
                        + getGroupUserSubqueryColumns()
                        + " FROM "
                        + tabGroupUsers()
                        + " GU WHERE GU."
                        + colGroupUserUserId()
                        + " = "
                        + users.column(colId())
                        + " AND "));
            notExistsClause.add(groupClause);
            notExistsClause.add(new CmsSimpleQueryFragment(" ) "));
            select.addCondition(notExistsClause);
        }
    }
1302735
public function hasPermission(string $name): bool
    {
        $permissions = $this->getPermissions();
        if (array_search('all', $permissions) !== false) {
            return true;
        }
        return array_search($name, $permissions) !== false;
    }
531218
public function hasPermission($recipient, $permission)
    {

        if ($recipient instanceof Group) {
            $check = true;
            foreach ($recipient->getLogins() as $login) {
                if ($this->hasLoginPermission($login, $permission) === false) {
                    $check = false;
                }
            }

            return $check;
        } else {
            return $this->hasLoginPermission($recipient, $permission);
        }
    }
736434
public static void checkSuperuserPrivilege(UserGroupInformation owner, 
                                             String supergroup) 
  throws AccessControlException {
    PermissionChecker checker = 
      new PermissionChecker(owner.getUserName(), supergroup);
    if (!checker.isSuper) {
      throw new AccessControlException("Access denied for user " 
          + checker.user + ". Superuser privilege is required");
    }
  }
585456
protected function getMatchingAuthzGroup($permissionAuthzGroup, array $authzGroups)
    {
        $invert = $this->stringStartsWith($permissionAuthzGroup, '!');
        
        if ($invert) {
            $permissionAuthzGroup = substr($permissionAuthzGroup, 1);
        }
        
        $matches = [];
        
        foreach ($authzGroups as $authzGroup) {
            $match = $this->authzGroupsAreEqual($permissionAuthzGroup, $authzGroup);
            
            if ($match && $invert) {
                return null;
            }
            
            if ($match && !$invert || !$match && $invert) {
                $matches[] = $authzGroup;
            }
        }
        
        return !empty($matches) ? $matches[0] : null;
    }
1305642
function (set1, set2) {
				
		if (set1 instanceof Array === false ||
			set2 instanceof Array === false)
			return false;
		
		// return true if at least one match is found
		for (var i=0; i < set1.length; i++) {
			for (var j=0; j < set2.length; j++) {
				if (set1[i] === set2[j]) {
                    //console.log("matched group/permission: " + set1[i]);
					return true;
                }
            }
        }
		return false;
	}
857549
public function IsInArticleGroups($aGroupList)
    {
        $bIsInGroups = false;
        $aArticleGroups = $this->GetMLTIdList('shop_article_group');
        $aIntersec = array_intersect($aArticleGroups, $aGroupList);

        if (0 == count($aIntersec) && 0 == count($aArticleGroups) && $this->IsVariant()) {
            $oParent = &$this->GetFieldVariantParent();
            if ($oParent) {
                $bIsInGroups = $oParent->IsInArticleGroups($aGroupList);
            }
        } else {
            $bIsInGroups = (count($aIntersec) > 0);
        }

        return $bIsInGroups;
    }
379043
@Override
    public boolean rmGroup(Node node) {
        LdapGroup group = (LdapGroup) node;
        try {
            deletionCount++;
            ctx.unbind(getOuForNode(group));
        } catch (NamingException ex) {
            handleNamingException(group, ex);
        }
        Node ldapGroup = getGroup(group.getCn());
        return ldapGroup.isEmpty();
    }
1319251
protected static function isValidGroupId($group)
    {
        if (empty($group)) {
            echo new \Exception('group('.var_export($group, true).') empty');
            return false;
        }
        return true;
    }
552870
public function checkKeyExists($key,$group,$allowempty = false) {
		if (!$this->locale || $this->locale == '') {
			return false;
		}
		
		$data = $this->loadDataForGroup($group,$allowempty);
		
		if (isset($data[$key])) {
			// check if data are in a file
			if (strpos($data[$key],'file:') === 0) {
				$filname = substr($data[$key],5);
				$file_path = $this->localespath.$this->locale.'/files/'.$filname;
				
				if (@file_exists($file_path)) {
					return true;
				}
				
				return false;
			}
			return true;
		}
		
		return false;
	}