Zarafa specific functions — This section describes Zarafa specific functions to manage users and groups and get and set permissions on folders.
long mapi_zarafa_createuser(store $storeid,
string $username,
string $password,
string $fullname,
string $emailaddress,
long $isnonactive,
long $isadmin);
boolean mapi_zarafa_setuser(store $store,
long $userid,
string $username,
string $fullname,
string $emailaddress,
string $password,
long $isnonactive,
long $isadmin);
boolean mapi_zarafa_createstore(store $storeid,
long $storetype,
long $userid);
boolean mapi_zarafa_deleteuser(resource $store,
string $username);
array mapi_zarafa_getuserlist(resource $messagestore,
int $companyid);
array mapi_zarafa_getuser_by_id(resource $messagestore,
int $userid);
array mapi_zarafa_getuser_by_name(resource $messagestore,
string $username);
array mapi_zarafa_getgroup_by_id(resource $messagestore,
int $groupid);
array mapi_zarafa_getgroup_by_name(resource $messagestore,
string $group);
boolean mapi_zarafa_setgroup(resource $messagestore,
long $groupid,
string $groupname);
array mapi_zarafa_getgrouplist(resource $messagestore,
int $companyid);
long mapi_zarafa_creategroup(resource $messagestore,
string $groupname);
boolean mapi_zarafa_deletegroup(resource $messagestore,
string $groupname);
boolean mapi_zarafa_addgroupmember(resource $messagestore,
int $groupid,
int $userid);
boolean mapi_zarafa_deletegroupmember(resource $messagestore,
int $groupid,
int $userid);
array mapi_zarafa_getgrouplistofuser(resource $messagestore,
long $userid);
array mapi_zarafa_getuserlistofgroup(resource $messagestore,
long $groupid);
long mapi_zarafa_createcompany(resource $messagestore,
string $companyname);
boolean mapi_zarafa_deletecompany(resource $messagestore,
string $companyname);
array mapi_zarafa_getcompany_by_id(resource $messagestore,
int $companyid);
array mapi_zarafa_getcompany_by_name(resource $messagestore,
string $company);
array mapi_zarafa_getcompanylist(resource $messagestore);
boolean mapi_zarafa_add_company_remote_viewlist(resource $messagestore,
int $setcompanyid,
int $companyid);
boolean mapi_zarafa_del_company_remote_viewlist(resource $messagestore,
int $setcompanyid,
int $companyid);
array mapi_zarafa_get_remote_viewlist(resource $messagestore,
int $companyid);
boolean mapi_zarafa_add_user_remote_adminlist(resource $messagestore,
int $userid,
int $companyid);
boolean mapi_zarafa_del_user_remote_adminlist(resource $messagestore,
int $userid,
int $companyid);
array mapi_zarafa_get_remote_adminlist(resource $messagestore,
int $companyid);
boolean mapi_zarafa_add_quota_recipient(resource $messagestore,
int $companyid,
int $recipient,
int $type);
boolean mapi_zarafa_del_quota_recipient(resource $messagestore,
int $companyid,
int $recipientid,
int $type);
array mapi_zarafa_get_quota_recipientlist(resource $messagestore,
int $userid);
array mapi_zarafa_getpermissionrules(resource $mapiobject,
long $acl_type);
boolean mapi_zarafa_setpermissionrules(resource $mapiobject,
array $acls);
boolean mapi_inetmap_imtoinet(resource $session,
resource $addrbook,
resource $message,
array $flags);
long mapi_zarafa_createuser(store $storeid, string $username, string $password, string $fullname, string $emailaddress, long $isnonactive, long $isadmin)
Creates a new user on an Zarafa server
Creates a new user on the Zarafa server. This can only be done when a store is specified which is logged on to a server with administration rights. The user is then created, but is initially 'nonactive' after being created. If the username existed before the call to mapi_zarafa_createstore(), an error is generated. The returned value can be used in a call to mapi_zarafa_setuser to set user settings of the created user.
Example 3.87. Creating a user
$session = mapi_logon_zarafa($admin_user, $password, $serverlocation); $stores = mapi_getmsgstorestable($session); $storeslist = mapi_table_queryallrows($stores); $adminstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]); $userid = mapi_zarafa_createuser($adminstore, "newuser", "pass", "New User Name", "new@test.com"); if($userid == false) { print "Error creating user\n"; }
Sets user information for a specific user on a Zarafa server
This function sets the user information on a user previously created (with mapi_zarafa_createuser). This call can only be done by users with administration rights on the server.
boolean mapi_zarafa_setuser(store $store,
long $userid,
string $username,
string $fullname,
string $emailaddress,
string $password,
long $isnonactive,
long $isadmin);
Example 3.88. Setting user information
$store = mapi_openmsgstore_zarafa("user","password"); $userid = mapi_zarafa_createuser($store, "newuser", "pass", "New User Name", "new@test.com"); if($userid == false) print "Error creating user\n"; else mapi_zarafa_setuser($store, $userid, 'John Doe', 'john.doe@domain.com', 'password', 0);
Creates a store on a Zarafa server
Creates a complete store either for a specific user or creates a public store. When creating a user store, the standard folders 'Inbox', 'Outbox', etc. are all created and added to the store.
boolean mapi_zarafa_createstore(store $storeid,
long $storetype,
long $userid);
Example 3.89. Creating a store
$store = mapi_openmsgstore_zarafa("user","password"); $userid = mapi_zarafa_createuser($store, "newuser"); if($userid == false) print "Error creating user\n"; mapi_zarafa_setuser($store, $userid, 'John Doe', 'john.doe@domain.com', 'password', 0); mapi_zarafa_createstore($store, 0, $userid);
Deletes a Zarafa user.
This function deletes a user from the Zarafa
server. The deleted store will be moved to an Admin folder
in the toplevel of the public
store. true
is returned on
success.
boolean mapi_zarafa_deleteuser(resource $store,
string $username);
Example 3.90. Deleting a user
// Deleting a user, deleting store with it. $result = mapi_zarafa_deleteuser($store, "john");
Retreive a list of Zarafa users.
Returns an associative array of all users, with the username as key, and the full name as value.
array mapi_zarafa_getuserlist(resource $messagestore,
int $companyid);
Example 3.91. Listing the Zarafa users
$tempStoreslist = mapi_openmsgstore_zarafa($username, "password", "http://localhost:236/zarafa"); $msgstore = $tempStoreslist[0]; $users = mapi_zarafa_getuserlist($msgstore); print_r($users);
Array ( [SYSTEM] => SYSTEM User [username] => Fullname )
Retreive user information for zarafa user.
Returns an associative array of information for the specified user, or FALSE of the user does not exist or an other error occurred. The associative array contains 'userid', 'username', 'fullname', 'emailaddress', 'nonactive' and 'admin'.
array mapi_zarafa_getuser_by_id(resource $messagestore,
int $userid);
Example 3.92. Getting user information
$info = mapi_zarafa_getuser_by_id($msgstore, 10); print $info["userid"]; print $info["username"]; print $info["fullname"]; print $info["emailaddress"]; print $info["admin"]; print $info["nonactive"];
Retreive user information for zarafa user.
Returns an associative array of information for the specified user, or FALSE of the user does not exist or an other error occurred. The associative array contains 'userid', 'username', 'fullname', 'emailaddress', 'nonactive' and 'admin'.
array mapi_zarafa_getuser_by_name(resource $messagestore,
string $username);
Example 3.93. Getting user information
$info = mapi_zarafa_getuser($msgstore, "username"); print $info["userid"]; print $info["username"]; print $info["fullname"]; print $info["emailaddress"]; print $info["admin"]; print $info["nonactive"];
Retrieve group information for zarafa group.
Returns an associative array of information for the specified group, or FALSE of the group does not exist or an other error occurred. The associative array contains 'groupid' and 'groupname'.
array mapi_zarafa_getgroup_by_id(resource $messagestore,
int $groupid);
Example 3.94. Getting group information
$info = mapi_zarafa_getgroup_by_id($msgstore, 2); print $info["groupid"]; print $info["groupname"];
Retrieve group information for zarafa group.
Returns an associative array of information for the specified group, or FALSE of the group does not exist or an other error occurred. The associative array contains 'groupid' and 'groupname'.
array mapi_zarafa_getgroup_by_name(resource $messagestore,
string $group);
Example 3.95. Getting group information
$info = mapi_zarafa_getgroup($msgstore, "Everyone"); print $info["groupid"]; print $info["groupname"];
Set group information for a specific Zarafa group.
Modifies the given group, setting the groupname. Basically, this is a 'rename' of a group, as groups currently have no other information apart from their name. Returns TRUE on success, FALSE on error.
boolean mapi_zarafa_setgroup(resource $messagestore,
long $groupid,
string $groupname);
Get list of all groups
Returns an array of all groups. Each list item is an associative array with the keys 'groupname' and 'groupid'. There are as many items in the returned array as there are groups that are viewable by the user
array mapi_zarafa_getgrouplist(resource $messagestore,
int $companyid);
Create a new group.
This function creates a new group with the specified name on the server. After creation, the group will contain no users. Returns TRUE if the group was created successfully, FALSE if the creation failed. You cannot create a group which already exists.
long mapi_zarafa_creategroup(resource $messagestore,
string $groupname);
Delete an existing group.
This function deletes a group on the server. Any users within this group are left untouched. Returns TRUE if the deletion was successful, FALSE if the group could not be deleted (not found).
boolean mapi_zarafa_deletegroup(resource $messagestore,
string $groupname);
Add a user to a group.
This function adds a user to an existing group. Returns TRUE on success, FALSE on failure (ie unknown user or unknown group)
boolean mapi_zarafa_addgroupmember(resource $messagestore,
int $groupid,
int $userid);
Delete a user from a group.
This function deletes a user from an existing group. Returns TRUE on success, FALSE on failure (ie unknown user or unknown group)
boolean mapi_zarafa_deletegroupmember(resource $messagestore,
int $groupid,
int $userid);
Example 3.101. Deleting a user from a group
mapi_zarafa_deletegroupmember($msgstore,$groupid,$userid);
Get a list of groups for a specific user.
This function returns a list of groups in the same way as mapi_zarafa_getgrouplist, but only returns the groups of which the specified user is a member.
array mapi_zarafa_getgrouplistofuser(resource $messagestore,
long $userid);
Get a list of users for a specific group.
This function returns a list of users in the same way as mapi_zarafa_getuserlist, but only returns the users that are members of the specified group.
array mapi_zarafa_getuserlistofgroup(resource $messagestore,
long $groupid);
Create a new company.
This function creates a new company with the specified name on the server. After creation, the company will contain no users. Returns TRUE if the company was created successfully, FALSE if the creation failed. You cannot create a company which already exists.
long mapi_zarafa_createcompany(resource $messagestore,
string $companyname);
Delete an existing company.
This function deletes a company on the server. Any users within this company are left untouched. Returns TRUE if the deletion was successful, FALSE if the company could not be deleted (not found).
boolean mapi_zarafa_deletecompany(resource $messagestore,
string $companyname);
Retrieve company information for zarafa company.
Returns an associative array of information for the specified company, or FALSE of the company does not exist or an other error occurred. The associative array contains 'companyid' and 'companyname'.
array mapi_zarafa_getcompany_by_id(resource $messagestore,
int $companyid);
Example 3.106. Getting company information
$info = mapi_zarafa_getcompany_by_id($msgstore, 2); print $info["companyid"]; print $info["companyname"];
Retrieve company information for zarafa company.
Returns an associative array of information for the specified company, or FALSE of the company does not exist or an other error occurred. The associative array contains 'companyid' and 'companyname'.
array mapi_zarafa_getcompany_by_name(resource $messagestore,
string $company);
Example 3.107. Getting company information
$info = mapi_zarafa_getcompany_by_name($msgstore, "default"); print $info["companyid"]; print $info["companyname"];
Get list of all companies
Returns an array of all companies on the server.Each list item is an associative array with the keys 'companyname' and 'companyid'. There are as many items in the returned array as there are companies
array mapi_zarafa_getcompanylist(resource $messagestore);
Add a company to the remote view list of a different company
This will add a company (setcompanyid) to the remote view list of a different company (companyid). This will allow the members of company 'companyid' to view the members of company 'setcompanyid'.
boolean mapi_zarafa_add_company_remote_viewlist(resource $messagestore,
int $setcompanyid,
int $companyid);
Example 3.109. Add a company to the remote view list of a different company
mapi_zarafa_add_company_remote_viewlist($msgstore, $setcompanyid, $companyid);
Delete a company from the remote view list of a different company
This will delete a company (setcompanyid) from the remote view list of a different company (companyid). This will prevent the members of company 'companyid' to view the members of company 'setcompanyid'.
boolean mapi_zarafa_del_company_remote_viewlist(resource $messagestore,
int $setcompanyid,
int $companyid);
Example 3.110. Delete a company from the remote view list of a different company
mapi_zarafa_del_company_remote_viewlist($msgstore, $setcompanyid, $companyid);
List all companies in the remote view list
This will return the remote view list for the specified company.
array mapi_zarafa_get_remote_viewlist(resource $messagestore,
int $companyid);
Example 3.111. List all companies in the remote view list
$companies = mapi_zarafa_get_remote_viewlist($msgstore, $companyid); print_r($companies);
Add a user to the remote admin list of a company
This will add a user to the remote admin list of a company. This will allow the user to perform administrator tasks over the specified company.
boolean mapi_zarafa_add_user_remote_adminlist(resource $messagestore,
int $userid,
int $companyid);
Example 3.112. Add a user to the remote admin list of a different company
mapi_zarafa_add_user_remote_adminlist($msgstore, $userid, $companyid);
Delete a user from the remote admin list of a company
This will delete an user from the remote admin list of a company. This will strip the administrator rights for the user on the specified company.
boolean mapi_zarafa_del_user_remote_adminlist(resource $messagestore,
int $userid,
int $companyid);
Example 3.113. Delete a user from the admin list of a company
mapi_zarafa_del_user_remote_adminlist($msgstore, $userid, $companyid);
List all users in the remote admin list
This will return the remote admin list for the specified company.
array mapi_zarafa_get_remote_adminlist(resource $messagestore,
int $companyid);
Example 3.114. List all users in the remote admin list
$users = mapi_zarafa_get_remote_adminlist($msgstore, $companyid); print_r($users);
Add a recipient to the recipient list of a company
When a user exceeds his quota, he will receive a warning email. With this function you can edit the list of additional recipients for this email. With the type argument you can set if the recipient list of userquota or companyquota warnings should be edited.
boolean mapi_zarafa_add_quota_recipient(resource $messagestore,
int $companyid,
int $recipient,
int $type);
Example 3.115. Add a recipient to the recipient list of a company
mapi_zarafa_add_quota_recipient($msgstore, $companyid, $recipientid, USEROBJECT_TYPE_COMPANY);
Delete a recipient from the recipient list of a company
When a user exceeds his quota, he will receive a warning email. With this function you can edit the list of additional recipients for this email. With the type argument you can set if the recipient list of userquota or companyquota warnings should be edited.
boolean mapi_zarafa_del_quota_recipient(resource $messagestore,
int $companyid,
int $recipientid,
int $type);
Example 3.116. Delete a recipient from the recipient list of a company
mapi_zarafa_del_quota_recipient($msgstore, $companyid, $userid, USEROBJECT_TYPE_COMPANY);
List all users in the recipient list
When a user exceeds his quota, he will receive a warning email. With this function you can request the list of additional recipients for this email. The userid as argument can either be a userid or companyid.
array mapi_zarafa_get_quota_recipientlist(resource $messagestore,
int $userid);
Example 3.117. List all users in the recipient list
$users = mapi_zarafa_get_quota_recipientlist($msgstore, $userid); print_r($users);
Get a list of ACLs from an object.
This function returns an array of set ACLs of the requested type.
The type field is one of: ACCESS_TYPE_DENIED, ACCESS_TYPE_GRANT, ACCESS_TYPE_BOTH
The 'rights' field in the array is the access value. These values are defined in the ecRights* defines, found in include/mapidefs.php. The values are bitwise OR-ed. 1531 == 0x5FB == ecRightsAll.
The state field is one of: RIGHT_NORMAL, RIGHT_NEW, RIGHT_MODIFY, RIGHT_DELETED, RIGHT_AUTOUPDATE_DENIED. In the mapi_zarafa_getpermissionrules(), only RIGHT_NORMAL is returned.
array mapi_zarafa_getpermissionrules(resource $mapiobject,
long $acl_type);
This is a mapi object. It can be a store, folder, message or attachment.
Note: Only ACLs on the store and on a folder work.
Example 3.118. Getting the ACL list of the store.
$acls = mapi_zarafa_getpermissionrules($msgstore, ACCESS_TYPE_GRANT); print_r($acls);
Output:
Array ( [0] => Array ( [userid] => 4 [type] => 2 [rights] => 1531 [state] => 0 ) )
Set a list of ACLs on an object.
This function sets returns an array of set ACLs of the requested type.
Each entry contains the following fields: userid, type, rights, state.
boolean mapi_zarafa_setpermissionrules(resource $mapiobject,
array $acls);
This is a mapi object. It can be a store, folder, message or attachment.
Note: Only ACLs on the store and on a folder work.
Example 3.119. Setting the ACL list on the inbox.
$acls = array( 0 => array( 'userid' => 3, 'type' => ACCESS_TYPE_GRANT, 'rights' => ecRightsFullControl, 'state' => RIGHT_NEW | RIGHT_AUTOUPDATE_DENIED ) ); $ret = mapi_zarafa_setpermissionrules($inbox, $acls);
Converts a MAPI Message into an RFC822-formatted e-mail stream.
stream mapi_inetmapi_imtoinet(resource $session,
resource $addrbook,
resource $message,
array $flags);