Back to index

d-push  2.0
Static Public Member Functions
MAPIUtils Class Reference

MAPI to AS mapping class. More...

List of all members.

Static Public Member Functions

static GetEmailRestriction ($timestamp)
 Create a MAPI restriction to use within an email folder which will return all messages since since $timestamp.
static GetCalendarRestriction ($store, $timestamp)
 Create a MAPI restriction to use in the calendar which will return all future calendar items, plus those since $timestamp.
static GetContactPicRestriction ()
 Create a MAPI restriction in order to check if a contact has a picture.
static GetSearchRestriction ($query)
 Create a MAPI restriction for search.
static handleRecurringItem (&$mapiprops, &$props)
 Handles recurring item for meeting request coming from tnef.
static readPropStream ($message, $prop)
 Reads data of large properties from a stream.
static IsUnicodeStore ($store)
 Checks if a store supports properties containing unicode characters.
static StoreAttachment ($mapimessage, $part)
 Gets attachment from a Mail_mimeDecode parsed email and stores it into MAPI.
static GetContainerClassFromFolderType ($foldertype)
 Returns the MAPI PR_CONTAINER_CLASS string for an ActiveSync Foldertype.

Detailed Description

MAPI to AS mapping class.

Definition at line 50 of file mapiutils.php.


Member Function Documentation

static MAPIUtils::GetCalendarRestriction ( store,
timestamp 
) [static]

Create a MAPI restriction to use in the calendar which will return all future calendar items, plus those since $timestamp.

Parameters:
long$timestampTimestamp since when to include messages

public

Returns:
array

Definition at line 83 of file mapiutils.php.

                                                                      {
        // This is our viewing window
        $start = $timestamp;
        $end = 0x7fffffff; // infinite end

        $props = MAPIMapping::GetAppointmentProperties();
        $props = getPropIdsFromStrings($store, $props);

        $restriction = Array(RES_OR,
             Array(
                   // OR
                   // item.end > window.start && item.start < window.end
                   Array(RES_AND,
                         Array(
                               Array(RES_PROPERTY,
                                     Array(RELOP => RELOP_LE,
                                           ULPROPTAG => $props["starttime"],
                                           VALUE => $end
                                           )
                                     ),
                               Array(RES_PROPERTY,
                                     Array(RELOP => RELOP_GE,
                                           ULPROPTAG => $props["endtime"],
                                           VALUE => $start
                                           )
                                     )
                               )
                         ),
                   // OR
                   Array(RES_OR,
                         Array(
                               // OR
                               // (EXIST(recurrence_enddate_property) && item[isRecurring] == true && item[end] >= start)
                               Array(RES_AND,
                                     Array(
                                           Array(RES_EXIST,
                                                 Array(ULPROPTAG => $props["recurrenceend"],
                                                       )
                                                 ),
                                           Array(RES_PROPERTY,
                                                 Array(RELOP => RELOP_EQ,
                                                       ULPROPTAG => $props["isrecurring"],
                                                       VALUE => true
                                                       )
                                                 ),
                                           Array(RES_PROPERTY,
                                                 Array(RELOP => RELOP_GE,
                                                       ULPROPTAG => $props["recurrenceend"],
                                                       VALUE => $start
                                                       )
                                                 )
                                           )
                                     ),
                               // OR
                               // (!EXIST(recurrence_enddate_property) && item[isRecurring] == true && item[start] <= end)
                               Array(RES_AND,
                                     Array(
                                           Array(RES_NOT,
                                                 Array(
                                                       Array(RES_EXIST,
                                                             Array(ULPROPTAG => $props["recurrenceend"]
                                                                   )
                                                             )
                                                       )
                                                 ),
                                           Array(RES_PROPERTY,
                                                 Array(RELOP => RELOP_LE,
                                                       ULPROPTAG => $props["starttime"],
                                                       VALUE => $end
                                                       )
                                                 ),
                                           Array(RES_PROPERTY,
                                                 Array(RELOP => RELOP_EQ,
                                                       ULPROPTAG => $props["isrecurring"],
                                                       VALUE => true
                                                       )
                                                 )
                                           )
                                     )
                               )
                         ) // EXISTS OR
                   )
             );        // global OR

        return $restriction;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Create a MAPI restriction in order to check if a contact has a picture.

public

Returns:
array

Definition at line 177 of file mapiutils.php.

                                                      {
        return array ( RES_PROPERTY,
                        array (
                            RELOP => RELOP_EQ,
                            ULPROPTAG => mapi_prop_tag(PT_BOOLEAN, 0x7FFF),
                            VALUE => true
                        )
        );
    }

Here is the caller graph for this function:

static MAPIUtils::GetContainerClassFromFolderType ( foldertype) [static]

Returns the MAPI PR_CONTAINER_CLASS string for an ActiveSync Foldertype.

Parameters:
int$foldertypepublic
Returns:
string

Definition at line 340 of file mapiutils.php.

                                                                        {
        switch ($foldertype) {
            case SYNC_FOLDER_TYPE_TASK:
            case SYNC_FOLDER_TYPE_USER_TASK:
                return "IPF.Task";
                break;

            case SYNC_FOLDER_TYPE_APPOINTMENT:
            case SYNC_FOLDER_TYPE_USER_APPOINTMENT:
                return "IPF.Appointment";
                break;

            case SYNC_FOLDER_TYPE_CONTACT:
            case SYNC_FOLDER_TYPE_USER_CONTACT:
                return "IPF.Contact";
                break;

            case SYNC_FOLDER_TYPE_NOTE:
            case SYNC_FOLDER_TYPE_USER_NOTE:
                return "IPF.StickyNote";
                break;

            case SYNC_FOLDER_TYPE_JOURNAL:
            case SYNC_FOLDER_TYPE_USER_JOURNAL:
                return "IPF.Journal";
                break;

            case SYNC_FOLDER_TYPE_INBOX:
            case SYNC_FOLDER_TYPE_DRAFTS:
            case SYNC_FOLDER_TYPE_WASTEBASKET:
            case SYNC_FOLDER_TYPE_SENTMAIL:
            case SYNC_FOLDER_TYPE_OUTBOX:
            case SYNC_FOLDER_TYPE_USER_MAIL:
            case SYNC_FOLDER_TYPE_OTHER:
            case SYNC_FOLDER_TYPE_UNKNOWN:
            default:
                return "IPF.Note";
                break;
        }
    }

Here is the caller graph for this function:

static MAPIUtils::GetEmailRestriction ( timestamp) [static]

Create a MAPI restriction to use within an email folder which will return all messages since since $timestamp.

Parameters:
long$timestampTimestamp since when to include messages

public

Returns:
array

Definition at line 61 of file mapiutils.php.

                                                           {
        $restriction = array ( RES_PROPERTY,
                          array (   RELOP => RELOP_GE,
                                    ULPROPTAG => PR_MESSAGE_DELIVERY_TIME,
                                    VALUE => $timestamp
                          )
                      );

        return $restriction;
    }

Here is the caller graph for this function:

static MAPIUtils::GetSearchRestriction ( query) [static]

Create a MAPI restriction for search.

public

Parameters:
string$query
Returns:
array

Definition at line 196 of file mapiutils.php.

                                                        {
        return array(RES_AND,
                    array(
                        array(RES_OR,
                            array(
                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_DISPLAY_NAME, VALUE => $query)),
                                array(RES_CONTENT, array(FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_ACCOUNT, VALUE => $query)),
                            ), // RES_OR
                        ),
                        array(
                            RES_PROPERTY,
                            array(RELOP => RELOP_EQ, ULPROPTAG => PR_OBJECT_TYPE, VALUE => MAPI_MAILUSER)
                        )
                    ) // RES_AND
        );
    }

Here is the caller graph for this function:

static MAPIUtils::handleRecurringItem ( &$  mapiprops,
&$  props 
) [static]

Handles recurring item for meeting request coming from tnef.

public

Parameters:
array$mapiprops
array$props

Definition at line 222 of file mapiutils.php.

                                                                     {
        $mapiprops[$props["isrecurringtag"]] = true;
        $mapiprops[$props["sideeffects"]] = 369;
        //both goids have the same value
        $mapiprops[$props["goid2tag"]] = $mapiprops[$props["goidtag"]];
        $mapiprops[$props["type"]] = "IPM.Appointment";
        $mapiprops[$props["busystatus"]] = 1; //tentative
        $mapiprops[PR_RESPONSE_REQUESTED] = true;
        $mapiprops[PR_ICON_INDEX] = 1027;
        $mapiprops[$props["meetingstatus"]] = olMeetingReceived; // The recipient is receiving the request
        $mapiprops[$props["responsestatus"]] = olResponseNotResponded;
        $mapiprops[$props["usetnef"]] = true;
    }

Here is the caller graph for this function:

static MAPIUtils::IsUnicodeStore ( store) [static]

Checks if a store supports properties containing unicode characters.

public

Parameters:
MAPIStore$store

Definition at line 267 of file mapiutils.php.

                                                  {
        $supportmask = mapi_getprops($store, array(PR_STORE_SUPPORT_MASK));
        if (isset($supportmask[PR_STORE_SUPPORT_MASK]) && ($supportmask[PR_STORE_SUPPORT_MASK] & STORE_UNICODE_OK)) {
            ZLog::Write(LOGLEVEL_DEBUG, "Store supports properties containing Unicode characters.");
            define('STORE_SUPPORTS_UNICODE', true);
            //setlocale to UTF-8 in order to support properties containing Unicode characters
            setlocale(LC_CTYPE, "en_US.UTF-8");
            define('STORE_INTERNET_CPID', INTERNET_CPID_UTF8);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static MAPIUtils::readPropStream ( message,
prop 
) [static]

Reads data of large properties from a stream.

public

Parameters:
MAPIMessage$message
long$prop
Returns:
string

Definition at line 246 of file mapiutils.php.

                                                           {
        $stream = mapi_openproperty($message, $prop, IID_IStream, 0, 0);
        $data = "";
        $string = "";
        while(1) {
            $data = mapi_stream_read($stream, 1024);
            if(strlen($data) == 0)
                break;
            $string .= $data;
        }

        return $string;
    }

Here is the caller graph for this function:

static MAPIUtils::StoreAttachment ( mapimessage,
part 
) [static]

Gets attachment from a Mail_mimeDecode parsed email and stores it into MAPI.

Parameters:
mixed$mapimessagetarget message
object$partMail_mimeDecode part to be stored

public

Returns:
boolean

Definition at line 287 of file mapiutils.php.

                                                                {
        // attachment
        $attach = mapi_message_createattach($mapimessage);

        $filename = "";
        // Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
        if(isset($part->ctype_parameters["name"]))
            $filename = $part->ctype_parameters["name"];
        else if(isset($part->d_parameters["name"]))
            $filename = $part->d_parameters["filename"];
        else if (isset($part->d_parameters["filename"])) // sending appointment with nokia & android only filename is set
            $filename = $part->d_parameters["filename"];
        // filenames with more than 63 chars as splitted several strings
        else if (isset($part->d_parameters["filename*0"])) {
            for ($i=0; $i< count($part->d_parameters); $i++)
               if (isset($part->d_parameters["filename*".$i]))
                   $filename .= $part->d_parameters["filename*".$i];
        }
        else
            $filename = "untitled";

        // Android just doesn't send content-type, so mimeDecode doesn't performs base64 decoding
        // on meeting requests text/calendar somewhere inside content-transfer-encoding
        if (isset($part->headers['content-transfer-encoding']) && strpos($part->headers['content-transfer-encoding'], 'base64')) {
            if (strpos($part->headers['content-transfer-encoding'], 'text/calendar') !== false) {
                $part->ctype_primary = 'text';
                $part->ctype_secondary = 'calendar';
            }
            if (!isset($part->headers['content-type']))
                $part->body = base64_decode($part->body);
        }

        mapi_setprops($attach, array(
            // Set filename and attachment type
            PR_ATTACH_LONG_FILENAME => u2wi($filename),
            PR_ATTACH_METHOD => ATTACH_BY_VALUE,
            // Set attachment data
            PR_ATTACH_DATA_BIN => $part->body,
            // Set MIME type
            PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));

        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Utils::StoreAttachment: Attachment '%s' with %d bytes saved", $filename, strlen($part->body)));
        return mapi_savechanges($attach);
    }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: