PAMP:s60 contacts
From OpenSource
Extension for interacting with host phone's contact book.
NOTE Using module will crash (panic) on S60 version 3.x if it hasn't been installed with proper capabilities: WriteDeviceData and ReadDeviceData.
Contents |
Example Usage
<?php
$db = s60_contacts_open();
foreach ($db->contacts() as $c) {
print "Title: ".$c->title()."\n";
foreach ($c->fields() as $f) {
print $f->label()." : ".$f->value()."\n";
}
print "\n\n";
}
?>
Functions
s60_contacts_open
s60_contacts_open(string filename, string flag) -> s60_contacts_Database object
Returns an open s60_contacts_Database object. (or NULL on error)
- s60_contacts_open() - opens the default contact database file
- s60_contacts_open($filename [, 'e']) - opens file if it exists. Returns false if it doesn't.
- s60_contacts_open($filename , 'c') - opens file, creates new database if the file does not exist.
- s60_contacts_open($filename , 'n') - creates new empty database file and opens it.
Classes
s60_contacts_Database
This class represents a contact database.
open
open(string filename, string flag)
open() - opens the default contact database file
- open($filename [, 'e']) - opens file if it exists. Returns false if it doesn't.
- open($filename , 'c') - opens file, creates new database if the file does not exist.
- open($filename , 'n') - creates new empty database file and opens it.
close
close()
Closes the database connection.
field_types
field_types() -> array of s60_contacts_FieldType
Returns all field types.
add_contact
add_contact() -> s60_contacts_Contact object
Returns a new empty s60_contacts_Contact object.
get_contact
get_contact(integer id) -> s60_contacts_Contact object
Returns a s60_contacts_Contact object corresponding to given ID.
contacts
contacts() -> array of s60_contacts_Contact
Returns all contacts.
s60_contacts_FieldType
name
name() -> string
Returns field name.
id
id() -> integer
Returns field id (e.g. S60_CONTACTS_LAST_NAME).
location
location() -> integer
Returns field location (e.g. S60_CONTACTS_LOCATION_WORK).
storage_type
storage_type() --> integer
Returns field storage type (e.g. S60_CONTACTS_STORAGE_TEXT).
multi
multi() -> integer
Returns field multiplicity (e.g. S60_CONTACTS_MULTI_ONE)
- S60_CONTACTS_MULTI_ONE means that there may be zero or one fields of that type.
- S60_CONTACTS_MULTI_MANY means that there may be zero or more fields of that type.
is_read_only
is_read_only() -> boolean
Returns true if field is only readable.
is_name
is_name() -> boolean
S60_CONTACTS_FIRST_NAME and S60_CONTACTS_LAST_NAME are names.
is_numeric
is_numeric() -> boolean
Numeric types include phone numbers and e.g. P.O. Boxes.
is_phone_number
is_phone_number() -> boolean
Returns true if field is a phone number field.
is_email
is_email() -> boolean
Returns true if field is an email field.
is_email_over_sms
is_email_over_sms() -> boolean
This is similar (or same) as is_email() || is_phone_number()
is_mms
is_mms() -> boolean
Returns true if field is a mms field.
is_image
is_image() -> boolean
Returns true if field is an image field.
is_editable
is_editable() -> boolean
Returns true if user can modify this field.
is_addable
is_addable() -> boolean
Returns true if user can add this type of fields.
get_add_label
get_add_label() -> string
Returns a string representing the field type label shown when field type is added. Usually this is identical to name().
s60_contacts_Contact
This class represents a single entry in contact database.
id
id() -> integer
Unique identifier for contact. To be used with get_contact() from s60_contacts_Database class.
title
title() -> string
Returns title of contact.
last_modified
last_modified() -> float
Returns timestamp of last modification.
remove
remove()
Removes the contact. After calling this, the object is useless as it no longer refers to anything.
begin
begin()
Opens contact for writing. Must be called for contacts received from e.g. s60_contacts_Database class's get_contact(), before editing.
commit
commit()
Commits the contact. Unless this is called, no changes are made.
rollback
rollback()
All changes to contact since last call to begin() will disappear.
fields
fields() -> array of s60_contacs_Field
Returns all fields for the contact.
find_fields
find_fields(integer fieldId, integer location) -> array of s60_contacts_Field
Returns fields that match the search criteria. For a specific FieldType $ft one can find those fields by calling find_fields($ft->id(), $ft->location()) . Alternatively one could do e.g. find_fields(S60_CONTACTS_FIRST_NAME).
add_field
add_field(integer fieldId, integer location) -> s60_contacts_Field object
Adds a new field with default label and empty value, and returns a field object.
s60_contacts_Field
This class represents a single field in a contact book entry.
type
type() -> s60_contacts_FieldType object
Returns field's type as s60_contacts_FieldType object.
label
label() -> string
Returns field's label.
value
value() -> string or float
Returns string for text fields (also phone numbers), and float for datetime fields.
set_label
set_label(string new_label)
Sets field's label.
set_value
set_value(string or float new_value)
Assigns string for text fields (also phone numbers), and float for datetime fields.
remove
remove()
Removes the field. After calling this, the object is useless as it no longer refers to anything.
Constants
Field types
- S60_CONTACTS_NONE
- S60_CONTACTS_LAST_NAME
- S60_CONTACTS_FIRST_NAME
- S60_CONTACTS_PHONE_GENERAL
- S60_CONTACTS_PHONE_STANDARD
- S60_CONTACTS_PHONE_HOME
- S60_CONTACTS_PHONE_WORK
- S60_CONTACTS_PHONE_MOBILE
- S60_CONTACTS_FAX
- S60_CONTACTS_PAGER
- S60_CONTACTS_EMAIL
- S60_CONTACTS_POSTAL_ADDRESS
- S60_CONTACTS_URL
- S60_CONTACTS_JOB_TITLE
- S60_CONTACTS_COMPANY_NAME
- S60_CONTACTS_COMPANY_ADDRESS
- S60_CONTACTS_DTMF_STRING
- S60_CONTACTS_DATE
- S60_CONTACTS_NOTE
- S60_CONTACTS_PO_BOX
- S60_CONTACTS_EXTENDED_ADDDRESS
- S60_CONTACTS_STREET_ADDRESS
- S60_CONTACTS_POSTAL_CODE
- S60_CONTACTS_CITY
- S60_CONTACTS_STATE
- S60_CONTACTS_COUNTRY
- S60_CONTACTS_WVID
Location types
- S60_CONTACTS_LOCATION_NONE
- S60_CONTACTS_LOCATION_HOME
- S60_CONTACTS_LOCATION_WORK
Storage types
- S60_CONTACTS_STORAGE_TEXT
- S60_CONTACTS_STORAGE_STORE
- S60_CONTACTS_STORAGE_CONTACT
- S60_CONTACTS_STORAGE_TIME
Field type multiplicity
- S60_CONTACTS_MULTI_ONE
- S60_CONTACTS_MULTI_MANY
