From 4ea1f6c5065ec3ed4c697da280e9d964b6f55aac Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 1 Jan 2013 09:15:56 +0100 Subject: [PATCH] Adds IPermissionObject --- .../lib/data/IPermissionObject.class.php | 31 +++++++++++++++++++ .../data/category/ViewableCategory.class.php | 16 +++------- 2 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 wcfsetup/install/files/lib/data/IPermissionObject.class.php diff --git a/wcfsetup/install/files/lib/data/IPermissionObject.class.php b/wcfsetup/install/files/lib/data/IPermissionObject.class.php new file mode 100644 index 0000000000..934cb06974 --- /dev/null +++ b/wcfsetup/install/files/lib/data/IPermissionObject.class.php @@ -0,0 +1,31 @@ + + * @package com.woltlab.wcf.acl + * @subpackage data + * @category Community Framework + */ +interface IPermissionObject { + /** + * Checks if the active user has the given permissions for this object and + * throws a PermissionDeniedException if they don't have one of the permissions. + * + * @param array $permissions + */ + public function checkPermissions(array $permissions); + + /** + * Returns the permission value of the given permission for this object + * and the active user. + * + * @param string $permission + * @return mixed + */ + public function getPermission($permission); +} \ No newline at end of file diff --git a/wcfsetup/install/files/lib/data/category/ViewableCategory.class.php b/wcfsetup/install/files/lib/data/category/ViewableCategory.class.php index 691faa9e4c..27a1feaa56 100644 --- a/wcfsetup/install/files/lib/data/category/ViewableCategory.class.php +++ b/wcfsetup/install/files/lib/data/category/ViewableCategory.class.php @@ -1,12 +1,13 @@ @@ -14,7 +15,7 @@ use wcf\system\exception\PermissionDeniedException; * @subpackage data.category * @category Community Framework */ -class ViewableCategory extends DatabaseObjectDecorator { +class ViewableCategory extends DatabaseObjectDecorator implements IPermissionObject { /** * list of all parent category generations of this category * @var array @@ -39,10 +40,7 @@ class ViewableCategory extends DatabaseObjectDecorator { protected $permissions = null; /** - * Checks if the active user has all given permissions and throws a - * PermissionDeniedException if that isn't the case. - * - * @param array $permissions + * @see wcf\data\IPermissionObject::checkPermissions() */ public function checkPermissions(array $permissions) { foreach ($permissions as $permission) { @@ -82,11 +80,7 @@ class ViewableCategory extends DatabaseObjectDecorator { } /** - * Returns the acl permission value of the given permission for the active - * user and of this category. - * - * @param string $permission - * @return boolean + * @see wcf\data\IPermissionObject::getPermission() */ public function getPermission($permission) { if ($this->permissions === null) { -- 2.20.1