From: Michael M Slusarz Date: Tue, 24 Nov 2009 05:40:19 +0000 (-0700) Subject: Add Horde_Perms::hasAppPermission() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1db320d9df3d7978e9419591bc5a605e3adbff41;p=horde.git Add Horde_Perms::hasAppPermission() --- diff --git a/framework/Perms/lib/Horde/Perms.php b/framework/Perms/lib/Horde/Perms.php index 83e455509..f709dd1a8 100644 --- a/framework/Perms/lib/Horde/Perms.php +++ b/framework/Perms/lib/Horde/Perms.php @@ -434,6 +434,41 @@ class Horde_Perms } /** + * Finds out if the user has the specified rights to the given object, + * specific to a certain application. + * + * @param string $permission The permission to check. + * @param array $opts Additional options: + *
+     * 'app' - (string) The app to check.
+     *         DEFAULT: The current pushed app.
+     * 'opts' - (array) Additional options to pass to the app function.
+     *          DEFAULT: None
+     * 
+ * + * @return boolean Whether the user has the specified permissions. + */ + public function hasAppPermission($permission, $opts = array()) + { + $app = isset($opts['app']) + ? $opts['app'] + : $GLOBALS['registry']->getApp(); + + if ($this->exists($app . ':' . $permission)) { + $args = array($this->getPermissions($app . ':' . $permission)); + if (isset($opts['opts'])) { + $args[] = $opts['opts']; + } + + try { + return $GLOBALS['registry']->callAppMethod($app, 'hasPermission', array('args' => $args)); + } catch (Horde_Exception $e) {} + } + + return true; + } + + /** * Checks if a permission exists in the system. * * @param string $permission The permission to check.