Beispiel #1
0
 /**
  * Returns a list (array) of messages
  *
  * @param string        $folderid       id of the parent folder
  * @param long          $cutoffdate     timestamp in the past from which on messages should be returned
  *
  * @access public
  * @return array/false  array with messages or false if folder is not available
  */
 public function GetMessageList($folderid, $cutoffdate)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->GetMessageList('%s', '%s')", $folderid, $cutoffdate));
     $messages = array();
     foreach ($this->addressbooks as $addressbook) {
         $addressbookId = $this->convertAddressbookUrl($addressbook);
         $vcards = false;
         try {
             // We don't need the actual vcards here, we only need a list of all them
             // This petition is always "initial", and we don't "include_vcards"
             $this->server->set_url($addressbook);
             $vcards = $this->server->do_sync(true, false, CARDDAV_SUPPORTS_SYNC);
         } catch (Exception $ex) {
             ZLog::Write(LOGLEVEL_ERROR, sprintf("BackendCardDAV->GetMessageList - Error getting the vcards in '%s': %s", $addressbook, $ex->getMessage()));
         }
         if ($vcards === false) {
             ZLog::Write(LOGLEVEL_ERROR, sprintf("BackendCardDAV->GetMessageList - Error getting the vcards"));
         } else {
             $xml_vcards = new SimpleXMLElement($vcards);
             foreach ($xml_vcards->element as $vcard) {
                 $id = $addressbookId . "-" . $vcard->id->__toString();
                 $this->contactsetag[$id] = $vcard->etag->__toString();
                 $messages[] = $this->StatMessage($folderid, $id);
             }
         }
     }
     return $messages;
 }
echo "{$gal_url}\n";
$server = new carddav_backend($url);
$server->set_auth($username, $password);
//$server->enable_debug();
$raw = $server->get(false, false, true);
echo "{$raw}\n";
//var_dump($server->get_debug());
if ($raw !== false) {
    $xml = new SimpleXMLElement($raw);
    foreach ($xml->addressbook_element as $response) {
        if ($gal_url !== false) {
            if (strcmp(urldecode($response->url), $gal_url) == 0) {
                echo sprintf("BackendCardDAV::discoverAddressbooks() Ignoring GAL addressbook '%s'\n", $this->gal_url);
                continue;
            }
        }
        echo sprintf("BackendCardDAV::discoverAddressbooks() Found addressbook '%s'\n", urldecode($response->url));
    }
    unset($xml);
}
//$server->enable_debug();
$server->set_url($default_url);
$vcards = $server->do_sync(true, false, false);
//var_dump($server->get_debug());
echo "{$vcards}\n";
echo "-----------\n";
//$server->enable_debug();
// TODO: set to an existing vcard ID (you will get a list with the do_sync operation
$xml = $server->get_xml_vcard('131-52C19B00-7-7A512880');
//var_dump($server->get_debug());
echo "{$xml}\n";