From af6b8b99603214810db850ad21a5c39f8d864494 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 28 Jan 2011 15:42:18 +0100 Subject: [PATCH] Simplify. --- horde/lib/Api.php | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/horde/lib/Api.php b/horde/lib/Api.php index eacd34c95..695613cd1 100644 --- a/horde/lib/Api.php +++ b/horde/lib/Api.php @@ -563,25 +563,21 @@ class Horde_Api extends Horde_Registry_Api throw new Horde_Exception(_("You are not allowed to change shares.")); } - $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); - $share = $shares->getShare($shareName); try { + $share = $GLOBALS['injector'] + ->getInstance('Horde_Core_Factory_Share') + ->create($scope) + ->getShare($shareName); $perm = $share->getPermission(); - } catch (Horde_Share_Exception $e) { - throw new Horde_Exception_Prior($e); - } - - foreach ($permissions as $permission) { - $permission = Horde_String::upper($permission); - if (defined('Horde_Perms::' . $permission)) { - $perm->addUserPermission($userName, constant('Horde_Perms::' . $permission), false); + foreach ($permissions as $permission) { + $permission = Horde_String::upper($permission); + if (defined('Horde_Perms::' . $permission)) { + $perm->addUserPermission($userName, constant('Horde_Perms::' . $permission), false); + } } - } - - try { $share->setPermission($perm); } catch (Horde_Share_Exception $e) { - throw new Horde_Exception_Prior($e); + throw new Horde_Exception($e); } } @@ -603,8 +599,6 @@ class Horde_Api extends Horde_Registry_Api throw new Horde_Exception(_("You are not allowed to change shares.")); } - $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create($scope); - $shares->getShare($shareName); try { $groups = $GLOBALS['injector']->getInstance('Horde_Group'); $groupId = $groups->getGroupId($groupName); @@ -612,15 +606,18 @@ class Horde_Api extends Horde_Registry_Api throw new Horde_Exception($e); } - $perm = $share->getPermission(); - foreach ($permissions as $permission) { - $permission = Horde_String::upper($permission); - if (defined('Horde_Perms::' . $permission)) { - $perm->addGroupPermission($groupId, constant('Horde_Perms::' . $permission), false); - } - } - try { + $share = $GLOBALS['injector'] + ->getInstance('Horde_Core_Factory_Share') + ->create($scope) + ->getShare($shareName); + $perm = $share->getPermission(); + foreach ($permissions as $permission) { + $permission = Horde_String::upper($permission); + if (defined('Horde_Perms::' . $permission)) { + $perm->addGroupPermission($groupId, constant('Horde_Perms::' . $permission), false); + } + } $share->setPermission($perm); } catch (Horde_Share_Exception $e) { throw new Horde_Exception($e); -- 2.11.0