Difference between revisions of "External Bind"

From Davical
Jump to navigationJump to search
(Note units for external refresh period.)
m
Line 1: Line 1:
starting with version 0.9.9.5 it is now possible to import a remote calendar that is available from the web.  To enable this feature you must add the external_refresh configuration parameter:
+
starting with version 0.9.9.5 it is now possible to import a remote calendar that is available from the web.  To enable this feature you must add the ''external_refresh configuration'' parameter:
 
  /*
 
  /*
 
  * External subscription (BIND) minimum refresh interval
 
  * External subscription (BIND) minimum refresh interval
Line 8: Line 8:
  
 
That is the minimum time period to wait between checks to see if the remote file has been updated, it will only be refreshed when  
 
That is the minimum time period to wait between checks to see if the remote file has been updated, it will only be refreshed when  
1. a client tries to look at the calendar,  
+
# client tries to look at the calendar,  
2. the last update was more than $c->external_refresh minutes ago,
+
# the last update was more than $c->external_refresh minutes ago,
3. the remote server indicates the file has been updated it will reimport the calendar.
+
# the remote server indicates the file has been updated it will reimport the calendar.
  
Note that you need the php5-curl package (Debian/Ubuntu, other distros might call it differently) for this to work otherwise you get 500 errors when querying the calendar.
+
Note that you need the ''php5-curl package'' (Debian/Ubuntu, other distros might call it differently) for this to work otherwise you get 500 errors when querying the calendar.
  
 
With that setting in place it is now possible to bind a remote calendar, the request should look similar to the following:
 
With that setting in place it is now possible to bind a remote calendar, the request should look similar to the following:
Line 21: Line 21:
 
  <dav:bind xmlns:dav="DAV:">
 
  <dav:bind xmlns:dav="DAV:">
 
  <dav:segment>Melbourne Rebels 2011 Fixtures</dav:segment><dav:href>http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics</dav:href></dav:bind>
 
  <dav:segment>Melbourne Rebels 2011 Fixtures</dav:segment><dav:href>http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics</dav:href></dav:bind>
 
  
 
That request will create a calendar named "Melbourne Rebels 2011 Fixtures" in https://example.org/caldav.php/user/  with the contents imported from http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics.
 
That request will create a calendar named "Melbourne Rebels 2011 Fixtures" in https://example.org/caldav.php/user/  with the contents imported from http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics.

Revision as of 15:26, 30 June 2015

starting with version 0.9.9.5 it is now possible to import a remote calendar that is available from the web. To enable this feature you must add the external_refresh configuration parameter:

/*
* External subscription (BIND) minimum refresh interval
* Required if you want to enable remote binding ( webcal subscriptions )
* Default: none
*/
$c->external_refresh = 60; // Minutes

That is the minimum time period to wait between checks to see if the remote file has been updated, it will only be refreshed when

  1. client tries to look at the calendar,
  2. the last update was more than $c->external_refresh minutes ago,
  3. the remote server indicates the file has been updated it will reimport the calendar.

Note that you need the php5-curl package (Debian/Ubuntu, other distros might call it differently) for this to work otherwise you get 500 errors when querying the calendar.

With that setting in place it is now possible to bind a remote calendar, the request should look similar to the following:

BIND https://example.org/caldav.php/user/

<?xml version="1.0" encoding="utf-8"?>
<dav:bind xmlns:dav="DAV:">
<dav:segment>Melbourne Rebels 2011 Fixtures</dav:segment><dav:href>http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics</dav:href></dav:bind>

That request will create a calendar named "Melbourne Rebels 2011 Fixtures" in https://example.org/caldav.php/user/ with the contents imported from http://www.me.com/ca/sharesubscribe/1.282129618/731F31CB-B333-43A7-9A79-78F785CDF767.ics.

One can generate such a request with curl using the following:

USERNAME=yourusername
CALENDAR=http://mycal.example.net/calendar/caldav.php/yourusername/
REMOTE=http://www.example.org/calendar/file.ics
CALNAME="Remote Calendar"
curl --basic --user '${USERNAME}' -X BIND -H 'Content-Type: text/xml;charset="UTF-8"' --url '${CALENDAR}' -d '<?xml version="1.0" encoding="utf-8"?><bind xmlns="DAV:"><segment>${CALNAME}</segment><href>${REMOTE}</href></bind>'

This can generate a fair amount of load on the server, so I wouldn't suggest using a lot of these with a short refresh interval. They are shared between users based on the md5 of the remote url, so five users subscribing to the same calendar will all see the same data. Finally there is currently no provision for removing them or the data when no one actually bound to them, since no one is requesting updates they will just be taking space in the database the following should list them so they can be cleaned up.

select dav_name from collection where parent_container='/.external/' and collection_id not in ( select bound_source_id from dav_binding where external_url is not null);