return true;
}
- $perms = Horde_Perms::singleton();
if ($permmask === null) {
- $permmask = Horde_Perms::SHOW|Horde_Perms::READ;
+ $permmask = Horde_Perms::SHOW | Horde_Perms::READ;
}
# Default deny all permissions
$user = 0;
$superadmin = 0;
- $superadmin = $perms->hasPermission('beatnik:domains', Horde_Auth::getAuth(), $permmask);
+ $superadmin = $GLOBALS['perms']->hasPermission('beatnik:domains', Horde_Auth::getAuth(), $permmask);
while ($numparents >= 0) {
- $tmpuser = $perms->hasPermission($permname, Horde_Auth::getAuth(), $permmask);
+ $tmpuser = $GLOBALS['perms']->hasPermission($permname, Horde_Auth::getAuth(), $permmask);
$user = $user | $tmpuser;
if ($numparents > 0) {
--- /dev/null
+<?php
+class Horde_Core_Binder_Perms implements Horde_Injector_Binder
+{
+ public function create(Horde_Injector $injector)
+ {
+ $perm_driver = $perm_params = null;
+
+ if (empty($GLOBALS['conf']['perms']['driver'])) {
+ $perm_driver = empty($GLOBALS['conf']['datatree']['driver'])
+ ? null
+ : 'datatree';
+ } else {
+ $perm_driver = $GLOBALS['conf']['perms']['driver'];
+ $perm_params = Horde::getDriverConfig('perms', $perm_driver);
+ }
+
+ return Horde_Perms::factory($perm_driver, $perm_params);
+ }
+
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+}
$injector->addBinder('Horde_Db_Adapter_Base', new Horde_Core_Binder_Db('reader'));
$injector->addBinder('Horde_Log_Logger', new Horde_Core_Binder_Logger());
$injector->addBinder('Horde_Memcache', new Horde_Core_Binder_Memcache());
+ $injector->addBinder('Horde_Perms', new Horde_Core_Binder_Perms());
$injector->addBinder('Horde_Template', new Horde_Core_Binder_Template());
$injector->addBinder('Net_DNS_Resolver', new Horde_Core_Binder_Dns());
}
/* Create the global permissions object. */
- // TODO: Convert to using Horde_Injector
- $GLOBALS['perms'] = Horde_Perms::singleton();
- $injector->setInstance('Horde_Perms', $GLOBALS['perms']);
+ $GLOBALS['perms'] = $injector->getInstance('Horde_Perms');
/* Initialize notification object. Always attach status listener by
* default. */
<file name="Dns.php" role="php" />
<file name="Logger.php" role="php" />
<file name="Memcache.php" role="php" />
+ <file name="Perms.php" role="php" />
<file name="Template.php" role="php" />
</dir> <!-- /lib/Horde/Core/Binder -->
</dir> <!-- /lib/Horde/Core -->
<install name="lib/Horde/Core/Binder/Dns.php" as="Horde/Core/Binder/Dns.php" />
<install name="lib/Horde/Core/Binder/Logger.php" as="Horde/Core/Binder/Logger.php" />
<install name="lib/Horde/Core/Binder/Memcache.php" as="Horde/Core/Binder/Memcache.php" />
+ <install name="lib/Horde/Core/Binder/Perms.php" as="Horde/Core/Binder/Perms.php" />
<install name="lib/Horde/Core/Binder/Template.php" as="Horde/Core/Binder/Template.php" />
<install name="lib/Horde/ErrorHandler.php" as="Horde/ErrorHandler.php" />
<install name="lib/Horde/Exception/HookNotSet.php" as="Horde/Exception/HookNotSet.php" />
$this->prepareRegistry();
$this->prepareNotification();
- if (!isset($GLOBALS['perms'])) {
- $GLOBALS['perms'] = Horde_Perms::singleton();
- }
-
/** Provide the horde registry */
$GLOBALS['registry'] = new Horde_Registry();
protected $_appPerms;
/**
- * Singleton instance.
- *
- * @var array
- */
- static protected $_instance = null;
-
- /**
* Cache for integerToArray().
*
* @var array
}
/**
- * Attempts to return a reference to a concrete instance.
- * It will only create a new instance if no instance currently exists.
- *
- * This method must be invoked as: $var = Horde_Perms::singleton()
- *
- * @return Horde_Perms The concrete reference.
- * @throws Horde_Perms_Exception
- */
- static public function singleton()
- {
- if (is_null(self::$_instance)) {
- $perm_driver = $perm_params = null;
- if (empty($GLOBALS['conf']['perms']['driver'])) {
- $perm_driver = empty($GLOBALS['conf']['datatree']['driver'])
- ? null
- : 'datatree';
- } else {
- $perm_driver = $GLOBALS['conf']['perms']['driver'];
- $perm_params = Horde::getDriverConfig('perms', $perm_driver);
- }
-
- self::$_instance = self::factory($perm_driver, $perm_params);
- }
-
- return self::$_instance;
- }
-
- /**
* Returns the available permissions for a given level.
*
* @param string $name The permission's name.
static public function getTabs($context, &$vars)
{
global $shout;
- $perms = &Horde_Perms::singleton();
$permprefix = 'shout:contexts:' . $context;
{
if (Horde_Auth::isAdmin()) { return true; }
- $perms = &Horde_Perms::singleton();
if ($permmask === null) {
- $permmask = PERMS_SHOW|PERMS_READ;
+ $permmask = Horde_Perms::SHOW | Horde_Perms::READ;
}
# Default deny all permissions
$user = 0;
$superadmin = 0;
- $superadmin = $perms->hasPermission('shout:superadmin',
+ $superadmin = $GLOBALS['perms']->hasPermission('shout:superadmin',
Horde_Auth::getAuth(), $permmask);
while ($numparents >= 0) {
- $tmpuser = $perms->hasPermission($permname,
+ $tmpuser = $GLOBALS['perms']->hasPermission($permname,
Horde_Auth::getAuth(), $permmask);
$user = $user | $tmpuser;