From bef5eeda9357e0cee7aaa828c6fb048a583f21d3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 18 Sep 2015 13:24:44 +0200 Subject: [PATCH] NavigationController: Fix action unshare() refs #5600 --- .../controllers/NavigationController.php | 27 +++++++++---------- .../views/scripts/navigation/shared.phtml | 4 +-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/application/controllers/NavigationController.php b/application/controllers/NavigationController.php index db02adb89..1716c98ef 100644 --- a/application/controllers/NavigationController.php +++ b/application/controllers/NavigationController.php @@ -277,26 +277,25 @@ class NavigationController extends Controller 'onSuccess' => function ($form) use ($navigationConfigForm) { try { $navigationConfigForm->unshare($form->getValue('name')); + if ($navigationConfigForm->save()) { + Notification::success(sprintf( + t('Navigation item "%s" has been unshared'), + $form->getValue('name') + )); + } else { + // TODO: It failed obviously to write one of the configs, so we're leaving the user in + // a inconsistent state. Luckily, it's nothing lost but possibly duplicated... + Notification::error(sprintf( + t('Failed to unshare navigation item "%s"'), + $form->getValue('name') + )); + } } catch (NotFoundError $e) { throw $e; } catch (Exception $e) { Notification::error($e->getMessage()); } - if ($navigationConfigForm->save()) { - Notification::success(sprintf( - t('Navigation item "%s" has been unshared'), - $form->getValue('name') - )); - } else { - // TODO: It failed obviously to write one of the configs, so we're leaving the user in - // a inconsistent state. Luckily, it's nothing lost but possibly duplicated... - Notification::error(sprintf( - t('Failed to unshare navigation item "%s"'), - $form->getValue('name') - )); - } - $redirect = $form->getValue('redirect'); if (! empty($redirect)) { $form->setRedirectUrl(htmlspecialchars_decode($redirect)); diff --git a/application/views/scripts/navigation/shared.phtml b/application/views/scripts/navigation/shared.phtml index a8bb69e13..7f148e3e3 100644 --- a/application/views/scripts/navigation/shared.phtml +++ b/application/views/scripts/navigation/shared.phtml @@ -38,8 +38,8 @@ 'block', sprintf( $this->translate( - 'This is a child of the navigation item %s. You can' - . ' only unshare this item by unsharing its parent' + 'This is a child of the navigation item %1$s. You can' + . ' only unshare this item by unsharing %1$s' ), $item->parent )