From 4b761153993d39b25f1526c0bea889e03f4957c0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 29 Sep 2015 17:15:03 +0200 Subject: [PATCH] NavigationController: Require parameter type in action edit refs #10246 --- application/controllers/NavigationController.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/application/controllers/NavigationController.php b/application/controllers/NavigationController.php index 64abe9a51..e8f7879f3 100644 --- a/application/controllers/NavigationController.php +++ b/application/controllers/NavigationController.php @@ -267,14 +267,22 @@ class NavigationController extends Controller public function editAction() { $itemName = $this->params->getRequired('name'); + $itemType = $this->params->getRequired('type'); $referrer = $this->params->get('referrer', 'index'); + $user = $this->Auth()->getUser(); + if ($user->can('config/application/navigation')) { + $itemOwner = $this->params->get('owner', $user->getUsername()); + } else { + $itemOwner = $user->getUsername(); + } + $form = new NavigationConfigForm(); + $form->setUser($user); + $form->setShareConfig(Config::fromIni($this->getConfigPath($itemType))); + $form->setUserConfig(Config::fromIni($this->getConfigPath($itemType, $itemOwner))); $form->setRedirectUrl($referrer === 'shared' ? 'navigation/shared' : 'navigation'); - $form->setItemTypes($this->listItemTypes()); - $form->setTitle(sprintf($this->translate('Edit Navigation Item %s'), $itemName)); - $form->setUser($this->Auth()->getUser()); - $form->setShareConfig(Config::app('navigation')); + $form->setTitle(sprintf($this->translate('Edit %s %s'), $this->getItemLabel($itemType), $itemName)); $form->setOnSuccess(function (NavigationConfigForm $form) use ($itemName) { $data = array_map( function ($v) {