A DAViCal API via direct database manipulation.
see | \global\http://davical.org/ |
---|---|
category | OSS |
package | OSS_API |
copyright | Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland |
license | New BSD License |
__construct($dbparams)
createCalendar(array $user, string $name, string | null $privileges, bool $public_events_only, bool $publicly_readable, int | null $timezone, string $description)
Returns same array structure as createCollection
If principal has delegated principals, function iterates all of them and blocks access to new calendar.
see | \global\createCollection() |
---|
array
Davical user data
string
Calendars name
string
null
Default privileges to access calendar
bool
Flag to define if calendar contains only public event
bool
Flat to define publicly readable status
int
null
Time zone id.
string
Calendar description.
createCalendarUser(array $params, string $cname, int $type) : array
Takes same parameters as $this->createUser(); Returns an array wich contains user, principal and calendar collection data. array [ 'user' => array users data, 'principal' => array principals data, 'calendar' => array calendar collection data ]
see | \global\createUser() |
---|---|
see | \global\createPrincipal() |
see | \global\createCalendar() |
array
User parameters, sames as creatUser parameters.
string
Calendar name
int
Principle type id
array
Array wit data of user, principal and calendar collection.createCollection(array $user, string $type, string $name, string | null $privileges, bool $public_events_only, bool $publicly_readable, int | null $timezone, string $description) : array
Returns: array (size=17) 'user_no' => int 1024 'parent_container' => string '/nbdavical/' (length=11) 'dav_name' => string '/nbdavical/calendar/' (length=20) 'dav_etag' => string '-1' (length=2) 'dav_displayname' => string 'Davical User calendar' (length=21) 'is_calendar' => boolean true 'created' => string '2012-12-13 11:39:07.767205+00' (length=29) 'modified' => string '2012-12-13 11:39:07.767205+00' (length=29) 'public_events_only' => boolean false 'publicly_readable' => boolean false 'collection_id' => int 1034 'default_privileges' => null 'is_addressbook' => boolean false 'resourcetypes' => string '<DAV::collection/><urn:ietf:params:xml:ns:carddav:calendar/>' (length=60) 'schedule_transp' => string 'opaque' (length=6) 'timezone' => null 'description' => string '' (length=0)
array
Davical user data
string
Collection type
string
Calendars name
string
null
Default privileges to access calendar
bool
Flag to define if calendar contains only public event
bool
Flat to define publicly readable status
int
null
Time zone id.
string
Calendar description.
array
createPrincipal(array $user, int $type, $privileges) : array
Returns: array (size=5) 'principal_id' => int 1 'type_id' => int 1 'user_no' => int 1 'displayname' => string 'DAViCal Administrator' (length=21) 'default_privileges' => string '000000000000000000000000' (length=24)
pram | string $privileges Default prinicpals privileges by default is read/write. |
---|
array
Array of user details.
int
Principal Type id, by default principal type is person.
array
of prinicpal detailscreatePrincipalUser(array $params, int $type) : array
Takes same parameters as $this->createUser(); Returns an array wich contains user, principal and calendar collection data. array [ 'user' => array users data, 'principal' => array principals data, ]
see | \global\createUser() |
---|---|
see | \global\createPrincipal() |
array
User parameters, sames as creatUser parameters.
int
Principle type id
array
Array wit data of user, principal and calendar collection.createUser(array $params) : array
params: array 'active' => boolean 'email_ok' => string date time e.g.'2012-12-07 00:00:00+00' 'joined' => string date time e.g.'2012-12-07 00:00:00+00' 'updated' => string date time e.g.'2012-12-07 00:00:00+00' 'last_used' => string date time e.g.'2012-12-07 00:00:00+00' 'username' => string mandatory 'password' => string 'fullname' => string 'email' => string 'config_data' => null 'date_format_type' => string e.g. 'E' 'locale' => string e.g. 'en'
Returns: array 'user_no' => int 1 'active' => boolean true 'email_ok' => string '2012-12-07 00:00:00+00' (length=22) 'joined' => string '2012-12-07 11:49:55.231231+00' (length=29) 'updated' => string '2012-12-07 13:27:31.698669+00' (length=29) 'last_used' => string '2012-12-11 10:01:29.831451+00' (length=29) 'username' => string 'usrname' (length=7) 'password' => string 'encrypted' (length=9) 'fullname' => string 'Name susrname' (length=13) 'email' => string 'example@example.ie' (length=18) 'config_data' => null 'date_format_type' => string 'E' (length=1) 'locale' => string 'en' (length=2)
array
User parameters
array
of user detailsgetAllUsers() : array
Returns: array (size=n) 0 => 'user_no' => int 1 'active' => boolean true 'email_ok' => string '2012-12-07 00:00:00+00' (length=22) 'joined' => string '2012-12-07 11:49:55.231231+00' (length=29) 'updated' => string '2012-12-07 13:27:31.698669+00' (length=29) 'last_used' => string '2012-12-11 10:01:29.831451+00' (length=29) 'username' => string 'usrname' (length=7) 'password' => string 'hashed' (length=9) 'fullname' => string 'Name susrname' (length=13) 'email' => string 'example@example.ie' (length=18) 'config_data' => null 'date_format_type' => string 'E' (length=1) 'locale' => string 'en' (length=2) 1 => ...
array
All users registered in the databasegetCalendarById(int $collection_id) : array
Returns: array (size=17) 'user_no' => int 1024 'parent_container' => string '/nbdavical/' (length=11) 'dav_name' => string '/nbdavical/calendar/' (length=20) 'dav_etag' => string '-1' (length=2) 'dav_displayname' => string 'Davical User calendar' (length=21) 'is_calendar' => boolean true 'created' => string '2012-12-13 11:39:07.767205+00' (length=29) 'modified' => string '2012-12-13 11:39:07.767205+00' (length=29) 'public_events_only' => boolean false 'publicly_readable' => boolean false 'collection_id' => int 1034 'default_privileges' => null 'is_addressbook' => boolean false 'resourcetypes' => string '<DAV::collection/><urn:ietf:params:xml:ns:carddav:calendar/>' (length=60) 'schedule_transp' => string 'opaque' (length=6) 'timezone' => null 'description' => string '' (length=0)
int
Calendar collection id
array
getCalendarsByUserId(int $user_id) : array
Returns: array( size=n ) 0=> array (size=17) 'user_no' => int 1024 'parent_container' => string '/nbdavical/' (length=11) 'dav_name' => string '/nbdavical/calendar/' (length=20) 'dav_etag' => string '-1' (length=2) 'dav_displayname' => string 'Davical User calendar' (length=21) 'is_calendar' => boolean true 'created' => string '2012-12-13 11:39:07.767205+00' (length=29) 'modified' => string '2012-12-13 11:39:07.767205+00' (length=29) 'public_events_only' => boolean false 'publicly_readable' => boolean false 'collection_id' => int 1034 'default_privileges' => null 'is_addressbook' => boolean false 'resourcetypes' => string '<DAV::collection/><urn:ietf:params:xml:ns:carddav:calendar/>' (length=60) 'schedule_transp' => string 'opaque' (length=6) 'timezone' => null 'description' => string '' (length=0) 1 => array ......
int
Users id ( user_no )
array
getGrantedToPrincipalsIds(int $user_id) : array
Return: array ( size = n ) 0 => ['to_principal' => int 1084 ] 1 => ['to_principal' => int 1084 ] ............. N => array ...
int
User id ( user_no )
array
getPrincipalById(int $principal_id) : array
Returns: array (size=5) 'principal_id' => int 1 'type_id' => int 1 'user_no' => int 1 'displayname' => string 'DAViCal Administrator' (length=21) 'default_privileges' => string '000000000000000000000000' (length=24)
int
Principal id
array
getPrincipalByUserId(int $user_no) : array
Returns: array (size=5) 'principal_id' => int 1 'type_id' => int 1 'user_no' => int 1 'displayname' => string 'DAViCal Administrator' (length=21) 'default_privileges' => string '000000000000000000000000' (length=24)
int
User id
array
getSharedCalendarsForUser(int $user_id) : array
Calendars with PRIVILEGES_BLOCK are ignored.
Return: array ( size = n ) 0 => array (size=25) 'by_principal' => int 1100 'by_collection' => int 1101 'to_principal' => int 1084 'privileges' => string '000000001111111011100111' (length=24) 'is_group' => null 'principal_id' => int 1084 'type_id' => int 1 'user_no' => int 1051 'displayname' => string 'Davical Box' (length=11) 'default_privileges' => null 'parent_container' => string '/sdcc@sdcc.ie/' (length=14) 'dav_name' => string '/sdcc@sdcc.ie/calendar/' (length=23) 'dav_etag' => string '-1' (length=2) 'dav_displayname' => string 'South Dublin County Council calendar' (length=36) 'is_calendar' => boolean true 'created' => string '2012-12-14 16:24:20.325642+00' (length=29) 'modified' => string '2012-12-14 16:24:20.325642+00' (length=29) 'public_events_only' => boolean false 'publicly_readable' => boolean false 'collection_id' => int 1101 'is_addressbook' => boolean false 'resourcetypes' => string '<DAV::collection/><urn:ietf:params:xml:ns:carddav:calendar/>'' (length=61) 'schedule_transp' => string 'opaque' (length=6) 'timezone' => null 'description' => string '' (length=0) 1 => array ...
int
User id ( user_no )
array
getUserById(int $user_id) : array
Returns: array (size=13) 'user_no' => int 1 'active' => boolean true 'email_ok' => string '2012-12-07 00:00:00+00' (length=22) 'joined' => string '2012-12-07 11:49:55.231231+00' (length=29) 'updated' => string '2012-12-07 13:27:31.698669+00' (length=29) 'last_used' => string '2012-12-11 10:01:29.831451+00' (length=29) 'username' => string 'usrname' (length=7) 'password' => string 'encrypted' (length=9) 'fullname' => string 'Name susrname' (length=13) 'email' => string 'example@example.ie' (length=18) 'config_data' => null 'date_format_type' => string 'E' (length=1) 'locale' => string 'en' (length=2)
int
User id (user_no)
array
getUserByUsername(string $username) : array
Returns: array (size=13) 'user_no' => int 1 'active' => boolean true 'email_ok' => string '2012-12-07 00:00:00+00' (length=22) 'joined' => string '2012-12-07 11:49:55.231231+00' (length=29) 'updated' => string '2012-12-07 13:27:31.698669+00' (length=29) 'last_used' => string '2012-12-11 10:01:29.831451+00' (length=29) 'username' => string 'usrname' (length=7) 'password' => string 'encrypted' (length=9) 'fullname' => string 'Name susrname' (length=13) 'email' => string 'example@example.ie' (length=18) 'config_data' => null 'date_format_type' => string 'E' (length=1) 'locale' => string 'en' (length=2)
string
Username
array
getUsersForSharedCalendar(int $collection_id) : array
Users with PRIVILEGES_BLOCK are ignored.
Return: array ( size = n ) 0 => array (size=22) 'by_principal' => int 1094 'by_collection' => int 1095 'to_principal' => int 1089 'privileges' => string '000000001111111011100111' (length=24) 'is_group' => null 'principal_id' => int 1089 'type_id' => int 1 'user_no' => int 1048 'displayname' => string 'Nerijus Barauskas' (length=17) 'default_privileges' => string '000000000000000000000000' (length=24) 'active' => boolean true 'email_ok' => null 'joined' => string '2012-12-14 13:25:53.173706+00' (length=29) 'updated' => string '2012-12-14 13:25:53.173706+00' (length=29) 'last_used' => null 'username' => string 'nerijus@opensolutions.ie' (length=24) 'password' => string '**qwerty78' (length=10) 'fullname' => string 'Nerijus Barauskas' (length=17) 'email' => string 'nerijus@opensolutions.ie' (length=24) 'config_data' => null 'date_format_type' => string 'E' (length=1) 'locale' => null 1 => aray ....
int
Collection id
array
grantPrivileges(int $to_user_id, string $privileges, int $by_user_id, int $by_collection_id, bool $is_group) : bool
Grants privleges to principal if by_user_id is set or grant privileges to collection if by_collection_id is set. Users IDs should be passed, principal IDs will be loaded from database.
NOTICE: $by_user_id or $by_collection_id are mandatory params, if both is null it will thorw an Exception.
int
Users for who privleges will be grant.
string
Privileges to grant.
int
User by who privileges will be grant.
int
Collection by which privileges will be grant.
bool
Flag if to user is group
\OSS_Execpion |
if $by_user_id and $by_collection_id is null |
---|
bool
hashPassword(string $password, string $method) : string
It hashes three davical supported types hash:
* First and most unsecured hash is plain it just add two start infont of password.
* Second is md5 result is
string
Users password to login.
string
Hash method
string
return hashed string.removeCalendar(int $collection_id) : bool
Calls removeCollection() method
see | \global\removeCollection() |
---|
int
Collection id to remove
bool
true if removed.removeCollection(int $collection_id) : bool
int
Collection id to remove
bool
true if removed.removeGrantPrivileges(int $to_user_id, int $by_user_id, $by_collection_id) : bool
Grants privleges for prinicipal to collection or for principal to principal Users IDs should be passed, principal IDs will be loaded from database.
NOTICE: $by_user_id or $by_collection_id are mandatory params, if both is null it will thorw an Exception.
int
Users for who privleges will be removed.
int
User by who privileges will be removed.
\OSS_Execpion |
if $by_user_id and $by_collection_id is null |
---|
bool
removeUser(int $user_id) : bool
int
User id to remove (user_no)
bool
true if removed.setUserActiveState(int $user_id, bool $active) : bool
int
User id ( user_no )
bool
Active state true for active, false for inactive.
bool
ture if successsetUserPassword(int $user_id, string $hashed_password) : bool
int
User id ( user_no )
string
Hashed pasword.
bool
ture if successshareCalendar($user_no, $collection_id, $privileges) : bool
Then sharing calendar then function iterate all users delegate principals if new calendar's owner is already in list then it just update privileges. Otherwise it grants principal privileges to read only then iterate to all calendars and block the access for them, and finally set correct privileges to given calendar.
bool
unshareCalendar($user_no, $collection_id) : bool
Sets existent privileges to PRIVILEGES_BLOCK.
bool
updateGrantPrivileges(int $to_user_id, string $privileges, int $by_user_id, int $by_collection_id) : bool
Updated grants privleges to principal if by_user_id is set or grant privileges to collection if by_collection_id is set. Users IDs should be passed, principal IDs will be loaded from database.
NOTICE: $by_user_id or $by_collection_id are mandatory params, if both is null it will thorw an Exception.
int
Users for who privleges will be updated.
string
Privileges to set.
int
User by who privileges will be updated.
int
Collection by which privileges will be updated.
\OSS_Execpion |
if $by_user_id and $by_collection_id is null |
---|
bool
$PRIVILEGES
COLLECTION_TYPE_ADDRESSBOOK
COLLECTION_TYPE_CALENDAR
PASSWORD_HASH_MD5
PASSWORD_HASH_PLAIN
PASSWORD_HASH_SSHA
PRINCIPAL_TYPE_GROUP
PRINCIPAL_TYPE_PERSON
PRINCIPAL_TYPE_RESOURCE
PRIVILEGES_BLOCK
PRIVILEGES_NONE
PRIVILEGES_RO
PRIVILEGES_RW