/** * Cannot do something? * * @param array|string $actions The name of the actions. * @param null|string $resType The type of the resources. * @param null|int $resId The identifier of the resources. * * @return bool */ static function cannot($actions, $resType = null, $resId = null) { if ($resType) { self::$resType = $resType; } if ($resId) { self::$resId = $resId; } $cannot = true; $actions = self::analyzeActions($actions); foreach ($actions as $action) { foreach ((array) self::$resType as $resType) { $isAllowed = self::searchPermission(true, $action, $resType); $isDenied = self::searchPermission(false, $action, $resType); if (self::$relax) { $cannot = $isDenied || !$isAllowed; if ($cannot) { break; } } else { $cannot = $cannot ? $isDenied || !$isAllowed : false; } } } self::$relax = false; return $cannot; }