aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Cdav.php13
-rw-r--r--include/event.php68
-rw-r--r--install/schema_mysql.sql171
-rw-r--r--view/css/cdav_addressbook.css103
-rw-r--r--view/css/cdav_calendar.css22
5 files changed, 371 insertions, 6 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 856956b5b..f91dead04 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -1,7 +1,8 @@
<?php
-
namespace Zotlabs\Module;
+require_once('include/event.php');
+
class Cdav extends \Zotlabs\Web\Controller {
function init() {
@@ -762,7 +763,7 @@ class Cdav extends \Zotlabs\Web\Controller {
require_once 'vendor/autoload.php';
- head_add_css('/addon/cdav/view/css/cdav.css');
+ head_add_css('cdav.css');
if(argv(1) === 'calendar') {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
@@ -773,7 +774,7 @@ class Cdav extends \Zotlabs\Web\Controller {
if(argc() == 2 && argv(1) === 'calendar') {
head_add_css('/library/fullcalendar/fullcalendar.css');
- head_add_css('/addon/cdav/view/css/cdav_calendar.css');
+ head_add_css('cdav_calendar.css');
head_add_js('/library/moment/moment.min.js', 1);
head_add_js('/library/fullcalendar/fullcalendar.min.js', 1);
@@ -811,7 +812,7 @@ class Cdav extends \Zotlabs\Web\Controller {
$description = ['description', t('Description')];
$location = ['location', t('Location')];
- $o .= replace_macros(get_markup_template('cdav_calendar.tpl', 'addon/cdav'), [
+ $o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [
'$sources' => $sources,
'$color' => $color,
'$lang' => \App::$language,
@@ -979,7 +980,7 @@ class Cdav extends \Zotlabs\Web\Controller {
if(!$displayname)
return;
- head_add_css('/addon/cdav/view/css/cdav_addressbook.css');
+ head_add_css('cdav_addressbook.css');
$o = '';
@@ -1102,7 +1103,7 @@ class Cdav extends \Zotlabs\Web\Controller {
usort($cards, function($a, $b) { return strcasecmp($a['fn'], $b['fn']); });
}
- $o .= replace_macros(get_markup_template('cdav_addressbook.tpl', 'addon/cdav'), [
+ $o .= replace_macros(get_markup_template('cdav_addressbook.tpl'), [
'$id' => $id,
'$cards' => $cards,
'$displayname' => $displayname,
diff --git a/include/event.php b/include/event.php
index 001bd7dd3..b56a5fb3e 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1236,3 +1236,71 @@ function tasks_fetch($arr) {
return $ret;
}
+
+function cdav_principal($uri) {
+ $r = q("SELECT uri FROM principals WHERE uri = '%s' LIMIT 1",
+ dbesc($uri)
+ );
+
+ if($r[0]['uri'] === $uri)
+ return true;
+ else
+ return false;
+}
+
+function cdav_perms($needle, $haystack, $check_rw = false) {
+ foreach ($haystack as $item) {
+ if($check_rw) {
+ if(is_array($item['id'])) {
+ if ($item['id'][0] == $needle && $item['share-access'] != 2) {
+ return $item['{DAV:}displayname'];
+ }
+ }
+ else {
+ if ($item['id'] == $needle && $item['share-access'] != 2) {
+ return $item['{DAV:}displayname'];
+ }
+ }
+ }
+ else {
+ if(is_array($item['id'])) {
+ if ($item['id'][0] == $needle) {
+ return $item['{DAV:}displayname'];
+ }
+ }
+ else {
+ if ($item['id'] == $needle) {
+ return $item['{DAV:}displayname'];
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
+function translate_type($type) {
+
+ if(!$type)
+ return;
+
+ $type = strtoupper($type);
+
+ $map = [
+ 'CELL' => t('Mobile'),
+ 'HOME' => t('Home'),
+ 'HOME,VOICE' => t('Home, Voice'),
+ 'HOME,FAX' => t('Home, Fax'),
+ 'WORK' => t('Work'),
+ 'WORK,VOICE' => t('Work, Voice'),
+ 'WORK,FAX' => t('Work, Fax'),
+ 'OTHER' => t('Other')
+ ];
+
+ if (array_key_exists($type, $map)) {
+ return [$type, $map[$type]];
+ }
+ else {
+ return [$type, t('Other') . ' (' . $type . ')'];
+ }
+}
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index 37b8f1ac0..6938050cf 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -1404,3 +1404,174 @@ CREATE TABLE IF NOT EXISTS `xtag` (
KEY `xtag_hash` (`xtag_hash`),
KEY `xtag_flags` (`xtag_flags`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists addressbooks (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARBINARY(255),
+ displayname VARCHAR(255),
+ uri VARBINARY(200),
+ description TEXT,
+ synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1',
+ UNIQUE(principaluri(100), uri(100))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists cards (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ addressbookid INT(11) UNSIGNED NOT NULL,
+ carddata MEDIUMBLOB,
+ uri VARBINARY(200),
+ lastmodified INT(11) UNSIGNED,
+ etag VARBINARY(32),
+ size INT(11) UNSIGNED NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists addressbookchanges (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARBINARY(200) NOT NULL,
+ synctoken INT(11) UNSIGNED NOT NULL,
+ addressbookid INT(11) UNSIGNED NOT NULL,
+ operation TINYINT(1) NOT NULL,
+ INDEX addressbookid_synctoken (addressbookid, synctoken)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendarobjects (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ calendardata MEDIUMBLOB,
+ uri VARBINARY(200),
+ calendarid INTEGER UNSIGNED NOT NULL,
+ lastmodified INT(11) UNSIGNED,
+ etag VARBINARY(32),
+ size INT(11) UNSIGNED NOT NULL,
+ componenttype VARBINARY(8),
+ firstoccurence INT(11) UNSIGNED,
+ lastoccurence INT(11) UNSIGNED,
+ uid VARBINARY(200),
+ UNIQUE(calendarid, uri),
+ INDEX calendarid_time (calendarid, firstoccurence)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendars (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1',
+ components VARBINARY(21)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendarinstances (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ calendarid INTEGER UNSIGNED NOT NULL,
+ principaluri VARBINARY(100),
+ access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite',
+ displayname VARCHAR(100),
+ uri VARBINARY(200),
+ description TEXT,
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARBINARY(10),
+ timezone TEXT,
+ transparent TINYINT(1) NOT NULL DEFAULT '0',
+ share_href VARBINARY(100),
+ share_displayname VARCHAR(100),
+ share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid',
+ UNIQUE(principaluri, uri),
+ UNIQUE(calendarid, principaluri),
+ UNIQUE(calendarid, share_href)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendarchanges (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARBINARY(200) NOT NULL,
+ synctoken INT(11) UNSIGNED NOT NULL,
+ calendarid INT(11) UNSIGNED NOT NULL,
+ operation TINYINT(1) NOT NULL,
+ INDEX calendarid_synctoken (calendarid, synctoken)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendarsubscriptions (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARBINARY(200) NOT NULL,
+ principaluri VARBINARY(100) NOT NULL,
+ source TEXT,
+ displayname VARCHAR(100),
+ refreshrate VARCHAR(10),
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARBINARY(10),
+ striptodos TINYINT(1) NULL,
+ stripalarms TINYINT(1) NULL,
+ stripattachments TINYINT(1) NULL,
+ lastmodified INT(11) UNSIGNED,
+ UNIQUE(principaluri, uri)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists schedulingobjects (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARBINARY(255),
+ calendardata MEDIUMBLOB,
+ uri VARBINARY(200),
+ lastmodified INT(11) UNSIGNED,
+ etag VARBINARY(32),
+ size INT(11) UNSIGNED NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists locks (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ owner VARCHAR(100),
+ timeout INTEGER UNSIGNED,
+ created INTEGER,
+ token VARBINARY(100),
+ scope TINYINT,
+ depth TINYINT,
+ uri VARBINARY(1000),
+ INDEX(token),
+ INDEX(uri(100))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists principals (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARBINARY(200) NOT NULL,
+ email VARBINARY(80),
+ displayname VARCHAR(80),
+ UNIQUE(uri)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists groupmembers (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principal_id INTEGER UNSIGNED NOT NULL,
+ member_id INTEGER UNSIGNED NOT NULL,
+ UNIQUE(principal_id, member_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists propertystorage (
+ id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ path VARBINARY(1024) NOT NULL,
+ name VARBINARY(100) NOT NULL,
+ valuetype INT UNSIGNED,
+ value MEDIUMBLOB
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100));
+
+CREATE TABLE if not exists users (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ username VARBINARY(50),
+ digesta1 VARBINARY(32),
+ UNIQUE(username)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE if not exists calendarinstances (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ calendarid INTEGER UNSIGNED NOT NULL,
+ principaluri VARBINARY(100),
+ access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite',
+ displayname VARCHAR(100),
+ uri VARBINARY(200),
+ description TEXT,
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARBINARY(10),
+ timezone TEXT,
+ transparent TINYINT(1) NOT NULL DEFAULT '0',
+ share_href VARBINARY(100),
+ share_displayname VARCHAR(100),
+ share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid',
+ UNIQUE(principaluri, uri),
+ UNIQUE(calendarid, principaluri),
+ UNIQUE(calendarid, share_href)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
diff --git a/view/css/cdav_addressbook.css b/view/css/cdav_addressbook.css
new file mode 100644
index 000000000..038358e43
--- /dev/null
+++ b/view/css/cdav_addressbook.css
@@ -0,0 +1,103 @@
+.vcard-header {
+ cursor: pointer;
+ padding: 7px 10px;
+ margin-bottom: 3px;
+}
+
+.vcard-header:hover,
+.vcard-header.active {
+ background-color: rgb(238,238,238);
+ cursor: pointer;
+}
+
+.vcard-header.active:hover {
+ cursor: initial;
+}
+
+.vcard-add-field {
+ margin-top: 8px;
+ display: none;
+}
+
+.vcard-cancel {
+ margin: 6px 10px;
+ height: 32px;
+ line-height: 32px;
+ color: #777;
+ font-size: 16px;
+
+ cursor: pointer;
+ display: none;
+ float: right;
+}
+
+.vcard-info {
+ display: none;
+}
+
+.vcard-nophoto {
+ display: inline-block;
+ width: 32px;
+ height: 32px;
+ border-radius: 4px;
+ border: 1px solid #ccc;
+ text-align: center;
+ font-size: 20px;
+ color: #fff;
+ background-color: #ddd;
+}
+
+.vcard-photo {
+ width: 32px;
+ height: 32px;
+ border-radius: 4px;
+ border: 1px solid #ccc;
+ text-align: center;
+}
+
+.vcard-fn-preview,
+input.vcard-fn {
+ font-size: 16px !important;
+ margin-left: 5px;
+}
+
+.vcard-email-preview,
+.vcard-tel-preview {
+ color: #999;
+}
+
+
+.vcard-fn,
+#create_form,
+#more_block {
+ display: none;
+}
+
+input.vcard-fn,
+.vcard-fn-create input,
+.vcard-org input,
+.vcard-title input,
+.vcard-tel input,
+.vcard-email input,
+.vcard-impp input,
+.vcard-url input,
+.vcard-adr input,
+.vcard-note input {
+ padding: 0px;
+ margin-left: 5px;
+ border-width: 0px 0px 1px 0px;
+ border-radius: 0px;
+ background-color: transparent;
+ min-width: 160px;
+}
+
+#template-form-vcard-org,
+#template-form-vcard-title,
+#template-form-vcard-tel,
+#template-form-vcard-email,
+#template-form-vcard-impp,
+#template-form-vcard-url,
+#template-form-vcard-adr,
+#template-form-vcard-note {
+ display: none;
+}
diff --git a/view/css/cdav_calendar.css b/view/css/cdav_calendar.css
new file mode 100644
index 000000000..d68278a63
--- /dev/null
+++ b/view/css/cdav_calendar.css
@@ -0,0 +1,22 @@
+/* fix borders */
+
+.fc th:first-child,
+.fc td:first-child {
+ border-left-width: 0px;
+}
+
+.fc th:last-child,
+.fc td:last-child {
+ border-right-width: 0px;
+ border-bottom-width: 0px;
+}
+
+.fc-unthemed th,
+.fc-unthemed td,
+.fc-unthemed thead,
+.fc-unthemed tbody,
+.fc-unthemed .fc-divider,
+.fc-unthemed .fc-row,
+.fc-unthemed .fc-popover {
+ border-color: #ccc !important;
+}