diff --git a/config/example-config.php b/config/example-config.php index 3db0b7cf..8c157609 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -316,3 +316,26 @@ $c->collections_always_exist = false; * enabled this option... */ // $c->allow_get_email_visibility = false; + + + /*************************************************************************** +* * +* Push Notification Server * +* * +***************************************************************************/ + +/* + * This enable XMPP PubSub push notifications to clients that request them. + * N.B. this will publish urls for ALL updates and does NOT restrict + * subscription permissions on the jabber server! That means anyone with + * read access to the pubsub tree of your jabber server can watch for updates, + * they will only see URL's to the updated entries not the calendar data. + * + * Only tested with ejabberd 2.0.x + */ + +// $c->notifications_server = array( 'host' => $_SERVER['SERVER_NAME'], // jabber server hostname +// 'jid' => 'user@example.com', // user(JID) to login/ publish as 'password' => '', // password for above account +// // 'debug_jid' => 'otheruser@example.com' // send a copy of all publishes to this jid +// ); +// include ( 'pubsub.php' ); diff --git a/inc/CalDAVPrincipal.php b/inc/CalDAVPrincipal.php index f9cd3985..a9640b5c 100644 --- a/inc/CalDAVPrincipal.php +++ b/inc/CalDAVPrincipal.php @@ -180,6 +180,12 @@ class CalDAVPrincipal $this->dropbox_url = sprintf( '%s.drop/', $this->url); $this->notifications_url = sprintf( '%s.notify/', $this->url); + if ( isset ( $c->notifications_server ) ) { + $this->xmpp_uri = 'xmpp:pubsub.'.$c->notifications_server['host'].'?pubsub;node=/home/'.$c->notifications_server['host']; + $this->xmpp_uri .= '/'.preg_replace ( '/@.*$/', '', $c->notifications_server['jid'] ).'/DAViCal'.$this->url; + $this->xmpp_server = $c->notifications_server['host']; + } + $this->group_member_set = array(); $qry = new PgQuery('SELECT * FROM relationship LEFT JOIN usr ON (from_user = usr.user_no) LEFT JOIN role_member ON (to_user = role_member.user_no) LEFT JOIN roles USING (role_no) WHERE to_user = ? AND role_name = '."'Group'", $this->user_no ); if ( $qry->Exec('CalDAVPrincipal') && $qry->rows > 0 ) { @@ -406,6 +412,20 @@ class CalDAVPrincipal $reply->CalendarserverElement($prop, 'notifications-URL', $reply->href($this->notifications_url) ); break; + case 'http://calendarserver.org/ns/:xmpp-server': + if ( isset ( $this->xmpp_uri ) ) + $reply->CalendarserverElement($prop, 'xmpp-server', $this->xmpp_server ); + else + $not_found[] = $reply->Tag($tag); + break; + + case 'http://calendarserver.org/ns/:xmpp-uri': + if ( isset ( $this->xmpp_uri ) ) + $reply->CalendarserverElement($prop, 'xmpp-uri', $this->xmpp_uri ); + else + $not_found[] = $reply->Tag($tag); + break; + case 'urn:ietf:params:xml:ns:caldav:calendar-home-set': $reply->CalDAVElement($prop, 'calendar-home-set', $reply->href( $this->calendar_home_set ) ); break;