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 |
[edit] 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";
}
?>
[edit] Functions
[edit] 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.
[edit] Classes
[edit] s60_contacts_Database
This class represents a contact database.
[edit] 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.
[edit] close
close()
Closes the database connection.
[edit] field_types
field_types() -> array of s60_contacts_FieldType
Returns all field types.
[edit] add_contact
add_contact() -> s60_contacts_Contact object
Returns a new empty s60_contacts_Contact object.
[edit] get_contact
get_contact(integer id) -> s60_contacts_Contact object
Returns a s60_contacts_Contact object corresponding to given ID.
[edit] contacts
contacts() -> array of s60_contacts_Contact
Returns all contacts.
[edit] s60_contacts_FieldType
[edit] name
name() -> string
Returns field name.
[edit] id
id() -> integer
Returns field id (e.g. S60_CONTACTS_LAST_NAME).
[edit] location
location() -> integer
Returns field location (e.g. S60_CONTACTS_LOCATION_WORK).
[edit] storage_type
storage_type() --> integer
Returns field storage type (e.g. S60_CONTACTS_STORAGE_TEXT).
[edit] 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.
[edit] is_read_only
is_read_only() -> boolean
Returns true if field is only readable.
[edit] is_name
is_name() -> boolean
S60_CONTACTS_FIRST_NAME and S60_CONTACTS_LAST_NAME are names.
[edit] is_numeric
is_numeric() -> boolean
Numeric types include phone numbers and e.g. P.O. Boxes.
[edit] is_phone_number
is_phone_number() -> boolean
Returns true if field is a phone number field.
[edit] is_email
is_email() -> boolean
Returns true if field is an email field.
[edit] is_email_over_sms
is_email_over_sms() -> boolean
This is similar (or same) as is_email() || is_phone_number()
[edit] is_mms
is_mms() -> boolean
Returns true if field is a mms field.
[edit] is_image
is_image() -> boolean
Returns true if field is an image field.
[edit] is_editable
is_editable() -> boolean
Returns true if user can modify this field.
[edit] is_addable
is_addable() -> boolean
Returns true if user can add this type of fields.
[edit] 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().
[edit] s60_contacts_Contact
This class represents a single entry in contact database.
[edit] id
id() -> integer
Unique identifier for contact. To be used with get_contact() from s60_contacts_Database class.
[edit] title
title() -> string
Returns title of contact.
[edit] last_modified
last_modified() -> float
Returns timestamp of last modification.
[edit] remove
remove()
Removes the contact. After calling this, the object is useless as it no longer refers to anything.
[edit] begin
begin()
Opens contact for writing. Must be called for contacts received from e.g. s60_contacts_Database class's get_contact(), before editing.
[edit] commit
commit()
Commits the contact. Unless this is called, no changes are made.
[edit] rollback
rollback()
All changes to contact since last call to begin() will disappear.
[edit] fields
fields() -> array of s60_contacs_Field
Returns all fields for the contact.
[edit] 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).
[edit] 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.
[edit] s60_contacts_Field
This class represents a single field in a contact book entry.
[edit] type
type() -> s60_contacts_FieldType object
Returns field's type as s60_contacts_FieldType object.
[edit] label
label() -> string
Returns field's label.
[edit] value
value() -> string or float
Returns string for text fields (also phone numbers), and float for datetime fields.
[edit] set_label
set_label(string new_label)
Sets field's label.
[edit] set_value
set_value(string or float new_value)
Assigns string for text fields (also phone numbers), and float for datetime fields.
[edit] remove
remove()
Removes the field. After calling this, the object is useless as it no longer refers to anything.
[edit] Constants
[edit] 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
[edit] Location types
- S60_CONTACTS_LOCATION_NONE
- S60_CONTACTS_LOCATION_HOME
- S60_CONTACTS_LOCATION_WORK
[edit] Storage types
- S60_CONTACTS_STORAGE_TEXT
- S60_CONTACTS_STORAGE_STORE
- S60_CONTACTS_STORAGE_CONTACT
- S60_CONTACTS_STORAGE_TIME
[edit] Field type multiplicity
- S60_CONTACTS_MULTI_ONE
- S60_CONTACTS_MULTI_MANY
