\Sam_Driver_Amavisd_Sql

Sam SQL storage implementation using Horde_Db.

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Summary

Methods
Properties
Constants
__construct()
retrieve()
store()
hasCapability()
booleanToOption()
optionToBoolean()
getOption()
setOption()
getListOption()
setListOption()
setStackedOption()
No public properties found
No constants found
_mapNameToTable()
_mapAttributeToField()
_mapFieldToAttribute()
_createUserID()
_lookupUserID()
_lookupPolicyID()
$_options
$_defaults
$_user
$_capabilities
$_params
$_db
N/A
No private methods found
No private properties found
N/A

Properties

$_options

$_options : array

The user's preferences.

Type

array

$_defaults

$_defaults : array

The defaults to use if user hasn't defined a value.

Type

array

$_user

$_user : string

The user name.

Type

string

$_capabilities

$_capabilities : array

List of the capabilities supported by this driver.

Type

array

$_params

$_params : array

Parameter hash for the backend.

Type

array

$_db

$_db : \Horde_Db_Adapter

Handle for the current database connection.

Type

\Horde_Db_Adapter

Methods

__construct()

__construct(string  $user, array  $params = array()) 

Constructor.

Parameters

string $user

A user name.

array $params

Class parameters:

  • db: (Horde_Db_Adapater) A database handle.
  • table_map: (array) A map of table and field names. See config/backends.php.

retrieve()

retrieve() 

Retrieves user preferences from the backend.

Throws

\Sam_Exception

store()

store(boolean  $defaults = false) 

Stores user preferences and default values in the backend.

Parameters

boolean $defaults

Whether to store the global defaults instead of user options. Unused.

Throws

\Sam_Exception

hasCapability()

hasCapability(string  $capability) : boolean

Check to see if the backend supports a particular capability.

Parameters

string $capability

The name of the capability to check.

Returns

boolean —

True if the backend is capable, false otherwise.

booleanToOption()

booleanToOption(boolean  $boolean) : mixed

Converts a boolean option to a backend specific value.

Parameters

boolean $boolean

The value to convert.

Returns

mixed —

Y if true and N if false.

optionToBoolean()

optionToBoolean(mixed  $option) : boolean

Convert a backend specific boolean value to a PHP boolean.

Parameters

mixed $option

The value to convert.

Returns

boolean —

True if the backend-specific value is true, false otherwise.

getOption()

getOption(string  $option) : mixed

Returns a preference from user settings or global defaults.

Parameters

string $option

The option to retrieve.

Returns

mixed —

The requested option value.

setOption()

setOption(string  $option, string  $value, boolean  $defaults = false) 

Sets a preference value for the user or as global defaults, depending on the parameters.

Does not automatically store options to the backend.

Parameters

string $option

The option to set.

string $value

The new value.

boolean $defaults

Whether to set the global defaults instead of user options.

getListOption()

getListOption(string  $option) : string

Returns an internal address array as a new-line separated string.

Useful for retrieving whitelists and blacklists.

Parameters

string $option

The option to retrieve.

Returns

string —

New-line separated list value.

setListOption()

setListOption(string  $option, string  $value, boolean  $defaults = false) 

Sets an internal address array.

Useful for whitelists and blacklists. The passed data is split at whitespace. Does not automatically store options to the backend.

Parameters

string $option

The option to set.

string $value

A string of data that will be converted to an array and stored for later storage to the backend.

boolean $defaults

Whether to set the global defaults instead of user options.

setStackedOption()

setStackedOption(string  $option, string  $value, boolean  $defaults = false) 

Sets an internal array of options which have multiple elements of data stored in their value.

E.g. rewrite_header takes two elements, a header and a string, as in 'rewrite_header' => 'Subject SPAM'.

There can be multiple entries for these options, so they cannot be treated independently.

Does not automatically store options to the backend.

Parameters

string $option

The base option to set. Should only be 'rewrite_header' ATM.

string $value

A string of data that will be converted to an array and stored for later storage to the backend.

boolean $defaults

Whether to set the global defaults instead of user options.

_mapNameToTable()

_mapNameToTable(string  $table) : string

Converts a Sam table name to a table name that Amavisd-new will use.

Parameters

string $table

The Sam table to lookup.

Returns

string —

The converted Amavisd-new table or the original name if no match is found.

_mapAttributeToField()

_mapAttributeToField(string  $table, string  $attribute) : string

Converts a Sam attribute from a specific table to a field that Amavisd-new will use.

Parameters

string $table

The Sam table to lookup.

string $attribute

The Sam attribute to convert.

Returns

string —

The converted Amavisd-new field or the original attribute if no match is found.

_mapFieldToAttribute()

_mapFieldToAttribute(string  $table, string  $field) : string

Converts a Amavisd-new field from a specific table to a Sam attribute.

Parameters

string $table

The Sam table to lookup.

string $field

The Amavisd-new field to convert.

Returns

string —

The converted Sam attribute or the original field if no match is found.

_createUserID()

_createUserID() : string

Creates an Amavisd-new recipient for policy, whitelist and blacklist storage and retrieval.

Throws

\Sam_Exception

Returns

string —

The id of the newly created recipient.

_lookupUserID()

_lookupUserID() : string

Returns an Amavisd-new recipient for policy, whitelist and blacklist storage and retrieval.

Throws

\Sam_Exception

Returns

string —

The ID of the found or newly created recipient.

_lookupPolicyID()

_lookupPolicyID() : string|boolean

Returns an Amavisd-new policy for storage and retrieval.

Throws

\Sam_Exception

Returns

string|boolean —

The results of the of the policy lookup. Can be the ID of the policy, false if not found.