/**
  * Publishes the infomation
  * @paam timestamp $starttime Time from which to publish data  (usually now)
  * @paam integer $length Amount of seconds from $starttime we should publish
  */
 function publishFB($starttime, $length)
 {
     $start = $starttime;
     $end = $starttime + $length;
     // Get all the items in the calendar that we need
     $calendaritems = array();
     $restrict = array(RES_OR, array(array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => $this->proptags["startdate"], VALUE => $start)), array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => $this->proptags["startdate"], VALUE => $end)))), array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => $this->proptags["duedate"], VALUE => $start)), array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => $this->proptags["duedate"], VALUE => $end)))), array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_LT, ULPROPTAG => $this->proptags["startdate"], VALUE => $start)), array(RES_PROPERTY, array(RELOP => RELOP_GT, ULPROPTAG => $this->proptags["duedate"], VALUE => $end)))), array(RES_OR, array(array(RES_AND, array(array(RES_EXIST, array(ULPROPTAG => $this->proptags["enddate_recurring"])), array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => $this->proptags["recurring"], VALUE => true)), array(RES_PROPERTY, array(RELOP => RELOP_GE, ULPROPTAG => $this->proptags["enddate_recurring"], VALUE => $start)))), array(RES_AND, array(array(RES_NOT, array(array(RES_EXIST, array(ULPROPTAG => $this->proptags["enddate_recurring"])))), array(RES_PROPERTY, array(RELOP => RELOP_LE, ULPROPTAG => $this->proptags["startdate"], VALUE => $end)), array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => $this->proptags["recurring"], VALUE => true))))))));
     // global OR
     $contents = mapi_folder_getcontentstable($this->calendar);
     mapi_table_restrict($contents, $restrict);
     while (1) {
         $rows = mapi_table_queryrows($contents, array_values($this->proptags), 0, 50);
         if (!is_array($rows)) {
             break;
         }
         if (empty($rows)) {
             break;
         }
         foreach ($rows as $row) {
             $occurrences = array();
             if (isset($row[$this->proptags['recurring']]) && $row[$this->proptags['recurring']]) {
                 $recur = new Recurrence($this->store, $row);
                 $occurrences = $recur->getItems($starttime, $starttime + $length);
             } else {
                 $occurrences[] = $row;
             }
             $calendaritems = array_merge($calendaritems, $occurrences);
         }
     }
     // $calendaritems now contains all the calendar items in the specified time
     // frame. We now need to merge these into a flat array of begin/end/status
     // objects. This also filters out all the 'free' items (status 0)
     $freebusy = $this->mergeItemsFB($calendaritems);
     // $freebusy now contains the start, end and status of all items, merged.
     // Get the FB interface
     try {
         $fbsupport = mapi_freebusysupport_open($this->session, $this->store);
     } catch (MAPIException $e) {
         if ($e->getCode() == MAPI_E_NOT_FOUND) {
             $e->setHandled();
             if (function_exists("dump")) {
                 dump("Error in opening freebusysupport object.");
             }
         }
     }
     // Open updater for this user
     if (isset($fbsupport)) {
         $updaters = mapi_freebusysupport_loadupdate($fbsupport, array($this->entryid));
         $updater = $updaters[0];
         // Send the data
         mapi_freebusyupdate_reset($updater);
         mapi_freebusyupdate_publish($updater, $freebusy);
         mapi_freebusyupdate_savechanges($updater, $start - 24 * 60 * 60, $end);
         // We're finished
         mapi_freebusysupport_close($fbsupport);
     }
 }
 /**
  * Writes a SyncContact to MAPI
  *
  * @param mixed             $mapimessage
  * @param SyncContact       $contact
  *
  * @access private
  * @return boolean
  */
 private function setContact($mapimessage, $contact)
 {
     mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => "IPM.Contact"));
     // normalize email addresses
     if (isset($contact->email1address) && ($contact->email1address = $this->extractEmailAddress($contact->email1address)) === false) {
         unset($contact->email1address);
     }
     if (isset($contact->email2address) && ($contact->email2address = $this->extractEmailAddress($contact->email2address)) === false) {
         unset($contact->email2address);
     }
     if (isset($contact->email3address) && ($contact->email3address = $this->extractEmailAddress($contact->email3address)) === false) {
         unset($contact->email3address);
     }
     $contactmapping = MAPIMapping::GetContactMapping();
     $contactprops = MAPIMapping::GetContactProperties();
     $this->setPropsInMAPI($mapimessage, $contact, $contactmapping);
     ///set display name from contact's properties
     $cname = $this->composeDisplayName($contact);
     //get contact specific mapi properties and merge them with the AS properties
     $contactprops = array_merge($this->getPropIdsFromStrings($contactmapping), $this->getPropIdsFromStrings($contactprops));
     //contact specific properties to be set
     $props = array();
     //need to be set in order to show contacts properly in outlook and wa
     $nremails = array();
     $abprovidertype = 0;
     if (isset($contact->email1address)) {
         $this->setEmailAddress($contact->email1address, $cname, 1, $props, $contactprops, $nremails, $abprovidertype);
     }
     if (isset($contact->email2address)) {
         $this->setEmailAddress($contact->email2address, $cname, 2, $props, $contactprops, $nremails, $abprovidertype);
     }
     if (isset($contact->email3address)) {
         $this->setEmailAddress($contact->email3address, $cname, 3, $props, $contactprops, $nremails, $abprovidertype);
     }
     $props[$contactprops["addressbooklong"]] = $abprovidertype;
     $props[$contactprops["displayname"]] = $props[$contactprops["subject"]] = $cname;
     //pda multiple e-mail addresses bug fix for the contact
     if (!empty($nremails)) {
         $props[$contactprops["addressbookmv"]] = $nremails;
     }
     //set addresses
     $this->setAddress("home", $contact->homecity, $contact->homecountry, $contact->homepostalcode, $contact->homestate, $contact->homestreet, $props, $contactprops);
     $this->setAddress("business", $contact->businesscity, $contact->businesscountry, $contact->businesspostalcode, $contact->businessstate, $contact->businessstreet, $props, $contactprops);
     $this->setAddress("other", $contact->othercity, $contact->othercountry, $contact->otherpostalcode, $contact->otherstate, $contact->otherstreet, $props, $contactprops);
     //set the mailing address and its type
     if (isset($props[$contactprops["businessaddress"]])) {
         $props[$contactprops["mailingaddress"]] = 2;
         $this->setMailingAddress($contact->businesscity, $contact->businesscountry, $contact->businesspostalcode, $contact->businessstate, $contact->businessstreet, $props[$contactprops["businessaddress"]], $props, $contactprops);
     } elseif (isset($props[$contactprops["homeaddress"]])) {
         $props[$contactprops["mailingaddress"]] = 1;
         $this->setMailingAddress($contact->homecity, $contact->homecountry, $contact->homepostalcode, $contact->homestate, $contact->homestreet, $props[$contactprops["homeaddress"]], $props, $contactprops);
     } elseif (isset($props[$contactprops["otheraddress"]])) {
         $props[$contactprops["mailingaddress"]] = 3;
         $this->setMailingAddress($contact->othercity, $contact->othercountry, $contact->otherpostalcode, $contact->otherstate, $contact->otherstreet, $props[$contactprops["otheraddress"]], $props, $contactprops);
     }
     if (isset($contact->picture)) {
         $picbinary = base64_decode($contact->picture);
         $picsize = strlen($picbinary);
         if ($picsize < MAX_EMBEDDED_SIZE) {
             $props[$contactprops["haspic"]] = false;
             // TODO contact picture handling
             // check if contact has already got a picture. delete it first in that case
             // delete it also if it was removed on a mobile
             $picprops = mapi_getprops($mapimessage, array($props[$contactprops["haspic"]]));
             if (isset($picprops[$props[$contactprops["haspic"]]]) && $picprops[$props[$contactprops["haspic"]]]) {
                 ZLog::Write(LOGLEVEL_DEBUG, "Contact already has a picture. Delete it");
                 $attachtable = mapi_message_getattachmenttable($mapimessage);
                 mapi_table_restrict($attachtable, MAPIUtils::GetContactPicRestriction());
                 $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
                 if (isset($rows) && is_array($rows)) {
                     foreach ($rows as $row) {
                         mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]);
                     }
                 }
             }
             // only set picture if there's data in the request
             if ($picbinary !== false && $picsize > 0) {
                 $props[$contactprops["haspic"]] = true;
                 $pic = mapi_message_createattach($mapimessage);
                 // Set properties of the attachment
                 $picprops = array(PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg", PR_DISPLAY_NAME => "ContactPicture.jpg", 0x7fff000b => true, PR_ATTACHMENT_HIDDEN => false, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_EXTENSION_A => ".jpg", PR_ATTACH_NUM => 1, PR_ATTACH_SIZE => $picsize, PR_ATTACH_DATA_BIN => $picbinary);
                 mapi_setprops($pic, $picprops);
                 mapi_savechanges($pic);
             }
         }
     }
     if (isset($contact->asbody)) {
         $this->setASbody($contact->asbody, $props, $contactprops);
     }
     //set fileas
     if (defined('FILEAS_ORDER')) {
         $lastname = isset($contact->lastname) ? $contact->lastname : "";
         $firstname = isset($contact->firstname) ? $contact->firstname : "";
         $middlename = isset($contact->middlename) ? $contact->middlename : "";
         $company = isset($contact->companyname) ? $contact->companyname : "";
         $props[$contactprops["fileas"]] = Utils::BuildFileAs($lastname, $firstname, $middlename, $company);
     } else {
         ZLog::Write(LOGLEVEL_DEBUG, "FILEAS_ORDER not defined");
     }
     mapi_setprops($mapimessage, $props);
 }
 /**
  * A wrapper for mapi_inetmapi_imtoinet function
  *
  * @param MAPIMessage       $mapimessage
  * @param SyncObject        $message
  *
  * @access private
  * @return boolean
  */
 private function imtoinet($mapimessage, &$message)
 {
     // if it is a signed message get a full attachment generated by ZCP
     $props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
     if (isset($props[PR_MESSAGE_CLASS]) && $props[PR_MESSAGE_CLASS] && strpos(strtolower($props[PR_MESSAGE_CLASS]), 'multipartsigned')) {
         // find the required attachment
         $attachtable = mapi_message_getattachmenttable($mapimessage);
         mapi_table_restrict($attachtable, MAPIUtils::GetSignedAttachmentRestriction());
         if (mapi_table_getrowcount($attachtable) == 1) {
             $rows = mapi_table_queryrows($attachtable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE), 0, 1);
             if (isset($rows[0][PR_ATTACH_NUM])) {
                 $mapiattach = mapi_message_openattach($mapimessage, $rows[0][PR_ATTACH_NUM]);
                 $stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN);
                 $streamsize = $rows[0][PR_ATTACH_SIZE];
             }
         }
     } elseif (function_exists("mapi_inetmapi_imtoinet")) {
         $addrbook = $this->getAddressbook();
         $stream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array('use_tnef' => -1));
         $mstreamstat = mapi_stream_stat($stream);
         $streamsize = $mstreamstat["cb"];
     }
     if (isset($stream) && isset($streamsize)) {
         if (Request::GetProtocolVersion() >= 12.0) {
             if (!isset($message->asbody)) {
                 $message->asbody = new SyncBaseBody();
             }
             //TODO data should be wrapped in a MapiStreamWrapper
             $message->asbody->data = mapi_stream_read($stream, $streamsize);
             $message->asbody->estimatedDataSize = $streamsize;
             $message->asbody->truncated = 0;
         } else {
             $message->mimetruncated = 0;
             //TODO mimedata should be a wrapped in a MapiStreamWrapper
             $message->mimedata = mapi_stream_read($stream, $streamsize);
             $message->mimesize = $streamsize;
         }
         unset($message->body, $message->bodytruncated);
         return true;
     } else {
         ZLog::Write(LOGLEVEL_ERROR, sprintf("Error opening attachment for imtoinet"));
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Returns subfolders of given type for a folder or false if there are none.
  *
  * @access public
  *
  * @param MAPIFolder $folder
  * @param string $type
  *
  * @return MAPITable|boolean
  */
 public static function GetSubfoldersForType($folder, $type)
 {
     $subfolders = mapi_folder_gethierarchytable($folder, CONVENIENT_DEPTH);
     mapi_table_restrict($subfolders, MAPIUtils::GetFolderTypeRestriction($type));
     if (mapi_table_getrowcount($subfolders) > 0) {
         return mapi_table_queryallrows($subfolders, array(PR_ENTRYID));
     }
     return false;
 }
Esempio n. 5
0
/**
 * Get the private contact folder of all users
 */
function getPrivateContactFolders($session, $defaultstore)
{
    $addrbook = mapi_openaddressbook($session);
    $addr_entryid = mapi_ab_getdefaultdir($addrbook);
    $abcontainer = mapi_ab_openentry($addrbook, $addr_entryid);
    $contentstable = mapi_folder_getcontentstable($abcontainer);
    // restrict table on only MAPI_MAILUSER accounts
    mapi_table_restrict($contentstable, array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_OBJECT_TYPE, VALUE => array(PR_OBJECT_TYPE => MAPI_MAILUSER))));
    // sort table on display name
    mapi_table_sort($contentstable, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
    $users = mapi_table_queryrows($contentstable, array(PR_ACCOUNT, PR_ENTRYID, PR_DISPLAY_NAME), 0, mapi_table_getrowcount($contentstable));
    $contactArray = array();
    for ($i = 0; $i < sizeof($users); $i++) {
        $store_entryid = mapi_msgstore_createentryid($defaultstore, $users[$i][PR_ACCOUNT]);
        $store = mapi_openmsgstore($session, $store_entryid);
        $rootcontainer = mapi_msgstore_openentry($store);
        if ($rootcontainer) {
            $props = mapi_getprops($rootcontainer, array(PR_IPM_CONTACT_ENTRYID));
            if (isset($props[PR_IPM_CONTACT_ENTRYID])) {
                $entryid = $props[PR_IPM_CONTACT_ENTRYID];
                $folder = mapi_msgstore_openentry($store, $entryid);
                if ($folder) {
                    $table = mapi_folder_getcontentstable($folder);
                    $totalrow = mapi_table_getrowcount($table);
                    $rows = array();
                    $contacts = array();
                    $properties = getContactProperties($defaultstore);
                    if ($totalrow > 0) {
                        $rows = mapi_table_queryrows($table, $properties, 0, $totalrow);
                        for ($j = 0; $j < sizeof($rows); $j++) {
                            $rows[$j][268370178] = md5($rows[$j][268370178]);
                        }
                        for ($k = 0; $k < sizeof($rows); $k++) {
                            // do not add private contacts
                            if (!array_key_exists(-2119827445, $rows[$k]) || array_key_exists(-2119827445, $rows[$k]) && $rows[$k][-2119827445] != 1) {
                                foreach ($rows[$k] as $key => $value) {
                                    $attribute = mapKey($key);
                                    if ($attribute != "") {
                                        $contacts[$k][$attribute] = $value;
                                    }
                                }
                            }
                        }
                        $contactArray[] = array("username" => $users[$i][PR_ACCOUNT], "contacts" => $contacts);
                    }
                }
            }
        }
    }
    //	print_r($contactArray);
    return $contactArray;
}
Esempio n. 6
0
 /**
  * Creates a search folder if it not exists or opens an existing one
  * and returns it.
  *
  * @param mapiFolderObject $searchFolderRoot
  *
  * @return mapiFolderObject
  */
 private function createSearchFolder($searchFolderRoot)
 {
     $folderName = "Z-Push Search Folder " . @getmypid();
     $searchFolders = mapi_folder_gethierarchytable($searchFolderRoot);
     $restriction = array(RES_CONTENT, array(FUZZYLEVEL => FL_PREFIX, ULPROPTAG => PR_DISPLAY_NAME, VALUE => array(PR_DISPLAY_NAME => $folderName)));
     //restrict the hierarchy to the z-push search folder only
     mapi_table_restrict($searchFolders, $restriction);
     if (mapi_table_getrowcount($searchFolders)) {
         $searchFolder = mapi_table_queryrows($searchFolders, array(PR_ENTRYID), 0, 1);
         return mapi_msgstore_openentry($this->store, $searchFolder[0][PR_ENTRYID]);
     }
     return mapi_folder_createfolder($searchFolderRoot, $folderName, null, 0, FOLDER_SEARCH);
 }
Esempio n. 7
0
 function getSearchResults($searchquery, $searchrange)
 {
     // only return users from who the displayName or the username starts with $name
     //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
     $addrbook = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($addrbook);
     $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = $this->_getSearchRestriction(u2w($searchquery));
     mapi_table_restrict($table, $restriction);
     mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
     //range for the search results, default symbian range end is 50, wm 99,
     //so we'll use that of nokia
     $rangestart = 0;
     $rangeend = 50;
     if ($searchrange != '0') {
         $pos = strpos($searchrange, '-');
         $rangestart = substr($searchrange, 0, $pos);
         $rangeend = substr($searchrange, $pos + 1);
     }
     $items = array();
     $querycnt = mapi_table_getrowcount($table);
     //do not return more results as requested in range
     $querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
     $items['range'] = $rangestart . '-' . ($querylimit - 1);
     $items['searchtotal'] = $querycnt;
     if ($querycnt > 0) {
         $abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION), $rangestart, $querylimit);
     }
     for ($i = 0; $i < $querylimit; $i++) {
         $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_DISPLAY_NAME]);
         if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0) {
             $items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_ACCOUNT]);
         }
         $items[$i][SYNC_GAL_ALIAS] = w2u($abentries[$i][PR_ACCOUNT]);
         //it's not possible not get first and last name of an user
         //from the gab and user functions, so we just set lastname
         //to displayname and leave firstname unset
         //this was changed in Zarafa 6.40, so we try to get first and
         //last name and fall back to the old behaviour if these values are not set
         if (isset($abentries[$i][PR_GIVEN_NAME])) {
             $items[$i][SYNC_GAL_FIRSTNAME] = w2u($abentries[$i][PR_GIVEN_NAME]);
         }
         if (isset($abentries[$i][PR_SURNAME])) {
             $items[$i][SYNC_GAL_LASTNAME] = w2u($abentries[$i][PR_SURNAME]);
         }
         if (!isset($items[$i][SYNC_GAL_LASTNAME])) {
             $items[$i][SYNC_GAL_LASTNAME] = $items[$i][SYNC_GAL_DISPLAYNAME];
         }
         $items[$i][SYNC_GAL_EMAILADDRESS] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
         //check if an user has an office number or it might produce warnings in the log
         if (isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_PHONE] = w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]);
         }
         //check if an user has a mobile number or it might produce warnings in the log
         if (isset($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_MOBILEPHONE] = w2u($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER]);
         }
         //check if an user has a home number or it might produce warnings in the log
         if (isset($abentries[$i][PR_HOME_TELEPHONE_NUMBER])) {
             $items[$i][SYNC_GAL_HOMEPHONE] = w2u($abentries[$i][PR_HOME_TELEPHONE_NUMBER]);
         }
         if (isset($abentries[$i][PR_COMPANY_NAME])) {
             $items[$i][SYNC_GAL_COMPANY] = w2u($abentries[$i][PR_COMPANY_NAME]);
         }
         if (isset($abentries[$i][PR_TITLE])) {
             $items[$i][SYNC_GAL_TITLE] = w2u($abentries[$i][PR_TITLE]);
         }
         if (isset($abentries[$i][PR_OFFICE_LOCATION])) {
             $items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]);
         }
     }
     return $items;
 }
Esempio n. 8
0
 function getSearchResults($searchquery, $searchrange)
 {
     // only return users from who the displayName or the username starts with $name
     //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
     $addrbook = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($addrbook);
     $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = $this->_getSearchRestriction(u2w($searchquery));
     mapi_table_restrict($table, $restriction);
     mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
     //range for the search results, default symbian range end is 50, wm 99,
     //so we'll use that of nokia
     $rangestart = 0;
     $rangeend = 50;
     if ($searchrange != '0') {
         $pos = strpos($searchrange, '-');
         $rangestart = substr($searchrange, 0, $pos);
         $rangeend = substr($searchrange, $pos + 1);
     }
     $items = array();
     $querycnt = mapi_table_getrowcount($table);
     //do not return more results as requested in range
     $querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
     $items['range'] = $rangestart . '-' . ($querylimit - 1);
     $abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER), $rangestart, $querylimit);
     for ($i = 0; $i < $querylimit; $i++) {
         $items[$i]["username"] = w2u($abentries[$i][PR_ACCOUNT]);
         $items[$i]["fullname"] = w2u($abentries[$i][PR_DISPLAY_NAME]);
         if (strlen(trim($items[$i]["fullname"])) == 0) {
             $items[$i]["fullname"] = $items[$i]["username"];
         }
         $items[$i]["emailaddress"] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
         $items[$i]["nameid"] = $searchquery;
         //check if an user has a business phone or it might produce warnings in the log
         $items[$i]["businessphone"] = isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) ? w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) : "";
     }
     return $items;
 }
Esempio n. 9
0
 function readResolveRecipientfromGAL($emailaddress)
 {
     $ab = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($ab);
     $ab_dir = mapi_ab_openentry($ab, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_SMTP_ADDRESS, VALUE => $emailaddress));
     mapi_table_restrict($table, $restriction);
     $rows = mapi_table_queryrows($table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_USER_CERTIFICATE), 0, 999);
     return $rows;
 }
Esempio n. 10
0
 /**
  * Returns contacts matching given email address from a folder.
  *
  * @param MAPIStore $store
  * @param binary $folderEntryid
  * @param string $email
  *
  * @return array|boolean
  */
 private function getContactsFromFolder($store, $folderEntryid, $email)
 {
     $folder = mapi_msgstore_openentry($store, $folderEntryid);
     $folderContent = mapi_folder_getcontentstable($folder);
     mapi_table_restrict($folderContent, MAPIUtils::GetEmailAddressRestriction($store, $email));
     // TODO max limit
     if (mapi_table_getrowcount($folderContent) > 0) {
         return mapi_table_queryallrows($folderContent, array(PR_DISPLAY_NAME, PR_USER_X509_CERTIFICATE));
     }
     return false;
 }
Esempio n. 11
0
 /**
  * Finds the chunk and returns a property array.
  *
  * @param ressoure $store
  * @param string $folderid
  * @param string $chunkName
  *
  * @access private
  * @return array
  */
 private function findChunk($store, $folderid, $chunkName)
 {
     // search for the chunk message
     $folder = $this->getFolder($store, $folderid);
     $table = mapi_folder_getcontentstable($folder);
     if (!$table) {
         $this->Log(sprintf("Kopano->findChunk: Error, unable to read contents table to find chunk '%d': 0x%08X", $chunkId, mapi_last_hresult()));
     }
     $restriction = array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_SUBJECT, VALUE => $chunkName));
     mapi_table_restrict($table, $restriction);
     $entries = mapi_table_queryallrows($table, array(PR_ENTRYID, $this->mapiprops['chunkCRC']));
     if (isset($entries[0])) {
         return $entries[0];
     }
     return array();
 }
Esempio n. 12
0
 function getSearchResultsGAL($searchquery)
 {
     // only return users from who the displayName or the username starts with $name
     //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
     $addrbook = mapi_openaddressbook($this->_session);
     $ab_entryid = mapi_ab_getdefaultdir($addrbook);
     $ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
     $table = mapi_folder_getcontentstable($ab_dir);
     $restriction = $this->_getSearchRestriction(u2w($searchquery));
     mapi_table_restrict($table, $restriction);
     mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
     // CHANGED dw2412 AS V12.0 Support (to menetain single return way...
     $items['rows'] = array();
     for ($i = 0; $i < mapi_table_getrowcount($table); $i++) {
         $user_data = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER), $i, 1);
         $item = array();
         $item["username"] = w2u($user_data[0][PR_ACCOUNT]);
         $item["fullname"] = w2u($user_data[0][PR_DISPLAY_NAME]);
         if (strlen(trim($item["fullname"])) == 0) {
             $item["fullname"] = $item["username"];
         }
         $item["emailaddress"] = w2u($user_data[0][PR_SMTP_ADDRESS]);
         $item["nameid"] = $searchquery;
         $item["businessphone"] = isset($user_data[0][PR_BUSINESS_TELEPHONE_NUMBER]) ? w2u($user_data[0][PR_BUSINESS_TELEPHONE_NUMBER]) : "";
         //do not return users without email
         if (strlen(trim($item["emailaddress"])) == 0) {
             continue;
         }
         // CHANGED dw2412 AS V12.0 Support (to menetain single return way...
         array_push($items['rows'], $item);
     }
     $items['status'] = 1;
     return $items;
 }