コード例 #1
0
 /**
  * Does a REPORT request
  *
  * @param string $url
  * @param array $properties List of requested properties must be specified as an array, in clark
  *        notation.
  * @param array $event_urls If specified, a multiget report request will be initiated with the
  *        specified event urls.
  * @param int $depth = 1 Depth should be either 0 or 1. A depth of 1 will cause a request to be
  *        made to the server to also return all child resources.
  * @return array Hash with ics event path as key and a hash array with properties and appropriate values.
  */
 public function prop_report($url, array $properties, array $event_urls = array(), $depth = 1)
 {
     $url = slashify($url);
     // iCloud
     $parent_tag = sizeof($event_urls) > 0 ? "c:calendar-multiget" : "d:propfind";
     $method = sizeof($event_urls) > 0 ? 'REPORT' : 'PROPFIND';
     $body = '<?xml version="1.0"?>' . "\n" . '<' . $parent_tag . ' xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">' . "\n";
     $body .= '  <d:prop>' . "\n";
     foreach ($properties as $property) {
         list($namespace, $elementName) = Sabre\DAV\XMLUtil::parseClarkNotation($property);
         if ($namespace === 'DAV:') {
             $body .= '    <d:' . $elementName . ' />' . "\n";
         } else {
             $body .= '    <x:' . $elementName . ' xmlns:x="' . $namespace . '"/>' . "\n";
         }
     }
     $body .= '  </d:prop>' . "\n";
     // http://tools.ietf.org/html/rfc4791#page-90
     // http://www.bedework.org/trac/bedework/wiki/Bedework/DevDocs/Filters
     /*
     if($start && $end)
     {
     $body.= '  <c:filter>'."\n".
     '    <c:comp-filter name="VCALENDAR">'."\n".
     '      <c:comp-filter name="VEVENT">'."\n".
     '        <c:time-range start="'.$start.'" end="'.$end.'" />'."\n".
     '      </c:comp-filter>'."\n".
     '    </c:comp-filter>'."\n".
     '  </c:filter>' . "\n";
     }
     */
     foreach ($event_urls as $event_url) {
         $body .= '<d:href>' . $event_url . '</d:href>' . "\n";
     }
     $body .= '</' . $parent_tag . '>';
     $response = $this->request($method, $url, $body, array('Depth' => $depth, 'Content-Type' => 'application/xml', 'User-Agent' => $this->user_agent));
     $result = $this->parseMultiStatus($response['body']);
     // If depth was 0, we only return the top item
     if ($depth === 0) {
         reset($result);
         $result = current($result);
         return isset($result[200]) ? $result[200] : array();
     }
     $new_result = array();
     foreach ($result as $href => $status_list) {
         $new_result[$href] = isset($status_list[200]) ? $status_list[200] : array();
     }
     return $new_result;
 }