Class abook_database

Description

Address book in a database backend

Backend for personal/shared address book stored in a database, accessed using the DB-classes in PEAR or PDO, the latter taking precedence if available..

IMPORTANT: If PDO is not available (it should be installed by default since PHP 5.1), then the PEAR modules must be in the include path for this class to work.

An array with the following elements must be passed to the class constructor (elements marked ? are optional):

   dsn       => database DNS (see PEAR for syntax, but more or
                less it is:  mysql://user:pass@hostname/dbname)
   table     => table to store addresses in (must exist)
   owner     => current user (owner of address data)
 ? name      => name of address book
 ? writeable => set writeable flag (true/false)
 ? listing   => enable/disable listing
The table used should have the following columns: owner, nickname, firstname, lastname, email, label The pair (owner,nickname) should be unique (primary key).

NOTE. This class should not be used directly. Use the "AddressBook" class instead.

Three settings that control PDO behavior can be specified in config/config_local.php if needed: boolean $disable_pdo SquirrelMail uses PDO by default to access the user preferences and address book databases, but setting this to TRUE will cause SquirrelMail to fall back to using Pear DB instead. boolean $pdo_show_sql_errors When database errors are encountered, setting this to TRUE causes the actual database error to be displayed, otherwise generic errors are displayed, preventing internal database information from being exposed. This should be enabled only for debugging purposes. string $pdo_identifier_quote_char By default, SquirrelMail will quote table and field names in database queries with what it thinks is the appropriate quote character for the database type being used (backtick for MySQL (and thus MariaDB), double quotes for all others), but you can override the character used by putting it here, or tell SquirrelMail NOT to quote identifiers by setting this to "none"

Located in /functions/abook_database.php (line 94)

addressbook_backend
   |
   --abook_database
Variable Summary
string $bname
string $btype
resource $dbh
string $dsn
bool $listing
string $owner
string $table
bool $writeable
Method Summary
abook_database abook_database (array $param)
bool add (array $userdata)
void close ()
string get_field_name (integer $field)
array list_addr ()
array lookup (string $value, [integer $field = SM_ABOOK_FIELD_NICKNAME])
bool modify (string $alias, array $userdata)
bool open ([bool $new = false])
bool remove (array $alias)
array search (string $expr)
Variables
string $bname = 'database' (line 104)

Backend name


Redefinition of:
addressbook_backend::$bname
Internal backend name
string $btype = 'local' (line 99)

Backend type


Redefinition of:
addressbook_backend::$btype
Backend type
resource $dbh = false (line 135)

Database Handle

string $dsn = '' (line 110)

Data Source Name (connection description)

string $identifier_quote_char = '' (line 117)

Character used to quote database table

and field names

bool $listing = true (line 145)

Enable/disable address book listing

string $owner = '' (line 130)

Owner name

Limits list of database entries visible to end user

string $table = '' (line 123)

Table that stores addresses

bool $writeable = true (line 140)

Enable/disable writing into address book


Redefinition of:
addressbook_backend::$writeable
Writeable flag

Inherited Variables

Inherited from addressbook_backend

addressbook_backend::$bnum
addressbook_backend::$error
addressbook_backend::$sname
Methods
Constructor abook_database (line 153)

Constructor

abook_database abook_database (array $param)
  • array $param: address book backend options
add (line 596)

Add address

bool add (array $userdata)
  • array $userdata: added data

Redefinition of:
addressbook_backend::add()
Add entry to backend
close (line 302)

Close the file and forget the filehandle

void close ()
get_field_name (line 323)

Determine internal database field name given one of the SquirrelMail SM_ABOOK_FIELD_* constants

  • return: The desired field name, or the string "ERROR" if the $field is not understood (the caller is responsible for handing errors)
string get_field_name (integer $field)
  • integer $field: The SM_ABOOK_FIELD_* contant to look up
list_addr (line 529)

List all addresses

  • return: search results
array list_addr ()

Redefinition of:
addressbook_backend::list_addr()
List all entries in backend
lookup (line 456)

Lookup an address by the indicated field.

  • return: Array with lookup results when the value was found, an empty array if the value was not found.
array lookup (string $value, [integer $field = SM_ABOOK_FIELD_NICKNAME])
  • string $value: The value to look up
  • integer $field: The field to look in, should be one of the SM_ABOOK_FIELD_* constants defined in include/constants.php (OPTIONAL; defaults to nickname field) NOTE: uniqueness is only guaranteed when the nickname field is used here; otherwise, the first matching address is returned.

Redefinition of:
addressbook_backend::lookup()
Find entry in backend by the indicated field
modify (line 727)

Modify address

bool modify (string $alias, array $userdata)
  • string $alias: modified alias
  • array $userdata: new data

Redefinition of:
addressbook_backend::modify()
Modify entry in backend
open (line 215)

Open the database.

bool open ([bool $new = false])
  • bool $new: new connection if it is true
remove (line 663)

Deletes address book entries

bool remove (array $alias)
  • array $alias: aliases that have to be deleted. numerical array with nickname values

Redefinition of:
addressbook_backend::remove()
Remove entry from backend
search (line 350)

Search the database

Backend supports only * and ? wildcards. Complex eregs are not supported. Search is case insensitive.

  • return: search results. boolean false on error
array search (string $expr)
  • string $expr: search expression

Redefinition of:
addressbook_backend::search()
Search for entries in backend

Inherited Methods

Inherited From addressbook_backend

addressbook_backend::add()
addressbook_backend::fullname()
addressbook_backend::list_addr()
addressbook_backend::lookup()
addressbook_backend::modify()
addressbook_backend::remove()
addressbook_backend::search()
addressbook_backend::set_error()

Documentation generated on Tue, 06 Dec 2016 04:24:05 +0100 by phpDocumentor 1.4.3