Database Upgrade routine, and some bugfixes
parent
5b83872773
commit
9c757b18ab
|
@ -6,12 +6,14 @@ It's still in a very early stage, so expect major bugs. Please feel free to repo
|
||||||
At the moment, the calendar system supports the following features:
|
At the moment, the calendar system supports the following features:
|
||||||
- A web-based drag&drop interface for managing events
|
- A web-based drag&drop interface for managing events
|
||||||
- All-Day-Events, Multi-Day-Events, and time-based events
|
- All-Day-Events, Multi-Day-Events, and time-based events
|
||||||
|
- Giving the subject, a description, a location and a color for the event (the color is not available through CalDAV, though)
|
||||||
- Recurrences (not the whole set of options given in the iCalendar spec, but the most important ones)
|
- Recurrences (not the whole set of options given in the iCalendar spec, but the most important ones)
|
||||||
|
- Notification by e-mail. Multiple notifications can be set per event
|
||||||
- Multiple calendars per user
|
- Multiple calendars per user
|
||||||
- Access to the events using CalDAV (using iPhone, Thunderbird Lightning etc., see below)
|
- Access to the events using CalDAV (using iPhone, Thunderbird Lightning etc., see below)
|
||||||
- Read-only access to the friendica-native events (also using CalDAV)
|
- Read-only access to the friendica-native events (also using CalDAV)
|
||||||
- The friendica-contacts are made available using CardDAV (confirmed to work with iOS)
|
- The friendica-contacts are made available using CardDAV (confirmed to work with iOS)
|
||||||
- Giving the subject, a description, a location and a color for the event (the color is not available through CalDAV, though)
|
- The events of a calendar can be exported as ICS file. ICS files can be imported into a calendar
|
||||||
|
|
||||||
|
|
||||||
Internationalization:
|
Internationalization:
|
||||||
|
@ -33,7 +35,6 @@ In case of errors, the SQL-statement to create the tables manually are shown in
|
||||||
Functuality missing: (a.k.a. "Roadmap")
|
Functuality missing: (a.k.a. "Roadmap")
|
||||||
- Sharing events; all events are private at the moment, therefore this system is not a complete replacement for the friendica-native events
|
- Sharing events; all events are private at the moment, therefore this system is not a complete replacement for the friendica-native events
|
||||||
- Attendees / Collaboration
|
- Attendees / Collaboration
|
||||||
- ICS Export and Import
|
|
||||||
|
|
||||||
|
|
||||||
Used libraries
|
Used libraries
|
||||||
|
|
|
@ -21,8 +21,6 @@ $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"] = array(CALDAV_FRIENDICA_MINE, CALDA
|
||||||
define("CARDDAV_NAMESPACE_COMMUNITYCONTACTS", 1);
|
define("CARDDAV_NAMESPACE_COMMUNITYCONTACTS", 1);
|
||||||
define("CARDDAV_NAMESPACE_PHONECONTACTS", 2);
|
define("CARDDAV_NAMESPACE_PHONECONTACTS", 2);
|
||||||
|
|
||||||
define("CALDAV_DB_VERSION", 2);
|
|
||||||
|
|
||||||
define("CALDAV_MAX_YEAR", date("Y") + 5);
|
define("CALDAV_MAX_YEAR", date("Y") + 5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +105,11 @@ function dav_compat_principal2namespace($principalUri = "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dav_compat_currentUserPrincipal() {
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function dav_compat_currentUserPrincipal()
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
return "principals/users/" . strtolower($a->user["nickname"]);
|
return "principals/users/" . strtolower($a->user["nickname"]);
|
||||||
}
|
}
|
||||||
|
@ -172,12 +174,36 @@ function wdcal_calendar_factory($namespace, $namespace_id, $uri, $calendar = nul
|
||||||
* @return Sabre_CalDAV_Backend_Common
|
* @return Sabre_CalDAV_Backend_Common
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function wdcal_calendar_factory_by_id($calendar_id) {
|
function wdcal_calendar_factory_by_id($calendar_id)
|
||||||
|
{
|
||||||
$calendar = Sabre_CalDAV_Backend_Common::loadCalendarById($calendar_id);
|
$calendar = Sabre_CalDAV_Backend_Common::loadCalendarById($calendar_id);
|
||||||
return wdcal_calendar_factory($calendar["namespace"], $calendar["namespace_id"], $calendar["uri"], $calendar);
|
return wdcal_calendar_factory($calendar["namespace"], $calendar["namespace_id"], $calendar["uri"], $calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $user_id
|
||||||
|
* @param bool $withcheck
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function wdcal_create_std_calendars_get_statements($user_id, $withcheck = true)
|
||||||
|
{
|
||||||
|
$stms = array();
|
||||||
|
$a = get_app();
|
||||||
|
$uris = array(
|
||||||
|
'private' => t("Private Calendar"),
|
||||||
|
CALDAV_FRIENDICA_MINE => t("Friendica Events: Mine"),
|
||||||
|
CALDAV_FRIENDICA_CONTACTS => t("Friendica Events: Contacts"),
|
||||||
|
);
|
||||||
|
foreach ($uris as $uri => $name) {
|
||||||
|
$cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'",
|
||||||
|
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri));
|
||||||
|
if (count($cals) == 0 || !$withcheck) $stms[] =
|
||||||
|
sprintf("INSERT INTO %s%scalendars (`namespace`, `namespace_id`, `displayname`, `timezone`, `ctag`, `uri`, `has_vevent`, `has_vtodo`)
|
||||||
|
VALUES (%d, %d, '%s', '%s', 1, '%s', 1, 0)",
|
||||||
|
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($name), dbesc($a->timezone), dbesc($uri));
|
||||||
|
}
|
||||||
|
return $stms;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -189,19 +215,6 @@ function wdcal_create_std_calendars()
|
||||||
$privates = q("SELECT COUNT(*) num FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
|
$privates = q("SELECT COUNT(*) num FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
|
||||||
if ($privates[0]["num"] > 0) return;
|
if ($privates[0]["num"] > 0) return;
|
||||||
|
|
||||||
$uris = array(
|
$stms = wdcal_create_std_calendars_get_statements($a->user["uid"]);
|
||||||
'private' => t("Private Calendar"),
|
foreach ($stms as $stmt) q($stmt);
|
||||||
CALDAV_FRIENDICA_MINE => t("Friendica Events: Mine"),
|
|
||||||
CALDAV_FRIENDICA_CONTACTS => t("Friendica Events: Contacts"),
|
|
||||||
);
|
|
||||||
foreach ($uris as $uri => $name) {
|
|
||||||
$cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'",
|
|
||||||
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, $a->user["uid"], dbesc($uri));
|
|
||||||
if (count($cals) == 0) {
|
|
||||||
q("INSERT INTO %s%scalendars (`namespace`, `namespace_id`, `displayname`, `timezone`, `ctag`, `uri`, `has_vevent`, `has_vtodo`) VALUES (%d, %d, '%s', '%s', 1, '%s', 1, 0)",
|
|
||||||
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]), dbesc($name), dbesc($a->timezone), dbesc($uri)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ define("DAV_DISPLAYNAME", "{DAV:}displayname");
|
||||||
define("DAV_CALENDARCOLOR", "{http://apple.com/ns/ical/}calendar-color");
|
define("DAV_CALENDARCOLOR", "{http://apple.com/ns/ical/}calendar-color");
|
||||||
|
|
||||||
|
|
||||||
|
class DAVVersionMismatchException extends Exception {}
|
||||||
|
|
||||||
|
|
||||||
class vcard_source_data_email
|
class vcard_source_data_email
|
||||||
{
|
{
|
||||||
|
@ -357,8 +359,8 @@ function dav_create_empty_vevent($uid = "")
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Sabre_VObject_Component_VCalendar $vObject
|
* @param Sabre_VObject_Component_VEvent $vObject
|
||||||
* @return Sabre_VObject_Component_VEvent|null
|
* @return Sabre_VObject_Component|null
|
||||||
*/
|
*/
|
||||||
function dav_get_eventComponent(&$vObject)
|
function dav_get_eventComponent(&$vObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,6 +152,7 @@ class Sabre_CalDAV_Backend_Private extends Sabre_CalDAV_Backend_Common
|
||||||
* common one is '{DAV:}displayname'.
|
* common one is '{DAV:}displayname'.
|
||||||
*
|
*
|
||||||
* @param string $principalUri
|
* @param string $principalUri
|
||||||
|
* @throws DAVVersionMismatchException
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCalendarsForUser($principalUri)
|
public function getCalendarsForUser($principalUri)
|
||||||
|
@ -162,6 +163,7 @@ class Sabre_CalDAV_Backend_Private extends Sabre_CalDAV_Backend_Common
|
||||||
$cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), IntVal($n["namespace_id"]));
|
$cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), IntVal($n["namespace_id"]));
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($cals as $cal) {
|
foreach ($cals as $cal) {
|
||||||
|
if (!isset($cal["uri"])) throw new DAVVersionMismatchException();
|
||||||
if (in_array($cal["uri"], $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"])) continue;
|
if (in_array($cal["uri"], $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"])) continue;
|
||||||
|
|
||||||
$dat = array(
|
$dat = array(
|
||||||
|
|
|
@ -9,103 +9,71 @@ function dav_get_update_statements($from_version)
|
||||||
{
|
{
|
||||||
$stms = array();
|
$stms = array();
|
||||||
|
|
||||||
if ($from_version <= 0) {
|
if ($from_version == 1) {
|
||||||
$stms[] = "ALTER TABLE `dav_calendars` ADD `uri` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `description` , ADD `has_vevent` TINYINT NOT NULL DEFAULT '1' AFTER `uri` , ADD `has_vtodo` TINYINT NOT NULL DEFAULT '1' AFTER `has_vevent`";
|
$stms[] = "ALTER TABLE `dav_calendarobjects`
|
||||||
|
ADD `calendar_id` INT NOT NULL AFTER `namespace_id` ,
|
||||||
|
ADD `user_temp` INT NOT NULL AFTER `calendar_id` ";
|
||||||
|
$stms[] = "ALTER TABLE `dav_calendarobjects`
|
||||||
|
ADD `componentType` ENUM( 'VEVENT', 'VTODO' ) NOT NULL DEFAULT 'VEVENT' AFTER `lastmodified` ,
|
||||||
|
ADD `firstOccurence` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `componentType` ,
|
||||||
|
ADD `lastOccurence` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `firstOccurence`";
|
||||||
|
$stms[] = "UPDATE dav_calendarobjects a JOIN dav_calendars b ON a.namespace = b.namespace AND a.namespace_id = b.namespace_id SET a.user_temp = b.uid";
|
||||||
|
$stms[] = "DROP TABLE IF EXISTS
|
||||||
|
`dav_addressbooks_community` ,
|
||||||
|
`dav_addressbooks_phone` ,
|
||||||
|
`dav_cache_synchronized` ,
|
||||||
|
`dav_caldav_log` ,
|
||||||
|
`dav_calendars` ,
|
||||||
|
`dav_cal_virtual_object_cache` ,
|
||||||
|
`dav_cards` ,
|
||||||
|
`dav_jqcalendar` ,
|
||||||
|
`dav_locks` ,
|
||||||
|
`dav_notifications` ;";
|
||||||
|
|
||||||
$stms[] = "UPDATE `dav_calendars` SET `uri` = 'private' WHERE `namespace` = 1";
|
$stms = array_merge($stms, dav_get_create_statements(array("dav_calendarobjects")));
|
||||||
$stms[] = "UPDATE `dav_calendars` SET `uri` = 'friendica-mine' WHERE `namespace` = 2 AND `namespace_id` = 1";
|
|
||||||
$stms[] = "UPDATE `dav_calendars` SET `uri` = 'friendica-contacts' WHERE `namespace` = 2 AND `namespace_id` = 2";
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendars` DROP PRIMARY KEY ";
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendars` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ";
|
|
||||||
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendarobjects` ADD `calendar_id` INT NOT NULL AFTER `id` ";
|
$user_ids = q("SELECT DISTINCT `uid` FROM %s%scalendars", CALDAV_SQL_DB, CALDAV_SQL_PREFIX);
|
||||||
$stms[] = "UPDATE `dav_calendarobjects` a JOIN `dav_calendars` b ON a.`namespace` = b.`namespace` AND a.`namespace_id` = b.`namespace_id` SET a.`calendar_id` = b.`id`";
|
foreach ($user_ids as $user) $stms = array_merge($stms, wdcal_create_std_calendars_get_statements($user["uid"], false));
|
||||||
$stms[] = "ALTER TABLE `dav_calendarobjects` DROP `namespace` , DROP `namespace_id` ;";
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendarobjects` ADD INDEX ( `calendar_id` ) ";
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendarobjects` ADD `componentType` ENUM( 'VEVENT', 'VTODO' ) NOT NULL DEFAULT 'VEVENT' AFTER `calendardata` ,
|
|
||||||
ADD `firstOccurence` TIMESTAMP NOT NULL AFTER `lastmodified` ,
|
|
||||||
ADD `lastOccurence` TIMESTAMP NOT NULL AFTER `firstOccurence`";
|
|
||||||
|
|
||||||
$stms[] = "DROP TABLE `dav_jqcalendar`";
|
$stms[] = "UPDATE dav_calendarobjects a JOIN dav_calendars b
|
||||||
$stms[] = "CREATE TABLE IF NOT EXISTS `dav_jqcalendar` (
|
ON b.`namespace` = " . CALDAV_NAMESPACE_PRIVATE . " AND a.`user_temp` = b.`namespace_id` AND b.`uri` = 'private'
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
SET a.`calendar_id` = b.`id`";
|
||||||
`ical_recurr_uri` varchar(100) DEFAULT NULL,
|
|
||||||
`calendar_id` int(10) unsigned NOT NULL,
|
|
||||||
`calendarobject_id` int(10) unsigned NOT NULL,
|
|
||||||
`Subject` varchar(1000) NOT NULL,
|
|
||||||
`StartTime` timestamp NULL DEFAULT NULL,
|
|
||||||
`EndTime` timestamp NULL DEFAULT NULL,
|
|
||||||
`IsEditable` tinyint(3) unsigned NOT NULL,
|
|
||||||
`IsAllDayEvent` tinyint(4) NOT NULL,
|
|
||||||
`IsRecurring` tinyint(4) NOT NULL,
|
|
||||||
`Color` CHAR(6) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `calendarByStart` (`calendar_id`,`StartTime`),
|
|
||||||
KEY `calendarobject_id` (`calendarobject_id`,`ical_recurr_uri`)
|
|
||||||
) DEFAULT CHARSET=utf8 ";
|
|
||||||
|
|
||||||
|
$stms[] = "ALTER TABLE `dav_calendarobjects` DROP `namespace`, DROP `namespace_id`, DROP `user_temp`";
|
||||||
|
|
||||||
$stms[] = "ALTER TABLE `dav_notifications` ADD `calendar_id` INT NOT NULL AFTER `ical_recurr_uri` ";
|
|
||||||
$stms[] = "ALTER TABLE `dav_notifications` DROP INDEX `ical_uri` , ADD INDEX `ical_uri` ( `calendar_id` , `ical_uri` , `ical_recurr_uri` ) ";
|
|
||||||
$stms[] = "TRUNCATE TABLE `dav_notifications`";
|
|
||||||
$stms[] = "ALTER TABLE `dav_notifications` DROP `namespace` , DROP `namespace_id`";
|
|
||||||
|
|
||||||
$stms[] = "TRUNCATE TABLE `dav_cal_virtual_object_cache`";
|
|
||||||
$stme[] = "ALTER TABLE `dav_cal_virtual_object_cache` ADD `calendar_id` INT UNSIGNED NOT NULL AFTER `id` ";
|
|
||||||
$stms[] = "ALTER TABLE `dav_cal_virtual_object_cache` DROP INDEX `ref_type` , ADD INDEX `ref_type` ( `calendar_id` , `data_end` ) ";
|
|
||||||
$stms[] = "ALTER TABLE `dav_cal_virtual_object_cache` DROP `uid`, DROP `namespace` , DROP `namespace_id` ";
|
|
||||||
|
|
||||||
$stms[] = "CREATE TABLE `friendica`.`dav_cal_virtual_object_sync` (
|
|
||||||
`calendar_id` INT UNSIGNED NOT NULL ,
|
|
||||||
`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
|
|
||||||
PRIMARY KEY ( `calendar_id` )
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
|
||||||
|
|
||||||
$stms[] = "DROP TABLE `dav_cache_synchronized` ";
|
|
||||||
|
|
||||||
$stms[] = "UPDATE `dav_calendars` SET `namespace` = 1, `namespace_id` = `uid`"; // last
|
|
||||||
$stms[] = "ALTER TABLE `dav_calendars` DROP `uid`";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stms;
|
return $stms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param array $except
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function dav_get_create_statements()
|
function dav_get_create_statements($except = array())
|
||||||
{
|
{
|
||||||
$arr = array();
|
$arr = array();
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_community` (
|
if (!in_array("dav_addressbooks_community", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_community` (
|
||||||
`uid` int(11) NOT NULL,
|
`uid` int(11) NOT NULL,
|
||||||
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY (`uid`)
|
PRIMARY KEY (`uid`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_phone` (
|
if (!in_array("dav_addressbooks_phone", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_phone` (
|
||||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`uid` int(11) NOT NULL,
|
`uid` int(11) NOT NULL,
|
||||||
`principaluri` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`principaluri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
`displayname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`displayname` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
`uri` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
`description` text COLLATE utf8_unicode_ci,
|
`description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
|
||||||
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `principaluri` (`principaluri`,`uri`)
|
UNIQUE KEY `principaluri` (`principaluri`,`uri`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_cache_synchronized` (
|
if (!in_array("dav_caldav_log", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_caldav_log` (
|
||||||
`uid` mediumint(8) unsigned NOT NULL,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`namespace` smallint(6) NOT NULL,
|
|
||||||
`namespace_id` int(11) NOT NULL,
|
|
||||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`uid`,`namespace`,`namespace_id`),
|
|
||||||
KEY `namespace` (`namespace`,`namespace_id`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_caldav_log` (
|
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`uid` mediumint(9) NOT NULL,
|
`uid` mediumint(9) NOT NULL,
|
||||||
`ip` varchar(15) NOT NULL,
|
`ip` varchar(15) NOT NULL,
|
||||||
`user_agent` varchar(100) NOT NULL,
|
`user_agent` varchar(100) NOT NULL,
|
||||||
|
@ -116,127 +84,111 @@ function dav_get_create_statements()
|
||||||
KEY `mitglied` (`uid`)
|
KEY `mitglied` (`uid`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendarobjects` (
|
if (!in_array("dav_calendarobjects", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendarobjects` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`namespace` mediumint(9) NOT NULL,
|
`calendar_id` int(11) NOT NULL,
|
||||||
`namespace_id` int(10) unsigned NOT NULL,
|
|
||||||
`calendardata` text,
|
`calendardata` text,
|
||||||
`uri` varchar(200) NOT NULL,
|
`uri` varchar(200) NOT NULL,
|
||||||
`lastmodified` timestamp NULL DEFAULT NULL,
|
`lastmodified` timestamp NULL DEFAULT NULL,
|
||||||
|
`componentType` enum('VEVENT','VTODO') NOT NULL DEFAULT 'VEVENT',
|
||||||
|
`firstOccurence` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`lastOccurence` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`etag` varchar(15) NOT NULL,
|
`etag` varchar(15) NOT NULL,
|
||||||
`size` int(10) unsigned NOT NULL,
|
`size` int(10) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uri` (`uri`,`namespace`,`namespace_id`),
|
UNIQUE KEY `uri` (`uri`),
|
||||||
KEY `namespace` (`namespace`,`namespace_id`)
|
KEY `calendar_id` (`calendar_id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendars` (
|
if (!in_array("dav_calendars", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendars` (
|
||||||
`namespace` mediumint(9) NOT NULL,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`namespace` mediumint(9) NOT NULL,
|
||||||
`namespace_id` int(10) unsigned NOT NULL,
|
`namespace_id` int(10) unsigned NOT NULL,
|
||||||
`uid` mediumint(8) unsigned NOT NULL,
|
|
||||||
`calendarorder` int(11) NOT NULL DEFAULT '1',
|
`calendarorder` int(11) NOT NULL DEFAULT '1',
|
||||||
`calendarcolor` varchar(20) NOT NULL DEFAULT '#5858FF',
|
`calendarcolor` char(6) NOT NULL DEFAULT '5858FF',
|
||||||
`displayname` varchar(200) NOT NULL,
|
`displayname` varchar(200) NOT NULL,
|
||||||
`timezone` text NOT NULL,
|
`timezone` text NOT NULL,
|
||||||
`description` varchar(500) NOT NULL,
|
`description` varchar(500) NOT NULL,
|
||||||
`uri` varchar(50) DEFAULT NULL,
|
`uri` varchar(50) NOT NULL DEFAULT '',
|
||||||
`has_vevent` tinyint(4) NOT NULL DEFAULT '1',
|
`has_vevent` tinyint(4) NOT NULL DEFAULT '1',
|
||||||
`has_vtodo` tinyint(4) NOT NULL DEFAULT '1',
|
`has_vtodo` tinyint(4) NOT NULL DEFAULT '1',
|
||||||
`ctag` int(10) unsigned NOT NULL,
|
`ctag` int(10) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`namespace`,`namespace_id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `uid` (`uid`)
|
UNIQUE KEY (`namespace` , `namespace_id` , `uri`),
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
KEY `uri` (`uri`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_cal_virtual_object_cache` (
|
if (!in_array("dav_cal_virtual_object_cache", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cal_virtual_object_cache` (
|
||||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`uid` mediumint(8) unsigned NOT NULL,
|
`calendar_id` int(10) unsigned NOT NULL,
|
||||||
`namespace` mediumint(9) NOT NULL,
|
|
||||||
`namespace_id` int(11) NOT NULL DEFAULT '0',
|
|
||||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`data_uri` char(80) NOT NULL,
|
`data_uri` char(80) NOT NULL,
|
||||||
`data_subject` varchar(1000) NOT NULL,
|
`data_summary` varchar(1000) NOT NULL,
|
||||||
`data_location` varchar(1000) NOT NULL,
|
`data_location` varchar(1000) NOT NULL,
|
||||||
`data_description` text NOT NULL,
|
|
||||||
`data_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`data_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`data_end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`data_end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`data_allday` tinyint(4) NOT NULL,
|
`data_allday` tinyint(4) NOT NULL,
|
||||||
`data_type` varchar(20) NOT NULL,
|
`data_type` varchar(20) NOT NULL,
|
||||||
`ical` text NOT NULL,
|
`calendardata` text NOT NULL,
|
||||||
`ical_size` int(11) NOT NULL,
|
`size` int(11) NOT NULL,
|
||||||
`ical_etag` varchar(15) NOT NULL,
|
`etag` varchar(15) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `ref_type` (`namespace`,`namespace_id`),
|
KEY `data_uri` (`data_uri`),
|
||||||
KEY `mitglied` (`uid`,`data_end`),
|
KEY `ref_type` (`calendar_id`,`data_end`)
|
||||||
KEY `data_uri` (`data_uri`)
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_cards` (
|
if (!in_array("dav_cal_virtual_object_sync", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cal_virtual_object_sync` (
|
||||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
`calendar_id` int(10) unsigned NOT NULL,
|
||||||
|
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`calendar_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
|
if (!in_array("dav_cards", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cards` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`namespace` tinyint(3) unsigned NOT NULL,
|
`namespace` tinyint(3) unsigned NOT NULL,
|
||||||
`namespace_id` int(11) unsigned NOT NULL,
|
`namespace_id` int(11) unsigned NOT NULL,
|
||||||
`contact` int(11) DEFAULT NULL,
|
`contact` int(11) DEFAULT NULL,
|
||||||
`carddata` mediumtext COLLATE utf8_unicode_ci,
|
`carddata` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci,
|
||||||
`uri` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
`uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
`lastmodified` int(11) unsigned DEFAULT NULL,
|
`lastmodified` int(11) unsigned DEFAULT NULL,
|
||||||
`manually_edited` tinyint(4) NOT NULL DEFAULT '0',
|
`manually_edited` tinyint(4) NOT NULL DEFAULT '0',
|
||||||
`manually_deleted` tinyint(4) NOT NULL DEFAULT '0',
|
`manually_deleted` tinyint(4) NOT NULL DEFAULT '0',
|
||||||
`etag` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
|
`etag` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`size` int(10) unsigned NOT NULL,
|
`size` int(10) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `namespace` (`namespace`,`namespace_id`,`contact`),
|
UNIQUE KEY `namespace` (`namespace`,`namespace_id`,`contact`),
|
||||||
KEY `contact` (`contact`)
|
KEY `contact` (`contact`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_jqcalendar` (
|
if (!in_array("dav_jqcalendar", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_jqcalendar` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`uid` int(10) unsigned NOT NULL,
|
`ical_recurr_uri` varchar(100) DEFAULT NULL,
|
||||||
`ical_uri` varchar(200) NOT NULL,
|
`calendar_id` int(10) unsigned NOT NULL,
|
||||||
`ical_recurr_uri` varchar(100) NOT NULL,
|
`calendarobject_id` int(10) unsigned NOT NULL,
|
||||||
`namespace` mediumint(9) NOT NULL,
|
`Summary` varchar(100) NOT NULL,
|
||||||
`namespace_id` int(11) NOT NULL,
|
|
||||||
`permission_edit` tinyint(4) NOT NULL DEFAULT '1',
|
|
||||||
`Subject` varchar(1000) DEFAULT NULL,
|
|
||||||
`Location` varchar(1000) DEFAULT NULL,
|
|
||||||
`Description` text,
|
|
||||||
`StartTime` timestamp NULL DEFAULT NULL,
|
`StartTime` timestamp NULL DEFAULT NULL,
|
||||||
`EndTime` timestamp NULL DEFAULT NULL,
|
`EndTime` timestamp NULL DEFAULT NULL,
|
||||||
`IsAllDayEvent` smallint(6) NOT NULL,
|
`IsEditable` tinyint(3) unsigned NOT NULL,
|
||||||
`Color` varchar(20) DEFAULT NULL,
|
`IsAllDayEvent` tinyint(4) NOT NULL,
|
||||||
`RecurringRule` varchar(500) DEFAULT NULL,
|
`IsRecurring` tinyint(4) NOT NULL,
|
||||||
|
`Color` char(6) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `user` (`uid`,`StartTime`),
|
KEY `calendarByStart` (`calendar_id`,`StartTime`),
|
||||||
KEY `zuord_typ` (`namespace`,`namespace_id`),
|
KEY `calendarobject_id` (`calendarobject_id`,`ical_recurr_uri`)
|
||||||
KEY `ical_uri` (`ical_uri`,`ical_recurr_uri`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_locks` (
|
if (!in_array("dav_notifications", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_notifications` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`owner` varchar(100) DEFAULT NULL,
|
`ical_recurr_uri` varchar(100) DEFAULT NULL,
|
||||||
`timeout` int(10) unsigned DEFAULT NULL,
|
`calendar_id` int(11) NOT NULL,
|
||||||
`created` int(11) DEFAULT NULL,
|
`calendarobject_id` int(10) unsigned NOT NULL,
|
||||||
`token` varchar(100) DEFAULT NULL,
|
`action` enum('email','display') NOT NULL DEFAULT 'email',
|
||||||
`scope` tinyint(4) DEFAULT NULL,
|
|
||||||
`depth` tinyint(4) DEFAULT NULL,
|
|
||||||
`uri` text,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
|
||||||
|
|
||||||
|
|
||||||
$arr[] = "CREATE TABLE IF NOT EXISTS `dav_notifications` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`uid` int(10) unsigned NOT NULL,
|
|
||||||
`ical_uri` varchar(200) NOT NULL,
|
|
||||||
`ical_recurr_uri` varchar(100) NOT NULL,
|
|
||||||
`namespace` mediumint(8) unsigned NOT NULL,
|
|
||||||
`namespace_id` int(10) unsigned NOT NULL,
|
|
||||||
`alert_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`alert_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`rel_type` enum('second','minute','hour','day','week','month','year') NOT NULL,
|
|
||||||
`rel_value` mediumint(9) NOT NULL,
|
|
||||||
`notified` tinyint(4) NOT NULL DEFAULT '0',
|
`notified` tinyint(4) NOT NULL DEFAULT '0',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `notified` (`notified`,`alert_date`),
|
KEY `notified` (`notified`,`alert_date`),
|
||||||
KEY `ical_uri` (`uid`,`ical_uri`,`ical_recurr_uri`)
|
KEY `calendar_id` (`calendar_id`,`calendarobject_id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
||||||
|
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
@ -246,10 +198,11 @@ function dav_get_create_statements()
|
||||||
*/
|
*/
|
||||||
function dav_check_tables()
|
function dav_check_tables()
|
||||||
{
|
{
|
||||||
$dbv = get_config("dav", "db_version");
|
$x = q("DESCRIBE %s%scalendars", CALDAV_SQL_DB, CALDAV_SQL_PREFIX);
|
||||||
if ($dbv == CALDAV_DB_VERSION) return 0; // Correct
|
if (!$x) return -1;
|
||||||
if (is_numeric($dbv) || $dbv == "CALDAV_DB_VERSION") return 1; // Older version (update needed)
|
if (count($x) == 9) return 1; // Version 0.1
|
||||||
return -1; // Not installed
|
if (count($x) == 12) return 0; // Correct
|
||||||
|
return -2; // Unknown version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,8 +220,6 @@ function dav_create_tables()
|
||||||
if ($db->error) $errors[] = $db->error;
|
if ($db->error) $errors[] = $db->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($errors) == 0) set_config("dav", "db_version", CALDAV_DB_VERSION);
|
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,9 +228,9 @@ function dav_create_tables()
|
||||||
*/
|
*/
|
||||||
function dav_upgrade_tables()
|
function dav_upgrade_tables()
|
||||||
{
|
{
|
||||||
$dbv = get_config("dav", "db_version");
|
$ver = dav_check_tables();
|
||||||
if ($dbv == "CALDAV_DB_VERSION") $ver = 0;
|
if (!in_array($ver, array(1) )) return array("Unknown error");
|
||||||
else $ver = IntVal($dbv);
|
|
||||||
$stms = dav_get_update_statements($ver);
|
$stms = dav_get_update_statements($ver);
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
|
@ -289,7 +240,5 @@ function dav_upgrade_tables()
|
||||||
if ($db->error) $errors[] = $db->error;
|
if ($db->error) $errors[] = $db->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($errors) == 0) set_config("dav", "db_version", CALDAV_DB_VERSION);
|
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
|
@ -133,7 +133,7 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual
|
||||||
"is_allday" => ($allday ? 1 : 0),
|
"is_allday" => ($allday ? 1 : 0),
|
||||||
"is_moredays" => (substr($start, 0, 10) != substr($finish, 0, 10)),
|
"is_moredays" => (substr($start, 0, 10) != substr($finish, 0, 10)),
|
||||||
"is_recurring" => ($row["type"] == "birthday"),
|
"is_recurring" => ($row["type"] == "birthday"),
|
||||||
"color" => "#f8f8ff",
|
"color" => "7878ff",
|
||||||
"is_editable" => 0,
|
"is_editable" => 0,
|
||||||
"is_editable_quick" => 0,
|
"is_editable_quick" => 0,
|
||||||
"location" => $row["location"],
|
"location" => $row["location"],
|
||||||
|
|
140
dav/main.php
140
dav/main.php
|
@ -118,52 +118,55 @@ function dav_content()
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = "";
|
$x = "";
|
||||||
|
try {
|
||||||
if ($a->argv[1] == "settings") {
|
if ($a->argv[1] == "settings") {
|
||||||
return wdcal_getSettingsPage($a);
|
return wdcal_getSettingsPage($a);
|
||||||
} elseif ($a->argv[1] == "wdcal") {
|
} elseif ($a->argv[1] == "wdcal") {
|
||||||
if (isset($a->argv[2]) && strlen($a->argv[2]) > 0) {
|
if (isset($a->argv[2]) && strlen($a->argv[2]) > 0) {
|
||||||
if ($a->argv[2] == "new") {
|
if ($a->argv[2] == "new") {
|
||||||
$o = "";
|
$o = "";
|
||||||
if (isset($_REQUEST["save"])) {
|
if (isset($_REQUEST["save"])) {
|
||||||
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
||||||
$ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
$ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
||||||
if ($ret["ok"]) notice($ret["msg"]);
|
if ($ret["ok"]) notice($ret["msg"]);
|
||||||
else info($ret["msg"]);
|
else info($ret["msg"]);
|
||||||
goaway($a->get_baseurl() . "/dav/wdcal/");
|
goaway($a->get_baseurl() . "/dav/wdcal/");
|
||||||
}
|
|
||||||
$o .= wdcal_getNewPage();
|
|
||||||
return $o;
|
|
||||||
} else {
|
|
||||||
$calendar_id = IntVal($a->argv[2]);
|
|
||||||
if (isset($a->argv[3]) && $a->argv[3] == "ics-export") {
|
|
||||||
wdcal_print_user_ics($calendar_id);
|
|
||||||
} elseif (isset($a->argv[3]) && $a->argv[3] == "ics-import") {
|
|
||||||
return wdcal_import_user_ics($calendar_id);
|
|
||||||
} elseif (isset($a->argv[3]) && $a->argv[3] > 0) {
|
|
||||||
if (isset($a->argv[4]) && $a->argv[4] == "edit") {
|
|
||||||
$o = "";
|
|
||||||
if (isset($_REQUEST["save"])) {
|
|
||||||
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
|
||||||
$ret = wdcal_postEditPage($a->argv[3], $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
|
||||||
if ($ret["ok"]) notice($ret["msg"]);
|
|
||||||
else info($ret["msg"]);
|
|
||||||
goaway($a->get_baseurl() . "/dav/wdcal/");
|
|
||||||
}
|
|
||||||
$o .= wdcal_getEditPage($calendar_id, $a->argv[3]);
|
|
||||||
return $o;
|
|
||||||
} else {
|
|
||||||
return wdcal_getDetailPage($calendar_id, $a->argv[3]);
|
|
||||||
}
|
}
|
||||||
|
$o .= wdcal_getNewPage();
|
||||||
|
return $o;
|
||||||
} else {
|
} else {
|
||||||
// @TODO Edit Calendar
|
$calendar_id = IntVal($a->argv[2]);
|
||||||
|
if (isset($a->argv[3]) && $a->argv[3] == "ics-export") {
|
||||||
|
wdcal_print_user_ics($calendar_id);
|
||||||
|
} elseif (isset($a->argv[3]) && $a->argv[3] == "ics-import") {
|
||||||
|
return wdcal_import_user_ics($calendar_id);
|
||||||
|
} elseif (isset($a->argv[3]) && $a->argv[3] > 0) {
|
||||||
|
if (isset($a->argv[4]) && $a->argv[4] == "edit") {
|
||||||
|
$o = "";
|
||||||
|
if (isset($_REQUEST["save"])) {
|
||||||
|
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
||||||
|
$ret = wdcal_postEditPage($a->argv[3], $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
||||||
|
if ($ret["ok"]) notice($ret["msg"]);
|
||||||
|
else info($ret["msg"]);
|
||||||
|
goaway($a->get_baseurl() . "/dav/wdcal/");
|
||||||
|
}
|
||||||
|
$o .= wdcal_getEditPage($calendar_id, $a->argv[3]);
|
||||||
|
return $o;
|
||||||
|
} else {
|
||||||
|
return wdcal_getDetailPage($calendar_id, $a->argv[3]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// @TODO Edit Calendar
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$server = dav_create_server(true, true, false);
|
||||||
|
$cals = dav_get_current_user_calendars($server, DAV_ACL_READ);
|
||||||
|
$x = wdcal_printCalendar($cals, array(), $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$server = dav_create_server(true, true, false);
|
|
||||||
$cals = dav_get_current_user_calendars($server, DAV_ACL_READ);
|
|
||||||
$x = wdcal_printCalendar($cals, array(), $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200);
|
|
||||||
}
|
}
|
||||||
|
} catch (DAVVersionMismatchException $e) {
|
||||||
|
$x = t("The current version of this plugin has not been set up correctly. Please contact the system administrator of your installation of friendica to fix this.");
|
||||||
}
|
}
|
||||||
return $x;
|
return $x;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +211,6 @@ function dav_profile_tabs_hook(&$a, &$b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param App $a
|
* @param App $a
|
||||||
* @param object $b
|
* @param object $b
|
||||||
|
@ -220,9 +222,9 @@ function dav_cron(&$a, &$b)
|
||||||
$r = q("SELECT * FROM %s%snotifications WHERE `notified` = 0 AND `alert_date` <= NOW()", CALDAV_SQL_DB, CALDAV_SQL_PREFIX);
|
$r = q("SELECT * FROM %s%snotifications WHERE `notified` = 0 AND `alert_date` <= NOW()", CALDAV_SQL_DB, CALDAV_SQL_PREFIX);
|
||||||
foreach ($r as $not) {
|
foreach ($r as $not) {
|
||||||
q("UPDATE %s%snotifications SET `notified` = 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $not["id"]);
|
q("UPDATE %s%snotifications SET `notified` = 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $not["id"]);
|
||||||
$event = q("SELECT * FROM %s%sjqcalendar WHERE `calendarobject_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $not["calendarobject_id"]);
|
$event = q("SELECT * FROM %s%sjqcalendar WHERE `calendarobject_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $not["calendarobject_id"]);
|
||||||
$calendar = q("SELECT * FROM %s%scalendars WHERE `id` = %d", CALDAV_SQL_DB,CALDAV_SQL_PREFIX, $not["calendar_id"]);
|
$calendar = q("SELECT * FROM %s%scalendars WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $not["calendar_id"]);
|
||||||
$users = array();
|
$users = array();
|
||||||
if (count($calendar) != 1 || count($event) == 0) continue;
|
if (count($calendar) != 1 || count($event) == 0) continue;
|
||||||
switch ($calendar[0]["namespace"]) {
|
switch ($calendar[0]["namespace"]) {
|
||||||
case CALDAV_NAMESPACE_PRIVATE:
|
case CALDAV_NAMESPACE_PRIVATE:
|
||||||
|
@ -232,20 +234,21 @@ function dav_cron(&$a, &$b)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch ($not["action"]) {
|
switch ($not["action"]) {
|
||||||
case "email": case "display": // @TODO implement "Display"
|
case "email":
|
||||||
|
case "display": // @TODO implement "Display"
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$find = array( "%to%" , "%event%", "%url%");
|
$find = array("%to%", "%event%", "%url%");
|
||||||
$repl = array($user["username"], $event[0]["Summary"], $a->get_baseurl() . "/dav/wdcal/" . $calendar[0]["id"] . "/" . $not["calendarobject_id"] . "/");
|
$repl = array($user["username"], $event[0]["Summary"], $a->get_baseurl() . "/dav/wdcal/" . $calendar[0]["id"] . "/" . $not["calendarobject_id"] . "/");
|
||||||
$text_text = str_replace($find, $repl, "Hi %to%!\n\nThe event \"%event%\" is about to begin:\n%url%");
|
$text_text = str_replace($find, $repl, "Hi %to%!\n\nThe event \"%event%\" is about to begin:\n%url%");
|
||||||
$text_html = str_replace($find, $repl, "Hi %to%!<br>\n<br>\nThe event \"%event%\" is about to begin:<br>\n<a href='" . "%url%" . "'>%url%</a>");
|
$text_html = str_replace($find, $repl, "Hi %to%!<br>\n<br>\nThe event \"%event%\" is about to begin:<br>\n<a href='" . "%url%" . "'>%url%</a>");
|
||||||
$params = array(
|
$params = array(
|
||||||
'fromName' => FRIENDICA_PLATFORM,
|
'fromName' => FRIENDICA_PLATFORM,
|
||||||
'fromEmail' => t('noreply') . '@' . $a->get_hostname(),
|
'fromEmail' => t('noreply') . '@' . $a->get_hostname(),
|
||||||
'replyTo' => t('noreply') . '@' . $a->get_hostname(),
|
'replyTo' => t('noreply') . '@' . $a->get_hostname(),
|
||||||
'toEmail' => $user["email"],
|
'toEmail' => $user["email"],
|
||||||
'messageSubject' => t("Notification: " . $event[0]["Summary"]),
|
'messageSubject' => t("Notification: " . $event[0]["Summary"]),
|
||||||
'htmlVersion' => $text_html,
|
'htmlVersion' => $text_html,
|
||||||
'textVersion' => $text_text,
|
'textVersion' => $text_text,
|
||||||
'additionalMailHeader' => "",
|
'additionalMailHeader' => "",
|
||||||
);
|
);
|
||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
|
@ -257,8 +260,6 @@ function dav_cron(&$a, &$b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param App $a
|
* @param App $a
|
||||||
* @param null|object $o
|
* @param null|object $o
|
||||||
|
@ -277,7 +278,10 @@ function dav_plugin_admin_post(&$a = null, &$o = null)
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST["upgrade"])) {
|
if (isset($_REQUEST["upgrade"])) {
|
||||||
$errs = dav_upgrade_tables();
|
$errs = dav_upgrade_tables();
|
||||||
if (count($errs) == 0) info(t('The database tables have been updated.') . EOL);
|
if (count($errs) == 0) {
|
||||||
|
renderAllCalDavEntries();
|
||||||
|
info(t('The database tables have been updated.') . EOL);
|
||||||
|
}
|
||||||
else notice(t("An error occurred during the update.") . EOL);
|
else notice(t("An error occurred during the update.") . EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,18 +307,30 @@ function dav_plugin_admin(&$a, &$o)
|
||||||
$o .= t('Installed');
|
$o .= t('Installed');
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$o .= t('Upgrade needed') . "<br><br><input type='submit' name='upgrade' value='" . t('Upgrade') . "'>";
|
$o .= "<strong>" . t('Upgrade needed') . "</strong><br>" . t("Please back up all calendar data (the tables beginning with dav_*) before proceeding. While all calendar events <i>should</i> be converted to the new database structure, it's always safe to have a backup. Below, you can have a look at the database-queries that will be made when pressing the 'update'-button.") . "<br><br><input type='submit' name='upgrade' value='" . t('Upgrade') . "'>";
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
$o .= t('Not installed') . "<br><br><input type='submit' name='install' value='" . t('Install') . "'>";
|
$o .= t('Not installed') . "<br><br><input type='submit' name='install' value='" . t('Install') . "'>";
|
||||||
break;
|
break;
|
||||||
|
case -2:
|
||||||
|
default:
|
||||||
|
$o .= t('Unknown') . "<br><br>" . t("Something really went wrong. I cannot recover from this state automatically, sorry. Please go to the database backend, back up the data, and delete all tables beginning with 'dav_' manually. Afterwards, this installation routine should be able to reinitialize the tables automatically.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$o .= "<br><br>";
|
$o .= "<br><br>";
|
||||||
|
|
||||||
$o .= "<h3>" . t("Troubleshooting") . "</h3>";
|
$o .= "<h3>" . t("Troubleshooting") . "</h3>";
|
||||||
$o .= "<h4>" . t("Manual creation of the database tables:") . "</h4>";
|
$o .= "<h4>" . t("Manual creation of the database tables:") . "</h4>";
|
||||||
$o .= "<a href='#' onClick='\$(\"#sqlstatements\").show(); return false;'>" . t("Show SQL-statements") . "</a><blockquote style='display: none;' id='sqlstatements'><pre>";
|
$o .= "<a href='#' onClick='\$(\"#sqlstatements\").show(); return false;'>" . t("Show SQL-statements") . "</a><blockquote style='display: none;' id='sqlstatements'><pre>";
|
||||||
$tables = dav_get_create_statements();
|
switch ($dbstatus) {
|
||||||
foreach ($tables as $t) $o .= escape_tags($t . "\n\n");
|
case 1:
|
||||||
|
$tables = dav_get_update_statements(1);
|
||||||
|
foreach ($tables as $t) $o .= escape_tags($t . ";\n\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$tables = dav_get_create_statements();
|
||||||
|
foreach ($tables as $t) $o .= escape_tags($t . ";\n\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
$o .= "</pre></blockquote>";
|
$o .= "</pre></blockquote>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue