From a695628dcca9fb0ac11c693ee30483266bd1c08a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 1 May 2017 01:19:21 +0200 Subject: [PATCH] Added ACL support for menus See #2255 --- .../install/files/acp/templates/menuAdd.tpl | 235 +++++++++++------- .../files/lib/acp/form/MenuAddForm.class.php | 21 +- .../files/lib/acp/form/MenuEditForm.class.php | 5 + 3 files changed, 164 insertions(+), 97 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/menuAdd.tpl b/wcfsetup/install/files/acp/templates/menuAdd.tpl index 6402b54291..a79664de0e 100644 --- a/wcfsetup/install/files/acp/templates/menuAdd.tpl +++ b/wcfsetup/install/files/acp/templates/menuAdd.tpl @@ -24,114 +24,159 @@ {/if}
-
- -
-
- - {if $errorField == 'title'} - - {if $errorType == 'empty' || $errorType == 'multilingual'} - {lang}wcf.global.form.error.{@$errorType}{/lang} - {else} - {lang}wcf.acp.menu.title.error.{@$errorType}{/lang} - {/if} - - {/if} - {include file='multipleLanguageInputJavascript' elementIdentifier='title' forceSelection=false} -
- - - {if $action == 'add' || $menu->identifier != 'com.woltlab.wcf.MainMenu'} - -
+ {if $action == 'edit' && $menu->identifier == 'com.woltlab.wcf.MainMenu'} + {* editing the main menu *} +
+ +
- - - {if $errorField == 'position'} + + {if $errorField == 'title'} - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} + {if $errorType == 'empty' || $errorType == 'multilingual'} + {lang}wcf.global.form.error.{@$errorType}{/lang} {else} - {lang}wcf.acp.box.position.error.{@$errorType}{/lang} + {lang}wcf.acp.menu.title.error.{@$errorType}{/lang} {/if} {/if} + {include file='multipleLanguageInputJavascript' elementIdentifier='title' forceSelection=false}
+
+ {else} + {* anything, but the main menu *} +
+ -
-
-
- -
-
- - -
-
- - {if $errorField == 'cssClassName'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.box.cssClassName.error.{@$errorType}{/lang} +
+
+ +
+
+ + {if $errorField == 'title'} + + {if $errorType == 'empty' || $errorType == 'multilingual'} + {lang}wcf.global.form.error.{@$errorType}{/lang} + {else} + {lang}wcf.acp.menu.title.error.{@$errorType}{/lang} + {/if} + {/if} - - {/if} -
- + {include file='multipleLanguageInputJavascript' elementIdentifier='title' forceSelection=false} + + + + +
+
+ + + {if $errorField == 'position'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.box.position.error.{@$errorType}{/lang} + {/if} + + {/if} +
+ + +
+
+
+ +
+
+ + +
+
+ + {if $errorField == 'cssClassName'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.box.cssClassName.error.{@$errorType}{/lang} + {/if} + + {/if} +
+ + +
+
+
+ +
+
+
+
-
-
-
- -
-
-
-
-
- - -
-
-
-
- - -
-
-
    - {foreach from=$pageNodeList item=pageNode} - getDepth() > 1} style="padding-left: {$pageNode->getDepth()*20-20}px"{/if}> - - - {/foreach} -
-
-
- {/if} - - {event name='dataFields'} - +
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
    + {foreach from=$pageNodeList item=pageNode} + getDepth() > 1} style="padding-left: {$pageNode->getDepth()*20-20}px"{/if}> + + + {/foreach} +
+
+
+ + {event name='dataFields'} +
+
+ +
+ {include file='aclSimple'} +
+ + {/if} {event name='sections'} diff --git a/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php index b753c4911d..9e60537d5d 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php @@ -5,6 +5,7 @@ use wcf\data\menu\MenuAction; use wcf\data\menu\MenuEditor; use wcf\data\page\PageNodeTree; use wcf\form\AbstractForm; +use wcf\system\acl\simple\SimpleAclHandler; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\UserInputException; use wcf\system\language\I18nHandler; @@ -75,6 +76,12 @@ class MenuAddForm extends AbstractForm { */ public $pageIDs = []; + /** + * acl values + * @var array + */ + public $aclValues = []; + /** * @inheritDoc */ @@ -101,6 +108,7 @@ class MenuAddForm extends AbstractForm { if (isset($_POST['cssClassName'])) $this->cssClassName = StringUtil::trim($_POST['cssClassName']); if (isset($_POST['showHeader'])) $this->showHeader = intval($_POST['showHeader']); if (isset($_POST['pageIDs']) && is_array($_POST['pageIDs'])) $this->pageIDs = ArrayUtil::toIntegerArray($_POST['pageIDs']); + if (isset($_POST['aclValues']) && is_array($_POST['aclValues'])) $this->aclValues = $_POST['aclValues']; } /** @@ -188,10 +196,18 @@ class MenuAddForm extends AbstractForm { 'title' => 'wcf.menu.com.woltlab.wcf.genericMenu'.$menuEditor->menuID ]); } + + // save acl + SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $menuEditor->getDecoratedObject()->getBox()->boxID, $this->aclValues); + $this->saved(); // reset values - $this->title = ''; + $this->cssClassName = $this->title = ''; + $this->position = 'contentTop'; + $this->showOrder = 0; + $this->visibleEverywhere = $this->showHeader = 1; + $this->pageIDs = $this->aclValues = []; // show success message WCF::getTPL()->assign('success', true); @@ -217,7 +233,8 @@ class MenuAddForm extends AbstractForm { 'showHeader' => $this->showHeader, 'pageIDs' => $this->pageIDs, 'availablePositions' => Box::$availableMenuPositions, - 'pageNodeList' => (new PageNodeTree())->getNodeList() + 'pageNodeList' => (new PageNodeTree())->getNodeList(), + 'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues) ]); } } diff --git a/wcfsetup/install/files/lib/acp/form/MenuEditForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuEditForm.class.php index fcd60b872c..733c8e7a83 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuEditForm.class.php @@ -4,6 +4,7 @@ use wcf\data\box\BoxAction; use wcf\data\menu\Menu; use wcf\data\menu\MenuAction; use wcf\form\AbstractForm; +use wcf\system\acl\simple\SimpleAclHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\language\I18nHandler; use wcf\system\language\LanguageFactory; @@ -98,6 +99,8 @@ class MenuEditForm extends MenuAddForm { $boxAction->executeAction(); } + SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $this->menu->getBox()->boxID, $this->aclValues); + $this->saved(); // show success message @@ -120,6 +123,8 @@ class MenuEditForm extends MenuAddForm { $this->visibleEverywhere = $this->menu->getBox()->visibleEverywhere; $this->pageIDs = $this->menu->getBox()->getPageIDs(); $this->showHeader = $this->menu->getBox()->showHeader; + + $this->aclValues = SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.box', $this->menu->getBox()->boxID); } } -- 2.20.1