예제 #1
0
파일: Plugin.php 프로젝트: jtietema/Fizzy
 /**
  * afterGetProperties
  *
  * This method handler is invoked after properties for a specific resource
  * are received. This allows us to add any properties that might have been
  * missing.
  * 
  * @param string $path
  * @param array $properties 
  * @return void
  */
 public function afterGetProperties($path, &$properties)
 {
     // Find out if we are currently looking at a principal resource
     $currentNode = $this->server->tree->getNodeForPath($path);
     if ($currentNode instanceof Sabre_DAV_Auth_Principal) {
         // calendar-home-set property
         $calHome = '{' . self::NS_CALDAV . '}calendar-home-set';
         if (array_key_exists($calHome, $properties[404])) {
             $principalId = $currentNode->getName();
             $calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/';
             unset($properties[404][$calHome]);
             $properties[200][$calHome] = new Sabre_DAV_Property_Href($calendarHomePath);
         }
         // calendar-user-address-set property
         $calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set';
         if (array_key_exists($calProp, $properties[404])) {
             // Do we have an email address?
             $props = $currentNode->getProperties(array('{http://sabredav.org/ns}email-address'));
             if (isset($props['{http://sabredav.org/ns}email-address'])) {
                 $email = $props['{http://sabredav.org/ns}email-address'];
             } else {
                 // We're going to make up an emailaddress
                 $email = $currentNode->getName() . '.sabredav@' . $this->server->getHeader('host');
             }
             $properties[200][$calProp] = new Sabre_DAV_Property_Href('mailto:' . $email, false);
             unset($properties[404][$calProp]);
         }
     }
     if ($currentNode instanceof Sabre_CalDAV_Calendar || $currentNode instanceof Sabre_CalDAV_CalendarObject) {
         if (array_key_exists('{DAV:}supported-report-set', $properties[200])) {
             $properties[200]['{DAV:}supported-report-set']->addReport(array('{' . self::NS_CALDAV . '}calendar-multiget', '{' . self::NS_CALDAV . '}calendar-query'));
         }
     }
 }