Exemple #1
0
 function amr_format_organiser($org)
 {
     /* receive array of hopefully CN and MAILTO, and possibly SENTBY */
     if (ICAL_EVENTS_DEBUG) {
         echo '<br />Organiser array:    ';
         var_dump($org);
     }
     $text = '';
     if (!is_array($org)) {
         $org = amr_parseOrganiser('ORGANIZER;' . $org);
         // may not have been parsed yet (eg in wp events)
         //$org = amr_parse_property ('ORGANIZER;'.$org);
         if (ICAL_EVENTS_DEBUG) {
             var_dump($org);
         }
     }
     //	var_dump($org);
     if (!empty($org['CN'])) {
         if (!empty($org['MAILTO'])) {
             $text = '<a href="mailto:' . $org['MAILTO'] . '" >' . $org['CN'] . '</a>';
         } else {
             $text = $org['CN'];
         }
     } else {
         if (!empty($org['MAILTO'])) {
             $text = '<a href="mailto:' . $org['MAILTO'] . '" >' . $org['MAILTO'] . '</a>';
         }
     }
     if (!empty($text)) {
         $text .= '&nbsp;';
     }
     if (!empty($org['SENT-BY'])) {
         $text .= __('Sent by ', 'amr-ical-events-list') . '<a href="mailto:' . $org['SENT-BY'] . '" >' . $org['SENT-BY'] . '</a>';
     }
     return $text;
 }
Exemple #2
0
function amr_parse_property($parts)
{
    /* would receive something like array ('DTSTART; VALUE=DATE', '20060315')) */
    /*  NOTE: parts[0]    has the long tag eg: RDATE;TZID=US-EASTERN
    or could be DTEND;TZID=America/New_York;VALUE=DATE-TIME:     and the date 20110724T100000 in parts 1  (see forum note from dusty - he is generating the DATETIME
    		parts[1]  the bit after the :  19960403T020000Z/19960403T040000Z, 19960404T010000Z/PT3H
    		IF 'Z' then must be in UTC
    		If no Z
    */
    global $amr_globaltz;
    if (empty($parts[1])) {
        return false;
    }
    // we got crap
    $tzobj = $amr_globaltz;
    /* Because if there is no timezone specified in any way for the date time then it must a floating value, and so should be created in the global timezone.*/
    //	if (ICAL_EVENTS_DEBUG or isset($_REQUEST['tzdebug'])) {echo '<br /> Property : '.$parts[0];}
    $p0 = explode(';', $parts[0]);
    /* Looking for ; VALUE = something...;   or TZID=... or both, or more than one anyway ???*/
    // the first bit will be the property like PRODID, or X_WR_TIMEZONE
    // the next will be the modifiers
    $prop = array_shift($p0);
    if (!empty($p0)) {
        // if we have some modifiers
        foreach ($p0 as $p) {
            // handle special modifiers , could be  VALUE=DATE, TZID=
            if (stristr($p, 'TZID')) {
                /* Normal TZ, not the one with the path eg:  DTSTART;TZID=US-Eastern:19980119T020000 or  zimbras TZID="GMT+01.00/+02.00 */
                //				$TZID = substr($p0[1], 4 );
                $TZID = substr($p, 4);
                $tzobj = amr_parseTZID($TZID);
            } else {
                /* might be just a value=date, in which case we use the global tz?  no may still have TZid */
                $tzobj = $amr_globaltz;
                if (stristr($p, 'VALUE')) {
                    // we have a possibly redundant modified
                    $VALUE = substr($p, 6);
                    // take everything after the '='
                } else {
                    // not necessary to deal with modifier here or unknown maybe custom modifiers
                    // only urgent to get tZID's.. or maybe we could even do those later?
                    //check it out on major code revamp, meanwhile if it aint broke, dont fix it
                }
            }
        }
    }
    //	else $tzobj = $amr_globaltz;  /* Because if there is no timezone specified in any way for the date time then it must a floating value, and so should be created in the global timezone.*/
    //	switch ($p0[0]) {
    switch ($prop) {
        case 'CREATED':
        case 'COMPLETED':
        case 'LAST-MODIFIED':
        case 'DTSTART':
        case 'DTEND':
        case 'DTSTAMP':
        case 'DUE':
            if (isset($VALUE)) {
                $date = amr_parseValue($VALUE, $parts[1], $tzobj);
            } else {
                $date = amr_parseSingleDate('DATE-TIME', $parts[1], $tzobj);
            }
            if (is_object($date) and ($prop === 'LAST-MODIFIED' or $prop === 'CREATED')) {
                amr_track_last_mod($date);
            }
            return $date;
        case 'ALARM':
        case 'RECURRENCE-ID':
            /* could also have range ?*/
            if (isset($VALUE)) {
                return amr_parseValue($VALUE, $parts[1], $tzobj);
            } elseif (isset($RANGE)) {
                return amr_parseRange($RANGE, $parts[1], $tzobj);
            } else {
                return amr_parseSingleDate('DATE-TIME', $parts[1], $tzobj);
            }
        case 'EXRULE':
        case 'RRULE':
            return amr_parseRRULE($parts[1]);
        case 'BDAY':
            return amr_parseDate($parts[1]);
        case 'EXDATE':
            if (isset($_REQUEST['debugexc'])) {
                echo '<br>  Parsing EXDATE ';
            }
        case 'RDATE':
            return amr_parseRDATE($parts[1], $tzobj);
        case 'TRIGGER':
            /* not supported yet, check for datetime and / or duration */
        /* not supported yet, check for datetime and / or duration */
        case 'DURATION':
            $dur = amr_parseDuration($parts[1]);
            if (isset($_GET['debugdur'])) {
                echo '<br />Parts1 = ' . $parts[1] . '<br />Duration = ';
                var_dump($dur);
            }
            return $dur;
        case 'FREEBUSY':
            return amr_parsePeriod($parts[1]);
        case 'TZID':
            /* ie TZID is a property, not part of a date spec */
            return $parts[1];
        case 'ORGANIZER':
            return amr_parseOrganiser($parts);
        case 'ATTENDEE':
            return amr_parseAttendees($parts);
        case 'ATTACH':
            $attach = amr_parseAttach($parts);
            if (ICAL_EVENTS_DEBUG) {
                echo '<br />ATTACH returned:<br />' . print_r($attach, true);
            }
            return $attach;
        case 'CATEGORIES':
            $cats = amr_parse_CATEGORIES($parts[1]);
            return $cats;
        default:
            return amr_parseDefault($prop, $parts);
    }
}