Merge pull request #768 from ByteHamster/upgrade-sabredav
Upgraded SabreDAV
This commit is contained in:
commit
78fb212a46
7 changed files with 258 additions and 13 deletions
|
@ -24,5 +24,5 @@
|
||||||
# This copyright notice MUST APPEAR in all copies of the script!
|
# This copyright notice MUST APPEAR in all copies of the script!
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
define("BAIKAL_VERSION", "0.5.0");
|
define("BAIKAL_VERSION", "0.5.1");
|
||||||
define("BAIKAL_HOMEPAGE", "http://sabre.io/baikal/");
|
define("BAIKAL_HOMEPAGE", "http://sabre.io/baikal/");
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
namespace Baikal\Model;
|
namespace Baikal\Model;
|
||||||
|
|
||||||
class Calendar extends \Flake\Core\Model\Db {
|
class Calendar extends \Flake\Core\Model\Db {
|
||||||
const DATATABLE = "calendars";
|
const DATATABLE = "calendarinstances";
|
||||||
const PRIMARYKEY = "id";
|
const PRIMARYKEY = "id";
|
||||||
const LABELFIELD = "displayname";
|
const LABELFIELD = "displayname";
|
||||||
|
|
||||||
|
@ -40,8 +40,25 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
"calendarorder" => 0,
|
"calendarorder" => 0,
|
||||||
"calendarcolor" => "",
|
"calendarcolor" => "",
|
||||||
"timezone" => "",
|
"timezone" => "",
|
||||||
"components" => "",
|
"calendarid" => 0
|
||||||
];
|
];
|
||||||
|
protected $oCalendar; # Baikal\Model\Calendar\Calendar
|
||||||
|
|
||||||
|
protected function initFloating() {
|
||||||
|
parent::initFloating();
|
||||||
|
$this->oCalendar = new Calendar\Calendar();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initByPrimary($sPrimary) {
|
||||||
|
parent::initByPrimary($sPrimary);
|
||||||
|
$this->oCalendar = new Calendar\Calendar($this->get("calendarid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function persist() {
|
||||||
|
$this->oCalendar->persist();
|
||||||
|
$this->aData["calendarid"] = $this->oCalendar->get("id");
|
||||||
|
parent::persist();
|
||||||
|
}
|
||||||
|
|
||||||
static function icon() {
|
static function icon() {
|
||||||
return "icon-calendar";
|
return "icon-calendar";
|
||||||
|
@ -67,6 +84,10 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
|
|
||||||
function get($sPropName) {
|
function get($sPropName) {
|
||||||
|
|
||||||
|
if ($sPropName === "components") {
|
||||||
|
return $this->oCalendar->get($sPropName);
|
||||||
|
}
|
||||||
|
|
||||||
if ($sPropName === "todos") {
|
if ($sPropName === "todos") {
|
||||||
# TRUE if components contains VTODO, FALSE otherwise
|
# TRUE if components contains VTODO, FALSE otherwise
|
||||||
if (($sComponents = $this->get("components")) !== "") {
|
if (($sComponents = $this->get("components")) !== "") {
|
||||||
|
@ -94,6 +115,10 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
|
|
||||||
function set($sPropName, $sValue) {
|
function set($sPropName, $sValue) {
|
||||||
|
|
||||||
|
if ($sPropName === "components") {
|
||||||
|
return $this->oCalendar->set($sPropName, $sValue);
|
||||||
|
}
|
||||||
|
|
||||||
if ($sPropName === "todos") {
|
if ($sPropName === "todos") {
|
||||||
|
|
||||||
if (($sComponents = $this->get("components")) !== "") {
|
if (($sComponents = $this->get("components")) !== "") {
|
||||||
|
@ -112,7 +137,7 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::set("components", implode(",", $aComponents));
|
return $this->set("components", implode(",", $aComponents));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sPropName === "notes") {
|
if ($sPropName === "notes") {
|
||||||
|
@ -133,7 +158,7 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::set("components", implode(",", $aComponents));
|
return $this->set("components", implode(",", $aComponents));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::set($sPropName, $sValue);
|
return parent::set($sPropName, $sValue);
|
||||||
|
@ -215,5 +240,6 @@ class Calendar extends \Flake\Core\Model\Db {
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::destroy();
|
parent::destroy();
|
||||||
|
$this->oCalendar->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
Core/Frameworks/Baikal/Model/Calendar/Calendar.php
Normal file
60
Core/Frameworks/Baikal/Model/Calendar/Calendar.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
#################################################################
|
||||||
|
# Copyright notice
|
||||||
|
#
|
||||||
|
# (c) 2013 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||||
|
# All rights reserved
|
||||||
|
#
|
||||||
|
# http://baikal-server.com
|
||||||
|
#
|
||||||
|
# This script is part of the Baïkal Server project. The Baïkal
|
||||||
|
# Server project is free software; you can redistribute it
|
||||||
|
# and/or modify it under the terms of the GNU General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# The GNU General Public License can be found at
|
||||||
|
# http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
#
|
||||||
|
# This script is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# This copyright notice MUST APPEAR in all copies of the script!
|
||||||
|
#################################################################
|
||||||
|
|
||||||
|
|
||||||
|
namespace Baikal\Model\Calendar;
|
||||||
|
|
||||||
|
class Calendar extends \Flake\Core\Model\Db {
|
||||||
|
const DATATABLE = "calendars";
|
||||||
|
const PRIMARYKEY = "id";
|
||||||
|
const LABELFIELD = "components";
|
||||||
|
|
||||||
|
protected $aData = [
|
||||||
|
"synctoken" => "",
|
||||||
|
"components" => ""
|
||||||
|
];
|
||||||
|
|
||||||
|
function hasInstances() {
|
||||||
|
$rSql = $GLOBALS["DB"]->exec_SELECTquery(
|
||||||
|
"*",
|
||||||
|
"calendarinstances",
|
||||||
|
"calendarid" . "='" . $this->aData["id"] . "'"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (($aRs = $rSql->fetch()) === false) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
reset($aRs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy() {
|
||||||
|
if (!$this->hasInstances()) {
|
||||||
|
parent::destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -377,6 +377,141 @@ CREATE TABLE addressbooks (
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (version_compare($sVersionFrom, '0.5.1', '<')) {
|
||||||
|
if (!defined("PROJECT_DB_MYSQL") || PROJECT_DB_MYSQL === false) {
|
||||||
|
$pdo->exec(<<<SQL
|
||||||
|
CREATE TABLE calendarinstances (
|
||||||
|
id integer primary key asc NOT NULL,
|
||||||
|
calendarid integer,
|
||||||
|
principaluri text,
|
||||||
|
access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1',
|
||||||
|
displayname text,
|
||||||
|
uri text NOT NULL,
|
||||||
|
description text,
|
||||||
|
calendarorder integer,
|
||||||
|
calendarcolor text,
|
||||||
|
timezone text,
|
||||||
|
transparent bool,
|
||||||
|
share_href text,
|
||||||
|
share_displayname text,
|
||||||
|
share_invitestatus integer DEFAULT '2',
|
||||||
|
UNIQUE (principaluri, uri),
|
||||||
|
UNIQUE (calendarid, principaluri),
|
||||||
|
UNIQUE (calendarid, share_href)
|
||||||
|
);
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
$this->aSuccess[] = 'Created calendarinstances table';
|
||||||
|
$pdo->exec('
|
||||||
|
INSERT INTO calendarinstances
|
||||||
|
(
|
||||||
|
calendarid,
|
||||||
|
principaluri,
|
||||||
|
access,
|
||||||
|
displayname,
|
||||||
|
uri,
|
||||||
|
description,
|
||||||
|
calendarorder,
|
||||||
|
calendarcolor,
|
||||||
|
transparent
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
principaluri,
|
||||||
|
1,
|
||||||
|
displayname,
|
||||||
|
uri,
|
||||||
|
description,
|
||||||
|
calendarorder,
|
||||||
|
calendarcolor,
|
||||||
|
transparent
|
||||||
|
FROM calendars
|
||||||
|
');
|
||||||
|
$this->aSuccess[] = 'Migrated calendarinstances table';
|
||||||
|
$calendarBackup = 'calendars_3_1';
|
||||||
|
$pdo->exec('ALTER TABLE calendars RENAME TO ' . $calendarBackup);
|
||||||
|
$this->aSuccess[] = 'Did calendars backup';
|
||||||
|
|
||||||
|
$pdo->exec(<<<SQL
|
||||||
|
CREATE TABLE calendars (
|
||||||
|
id integer primary key asc NOT NULL,
|
||||||
|
synctoken integer DEFAULT 1 NOT NULL,
|
||||||
|
components text NOT NULL
|
||||||
|
);
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
$this->aSuccess[] = 'Created new calendars table';
|
||||||
|
} else { // mysql
|
||||||
|
$pdo->exec(<<<SQL
|
||||||
|
CREATE TABLE 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;
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
$this->aSuccess[] = 'Created calendarinstances table';
|
||||||
|
$pdo->exec('
|
||||||
|
INSERT INTO calendarinstances
|
||||||
|
(
|
||||||
|
calendarid,
|
||||||
|
principaluri,
|
||||||
|
access,
|
||||||
|
displayname,
|
||||||
|
uri,
|
||||||
|
description,
|
||||||
|
calendarorder,
|
||||||
|
calendarcolor,
|
||||||
|
transparent
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
principaluri,
|
||||||
|
1,
|
||||||
|
displayname,
|
||||||
|
uri,
|
||||||
|
description,
|
||||||
|
calendarorder,
|
||||||
|
calendarcolor,
|
||||||
|
transparent
|
||||||
|
FROM calendars
|
||||||
|
');
|
||||||
|
$this->aSuccess[] = 'Migrated calendarinstances table';
|
||||||
|
$calendarBackup = 'calendars_3_1';
|
||||||
|
$pdo->exec('RENAME TABLE calendars TO ' . $calendarBackup);
|
||||||
|
$this->aSuccess[] = 'Did calendars backup';
|
||||||
|
|
||||||
|
$pdo->exec(<<<SQL
|
||||||
|
CREATE TABLE calendars (
|
||||||
|
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1',
|
||||||
|
components VARBINARY(21)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
$this->aSuccess[] = 'Created new calendars table';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->exec(<<<SQL
|
||||||
|
INSERT INTO calendars (id, synctoken, components) SELECT id, synctoken, COALESCE(components,"VEVENT,VTODO,VJOURNAL") as components FROM $calendarBackup
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
$this->aSuccess[] = 'Migrated calendars table';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->updateConfiguredVersion($sVersionTo);
|
$this->updateConfiguredVersion($sVersionTo);
|
||||||
|
|
|
@ -26,6 +26,7 @@ CREATE TABLE addressbookchanges (
|
||||||
operation TINYINT(1) NOT NULL,
|
operation TINYINT(1) NOT NULL,
|
||||||
INDEX addressbookid_synctoken (addressbookid, synctoken)
|
INDEX addressbookid_synctoken (addressbookid, synctoken)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
CREATE TABLE calendarobjects (
|
CREATE TABLE calendarobjects (
|
||||||
id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
calendardata MEDIUMBLOB,
|
calendardata MEDIUMBLOB,
|
||||||
|
@ -43,17 +44,28 @@ CREATE TABLE calendarobjects (
|
||||||
|
|
||||||
CREATE TABLE calendars (
|
CREATE TABLE calendars (
|
||||||
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1',
|
||||||
|
components VARBINARY(21)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE calendarinstances (
|
||||||
|
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
calendarid INTEGER UNSIGNED NOT NULL,
|
||||||
principaluri VARBINARY(100),
|
principaluri VARBINARY(100),
|
||||||
|
access TINYINT(1) NOT NULL DEFAULT '1',
|
||||||
displayname VARCHAR(100),
|
displayname VARCHAR(100),
|
||||||
uri VARBINARY(200),
|
uri VARBINARY(200),
|
||||||
synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1',
|
|
||||||
description TEXT,
|
description TEXT,
|
||||||
calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
calendarcolor VARBINARY(10),
|
calendarcolor VARBINARY(10),
|
||||||
timezone TEXT,
|
timezone TEXT,
|
||||||
components VARBINARY(21),
|
|
||||||
transparent TINYINT(1) NOT NULL DEFAULT '0',
|
transparent TINYINT(1) NOT NULL DEFAULT '0',
|
||||||
UNIQUE(principaluri, uri)
|
share_href VARBINARY(100),
|
||||||
|
share_displayname VARCHAR(100),
|
||||||
|
share_invitestatus TINYINT(1) NOT NULL DEFAULT '2',
|
||||||
|
UNIQUE(principaluri, uri),
|
||||||
|
UNIQUE(calendarid, principaluri),
|
||||||
|
UNIQUE(calendarid, share_href)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
CREATE TABLE calendarchanges (
|
CREATE TABLE calendarchanges (
|
||||||
|
|
|
@ -42,16 +42,28 @@ CREATE TABLE calendarobjects (
|
||||||
|
|
||||||
CREATE TABLE calendars (
|
CREATE TABLE calendars (
|
||||||
id integer primary key asc NOT NULL,
|
id integer primary key asc NOT NULL,
|
||||||
principaluri text NOT NULL,
|
synctoken integer DEFAULT 1 NOT NULL,
|
||||||
|
components text NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE calendarinstances (
|
||||||
|
id integer primary key asc NOT NULL,
|
||||||
|
calendarid integer,
|
||||||
|
principaluri text,
|
||||||
|
access integer,
|
||||||
displayname text,
|
displayname text,
|
||||||
uri text NOT NULL,
|
uri text NOT NULL,
|
||||||
synctoken integer DEFAULT 1 NOT NULL,
|
|
||||||
description text,
|
description text,
|
||||||
calendarorder integer,
|
calendarorder integer,
|
||||||
calendarcolor text,
|
calendarcolor text,
|
||||||
timezone text,
|
timezone text,
|
||||||
components text NOT NULL,
|
transparent bool,
|
||||||
transparent bool
|
share_href text,
|
||||||
|
share_displayname text,
|
||||||
|
share_invitestatus integer DEFAULT '2',
|
||||||
|
UNIQUE (principaluri, uri),
|
||||||
|
UNIQUE (calendarid, principaluri),
|
||||||
|
UNIQUE (calendarid, share_href)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE calendarchanges (
|
CREATE TABLE calendarchanges (
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php" : ">=5.5",
|
"php" : ">=5.5",
|
||||||
"sabre/dav" : "~3.1.2",
|
"sabre/dav" : "~3.2.3",
|
||||||
"twig/twig" : "~1.8.0"
|
"twig/twig" : "~1.8.0"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
|
|
Loading…
Reference in a new issue