Properties

$_db

$_db : \Horde_Db

Type

\Horde_Db

$_params

$_params : array

A hash containing any parameters for the current driver.

Type

array

$_ldap

$_ldap : resource

Reference to initialized LDAP driver.

Type

resource

$_users

$_users : array

Cache for retrieved getUsers() results.

Type

array

$_fieldmap

$_fieldmap : array

Map of internal field names to LDAP attribute names.

Type

array

Methods

__construct()

__construct(array  $params) 

Constructor.

Parameters

array $params

Any parameters needed for this driver.

getDomains()

getDomains() : array

Returns the list of domains from the backend.

Returns

array —

All the domains and their data in an array.

getDomain()

getDomain(integer  $domain_id) : array

Returns the specified domain information from the backend.

Parameters

integer $domain_id

The id of the domain to fetch.

Returns

array —

The domain's information in an array.

getDomainByName()

getDomainByName(  $domain_name) : array

Given a domain name returns the information from the backend.

Parameters

$domain_name

Returns

array —

The domain's information in an array.

getDomainNumUsers()

getDomainNumUsers(string  $domain_name) : integer

Returns the current number of users for a domain.

Parameters

string $domain_name

The name of the domain for which to get the current number of users.

Returns

integer —

The current number of users.

getUsers()

getUsers(string  $domain = null) : array

Returns all available users, if a domain name is passed then limit the list of users only to those users.

Parameters

string $domain

The name of the domain for which to fetch the users.

Throws

\Vilma_Exception

Returns

array —

The available users and their stored information.

getUser()

getUser(integer  $user_id) : array

Returns the user information for a given user id.

Parameters

integer $user_id

The id of the user for which to fetch information.

Returns

array —

The user information.

deleteUser()

deleteUser(integer  $user_id) 

Deletes a user.

Parameters

integer $user_id

The id of the user to delete.

Throws

\Vilma_Exception

getVirtuals()

getVirtuals(string  $filter) : array

Returns available virtual emails.

Parameters

string $filter

If passed a domain then return all virtual emails for the domain, otherwise if passed a user name return all virtual emails for that user.

Returns

array —

The available virtual emails.

getVirtual()

getVirtual(integer  $virtual_id) : array

Returns information for a virtual id.

Parameters

integer $virtual_id

The virtual id for which to return information.

Returns

array —

The virtual email information.

saveVirtual()

saveVirtual(array  $info, string  $domain) 

Saves virtual email address to the backend.

Parameters

array $info

The virtual email data.

string $domain

The name of the domain for this virtual email.

Throws

\Vilma_Exception

deleteVirtual()

deleteVirtual(integer  $virtual_id) 

Deletes a virtual email.

Parameters

integer $virtual_id

The id of the virtual email to delete.

saveDomain()

saveDomain(array  $info) 

Saves a domain with the provided information.

Parameters

array $info

Array of details to save the domain.

Throws

\Vilma_Exception

deleteDomain()

deleteDomain(integer  $domain_id) 

Deletes a domain and all the users and virtuals within it.

Parameters

integer $domain_id

The id of the domain to delete.

Throws

\Vilma_Exception

getDomainAdmin()

getDomainAdmin(string  $domain_name) : string

Returns the user who is the domain administrator.

Parameters

string $domain_name

The name of the domain for which to return the administrator.

Throws

\Vilma_Exception

Returns

string —

The domain administrator.

getDomainQuota()

getDomainQuota(string  $domain_name) : integer

Returns the configured quota for this domain.

Parameters

string $domain_name

The name of the domain for which to return the quota.

Throws

\Vilma_Exception

Returns

integer —

The domain quota.

getDomainMaxUsers()

getDomainMaxUsers(string  $domain_name) : integer

Returns the maximum number of users allowed for a given domain.

Parameters

string $domain_name

The name of the domain for which to return the maximum users.

Throws

\Vilma_Exception

Returns

integer —

The maximum number of allowed users.

isBelowMaxUsers()

isBelowMaxUsers(string  $domain) : boolean

Checks if the given domain is below the maximum allowed users.

Parameters

string $domain

The domain name to check.

Returns

boolean —

True if the domain does not have a maximum limit (0) or current number of users is below the maximum number allowed.

getAllUsers()

getAllUsers() : array

Returns all the users sorted by domain and as arrays of each domain.

Returns

array —

An array of domains then users for each domain.

getUserStatus()

getUserStatus(array  $user) : array

Does a series of checks for a given user to determine the status.

Parameters

array $user

The user's details in an array as returned by the getUser() function.

Throws

\Vilma_Exception

if an error occurs looking up the user status.

Returns

array —

Either an array of error messages found during the checks or an array with a single element stating that the user is ready.

saveUser()

saveUser(  $info) 

Parameters

$info

Throws

\Vilma_Exception

getUserFormAttributes()

getUserFormAttributes() 

getAddresses()

getAddresses(string  $domain, string  $type = 'all', string  $key = 'user_name', integer  $direction) : array

Returns a list of all users, aliases, or groups and forwards for a domain.

Parameters

string $domain

Domain on which to search.

string $type

Only return a specific type. One of 'all', 'user', 'alias', 'forward', or 'group'.

string $key

Sort list by this key.

integer $direction

Sort direction.

Returns

array —

Account information for this domain.

getAddressInfo()

getAddressInfo(string  $address, string  $type = 'all') : array

Returns an array of information related to the address passed in.

Parameters

string $address

Address for which information will be pulled.

string $type

Address type to request. One of 'all', 'user', 'alias', 'forward' or 'group'.

Throws

\Vilma_Exception

if address of that type doesn't exist.

Returns

array —

Array of user information on success or empty array if the user does not exist.

saveAlias()

saveAlias(array  $info) 

Saves or creates alias records for a user.

Parameters

array $info

The info used to store the information. Required fields are:

  • 'address': The destination address (used for LDAP ID lookup).
  • 'alias_address': The alias to create or the new data for the modified entry.
  • 'alias': The alias we are modifying, if we are modifying an existing one.

Throws

\Vilma_Exception

deleteAlias()

deleteAlias(array  $info) 

Deletes alias records for a given user.

Parameters

array $info

The info used to store the information. Required fields are:

  • 'address': The destination address (used for LDAP ID lookup).
  • 'alias': The alias we are deleting.

Throws

\Vilma_Exception

saveForward()

saveForward(array  $info) 

Saves or creates forward records for a given user.

Parameters

array $info

The info used to store the information. Required fields are:

  • 'address': The destination address (used for LDAP ID lookup).
  • 'forward_address': The forward to create or the new data for the modified entry.
  • 'forward': The forward we are modifying, if we are modifying an existing one.

Throws

\Vilma_Exception

deleteForward()

deleteForward(array  $info) 

Deletes forward records for a given user.

Parameters

array $info

The info used to store the information. Required fields are:

  • 'address': The destination address (used for LDAP ID lookup).
  • 'forward': The forward we are deleting.

Throws

\Vilma_Exception

factory()

factory(string  $driver = null, array  $params = null) : \Vilma_Driver

Attempts to return a concrete Vilma_Driver instance based on $driver.

Parameters

string $driver

The type of concrete Vilma_Driver subclass to return.

array $params

A hash containing any additional configuration or connection parameters a subclass might need.

Throws

\Vilma_Exception

Returns

\Vilma_Driver

The newly created concrete Vilma_Driver instance.

_connect()

_connect() 

_saveDomain()

_saveDomain(array  $info) 

Saves a domain with the provided information.

Parameters

array $info

Array of details to save the domain.

_deleteDomain()

_deleteDomain(integer  $domain_id) 

Deletes a domain.

Parameters

integer $domain_id

The id of the domain to delete.

Throws

\Vilma_Exception

_saveUser()

_saveUser(array  $info) : array

Saves a user to the backend.

Parameters

array $info

The user information to save.

Throws

\Vilma_Exception

Returns

array —

The user information.

_getAddresses()

_getAddresses(string  $domain, string  $type = 'all') : array

Returns a list of all users, aliases, or groups and forwards for a domain.

Parameters

string $domain

Domain on which to search.

string $type

Only return a specific type. One of 'all', 'user', 'alias','forward', or 'group'.

Returns

array —

Account information for this domain

_getTableFields()

_getTableFields(  $table) : string

Returns the list of fields from a specific table for SQL statements.

Parameters

$table

Returns

string

_getTableField()

_getTableField(  $table,   $field) : string

Returns the real name of a field from a specific table for SQL statements.

Parameters

$table
$field

Returns

string

_prepareRecord()

_prepareRecord(  $table,   $record) : array

Parameters

$table
$record

Returns

array

_initialize()

_initialize() 

Initializes this backend, connects to the SQL database.

Throws

\Vilma_Exception

_updateUser()

_updateUser(array  $info) : array

Updates a user in the backend.

Parameters

array $info

The user information to save.

Throws

\Vilma_Exception

Returns

array —

The user information.

_createUser()

_createUser(array  $info) : array

Creates a user in the backend.

Parameters

array $info

The user information to save.

Throws

\Vilma_Exception

Returns

array —

The user information.

_getAliases()

_getAliases(string  $target = null) : array

Returns available email address aliases.

Parameters

string $target

If passed a domain then return all alias emails for the domain, otherwise if passed a user name return all virtual emails for that user.

Returns

array —

The used email aliases.

_getGroupsAndForwards()

_getGroupsAndForwards(string  $acquire = null, string  $domain = null) : array

Returns all available groups and forwards unless otherwise specified.

If a domain name is passed then limit the results to groups or forwards in that domain.

Parameters

string $acquire

The default behavior is to acquire both groups and forwards; a value of 'group' will return only groups and a value of 'forward' will return only forwards.

string $domain

The name of the domain from which to fetch.

Returns

array —

The available groups and forwards with details.

_searchForUser()

_searchForUser(string  $email_id) : array

Searchs for a given email account.

Parameters

string $email_id

The id of the account to be searched for.

Returns

array —

Data for given email account on success or no information found.