/** * Create or Update one event * * @access public * @param $data string VCALENDAR text * @param $url string URL for the calendar, if false a new calendar object is created * @param $etag string ETAG for the calendar, if '*' is a new object * @return array */ public function CreateUpdateCalendar($data, $url = false, $etag = "*") { if ($url === false) { $url = sprintf("%s%s/%s-%s.ics", $this->_caldav_path, CALDAV_PERSONAL, gmdate("Ymd\\THis\\Z"), hash("md5", microtime())); $etag = "*"; } return $this->_caldav->DoPUTRequest($url, $data, $etag); }
/** * Change/Add a message with contents received from ActiveSync * @see BackendDiff::ChangeMessage() */ public function ChangeMessage($folderid, $id, $message, $contentParameters) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV->ChangeMessage('%s','%s')", $folderid, $id)); if ($id) { $mod = $this->StatMessage($folderid, $id); $etag = $mod['mod']; } else { $etag = "*"; $date = gmdate("Ymd\\THis\\Z"); $random = hash("md5", microtime()); $id = $date . "-" . $random . ".ics"; } $data = $this->_ParseASToVCalendar($message, $folderid, substr($id, 0, strlen($id) - 4)); $url = $this->_caldav_path . substr($folderid, 1) . "/" . $id; $etag_new = $this->_caldav->DoPUTRequest($url, $data, $etag); $item = array(); $item['href'] = $id; $item['etag'] = $etag_new; $item['data'] = $data; $this->_collection[$id] = $item; return $this->StatMessage($folderid, $id); }
static function putIcal($data, $params = false) { ob_start(); require_once ROOTPATH . '/plugins/davicalCliente/caldav-client-v2.php'; $cal = new CalDAVClient(Config::service('CalDAV', 'url') . '/' . $params['location'] . '/', Config::me('uid'), Config::me('password')); $cal->DoPUTRequest(Config::service('CalDAV', 'url') . '/' . $params['location'] . '/' . $params['uid'] . '.ics', $data); ob_end_clean(); }
if (isset($local_calendar->getctag)) { $newcache->local_ctag = $local_calendar->getctag; } } } if ($sync_out) { printf("Sync out\n"); // Delete any remote events which have been removed from the local server foreach ($server_delete_urls as $href => $etag) { $caldav->DoDELETERequest($args->url . $href, $etag); printf("\nDELETE Response:\n%s\n", $caldav->GetResponseHeaders()); unset($newcache->server_etags[$fname]); } // Push locally updated events to the remote server foreach ($push_urls as $href => $etag) { $new_etag = $caldav->DoPUTRequest($args->url . $href, $push_events[$href], $etag); printf("\nPUT:\n%s\nResponse:\n%s\n", $caldav->GetHttpRequest(), $caldav->GetResponseHeaders()); if (!isset($new_etag) || $new_etag == '') { if (preg_match('{^Location:\\s+.*/([^/]+)$}im', $caldav->GetResponseHeaders(), $matches)) { /** How annoying. It seems the other server renamed the event on PUT so we move the local copy to match their name */ $new_href = preg_replace('{\\r?\\n.*$}s', '', $matches[1]); $qry = new AwlQuery('UPDATE caldav_data SET dav_name = :new_dav_name WHERE dav_name = :old_dav_name', array(':new_dav_name' => $args->local_collection_path . $new_href, ':old_dav_name' => $args->local_collection_path . $href)); $qry->Exec('sync_pull', __LINE__, __FILE__); $new_cache->local_etags[$new_href] = $new_cache->local_etags[$href]; unset($new_cache->local_etags[$href]); $href = $new_href; $caldav->DoHEADRequest($args->url . $href); if (preg_match('{^Etag:\\s+"([^"]*)"\\s*$}im', $caldav->httpResponseHeaders, $matches)) { $new_etag = $matches[1]; } printf("\nHEAD:\n%s\nResponse:\n%s\n", $caldav->GetHttpRequest(), $caldav->GetResponseHeaders());