Commit 44578f78 authored by mku's avatar mku

ZP-215 #comment Review and optimize address book function usage #time 30m

git-svn-id: https://z-push.org/svn/z-push/trunk@1433 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent c1390b04
......@@ -45,6 +45,7 @@ class MAPIProvider {
private $session;
private $store;
private $zRFC822;
private $addressbook;
/**
* Constructor of the MAPI Provider
......@@ -1122,18 +1123,18 @@ class MAPIProvider {
//always set the PR_SENT_REPRESENTING_* props so that the attendee status update also works with the webaccess
if (!isset($props[$appointmentprops["representingentryid"]])) {
$props[$appointmentprops["representingname"]] = Request::GetAuthUser();
$props[$appointmentprops["sentrepresentingemail"]] = Request::GetAuthUser();
$props[$appointmentprops["sentrepresentingaddt"]] = "ZARAFA";
$props[$appointmentprops["representingentryid"]] = mapi_createoneoff(Request::GetAuthUser(), "ZARAFA", Request::GetAuthUser());
$props[$appointmentprops["representingname"]] = Request::GetAuthUser();
$props[$appointmentprops["sentrepresentingemail"]] = Request::GetAuthUser();
$props[$appointmentprops["sentrepresentingaddt"]] = "ZARAFA";
$props[$appointmentprops["representingentryid"]] = mapi_createoneoff(Request::GetAuthUser(), "ZARAFA", Request::GetAuthUser());
}
// Do attendees
if(isset($appointment->attendees) && is_array($appointment->attendees)) {
$recips = array();
//open addresss book for user resolve
$addrbook = mapi_openaddressbook($this->session);
//open addresss book for user resolve
$addrbook = $this->getAddressbook();
foreach($appointment->attendees as $attendee) {
$recip = array();
$recip[PR_EMAIL_ADDRESS] = u2w($attendee->email);
......@@ -1843,9 +1844,9 @@ class MAPIProvider {
* @return string
*/
private function getSMTPAddressFromEntryID($entryid) {
$ab = mapi_openaddressbook($this->session);
$addrbook = $this->getAddressbook();
$mailuser = mapi_ab_openentry($ab, $entryid);
$mailuser = mapi_ab_openentry($addrbook, $entryid);
if(!$mailuser)
return "";
......@@ -2157,8 +2158,8 @@ class MAPIProvider {
*/
private function imtoinet($mapimessage, &$message) {
if (function_exists("mapi_inetmapi_imtoinet")) {
$addrBook = mapi_openaddressbook($this->session);
$mstream = mapi_inetmapi_imtoinet($this->session, $addrBook, $mapimessage, array());
$addrbook = $this->getAddressbook();
$mstream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array());
$mstreamstat = mapi_stream_stat($mstream);
if ($mstreamstat['cb'] < MAX_EMBEDDED_SIZE) {
......@@ -2390,6 +2391,25 @@ class MAPIProvider {
$props[$appointmentprops["body"]] = "";
}
}
/**
* Get MAPI addressbook object
*
* @access private
* @return MAPIAddressbook object to be used with mapi_ab_* or false on failure
*/
private function getAddressbook() {
if (isset($this->addressbook) && $this->addressbook) {
return $this->addressbook;
}
$this->addressbook = mapi_openaddressbook($this->session);
$result = mapi_last_hresult();
if ($result && $this->addressbook === false) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("MAPIProvider->getAddressbook error opening addressbook 0x%X", $result));
return false;
}
return $this->addressbook;
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment