\Horde_Test_Stub_Registry

A test replacement for Horde_Registry.

Summary

Methods
Properties
Constants
__construct()
convertUsername()
getAuth()
isAdmin()
remoteHost()
setConfigFile()
loadConfigFile()
get()
getApp()
hasInterface()
listAPIs()
$hordeInit
No constants found
No protected methods found
$_user
$_app
$_configObjects
N/A
No private methods found
No private properties found
N/A

Properties

$hordeInit

$hordeInit : boolean

A flag that is set once the basic horde application has been minimally configured.

Type

boolean

$_user

$_user : string

The currrent user.

Type

string

$_app

$_app : string

The current application.

Type

string

$_configObjects

$_configObjects : array

List of pre-configured configuration objects.

Type

array

Methods

__construct()

__construct(string  $user, string  $app) 

Constructor.

Parameters

string $user

The current user.

string $app

The current application.

convertUsername()

convertUsername(string  $userId, boolean  $toHorde) : string

Converts an authentication username to a unique Horde username.

Parameters

string $userId

The username to convert.

boolean $toHorde

If true, convert to a Horde username. If false, convert to the auth username.

Throws

\Horde_Exception

Returns

string —

The converted username.

getAuth()

getAuth(string  $format = null) : mixed

Returns the currently logged in user, if there is one.

Parameters

string $format

The return format, defaults to the unique Horde ID. Alternative formats:

bare - Horde ID without any domain information.
       EXAMPLE: foo@example.com would be returned as 'foo'.
domain: Domain of the Horde ID.
        EXAMPLE: foo@example.com would be returned as 'example.com'.
original: The username used to originally login to Horde.

Returns

mixed —

The user ID or false if no user is logged in.

isAdmin()

isAdmin(array  $options = array()) : boolean

Is a user an administrator?

Parameters

array $options

Options:

'permission' - (string) Allow users with this permission admin access
               in the current context.
'permlevel' - (integer) The level of permissions to check for.
              Defaults to Horde_Perms::EDIT.
'user' - (string) The user to check.
         Defaults to self::getAuth().

Returns

boolean —

Whether or not this is an admin user.

remoteHost()

remoteHost() : object

Returns information about the remote host.

Returns

object —

An object with the following properties:

  - addr: (string) Remote IP address.
  - host: (string) Remote hostname (if resolvable; otherwise, this value
          is identical to 'addr').
  - proxy: (boolean) True if this user is connecting through a proxy.

setConfigFile()

setConfigFile(object  $loadconfig, string  $conf_file, mixed  $vars = null, string  $app = null) 

Assigns a (pre-configured) Loadconfig object.

This object will be returned by loadConfig(), if the same parameters are used.

Parameters

object $loadconfig

Configuration object.

string $conf_file

Configuration file name.

mixed $vars

List of config variables to load.

string $app

Application.

loadConfigFile()

loadConfigFile(string  $conf_file, mixed  $vars = null, string  $app = null) : \Horde_Test_Stub_Registry_Loadconfig

Load a configuration file from a Horde application's config directory.

This call is cached (a config file is only loaded once, regardless of the $vars value).

Parameters

string $conf_file

Configuration file name.

mixed $vars

List of config variables to load.

string $app

Application.

Throws

\Horde_Exception

Returns

\Horde_Test_Stub_Registry_Loadconfig

The config object.

get()

get(string  $parameter, string  $app = null) : string

Return the requested configuration parameter for the specified application. If no application is specified, the value of the current application is used. However, if the parameter is not present for that application, the Horde-wide value is used instead.

If that is not present, we return null.

Parameters

string $parameter

The configuration value to retrieve.

string $app

The application to get the value for.

Returns

string —

The requested parameter, or null if it is not set.

getApp()

getApp() : string

Return the current application - the app at the top of the application stack.

Returns

string —

The current application.

hasInterface()

hasInterface(string  $interface) : mixed

Determine if an interface is implemented by an active application.

Parameters

string $interface

The interface to check for.

Returns

mixed —

The application implementing $interface if we have it, false if the interface is not implemented.

listAPIs()

listAPIs() : array

Returns all available registry APIs.

Returns

array —

The API list.