--- /dev/null
+<?php
+namespace wcf\data;
+
+/**
+ * Every object with permissions has to implement this interface.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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<string> $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
<?php
namespace wcf\data\category;
use wcf\data\DatabaseObjectDecorator;
+use wcf\data\IPermissionObject;
use wcf\system\category\CategoryPermissionHandler;
use wcf\system\exception\PermissionDeniedException;
/**
* Represents a viewable category.
- *
+ *
* @author Matthias Schmidt
* @copyright 2001-2012 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @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<wcf\data\category\ViewableCategory>
protected $permissions = null;
/**
- * Checks if the active user has all given permissions and throws a
- * PermissionDeniedException if that isn't the case.
- *
- * @param array<string> $permissions
+ * @see wcf\data\IPermissionObject::checkPermissions()
*/
public function checkPermissions(array $permissions) {
foreach ($permissions as $permission) {
}
/**
- * 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) {