aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2017-07-04 12:07:11 +0200
committerMario Vavti <mario@mariovavti.com>2017-07-04 12:07:11 +0200
commitfbf868e97619374206a109ff17d8f6c51c13aeb6 (patch)
treec7488483b3dbd0d4fcfbe99fc7483cf46573677b /Zotlabs
parent5e0bb6ecd52b6d9d91102cc89fb9d9e61e337d0b (diff)
downloadvolse-hubzilla-fbf868e97619374206a109ff17d8f6c51c13aeb6.tar.gz
volse-hubzilla-fbf868e97619374206a109ff17d8f6c51c13aeb6.tar.bz2
volse-hubzilla-fbf868e97619374206a109ff17d8f6c51c13aeb6.zip
reimplement creation of default calendar and default addressbook using sabre classes
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Cdav.php42
1 files changed, 19 insertions, 23 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 068ad2450..b1d99620b 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -751,20 +751,19 @@ class Cdav extends \Zotlabs\Web\Controller {
$channel = \App::get_channel();
$principalUri = 'principals/' . $channel['channel_address'];
+ $pdo = \DBA::$dba->db;
+
+ require_once 'vendor/autoload.php';
+
+ head_add_css('cdav.css');
if(!cdav_principal($principalUri)) {
- $this->activate($channel);
+ $this->activate($pdo, $channel);
if(!cdav_principal($principalUri)) {
return;
}
}
- $pdo = \DBA::$dba->db;
-
- require_once 'vendor/autoload.php';
-
- head_add_css('cdav.css');
-
if(argv(1) === 'calendar') {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
$calendars = $caldavBackend->getCalendarsForUser($principalUri);
@@ -1151,7 +1150,7 @@ class Cdav extends \Zotlabs\Web\Controller {
}
- function activate($channel) {
+ function activate($pdo, $channel) {
if(! $channel)
return;
@@ -1177,24 +1176,21 @@ class Cdav extends \Zotlabs\Web\Controller {
);
//create default calendar
- $r = q("insert into calendars (components) values('%s') ",
- dbesc('VEVENT,VTODO')
- );
+ $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
+ $properties = [
+ '{DAV:}displayname' => t('Default Calendar'),
+ '{http://apple.com/ns/ical/}calendar-color' => '#3a87ad',
+ '{urn:ietf:params:xml:ns:caldav}calendar-description' => $channel['channel_name']
+ ];
- $r = q("insert into calendarinstances (principaluri, displayname, uri, description, calendarcolor) values( '%s', '%s', '%s', '%s', '%s') ",
- dbesc($uri),
- dbesc(t('Default Calendar')),
- dbesc('default'),
- dbesc($channel['channel_name']),
- dbesc('#3a87ad')
- );
+ $id = $caldavBackend->createCalendar($uri, 'default', $properties);
+ set_pconfig(local_channel(), 'cdav_calendar' , $id[0], 1);
//create default addressbook
- $r = q("insert into addressbooks (principaluri, displayname, uri) values('%s', '%s', '%s') ",
- dbesc($uri),
- dbesc(t('Default Addressbook')),
- dbesc('default')
- );
+ $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
+ $properties = ['{DAV:}displayname' => t('Default Addressbook')];
+ $carddavBackend->createAddressBook($uri, $default, $properties);
+
}
}