\Horde_Prefs_Identity

This class provides an interface to all identities a user might have.

Summary

Methods
Properties
Constants
__construct()
init()
save()
add()
get()
delete()
getDefault()
setDefault()
getValue()
getAll()
setValue()
isLocked()
hasValue()
verify()
getName()
getFromAddress()
getDefaultFromAddress()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
count()
getIterator()
No public properties found
No constants found
No protected methods found
$_identities
$_default
$_user
$_prefnames
$_prefs
N/A
No private methods found
No private properties found
N/A

Properties

$_identities

$_identities : array

Array containing all the user's identities.

Type

array

$_default

$_default : integer

A pointer to the user's standard identity.

This one is used by the methods returning values if no other one is specified.

Type

integer

$_user

$_user : string

The user whose identities these are.

Type

string

$_prefnames

$_prefnames : array

Preference names.

Type

array

$_prefs

$_prefs : \Horde_Prefs

The prefs object that this Identity points to.

Type

\Horde_Prefs

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Parameters:

  • default_identity: (string) The preference name for the default identity. DEFAULT: 'default_identity'
  • from_addr: (string) The preference name for the user's from e-mail address. DEFAULT: 'from_addr'
  • fullname: (string) The preference name for the user's full name. DEFAULT: 'fullname'
  • id: (string) The preference name for the identity name. DEFAULT: 'id'
  • identities: (string) The preference name for the identity store. DEFAULT: 'identities'
  • prefs: (Horde_Prefs) [REQUIRED] The prefs object to use.
  • properties: (array) The list of properties for the identity. DEFAULT: array('from_addr', 'fullname', 'id')
  • user: (string) [REQUIRED] The user whose prefs we are handling.

init()

init() 

Creates a default identity if none exists yet and sets the preferences up if the identities are locked.

save()

save() 

Saves all identities in the prefs backend.

add()

add(array  $identity = array()) : integer

Adds a new identity to the array of identities.

Parameters

array $identity

An identity hash to add.

Returns

integer —

The pointer to the created identity

get()

get(integer  $identity = null) : array

Returns a complete identity hash.

Parameters

integer $identity

The identity to retrieve.

Returns

array —

An identity hash. Returns null if the identity does not exist.

delete()

delete(integer  $identity) : array

Removes an identity from the array of identities.

Parameters

integer $identity

The pointer to the identity to be removed

Returns

array —

The removed identity.

getDefault()

getDefault() : integer

Returns a pointer to the current default identity.

Returns

integer —

The pointer to the current default identity.

setDefault()

setDefault(integer  $identity) : boolean

Sets the current default identity.

If the identity doesn't exist, the old default identity stays the same.

Parameters

integer $identity

The pointer to the new default identity.

Returns

boolean —

True on success, false on failure.

getValue()

getValue(string  $key, integer  $identity = null) : mixed

Returns a property from one of the identities. If this value doesn't exist or is locked, the property is retrieved from the prefs backend.

Parameters

string $key

The property to retrieve.

integer $identity

The identity to retrieve the property from.

Returns

mixed —

The value of the property.

getAll()

getAll(string  $key) : array

Returns an array with the specified property from all existing identities.

Parameters

string $key

The property to retrieve.

Returns

array —

The array with the values from all identities.

setValue()

setValue(string  $key, mixed  $val, integer  $identity = null) : boolean

Sets a property with a specified value.

Parameters

string $key

The property to set.

mixed $val

The value to which the property should be set.

integer $identity

The identity to set the property in.

Returns

boolean —

True on success, false on failure (property was locked).

isLocked()

isLocked() : boolean

Returns true if all properties are locked and therefore nothing in the identities can be changed.

Returns

boolean —

True if all properties are locked, false otherwise.

hasValue()

hasValue(string  $key, string  $value) : boolean

Returns true if the given address belongs to one of the identities.

Parameters

string $key

The identity key to search.

string $value

The value to search for in $key.

Returns

boolean —

True if the $value was found in $key.

verify()

verify(integer  $identity = null) 

Verifies and sanitizes all identity properties.

Parameters

integer $identity

The identity to verify.

Throws

\Horde_Prefs_Exception

getName()

getName(integer  $ident = null) : string

Returns the user's full name.

Parameters

integer $ident

The identity to retrieve the name from.

Returns

string —

The user's full name, or the user name if it doesn't exist.

getFromAddress()

getFromAddress(integer  $ident = null) : \Horde_Mail_Rfc822_Address

Returns the from address based on the chosen identity.

If no address can be found it is built from the current user.

Parameters

integer $ident

The identity to retrieve the address from.

Returns

\Horde_Mail_Rfc822_Address —

A valid from address.

getDefaultFromAddress()

getDefaultFromAddress(boolean  $fullname = false) : \Horde_Mail_Rfc822_Address

Generates the from address to use for the default identity.

Parameters

boolean $fullname

Include the fullname information.

Returns

\Horde_Mail_Rfc822_Address —

The default from address (object returned since 2.2.0).

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetGet()

offsetGet(  $offset) 

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

count()

count() 

getIterator()

getIterator()