Exemplo n.º 1
0
 /**
  * function connect()
  * Connects to a CalDAV-Server.
  *
  * Arguments:
  * @param $url URL to the CalDAV-server. E.g. http://exam.pl/baikal/cal.php/username/calendername/
  * @param $user Username to login with
  * @param $pass Password to login with
  *
  * Debugging:
  * @throws CalDAVException
  * For debugging purposes, just sorround everything with try { ... } catch (Exception $e) { echo $e->__toString(); }
  */
 function connect($url, $user, $pass)
 {
     //  Connect to CalDAV-Server and log in
     $client = new CalDAVClient($url, $user, $pass);
     // Valid CalDAV-Server? Or is it just a WebDAV-Server?
     if (!$client->isValidCalDAVServer()) {
         if ($client->GetHttpResultCode() == '401') {
             throw new CalDAVException('Login failed', $client);
         } elseif ($client->GetHttpResultCode() == '') {
             throw new CalDAVException('Can\'t reach server', $client);
         } else {
             throw new CalDAVException('Could\'n find a CalDAV-collection under the url', $client);
         }
     }
     // Check for errors
     if ($client->GetHttpResultCode() != '200') {
         if ($client->GetHttpResultCode() == '401') {
             throw new CalDAVException('Login failed', $client);
         } elseif ($client->GetHttpResultCode() == '') {
             throw new CalDAVException('Can\'t reach server', $client);
         } else {
             throw new CalDAVException('Recieved unknown HTTP status while checking the connection after establishing it', $client);
         }
     }
     $this->client = $client;
 }