PermissionModel::cachePermissions PHP Méthode

cachePermissions() public méthode

public cachePermissions ( null $UserID = null, null $RoleID = null ) : array | null
$UserID null
$RoleID null
Résultat array | null
    public function cachePermissions($UserID = null, $RoleID = null)
    {
        if (!$UserID) {
            $RoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_GUEST);
        }
        // Select all of the permission columns.
        $PermissionColumns = $this->PermissionColumns();
        foreach ($PermissionColumns as $ColumnName => $Value) {
            $this->SQL->select('p.`' . $ColumnName . '`', 'MAX');
        }
        $this->SQL->from('Permission p');
        if (!is_null($RoleID)) {
            $this->SQL->where('p.RoleID', $RoleID);
        } elseif (!is_null($UserID)) {
            $this->SQL->join('UserRole ur', 'p.RoleID = ur.RoleID')->where('ur.UserID', $UserID);
        }
        $this->SQL->select(array('p.JunctionTable', 'p.JunctionColumn', 'p.JunctionID'))->groupBy(array('p.JunctionTable', 'p.JunctionColumn', 'p.JunctionID'));
        $Result = $this->SQL->get()->resultArray();
        return $Result;
    }