Class abook_local_file

Description

Backend for address book as a pipe separated file

Stores the address book in a local file

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

   filename  => path to addressbook file
 ? create    => if true: file is created if it does not exist.
 ? umask     => umask set before opening file.
 ? name      => name of address book.
 ? detect_writeable => detect address book access permissions by
                checking file permissions.
 ? writeable => allow writing into address book. Used only when
                detect_writeable is set to false.
 ? listing   => enable/disable listing
 ? line_length => allowed address book record size
NOTE. This class should not be used directly. Use the "AddressBook" class instead.

Located in /functions/abook_local_file.php (line 36)

addressbook_backend
   |
   --abook_local_file
Variable Summary
string $bname
string $btype
bool $create
object $filehandle
string $filename
integer $line_length
bool $listing
string $umask
bool $writeable
Method Summary
bool abook_local_file (array $param)
bool add (array $userdata)
void close ()
array list_addr ()
void lock ()
array lookup (string $value, [integer $field = SM_ABOOK_FIELD_NICKNAME])
bool modify (string $alias, array $userdata)
bool open ([bool $new = false])
bool overwrite ( &$rows, array $rows)
void quotevalue (string $value, string 1)
bool remove (string $alias)
array search (string $expr)
void unlock ()
Variables
string $bname = 'local_file' (line 46)

Backend name


Redefinition of:
addressbook_backend::$bname
string $btype = 'local' (line 41)

Backend type


Redefinition of:
addressbook_backend::$btype
bool $create = false (line 62)

Create file, if it not present

bool $detect_writeable = true (line 67)

Detect, if address book is writeable by checking file permisions

object $filehandle = 0 (line 57)

File handle

string $filename = '' (line 52)

File used to store data

integer $line_length = 2048 (line 92)

Sets max entry size (number of bytes used for all address book fields

(including escapes) + 4 delimiters + 1 linefeed)

  • since: 1.5.2 and 1.4.9
bool $listing = true (line 80)

controls listing of address book

  • since: 1.5.1 and 1.4.9
string $umask (line 85)

Umask of the file

bool $writeable = false (line 74)

Control write access to address book

Option does not have any effect, if 'detect_writeable' is 'true'


Redefinition of:
addressbook_backend::$writeable

Inherited Variables

Inherited from addressbook_backend

addressbook_backend::$bnum
addressbook_backend::$error
addressbook_backend::$sname
Methods
Constructor abook_local_file (line 101)

Constructor

bool abook_local_file (array $param)
  • array $param: backend options
add (line 403)

Add address

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

Redefinition of:
addressbook_backend::add()
close (line 203)

Close the file and forget the filehandle

void close ()
list_addr (line 368)

List all addresses

  • return: list of all addresses
array list_addr ()

Redefinition of:
addressbook_backend::list_addr()
lock (line 211)

Lock the datafile - try 20 times in 5 seconds

void lock ()
lookup (line 331)

Lookup by the indicated field

  • return: search results
array lookup (string $value, [integer $field = SM_ABOOK_FIELD_NICKNAME])
  • string $value: Value to look up
  • integer $field: The field to look in, should be one of the SM_ABOOK_FIELD_* constants defined in functions/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()
modify (line 513)

Modify address

  • return: true, if operation successful
bool modify (string $alias, array $userdata)
  • string $alias: modified alias
  • array $userdata: new data

Redefinition of:
addressbook_backend::modify()
open (line 152)

Open the addressbook file and store the file pointer.

Use $file as the file to open, or the class' own filename property. If $param is empty and file is open, do nothing.

bool open ([bool $new = false])
  • bool $new: is file already opened
overwrite (line 232)

Overwrite the file with data from $rows

NOTE! Previous locks are broken by this function

bool overwrite ( &$rows, array $rows)
  • array $rows: new data
  • &$rows
quotevalue (line 590)

Function for quoting values before saving

void quotevalue (string $value, string 1)
  • string $value: string that has to be quoted
  • string 1: quoted string
remove (line 476)

Delete address

bool remove (string $alias)
  • string $alias: alias that has to be deleted

Redefinition of:
addressbook_backend::remove()
search (line 270)

Search the file

  • return: search results
array search (string $expr)
  • string $expr: search expression

Redefinition of:
addressbook_backend::search()
unlock (line 222)

Unlock the datafile

void unlock ()

Inherited Methods

Inherited From addressbook_backend

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

Documentation generated on Sun, 23 Nov 2014 04:20:17 +0100 by phpDocumentor 1.4.3