PermissionModel::saveAll PHP Méthode

saveAll() public méthode

public saveAll ( $Permissions, null $AllWhere = null )
$Permissions
$AllWhere null
    public function saveAll($Permissions, $AllWhere = null)
    {
        // Load the permission data corresponding to the where so unset permissions get ovewritten.
        if (is_array($AllWhere)) {
            $AllPermissions = $this->SQL->getWhere('Permission', $AllWhere)->resultArray();
            // Find the permissions that were loaded, but not saved.
            foreach ($AllPermissions as $i => $AllRow) {
                foreach ($Permissions as $SaveRow) {
                    if ($AllRow['RoleID'] == $SaveRow['RoleID'] && $AllRow['JunctionTable'] == $SaveRow['JunctionTable'] && $AllRow['JunctionID'] == $SaveRow['JunctionID']) {
                        unset($AllPermissions[$i]);
                        // saving handled already.
                        break;
                    }
                }
            }
            // Make all permission false that need to be saved here.
            foreach ($AllPermissions as &$AllRow) {
                foreach ($AllRow as $Name => $Value) {
                    if (strpos($Name, '.') !== false) {
                        $AllRow[$Name] = 0;
                    }
                }
            }
            if (count($AllPermissions) > 0) {
                $Permissions = array_merge($Permissions, $AllPermissions);
            }
        }
        foreach ($Permissions as $Row) {
            $this->save($Row);
        }
        // TODO: Clear the permissions for rows that aren't here.
    }