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 __construct (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 149)

Constructor (PHP4 style, kept for compatibility reasons)

bool abook_local_file (array $param)
  • array $param: backend options
Constructor __construct (line 101)

Constructor (PHP5 style, required in some future version of PHP)

bool __construct (array $param)
  • array $param: backend options
add (line 412)

Add address

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

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

Close the file and forget the filehandle

void close ()
list_addr (line 377)

List all addresses

  • return: list of all addresses
array list_addr ()

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

Lock the datafile - try 20 times in 5 seconds

void lock ()
lookup (line 340)

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 522)

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 161)

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 241)

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 599)

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 485)

Delete address

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

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

Search the file

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

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

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 Mon, 13 Jan 2020 04:24:11 +0100 by phpDocumentor 1.4.3