Documentation

Horde_Prefs_Identity
in package
implements ArrayAccess, Countable, IteratorAggregate

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

Tags
author

Jan Schneider jan@horde.org

category

Horde

copyright

2001-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes, Traits and Enums

ArrayAccess
Countable
IteratorAggregate

Table of Contents

$_default  : int
A pointer to the user's standard identity.
$_identities  : array<string|int, mixed>
Array containing all the user's identities.
$_prefnames  : array<string|int, mixed>
Preference names.
$_prefs  : Horde_Prefs
The prefs object that this Identity points to.
$_user  : string
The user whose identities these are.
__construct()  : mixed
Constructor.
add()  : int
Adds a new identity to the array of identities.
count()  : int
delete()  : array<string|int, mixed>
Removes an identity from the array of identities.
get()  : array<string|int, mixed>
Returns a complete identity hash.
getAll()  : array<string|int, mixed>
Returns an array with the specified property from all existing identities.
getDefault()  : int
Returns a pointer to the current default identity.
getDefaultFromAddress()  : Horde_Mail_Rfc822_Address
Generates the from address to use for the default identity.
getFromAddress()  : Horde_Mail_Rfc822_Address
Returns the from address based on the chosen identity.
getIterator()  : Traversable
getName()  : string
Returns the user's full name.
getValue()  : 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()  : bool
Returns true if the given address belongs to one of the identities.
init()  : mixed
Creates a default identity if none exists yet and sets the preferences up if the identities are locked.
isLocked()  : bool
Returns true if all properties are locked and therefore nothing in the identities can be changed.
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
save()  : mixed
Saves all identities in the prefs backend.
setDefault()  : bool
Sets the current default identity.
setValue()  : bool
Sets a property with a specified value.
verify()  : mixed
Verifies and sanitizes all identity properties.

Properties

$_default

A pointer to the user's standard identity.

protected int $_default = 0

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

$_identities

Array containing all the user's identities.

protected array<string|int, mixed> $_identities = array()

$_prefnames

Preference names.

protected array<string|int, mixed> $_prefnames = array('default_identity' => 'default_identity', 'from_addr' => 'from_addr', 'fullname' => 'fullname', 'id' => 'id', 'identities' => 'identities', 'properties' => array('id', 'fullname', 'from_addr'))

$_user

The user whose identities these are.

protected string $_user = \null

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = 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.
Return values
mixed

add()

Adds a new identity to the array of identities.

public add([array<string|int, mixed> $identity = array() ]) : int
Parameters
$identity : array<string|int, mixed> = array()

An identity hash to add.

Return values
int

The pointer to the created identity

count()

public count() : int
Tags
since
2.7.0
Return values
int

delete()

Removes an identity from the array of identities.

public delete(int $identity) : array<string|int, mixed>
Parameters
$identity : int

The pointer to the identity to be removed

Return values
array<string|int, mixed>

The removed identity.

get()

Returns a complete identity hash.

public get([int $identity = null ]) : array<string|int, mixed>
Parameters
$identity : int = null

The identity to retrieve.

Return values
array<string|int, mixed>

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

getAll()

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

public getAll(string $key) : array<string|int, mixed>
Parameters
$key : string

The property to retrieve.

Return values
array<string|int, mixed>

The array with the values from all identities.

getDefault()

Returns a pointer to the current default identity.

public getDefault() : int
Return values
int

The pointer to the current default identity.

getDefaultFromAddress()

Generates the from address to use for the default identity.

public getDefaultFromAddress([bool $fullname = false ]) : Horde_Mail_Rfc822_Address
Parameters
$fullname : bool = false

Include the fullname information.

Return values
Horde_Mail_Rfc822_Address

The default from address (object returned since 2.2.0).

getFromAddress()

Returns the from address based on the chosen identity.

public getFromAddress([int $ident = null ]) : Horde_Mail_Rfc822_Address

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

Parameters
$ident : int = null

The identity to retrieve the address from.

Tags
since

Horde_Prefs 2.3.0

Return values
Horde_Mail_Rfc822_Address

A valid from address.

getIterator()

public getIterator() : Traversable
Tags
since
2.7.0
Return values
Traversable

getName()

Returns the user's full name.

public getName([int $ident = null ]) : string
Parameters
$ident : int = null

The identity to retrieve the name from.

Return values
string

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

getValue()

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[, int $identity = null ]) : mixed
Parameters
$key : string

The property to retrieve.

$identity : int = null

The identity to retrieve the property from.

Return values
mixed

The value of the property.

hasValue()

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

public hasValue(string $key, string $value) : bool
Parameters
$key : string

The identity key to search.

$value : string

The value to search for in $key.

Return values
bool

True if the $value was found in $key.

init()

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

public init() : mixed
Return values
mixed

isLocked()

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

public isLocked() : bool
Return values
bool

True if all properties are locked, false otherwise.

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
since
2.7.0
Return values
mixed

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
since
2.7.0
Return values
mixed

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Tags
since
2.7.0
Return values
mixed

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
since
2.7.0
Return values
mixed

save()

Saves all identities in the prefs backend.

public save() : mixed
Return values
mixed

setDefault()

Sets the current default identity.

public setDefault(int $identity) : bool

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

Parameters
$identity : int

The pointer to the new default identity.

Return values
bool

True on success, false on failure.

setValue()

Sets a property with a specified value.

public setValue(string $key, mixed $val[, int $identity = null ]) : bool
Parameters
$key : string

The property to set.

$val : mixed

The value to which the property should be set.

$identity : int = null

The identity to set the property in.

Return values
bool

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

verify()

Verifies and sanitizes all identity properties.

public verify([int $identity = null ]) : mixed
Parameters
$identity : int = null

The identity to verify.

Tags
throws
Horde_Prefs_Exception
Return values
mixed

Search results