\Sam_Driver_Spamd_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
_mapAttributeToOption()
_mapOptionToAttribute()
_retrieve()
$_capabilities
$_option_map
$_options
$_defaults
$_user
$_params
$_db
N/A
No private methods found
No private properties found
N/A

Properties

$_capabilities

$_capabilities : array

Capabilities supported by the driver.

Type

array

$_option_map

$_option_map : array

Sam to SpamAssassin options mappings.

Type

array

$_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

$_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: (string) The name of the preference table.
  • global_user: (string, optional) A user name to use when setting global preferences. Defaults to '@GLOBAL'.

retrieve()

retrieve() 

Retrieves user preferences and default values 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.

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 —

1 if true and 0 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.

_mapAttributeToOption()

_mapAttributeToOption(string  $attribute) : string

Converts a Sam attribute to a SpamAssassin option.

Parameters

string $attribute

The Sam attribute to convert.

Returns

string —

The converted SpamAssassin option or the original attribute if no match is found.

_mapOptionToAttribute()

_mapOptionToAttribute(string  $option) : string

Converts a SpamAssassin option to a Sam attribute.

Parameters

string $option

The SpamAssassin option to convert.

Returns

string —

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

_retrieve()

_retrieve(boolean  $defaults = false) : array

Retrieve an option set from the storage backend.

Parameters

boolean $defaults

Whether to retrieve the global defaults instead of user options.

Throws

\Sam_Exception

Returns

array —

Array of option-value pairs.