예제 #1
0
 /**
  * Returning a SyncFolder
  * @see BackendDiff::GetFolder()
  */
 public function GetFolder($id)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV->GetFolder('%s')", $id));
     $val = $this->_caldav->GetCalendarDetails($this->_caldav_path . substr($id, 1) . "/");
     $folder = new SyncFolder();
     $folder->parentid = "0";
     $folder->displayname = $val->displayname;
     $folder->serverid = $id;
     if ($id[0] == "C") {
         if (defined('CALDAV_PERSONAL') && strtolower(substr($id, 1)) == CALDAV_PERSONAL) {
             $folder->type = SYNC_FOLDER_TYPE_APPOINTMENT;
         } else {
             $folder->type = SYNC_FOLDER_TYPE_USER_APPOINTMENT;
         }
     } else {
         if (defined('CALDAV_PERSONAL') && strtolower(substr($id, 1)) == CALDAV_PERSONAL) {
             $folder->type = SYNC_FOLDER_TYPE_TASK;
         } else {
             $folder->type = SYNC_FOLDER_TYPE_USER_TASK;
         }
     }
     return $folder;
 }
예제 #2
0
define('LOGLEVEL', LOGLEVEL_DEBUG);
define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
// $username = "******";
// $password = "******";
//
// define('CALDAV_SERVER', 'http://sogo-demo.inverse.ca');
// define('CALDAV_PORT', '80');
// define('CALDAV_PATH', '/SOGo/dav/%u/Calendar/');
// define('CALDAV_PERSONAL', 'personal');
// define('CALDAV_SUPPORTS_SYNC', true);
$caldav_path = str_replace('%u', $username, CALDAV_PATH);
$caldav = new CalDAVClient(CALDAV_SERVER . ":" . CALDAV_PORT . $caldav_path, $username, $password);
printf("Connected %d\n", $caldav->CheckConnection());
// Show options supported by server
$options = $caldav->DoOptionsRequest();
print_r($options);
$calendars = $caldav->FindCalendars();
print_r($calendars);
$path = $caldav_path . CALDAV_PERSONAL . "/";
$val = $caldav->GetCalendarDetails($path);
print_r($val);
$begin = gmdate("Ymd\\THis\\Z", time() - 24 * 7 * 60 * 60);
$finish = gmdate("Ymd\\THis\\Z", 2147483647);
$msgs = $caldav->GetEvents($begin, $finish, $path);
print_r($msgs);
// Initial sync
$results = $caldav->GetSync($path, true, CALDAV_SUPPORTS_SYNC);
print_r($results);
sleep(60);
$results = $caldav->GetSync($path, false, CALDAV_SUPPORTS_SYNC);
print_r($results);
예제 #3
0
// }
//
// // Now we have all of the remote calendars, we will look for the URL that
// // matches what we were originally supplied.  While this seems laborious
// // because we already have it, it means we could provide a match in some
// // other way (e.g. on displayname) and we could also present a list to
// // the user which is built from following the above process.
// foreach( $calendars AS $k => $a_calendar ) {
//   if ( $a_calendar->url == $args->url ) $calendar = $a_calendar;
// }
// if ( !isset($calendar) ) $calendar = $calendars[0];
// In reality we could have omitted all of the above parts, If we really do
// know the correct URL at the start.
// Everything now will be at our calendar URL
$caldav->SetCalendar($args->url);
$calendar = $caldav->GetCalendarDetails();
printf("Remote calendar '%s' is at %s\n", $calendar->displayname, $calendar->url);
// Generate a consistent filename for our synchronisation cache
if (!file_exists($args->cache_directory) && !is_dir($args->cache_directory)) {
    mkdir($args->cache_directory, 0750);
    // Not incredibly sensitive file contents - URLs and ETags
}
$sync_cache_filename = $args->cache_directory . '/' . md5($args->user . $calendar->url);
// Do we just need to sync everything across and overwrite all the local stuff?
$sync_all = !file_exists($sync_cache_filename) || $args->sync_all;
$sync_in = false;
$sync_out = false;
if ($args->sync_in || !$args->sync_out) {
    $sync_in = true;
}
if ($args->sync_out || !$args->sync_in) {