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() |
|---|
arrayDavical user data
stringCalendars name
stringnullDefault privileges to access calendar
boolFlag to define if calendar contains only public event
boolFlat to define publicly readable status
intnullTime zone id.
stringCalendar 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() |
arrayUser parameters, sames as creatUser parameters.
stringCalendar name
intPrinciple type id
arrayArray 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)
arrayDavical user data
stringCollection type
stringCalendars name
stringnullDefault privileges to access calendar
boolFlag to define if calendar contains only public event
boolFlat to define publicly readable status
intnullTime zone id.
stringCalendar description.
arraycreatePrincipal(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. |
|---|
arrayArray of user details.
intPrincipal Type id, by default principal type is person.
arrayof 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() |
arrayUser parameters, sames as creatUser parameters.
intPrinciple type id
arrayArray 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)
arrayUser parameters
arrayof 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 => ...
arrayAll 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)
intCalendar collection id
arraygetCalendarsByUserId(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 ......
intUsers id ( user_no )
arraygetGrantedToPrincipalsIds(int $user_id) : array
Return: array ( size = n ) 0 => ['to_principal' => int 1084 ] 1 => ['to_principal' => int 1084 ] ............. N => array ...
intUser id ( user_no )
arraygetPrincipalById(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)
intPrincipal id
arraygetPrincipalByUserId(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)
intUser id
arraygetSharedCalendarsForUser(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 ...
intUser id ( user_no )
arraygetUserById(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)
intUser id (user_no)
arraygetUserByUsername(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)
stringUsername
arraygetUsersForSharedCalendar(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 ....
intCollection id
arraygrantPrivileges(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.
intUsers for who privleges will be grant.
stringPrivileges to grant.
intUser by who privileges will be grant.
intCollection by which privileges will be grant.
boolFlag if to user is group
\OSS_Execpion |
if $by_user_id and $by_collection_id is null |
|---|
boolhashPassword(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
stringUsers password to login.
stringHash method
stringreturn hashed string.removeCalendar(int $collection_id) : bool
Calls removeCollection() method
| see | \global\removeCollection() |
|---|
intCollection id to remove
booltrue if removed.removeCollection(int $collection_id) : bool
intCollection id to remove
booltrue 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.
intUsers for who privleges will be removed.
intUser by who privileges will be removed.
\OSS_Execpion |
if $by_user_id and $by_collection_id is null |
|---|
boolremoveUser(int $user_id) : bool
intUser id to remove (user_no)
booltrue if removed.setUserActiveState(int $user_id, bool $active) : bool
intUser id ( user_no )
boolActive state true for active, false for inactive.
boolture if successsetUserPassword(int $user_id, string $hashed_password) : bool
intUser id ( user_no )
stringHashed pasword.
boolture 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.
boolunshareCalendar($user_no, $collection_id) : bool
Sets existent privileges to PRIVILEGES_BLOCK.
boolupdateGrantPrivileges(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.
intUsers for who privleges will be updated.
stringPrivileges to set.
intUser by who privileges will be updated.
intCollection 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