Back to index

d-push  2.0
Public Member Functions | Private Member Functions | Private Attributes
ICalParser Class Reference

List of all members.

Public Member Functions

 ICalParser (&$store, &$props)
 Constructor.
 ExtractProps ($ical, &$mapiprops)
 Function reads calendar part and puts mapi properties into an array.

Private Member Functions

 getTimestampFromStreamerDate ($data)
 Converts an YYYYMMDDTHHMMSSZ kind of string into an unixtimestamp.

Private Attributes

 $props

Detailed Description

Definition at line 46 of file icalparser.php.


Member Function Documentation

ICalParser::ExtractProps ( ical,
&$  mapiprops 
)

Function reads calendar part and puts mapi properties into an array.

Parameters:
string$icalthe ical data
array&$mapipropsmapi properties

public

Definition at line 69 of file icalparser.php.

                                                     {
        //mapping between partstat in ical and MAPI Meeting Response classes as well as icons
        $aClassMap = array(
            "ACCEPTED"          => array("class" => "IPM.Schedule.Meeting.Resp.Pos", "icon" => 0x405),
            "DECLINED"          => array("class" => "IPM.Schedule.Meeting.Resp.Neg", "icon" => 0x406),
            "TENTATIVE"         => array("class" => "IPM.Schedule.Meeting.Resp.Tent", "icon" => 0x407),
            "NEEDS-ACTION"      => array("class" => "IPM.Schedule.Meeting.Request", "icon" => 0x404), //iphone
            "REQ-PARTICIPANT"   => array("class" => "IPM.Schedule.Meeting.Request", "icon" => 0x404), //nokia
        );

        $aical = preg_split("/[\n]/", $ical);
        $elemcount = count($aical);
        $i=0;
        $nextline = $aical[0];

        //last element is empty
        while ($i < $elemcount - 1) {
            $line = $nextline;
            $nextline = $aical[$i+1];

            //if a line starts with a space or a tab it belongs to the previous line
            while (strlen($nextline) > 0 && ($nextline{0} == " " || $nextline{0} == "\t")) {
                $line = rtrim($line) . substr($nextline, 1);
                $nextline = $aical[++$i + 1];
            }
            $line = rtrim($line);

            switch (strtoupper($line)) {
                case "BEGIN:VCALENDAR":
                case "BEGIN:VEVENT":
                case "END:VEVENT":
                case "END:VCALENDAR":
                    break;
                default:
                    unset ($field, $data, $prop_pos, $property);
                    if (preg_match ("/([^:]+):(.*)/", $line, $line)){
                        $field = $line[1];
                        $data = $line[2];
                        $property = $field;
                        $prop_pos = strpos($property,';');
                        if ($prop_pos !== false) $property = substr($property, 0, $prop_pos);
                        $property = strtoupper($property);

                        switch ($property) {
                            case 'DTSTART':
                                $data = $this->getTimestampFromStreamerDate($data);
                                $mapiprops[$this->props["starttime"]] = $mapiprops[$this->props["commonstart"]] = $mapiprops[$this->props["clipstart"]] = $mapiprops[PR_START_DATE] = $data;
                                break;

                            case 'DTEND':
                                $data = $this->getTimestampFromStreamerDate($data);
                                $mapiprops[$this->props["endtime"]] = $mapiprops[$this->props["commonend"]] = $mapiprops[$this->props["recurrenceend"]] = $mapiprops[PR_END_DATE] = $data;
                                break;

                            case 'UID':
                                $mapiprops[$this->props["goidtag"]] = $mapiprops[$this->props["goid2tag"]] = Utils::GetOLUidFromICalUid($data);
                                break;

                            case 'ATTENDEE':
                                $fields = explode(";", $field);
                                foreach ($fields as $field) {
                                    $prop_pos     = strpos($field, '=');
                                    if ($prop_pos !== false) {
                                        switch (substr($field, 0, $prop_pos)) {
                                            case 'PARTSTAT'    : $partstat = substr($field, $prop_pos+1); break;
                                            case 'CN'        : $cn = substr($field, $prop_pos+1); break;
                                            case 'ROLE'        : $role = substr($field, $prop_pos+1); break;
                                            case 'RSVP'        : $rsvp = substr($field, $prop_pos+1); break;
                                        }
                                    }
                                }
                                if (isset($partstat) && isset($aClassMap[$partstat]) &&

                                   (!isset($mapiprops[PR_MESSAGE_CLASS]) || $mapiprops[PR_MESSAGE_CLASS] == "IPM.Schedule.Meeting.Request")) {
                                    $mapiprops[PR_MESSAGE_CLASS] = $aClassMap[$partstat]['class'];
                                    $mapiprops[PR_ICON_INDEX] = $aClassMap[$partstat]['icon'];
                                }
                                // START ADDED dw2412 to support meeting requests on HTC Android Mail App
                                elseif (isset($role) && isset($aClassMap[$role]) &&
                                   (!isset($mapiprops[PR_MESSAGE_CLASS]) || $mapiprops[PR_MESSAGE_CLASS] == "IPM.Schedule.Meeting.Request")) {
                                    $mapiprops[PR_MESSAGE_CLASS] = $aClassMap[$role]['class'];
                                    $mapiprops[PR_ICON_INDEX] = $aClassMap[$role]['icon'];
                                }
                                // END ADDED dw2412 to support meeting requests on HTC Android Mail App
                                if (!isset($cn)) $cn = "";
                                $data         = str_replace ("MAILTO:", "", $data);
                                $attendee[] = array ('name' => stripslashes($cn), 'email' => stripslashes($data));
                                break;

                            case 'ORGANIZER':
                                $field          = str_replace("ORGANIZER;CN=", "", $field);
                                $data          = str_replace ("MAILTO:", "", $data);
                                $organizer[] = array ('name' => stripslashes($field), 'email' => stripslashes($data));
                                break;

                            case 'LOCATION':
                                $data = str_replace("\\n", "<br />", $data);
                                $data = str_replace("\\t", "&nbsp;", $data);
                                $data = str_replace("\\r", "<br />", $data);
                                $data = stripslashes($data);
                                $mapiprops[$this->props["tneflocation"]] = $mapiprops[$this->props["location"]] = $data;
                                break;
                        }
                    }
                    break;
            }
            $i++;

        }
        $mapiprops[$this->props["usetnef"]] = true;
    }

Here is the call graph for this function:

Converts an YYYYMMDDTHHMMSSZ kind of string into an unixtimestamp.

Parameters:
string$dataprivate
Returns:
long

Definition at line 189 of file icalparser.php.

                                                          {
        $data = str_replace('Z', '', $data);
        $data = str_replace('T', '', $data);

        preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs);
        if ($regs[1] < 1970) {
            $regs[1] = '1971';
        }
        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
    }

Here is the caller graph for this function:

ICalParser::ICalParser ( &$  store,
&$  props 
)

Constructor.

Parameters:
mapistore$store
array&$propsproperties to be set

public

Definition at line 57 of file icalparser.php.

                                                {
         $this->props = $props;
    }

Member Data Documentation

ICalParser::$props [private]

Definition at line 47 of file icalparser.php.


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