PHP Class Horde_Prefs_Identity, horde

Author: Jan Schneider ([email protected])
Inheritance: implements ArrayAccess, implements Countable, implements IteratorAggregate
ファイルを表示 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_default integer This one is used by the methods returning values if no other one is specified.
$_identities array Array containing all the user's identities.
$_prefnames array Preference names.
$_prefs Horde_Prefs The prefs object that this Identity points to.
$_user string The user whose identities these are.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
add ( array $identity = [] ) : integer Adds a new identity to the array of identities.
count ( )
delete ( integer $identity ) : array Removes an identity from the array of identities.
get ( integer $identity = null ) : array Returns a complete identity hash.
getAll ( string $key ) : array Returns an array with the specified property from all existing identities.
getDefault ( ) : integer Returns a pointer to the current default identity.
getDefaultFromAddress ( boolean $fullname = false ) : Horde_Mail_Rfc822_Address Generates the from address to use for the default identity.
getFromAddress ( integer $ident = null ) : Horde_Mail_Rfc822_Address Returns the from address based on the chosen identity.
getIterator ( )
getName ( integer $ident = null ) : string Returns the user's full name.
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.
hasValue ( string $key, string $value ) : boolean Returns true if the given address belongs to one of the identities.
init ( ) Creates a default identity if none exists yet and sets the preferences up if the identities are locked.
isLocked ( ) : boolean Returns true if all properties are locked and therefore nothing in the identities can be changed.
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
save ( ) Saves all identities in the prefs backend.
setDefault ( integer $identity ) : boolean Sets the current default identity.
setValue ( string $key, mixed $val, integer $identity = null ) : boolean Sets a property with a specified value.
verify ( integer $identity = null ) Verifies and sanitizes all identity properties.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array 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.

add() public method

Adds a new identity to the array of identities.
public add ( array $identity = [] ) : integer
$identity array An identity hash to add.
return integer The pointer to the created identity

count() public method

Since: 2.7.0
public count ( )

delete() public method

Removes an identity from the array of identities.
public delete ( integer $identity ) : array
$identity integer The pointer to the identity to be removed
return array The removed identity.

get() public method

Returns a complete identity hash.
public get ( integer $identity = null ) : array
$identity integer The identity to retrieve.
return array An identity hash. Returns null if the identity does not exist.

getAll() public method

Returns an array with the specified property from all existing identities.
public getAll ( string $key ) : array
$key string The property to retrieve.
return array The array with the values from all identities.

getDefault() public method

Returns a pointer to the current default identity.
public getDefault ( ) : integer
return integer The pointer to the current default identity.

getDefaultFromAddress() public method

Generates the from address to use for the default identity.
public getDefaultFromAddress ( boolean $fullname = false ) : Horde_Mail_Rfc822_Address
$fullname boolean Include the fullname information.
return Horde_Mail_Rfc822_Address The default from address (object returned since 2.2.0).

getFromAddress() public method

If no address can be found it is built from the current user.
public getFromAddress ( integer $ident = null ) : Horde_Mail_Rfc822_Address
$ident integer The identity to retrieve the address from.
return Horde_Mail_Rfc822_Address A valid from address.

getIterator() public method

Since: 2.7.0
public getIterator ( )

getName() public method

Returns the user's full name.
public getName ( integer $ident = null ) : string
$ident integer The identity to retrieve the name from.
return string The user's full name, or the user name if it doesn't exist.

getValue() public method

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.
public getValue ( string $key, integer $identity = null ) : mixed
$key string The property to retrieve.
$identity integer The identity to retrieve the property from.
return mixed The value of the property.

hasValue() public method

Returns true if the given address belongs to one of the identities.
public hasValue ( string $key, string $value ) : boolean
$key string The identity key to search.
$value string The value to search for in $key.
return boolean True if the $value was found in $key.

init() public method

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

isLocked() public method

Returns true if all properties are locked and therefore nothing in the identities can be changed.
public isLocked ( ) : boolean
return boolean True if all properties are locked, false otherwise.

offsetExists() public method

Since: 2.7.0
public offsetExists ( $offset )

offsetGet() public method

Since: 2.7.0
public offsetGet ( $offset )

offsetSet() public method

Since: 2.7.0
public offsetSet ( $offset, $value )

offsetUnset() public method

Since: 2.7.0
public offsetUnset ( $offset )

save() public method

Saves all identities in the prefs backend.
public save ( )

setDefault() public method

If the identity doesn't exist, the old default identity stays the same.
public setDefault ( integer $identity ) : boolean
$identity integer The pointer to the new default identity.
return boolean True on success, false on failure.

setValue() public method

Sets a property with a specified value.
public setValue ( string $key, mixed $val, integer $identity = null ) : boolean
$key string The property to set.
$val mixed The value to which the property should be set.
$identity integer The identity to set the property in.
return boolean True on success, false on failure (property was locked).

verify() public method

Verifies and sanitizes all identity properties.
public verify ( integer $identity = null )
$identity integer The identity to verify.

Property Details

$_default protected_oe property

This one is used by the methods returning values if no other one is specified.
protected int $_default
return integer

$_identities protected_oe property

Array containing all the user's identities.
protected array $_identities
return array

$_prefnames protected_oe property

Preference names.
protected array $_prefnames
return array

$_prefs protected_oe property

The prefs object that this Identity points to.
protected Horde_Prefs $_prefs
return Horde_Prefs

$_user protected_oe property

The user whose identities these are.
protected string $_user
return string