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 { ...@@ -45,6 +45,7 @@ class MAPIProvider {
private $session; private $session;
private $store; private $store;
private $zRFC822; private $zRFC822;
private $addressbook;
/** /**
* Constructor of the MAPI Provider * Constructor of the MAPI Provider
...@@ -1133,7 +1134,7 @@ class MAPIProvider { ...@@ -1133,7 +1134,7 @@ class MAPIProvider {
$recips = array(); $recips = array();
//open addresss book for user resolve //open addresss book for user resolve
$addrbook = mapi_openaddressbook($this->session); $addrbook = $this->getAddressbook();
foreach($appointment->attendees as $attendee) { foreach($appointment->attendees as $attendee) {
$recip = array(); $recip = array();
$recip[PR_EMAIL_ADDRESS] = u2w($attendee->email); $recip[PR_EMAIL_ADDRESS] = u2w($attendee->email);
...@@ -1843,9 +1844,9 @@ class MAPIProvider { ...@@ -1843,9 +1844,9 @@ class MAPIProvider {
* @return string * @return string
*/ */
private function getSMTPAddressFromEntryID($entryid) { 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) if(!$mailuser)
return ""; return "";
...@@ -2157,8 +2158,8 @@ class MAPIProvider { ...@@ -2157,8 +2158,8 @@ class MAPIProvider {
*/ */
private function imtoinet($mapimessage, &$message) { private function imtoinet($mapimessage, &$message) {
if (function_exists("mapi_inetmapi_imtoinet")) { if (function_exists("mapi_inetmapi_imtoinet")) {
$addrBook = mapi_openaddressbook($this->session); $addrbook = $this->getAddressbook();
$mstream = mapi_inetmapi_imtoinet($this->session, $addrBook, $mapimessage, array()); $mstream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array());
$mstreamstat = mapi_stream_stat($mstream); $mstreamstat = mapi_stream_stat($mstream);
if ($mstreamstat['cb'] < MAX_EMBEDDED_SIZE) { if ($mstreamstat['cb'] < MAX_EMBEDDED_SIZE) {
...@@ -2390,6 +2391,25 @@ class MAPIProvider { ...@@ -2390,6 +2391,25 @@ class MAPIProvider {
$props[$appointmentprops["body"]] = ""; $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