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
NOTE. This class should not be used directly. Use the "AddressBook" class instead.

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

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

Backend name


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

Backend type


Redefinition of:
addressbook_backend::$btype
Backend type
bool $create = false (line 61)

Create file, if it not present

bool $detect_writeable = true (line 66)

Detect, if address book is writeable by checking file permisions

object $filehandle = 0 (line 56)

File handle

string $filename = '' (line 51)

File used to store data

integer $line_length = 2048 (line 90)

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

(including escapes) + 4 delimiters + 1 linefeed)

  • since: 1.5.2
bool $listing = true (line 78)

controls listing of address book

string $umask (line 83)

Umask of the file

bool $writeable = false (line 73)

Control write access to address book

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


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_local_file (line 147)

Constructor (PHP4 style, kept for compatibility reasons)

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

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

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

Add address

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

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

Close the file and forget the filehandle

void close ()
list_addr (line 388)

List all addresses

  • return: list of all addresses
array list_addr ()

Redefinition of:
addressbook_backend::list_addr()
List all entries in backend
lock (line 218)

Lock the datafile - try 20 times in 5 seconds

void lock ()
lookup (line 348)

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

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()
Modify entry in backend
open (line 159)

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

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

Delete address

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

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

Search the file

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

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

Unlock the datafile

void unlock ()

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