Ejemplo n.º 1
0
    function testAttribute2()
    {
        $in = array('BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', 'BEGIN:VEVENT', 'SUMMARY;LANGUAGE=nl-NL:meeting', 'X-SABRE;att1=val1;att2=val2:This is the property content', 'END:VEVENT', 'END:VCALENDAR');
        $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n", $in));
        $compare = '<?xml version="1.0"?>
<iCalendar xmlns="urn:ietf:params:xml:ns:xcal">
  <vcalendar>
    <version>2.0</version>
    <prodid>-//hacksw/handcal//NONSGML v1.0//EN</prodid>
    <vevent>
      <summary xml:lang="nl-NL">meeting</summary>
      <x-sabre att1="val1" att2="val2">This is the property content</x-sabre>
    </vevent>
  </vcalendar>
</iCalendar>';
        $this->assertEquals($compare, $out);
    }
Ejemplo n.º 2
0
 /**
  * Verify if a list of filters applies to the calendar data object 
  *
  * The calendarData object must be a valid iCalendar blob. The list of 
  * filters must be formatted as parsed by Sabre_CalDAV_Plugin::parseCalendarQueryFilters
  *
  * @param string $calendarData 
  * @param array $filters 
  * @return bool 
  */
 public function validateFilters($calendarData, $filters)
 {
     // We are converting the calendar object to an XML structure
     // This makes it far easier to parse
     $xCalendarData = Sabre_CalDAV_ICalendarUtil::toXCal($calendarData);
     $xml = simplexml_load_string($xCalendarData);
     $xml->registerXPathNamespace('c', 'urn:ietf:params:xml:ns:xcal');
     foreach ($filters as $xpath => $filter) {
         // if-not-defined comes first
         if (isset($filter['is-not-defined'])) {
             if (!$xml->xpath($xpath)) {
                 continue;
             } else {
                 return false;
             }
         }
         $elem = $xml->xpath($xpath);
         if (!$elem) {
             return false;
         }
         $elem = $elem[0];
         if (isset($filter['time-range'])) {
             switch ($elem->getName()) {
                 case 'vevent':
                     $result = $this->validateTimeRangeFilterForEvent($xml, $xpath, $filter);
                     if ($result === false) {
                         return false;
                     }
                     break;
                 case 'vtodo':
                     $result = $this->validateTimeRangeFilterForTodo($xml, $xpath, $filter);
                     if ($result === false) {
                         return false;
                     }
                     break;
                 case 'vjournal':
                 case 'vfreebusy':
                 case 'valarm':
                     // TODO: not implemented
                     break;
                     /*
                     
                                         case 'vjournal' :
                                             $result = $this->validateTimeRangeFilterForJournal($xml,$xpath,$filter);
                                             if ($result===false) return false;
                                             break;
                                         case 'vfreebusy' :
                                             $result = $this->validateTimeRangeFilterForFreeBusy($xml,$xpath,$filter);
                                             if ($result===false) return false;
                                             break;
                                         case 'valarm' :
                                             $result = $this->validateTimeRangeFilterForAlarm($xml,$xpath,$filter);
                                             if ($result===false) return false;
                                             break;
                     */
             }
         }
         if (isset($filter['text-match'])) {
             $currentString = (string) $elem;
             $isMatching = Sabre_DAV_StringUtil::textMatch($currentString, $filter['text-match']['value'], $filter['text-match']['collation']);
             if ($filter['text-match']['negate-condition'] && $isMatching) {
                 return false;
             }
             if (!$filter['text-match']['negate-condition'] && !$isMatching) {
                 return false;
             }
         }
     }
     return true;
 }