From: Marcel Werk Date: Fri, 24 Jun 2016 09:58:13 +0000 (+0200) Subject: Added acl support for boxes X-Git-Tag: 3.0.0_Beta_1~1363 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=98889e94f52c66df06687828c2b9a996fe153c27;p=GitHub%2FWoltLab%2FWCF.git Added acl support for boxes --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index aca198bf12..2f06ec0aca 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1040,6 +1040,10 @@ com.woltlab.wcf.page com.woltlab.wcf.acl.simple + + com.woltlab.wcf.box + com.woltlab.wcf.acl.simple + diff --git a/wcfsetup/install/files/acp/templates/boxAdd.tpl b/wcfsetup/install/files/acp/templates/boxAdd.tpl index 3e5f8fb7eb..c8c8fc28d6 100644 --- a/wcfsetup/install/files/acp/templates/boxAdd.tpl +++ b/wcfsetup/install/files/acp/templates/boxAdd.tpl @@ -61,6 +61,7 @@
  • {lang}wcf.acp.box.general{/lang}
  • {lang}wcf.acp.box.contents{/lang}
  • {lang}wcf.acp.box.pages{/lang}
  • +
  • {lang}wcf.acp.box.acl{/lang}
  • {event name='tabMenuTabs'} @@ -421,6 +422,10 @@ + +
    + {include file='aclSimple'} +
    diff --git a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php index 98008c2b8e..8e3d547045 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php @@ -10,6 +10,7 @@ use wcf\data\object\type\ObjectTypeCache; use wcf\data\page\Page; use wcf\data\page\PageNodeTree; use wcf\form\AbstractForm; +use wcf\system\acl\simple\SimpleAclHandler; use wcf\system\box\IConditionBoxController; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\IllegalLinkException; @@ -168,6 +169,12 @@ class BoxAddForm extends AbstractForm { */ public $pageNodeList; + /** + * acl values + * @var array + */ + public $aclValues = []; + /** * @inheritDoc */ @@ -234,6 +241,7 @@ class BoxAddForm extends AbstractForm { if (isset($_POST['title']) && is_array($_POST['title'])) $this->title = ArrayUtil::trim($_POST['title']); if (isset($_POST['content']) && is_array($_POST['content'])) $this->content = ArrayUtil::trim($_POST['content']); if (isset($_POST['boxControllerID'])) $this->boxControllerID = intval($_POST['boxControllerID']); + if (isset($_POST['aclValues']) && is_array($_POST['aclValues'])) $this->aclValues = $_POST['aclValues']; if (WCF::getSession()->getPermission('admin.content.cms.canUseMedia')) { if (isset($_POST['imageID']) && is_array($_POST['imageID'])) $this->imageID = ArrayUtil::toIntegerArray($_POST['imageID']); @@ -421,6 +429,9 @@ class BoxAddForm extends AbstractForm { $this->boxController->getProcessor()->saveConditions(); } + // save acl + SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $box->boxID, $this->aclValues); + // call saved event $this->saved(); @@ -431,7 +442,7 @@ class BoxAddForm extends AbstractForm { $this->boxType = $this->position = $this->cssClassName = $this->name = ''; $this->showOrder = $this->boxControllerID = 0; $this->visibleEverywhere = $this->showHeader = 1; - $this->title = $this->content = $this->images = $this->imageID = $this->pageIDs = []; + $this->title = $this->content = $this->images = $this->imageID = $this->pageIDs = $this->aclValues = []; $this->boxController = null; } @@ -466,7 +477,8 @@ class BoxAddForm extends AbstractForm { 'availableBoxControllers' => ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.boxController'), 'boxController' => $this->boxController, 'pageNodeList' => $this->pageNodeList, - 'pageHandlers' => $this->pageHandlers + 'pageHandlers' => $this->pageHandlers, + 'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues) ]); } } diff --git a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php index 3d25f1cbb5..37ba3739da 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php @@ -4,6 +4,7 @@ use wcf\data\box\Box; use wcf\data\box\BoxAction; use wcf\data\object\type\ObjectTypeCache; use wcf\form\AbstractForm; +use wcf\system\acl\simple\SimpleAclHandler; use wcf\system\box\IConditionBoxController; use wcf\system\exception\IllegalLinkException; use wcf\system\language\LanguageFactory; @@ -119,6 +120,8 @@ class BoxEditForm extends BoxAddForm { $this->boxController->getProcessor()->saveConditions(); } + SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $this->box->boxID, $this->aclValues); + // call saved event $this->saved(); @@ -171,6 +174,8 @@ class BoxEditForm extends BoxAddForm { } } + $this->aclValues = SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.box', $this->box->boxID); + $this->readBoxImages(); } } diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 9b936b9092..ba8d6d05f8 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -5,6 +5,7 @@ use wcf\data\media\ViewableMedia; use wcf\data\menu\Menu; use wcf\data\menu\MenuCache; use wcf\data\object\type\ObjectTypeCache; +use wcf\system\acl\simple\SimpleAclResolver; use wcf\system\box\IBoxController; use wcf\system\box\IConditionBoxController; use wcf\system\condition\ConditionHandler; @@ -480,6 +481,15 @@ class Box extends DatabaseObject { return []; } + /** + * Returns true if this box is accessible by current user. + * + * @return boolean + */ + public function isAccessible() { + return SimpleAclResolver::getInstance()->canAccess('com.woltlab.wcf.box', $this->boxID); + } + /** * Returns the box with the given idnetifier. * diff --git a/wcfsetup/install/files/lib/system/box/BoxHandler.class.php b/wcfsetup/install/files/lib/system/box/BoxHandler.class.php index dba652554d..71d03185f7 100644 --- a/wcfsetup/install/files/lib/system/box/BoxHandler.class.php +++ b/wcfsetup/install/files/lib/system/box/BoxHandler.class.php @@ -47,9 +47,11 @@ class BoxHandler extends SingletonFactory { $boxList->sqlOrderBy = 'showOrder'; $boxList->readObjects(); foreach ($boxList as $box) { - if (!isset($this->boxes[$box->position])) $this->boxes[$box->position] = []; - $this->boxes[$box->position][] = $box; - $this->boxesByIdentifier[$box->identifier] = $box; + if ($box->isAccessible()) { + if (!isset($this->boxes[$box->position])) $this->boxes[$box->position] = []; + $this->boxes[$box->position][] = $box; + $this->boxesByIdentifier[$box->identifier] = $box; + } } }