From ec37003a9aca87c4672f0729d7d8de538396a058 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Sat, 23 Nov 2013 18:36:40 +0200 Subject: [PATCH] revokeAll() implementation for PhpManager --- framework/yii/rbac/PhpManager.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/framework/yii/rbac/PhpManager.php b/framework/yii/rbac/PhpManager.php index a91d9bd..f3a68b5 100644 --- a/framework/yii/rbac/PhpManager.php +++ b/framework/yii/rbac/PhpManager.php @@ -221,6 +221,22 @@ class PhpManager extends Manager } /** + * Revokes all authorization assignments from a user. + * @param mixed $userId the user ID (see [[User::id]]) + * @return boolean whether removal is successful + */ + public function revokeAll($userId) + { + if (isset($this->_assignments[$userId]) && is_array($this->_assignments[$userId])) { + foreach ($this->_assignments[$userId] as $itemName => $value) + unset($this->_assignments[$userId][$itemName]); + return true; + } else { + return false; + } + } + + /** * Returns a value indicating whether the item has been assigned to the user. * @param mixed $userId the user ID (see [[User::id]]) * @param string $itemName the item name