src/Security/Permission.php
public static function get_groups_by_permission($codes)
    {
        $codeParams = is_array($codes) ? $codes : array($codes);
        $codeClause = DB::placeholders($codeParams);

        // Via Roles are groups that have the permission via a role
        /** @skipUpgrade */
        return Group::get()
            ->where(array(
                "\"PermissionRoleCode\".\"Code\" IN ($codeClause) OR \"Permission\".\"Code\" IN ($codeClause)"
                => array_merge($codeParams, $codeParams)
            ))
            ->leftJoin('Permission', "\"Permission\".\"GroupID\" = \"Group\".\"ID\"")
            ->leftJoin('Group_Roles', "\"Group_Roles\".\"GroupID\" = \"Group\".\"ID\"")
            ->leftJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\" = \"PermissionRole\".\"ID\"")
            ->leftJoin('PermissionRoleCode', "\"PermissionRoleCode\".\"RoleID\" = \"PermissionRole\".\"ID\"");
    }
public static function get_groups_by_permission($codes)
    {
        $codeParams = is_array($codes) ? $codes : array($codes);
        $codeClause = DB::placeholders($codeParams);

        // Via Roles are groups that have the permission via a role
        /** @skipUpgrade */
        return Group::get()
            ->where(array(
                "\"PermissionRoleCode\".\"Code\" IN ($codeClause) OR \"Permission\".\"Code\" IN ($codeClause)"
                => array_merge($codeParams, $codeParams)
            ))
            ->leftJoin('Permission', "\"Permission\".\"GroupID\" = \"Group\".\"ID\"")
            ->leftJoin('Group_Roles', "\"Group_Roles\".\"GroupID\" = \"Group\".\"ID\"")
            ->leftJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\" = \"PermissionRole\".\"ID\"")
            ->leftJoin('PermissionRoleCode', "\"PermissionRoleCode\".\"RoleID\" = \"PermissionRole\".\"ID\"");
    }
public static function get_groups_by_permission ( $ codes ) { $ codeParams = is_array ( $ codes ) ? $ codes : array ( $ codes ) ; $ codeClause = DB :: placeholders ( $ codeParams ) ; // Via Roles are groups that have the permission via a role /** @skipUpgrade */ return Group :: get ( ) -> where ( array ( "\"PermissionRoleCode\".\"Code\" IN ($codeClause) OR \"Permission\".\"Code\" IN ($codeClause)" => array_merge ( $ codeParams , $ codeParams ) ) ) -> leftJoin ( 'Permission' , "\"Permission\".\"GroupID\" = \"Group\".\"ID\"" ) -> leftJoin ( 'Group_Roles' , "\"Group_Roles\".\"GroupID\" = \"Group\".\"ID\"" ) -> leftJoin ( 'PermissionRole' , "\"Group_Roles\".\"PermissionRoleID\" = \"PermissionRole\".\"ID\"" ) -> leftJoin ( 'PermissionRoleCode' , "\"PermissionRoleCode\".\"RoleID\" = \"PermissionRole\".\"ID\"" ) ; }
Return all of the groups that have one of the given permission codes
@param array|string $codes Either a single permission code, or an array of permission codes
@return SS_List The matching group objects
Return all of the groups that have one of the given permission codes