2 commits - plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Nov 21 11:21:40 CET 2012
plugins/libkolab/LICENSE | 661 +++
plugins/libkolab/bin/Date_Recurrence_weekday.diff | 325 -
plugins/libkolab/bin/Date_last_weekday.diff | 37
plugins/libkolab/bin/get_horde_date.sh | 64
plugins/libkolab/lib/Horde_Date.php | 1304 -------
plugins/libkolab/lib/Horde_Date_Recurrence.php | 1673 ----------
plugins/libkolab/lib/Horde_Kolab_Format_XML_configuration.php | 76
plugins/libkolab/lib/kolab_format.php | 7
plugins/libkolab/lib/kolab_format_configuration.php | 13
plugins/libkolab/lib/kolab_format_contact.php | 91
plugins/libkolab/lib/kolab_format_distributionlist.php | 23
plugins/libkolab/lib/kolab_format_event.php | 135
plugins/libkolab/lib/kolab_format_file.php | 13
plugins/libkolab/lib/kolab_format_journal.php | 15
plugins/libkolab/lib/kolab_format_note.php | 14
plugins/libkolab/lib/kolab_format_task.php | 15
plugins/libkolab/libkolab.php | 11
plugins/libkolab/package.xml | 100
18 files changed, 761 insertions(+), 3816 deletions(-)
New commits:
commit 025a388ba5cb402b21a1c34e93dffb93cf393bb8
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Nov 21 11:21:19 2012 +0100
Finally remove the remaining Horde stuff after switching to libkolab for recurrence and format v2 support
diff --git a/plugins/libkolab/bin/Date_Recurrence_weekday.diff b/plugins/libkolab/bin/Date_Recurrence_weekday.diff
deleted file mode 100644
index e8b767d..0000000
--- a/plugins/libkolab/bin/Date_Recurrence_weekday.diff
+++ /dev/null
@@ -1,325 +0,0 @@
---- Date/Recurrence.php.orig 2012-07-10 19:54:48.000000000 +0200
-+++ Date/Recurrence.php 2012-07-10 19:55:38.000000000 +0200
-@@ -95,6 +95,20 @@
- public $recurData = null;
-
- /**
-+ * BYDAY recurrence number
-+ *
-+ * @var integer
-+ */
-+ public $recurNthDay = null;
-+
-+ /**
-+ * BYMONTH recurrence data
-+ *
-+ * @var array
-+ */
-+ public $recurMonths = array();
-+
-+ /**
- * All the exceptions from recurrence for this event.
- *
- * @var array
-@@ -157,6 +171,44 @@
- }
-
- /**
-+ *
-+ * @param integer $nthDay The nth weekday of month to repeat events on
-+ */
-+ public function setRecurNthWeekday($nth)
-+ {
-+ $this->recurNthDay = (int)$nth;
-+ }
-+
-+ /**
-+ *
-+ * @return integer The nth weekday of month to repeat events.
-+ */
-+ public function getRecurNthWeekday()
-+ {
-+ return isset($this->recurNthDay) ? $this->recurNthDay : ceil($this->start->mday / 7);
-+ }
-+
-+ /**
-+ * Specifies the months for yearly (weekday) recurrence
-+ *
-+ * @param array $months List of months (integers) this event recurs on.
-+ */
-+ function setRecurByMonth($months)
-+ {
-+ $this->recurMonths = (array)$months;
-+ }
-+
-+ /**
-+ * Returns a list of months this yearly event recurs on
-+ *
-+ * @return array List of months (integers) this event recurs on.
-+ */
-+ function getRecurByMonth()
-+ {
-+ return $this->recurMonths;
-+ }
-+
-+ /**
- * Returns the days this event recurs on.
- *
- * @return integer A mask consisting of Horde_Date::MASK_* constants
-@@ -546,8 +598,13 @@
- $estart = clone $this->start;
-
- // What day of the week, and week of the month, do we recur on?
-- $nth = ceil($this->start->mday / 7);
-- $weekday = $estart->dayOfWeek();
-+ if (isset($this->recurNthDay)) {
-+ $nth = $this->recurNthDay;
-+ $weekday = log($this->recurData, 2);
-+ } else {
-+ $nth = ceil($this->start->mday / 7);
-+ $weekday = $estart->dayOfWeek();
-+ }
-
- // Adjust $estart to be the first candidate.
- $offset = ($after->month - $estart->month) + ($after->year - $estart->year) * 12;
-@@ -660,8 +717,13 @@
- $estart = clone $this->start;
-
- // What day of the week, and week of the month, do we recur on?
-- $nth = ceil($this->start->mday / 7);
-- $weekday = $estart->dayOfWeek();
-+ if (isset($this->recurNthDay)) {
-+ $nth = $this->recurNthDay;
-+ $weekday = log($this->recurData, 2);
-+ } else {
-+ $nth = ceil($this->start->mday / 7);
-+ $weekday = $estart->dayOfWeek();
-+ }
-
- // Adjust $estart to be the first candidate.
- $offset = floor(($after->year - $estart->year + $this->recurInterval - 1) / $this->recurInterval) * $this->recurInterval;
-@@ -894,15 +956,6 @@
- case 'W':
- $this->setRecurType(self::RECUR_WEEKLY);
- if (!empty($remainder)) {
-- $maskdays = array(
-- 'SU' => Horde_Date::MASK_SUNDAY,
-- 'MO' => Horde_Date::MASK_MONDAY,
-- 'TU' => Horde_Date::MASK_TUESDAY,
-- 'WE' => Horde_Date::MASK_WEDNESDAY,
-- 'TH' => Horde_Date::MASK_THURSDAY,
-- 'FR' => Horde_Date::MASK_FRIDAY,
-- 'SA' => Horde_Date::MASK_SATURDAY,
-- );
- $mask = 0;
- while (preg_match('/^ ?[A-Z]{2} ?/', $remainder, $matches)) {
- $day = trim($matches[0]);
-@@ -953,7 +1006,10 @@
- list($year, $month, $mday) = sscanf($remainder, '%04d%02d%02d');
- $this->setRecurEnd(new Horde_Date(array('year' => $year,
- 'month' => $month,
-- 'mday' => $mday)));
-+ 'mday' => $mday,
-+ 'hour' => 23,
-+ 'min' => 59,
-+ 'sec' => 59)));
- }
- }
- }
-@@ -1049,6 +1105,16 @@
- // Always default the recurInterval to 1.
- $this->setRecurInterval(isset($rdata['INTERVAL']) ? $rdata['INTERVAL'] : 1);
-
-+ $maskdays = array(
-+ 'SU' => Horde_Date::MASK_SUNDAY,
-+ 'MO' => Horde_Date::MASK_MONDAY,
-+ 'TU' => Horde_Date::MASK_TUESDAY,
-+ 'WE' => Horde_Date::MASK_WEDNESDAY,
-+ 'TH' => Horde_Date::MASK_THURSDAY,
-+ 'FR' => Horde_Date::MASK_FRIDAY,
-+ 'SA' => Horde_Date::MASK_SATURDAY,
-+ );
-+
- switch (Horde_String::upper($rdata['FREQ'])) {
- case 'DAILY':
- $this->setRecurType(self::RECUR_DAILY);
-@@ -1057,15 +1123,6 @@
- case 'WEEKLY':
- $this->setRecurType(self::RECUR_WEEKLY);
- if (isset($rdata['BYDAY'])) {
-- $maskdays = array(
-- 'SU' => Horde_Date::MASK_SUNDAY,
-- 'MO' => Horde_Date::MASK_MONDAY,
-- 'TU' => Horde_Date::MASK_TUESDAY,
-- 'WE' => Horde_Date::MASK_WEDNESDAY,
-- 'TH' => Horde_Date::MASK_THURSDAY,
-- 'FR' => Horde_Date::MASK_FRIDAY,
-- 'SA' => Horde_Date::MASK_SATURDAY,
-- );
- $days = explode(',', $rdata['BYDAY']);
- $mask = 0;
- foreach ($days as $day) {
-@@ -1090,6 +1147,10 @@
- case 'MONTHLY':
- if (isset($rdata['BYDAY'])) {
- $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
-+ if (preg_match('/(-?[1-4])([A-Z]+)/', $rdata['BYDAY'], $m)) {
-+ $this->setRecurOnDay($maskdays[$m[2]]);
-+ $this->setRecurNthWeekday($m[1]);
-+ }
- } else {
- $this->setRecurType(self::RECUR_MONTHLY_DATE);
- }
-@@ -1100,6 +1161,14 @@
- $this->setRecurType(self::RECUR_YEARLY_DAY);
- } elseif (isset($rdata['BYDAY'])) {
- $this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
-+ if (preg_match('/(-?[1-4])([A-Z]+)/', $rdata['BYDAY'], $m)) {
-+ $this->setRecurOnDay($maskdays[$m[2]]);
-+ $this->setRecurNthWeekday($m[1]);
-+ }
-+ if ($rdata['BYMONTH']) {
-+ $months = explode(',', $rdata['BYMONTH']);
-+ $this->setRecurByMonth($months);
-+ }
- } else {
- $this->setRecurType(self::RECUR_YEARLY_DATE);
- }
-@@ -1163,13 +1232,19 @@
- break;
-
- case self::RECUR_MONTHLY_WEEKDAY:
-- $nth_weekday = (int)($this->start->mday / 7);
-- if (($this->start->mday % 7) > 0) {
-- $nth_weekday++;
-+ if (isset($this->recurNthDay)) {
-+ $nth_weekday = $this->recurNthDay;
-+ $day_of_week = log($this->recurData, 2);
-+ } else {
-+ $day_of_week = $this->start->dayOfWeek();
-+ $nth_weekday = (int)($this->start->mday / 7);
-+ if (($this->start->mday % 7) > 0) {
-+ $nth_weekday++;
-+ }
- }
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- $rrule = 'FREQ=MONTHLY;INTERVAL=' . $this->recurInterval
-- . ';BYDAY=' . $nth_weekday . $vcaldays[$this->start->dayOfWeek()];
-+ . ';BYDAY=' . $nth_weekday . $vcaldays[$day_of_week];
- break;
-
- case self::RECUR_YEARLY_DATE:
-@@ -1182,15 +1257,22 @@
- break;
-
- case self::RECUR_YEARLY_WEEKDAY:
-- $nth_weekday = (int)($this->start->mday / 7);
-- if (($this->start->mday % 7) > 0) {
-- $nth_weekday++;
-- }
-+ if (isset($this->recurNthDay)) {
-+ $nth_weekday = $this->recurNthDay;
-+ $day_of_week = log($this->recurData, 2);
-+ } else {
-+ $day_of_week = $this->start->dayOfWeek();
-+ $nth_weekday = (int)($this->start->mday / 7);
-+ if (($this->start->mday % 7) > 0) {
-+ $nth_weekday++;
-+ }
-+ }
-+ $months = !empty($this->recurMonths) ? join(',', $this->recurMonths) : $this->start->month;
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- $rrule = 'FREQ=YEARLY;INTERVAL=' . $this->recurInterval
- . ';BYDAY='
- . $nth_weekday
-- . $vcaldays[$this->start->dayOfWeek()]
-+ . $vcaldays[$day_of_week]
- . ';BYMONTH=' . $this->start->month;
- break;
- }
-@@ -1223,6 +1305,21 @@
-
- $this->setRecurInterval((int)$hash['interval']);
-
-+ $month2number = array(
-+ 'january' => 1,
-+ 'february' => 2,
-+ 'march' => 3,
-+ 'april' => 4,
-+ 'may' => 5,
-+ 'june' => 6,
-+ 'july' => 7,
-+ 'august' => 8,
-+ 'september' => 9,
-+ 'october' => 10,
-+ 'november' => 11,
-+ 'december' => 12,
-+ );
-+
- $parse_day = false;
- $set_daymask = false;
- $update_month = false;
-@@ -1255,11 +1352,9 @@
-
- case 'weekday':
- $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
-- $nth_weekday = (int)$hash['daynumber'];
-- $hash['daynumber'] = 1;
-+ $this->setRecurNthWeekday($hash['daynumber']);
- $parse_day = true;
-- $update_daynumber = true;
-- $update_weekday = true;
-+ $set_daymask = true;
- break;
- }
- break;
-@@ -1297,12 +1392,13 @@
- }
-
- $this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
-- $nth_weekday = (int)$hash['daynumber'];
-- $hash['daynumber'] = 1;
-+ $this->setRecurNthWeekday($hash['daynumber']);
- $parse_day = true;
-- $update_month = true;
-- $update_daynumber = true;
-- $update_weekday = true;
-+ $set_daymask = true;
-+
-+ if ($hash['month'] && isset($month2number[$hash['month']])) {
-+ $this->setRecurByMonth($month2number[$hash['month']]);
-+ }
- break;
- }
- }
-@@ -1368,21 +1464,6 @@
-
- if ($update_month || $update_daynumber || $update_weekday) {
- if ($update_month) {
-- $month2number = array(
-- 'january' => 1,
-- 'february' => 2,
-- 'march' => 3,
-- 'april' => 4,
-- 'may' => 5,
-- 'june' => 6,
-- 'july' => 7,
-- 'august' => 8,
-- 'september' => 9,
-- 'october' => 10,
-- 'november' => 11,
-- 'december' => 12,
-- );
--
- if (isset($month2number[$hash['month']])) {
- $this->start->month = $month2number[$hash['month']];
- }
-@@ -1398,7 +1479,7 @@
- }
-
- if ($update_weekday) {
-- $this->start->setNthWeekday($last_found_day, $nth_weekday);
-+ $this->setNthWeekday($nth_weekday);
- }
- }
-
diff --git a/plugins/libkolab/bin/Date_last_weekday.diff b/plugins/libkolab/bin/Date_last_weekday.diff
deleted file mode 100644
index d260360..0000000
--- a/plugins/libkolab/bin/Date_last_weekday.diff
+++ /dev/null
@@ -1,37 +0,0 @@
---- Date.php.orig 2012-07-10 19:14:26.000000000 +0200
-+++ Date.php 2012-07-10 19:16:22.000000000 +0200
-@@ -627,16 +627,25 @@
- return;
- }
-
-- $this->_mday = 1;
-- $first = $this->dayOfWeek();
-- if ($weekday < $first) {
-- $this->_mday = 8 + $weekday - $first;
-- } else {
-- $this->_mday = $weekday - $first + 1;
-+ if ($nth < 0) { // last $weekday of month
-+ $this->_mday = $lastday = Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
-+ $last = $this->dayOfWeek();
-+ $this->_mday += ($weekday - $last);
-+ if ($this->_mday > $lastday)
-+ $this->_mday -= 7;
-+ }
-+ else {
-+ $this->_mday = 1;
-+ $first = $this->dayOfWeek();
-+ if ($weekday < $first) {
-+ $this->_mday = 8 + $weekday - $first;
-+ } else {
-+ $this->_mday = $weekday - $first + 1;
-+ }
-+ $diff = 7 * $nth - 7;
-+ $this->_mday += $diff;
-+ $this->_correct(self::MASK_DAY, $diff < 0);
- }
-- $diff = 7 * $nth - 7;
-- $this->_mday += $diff;
-- $this->_correct(self::MASK_DAY, $diff < 0);
- }
-
- /**
diff --git a/plugins/libkolab/bin/get_horde_date.sh b/plugins/libkolab/bin/get_horde_date.sh
deleted file mode 100755
index b8e663d..0000000
--- a/plugins/libkolab/bin/get_horde_date.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-
-# Copy Horde_Date_Recurrence classes and dependencies to the given target directory.
-# This will create a standalone copy of the classes requried for date recurrence computation.
-
-SRCDIR=$1
-DESTDIR=$2
-BINDIR=`dirname $0`
-
-if [ ! -d "$SRCDIR" -o ! -d "$DESTDIR" ]; then
- echo "Usage: get_horde_date.sh SRCDIR DESTDIR"
- echo "Please enter valid source and destination directories for the Horde libs"
- exit 1
-fi
-
-
-# concat Date.php and Date/Utils.php
-HORDE_DATE="$DESTDIR/Horde_Date.php"
-
-echo "<?php
-
-/**
- * This is a concatenated copy of the following files:
- * Horde/Date.php, Horde/Date/Utils.php
- * Pull the latest version of these files from the PEAR channel of the Horde
- * project at http://pear.horde.org by installing the Horde_Date package.
- */
-" > $HORDE_DATE
-
-patch $SRCDIR/Date.php $BINDIR/Date_last_weekday.diff --output=$HORDE_DATE.patched
-sed 's/<?php//; s/?>//' $HORDE_DATE.patched >> $HORDE_DATE
-sed 's/<?php//; s/?>//' $SRCDIR/Date/Utils.php >> $HORDE_DATE
-
-# copy and patch Date/Recurrence.php
-HORDE_DATE_RECURRENCE="$DESTDIR/Horde_Date_Recurrence.php"
-
-echo "<?php
-
-/**
- * This is a modified copy of Horde/Date/Recurrence.php
- * Pull the latest version of this file from the PEAR channel of the Horde
- * project at http://pear.horde.org by installing the Horde_Date package.
- */
-
-if (!class_exists('Horde_Date'))
- require_once(dirname(__FILE__) . '/Horde_Date.php');
-
-// minimal required implementation of Horde_Date_Translation to avoid a huge dependency nightmare
-class Horde_Date_Translation
-{
- function t(\$arg) { return \$arg; }
- function ngettext(\$sing, \$plur, \$num) { return (\$num > 1 ? \$plur : \$sing); }
-}
-" > $HORDE_DATE_RECURRENCE
-
-patch $SRCDIR/Date/Recurrence.php $BINDIR/Date_Recurrence_weekday.diff --output=$HORDE_DATE_RECURRENCE.patched
-sed 's/<?php//; s/?>//' $HORDE_DATE_RECURRENCE.patched >> $HORDE_DATE_RECURRENCE
-
-# remove dependency to Horde_String
-sed -i '' "s/Horde_String::/strto/" $HORDE_DATE_RECURRENCE
-
-rm $DESTDIR/Horde_Date*.patched
-
-
diff --git a/plugins/libkolab/lib/Horde_Date.php b/plugins/libkolab/lib/Horde_Date.php
deleted file mode 100644
index 9197f84..0000000
--- a/plugins/libkolab/lib/Horde_Date.php
+++ /dev/null
@@ -1,1304 +0,0 @@
-<?php
-
-/**
- * This is a concatenated copy of the following files:
- * Horde/Date/Utils.php, Horde/Date/Recurrence.php
- * Pull the latest version of these files from the PEAR channel of the Horde
- * project at http://pear.horde.org by installing the Horde_Date package.
- */
-
-
-/**
- * Horde Date wrapper/logic class, including some calculation
- * functions.
- *
- * @category Horde
- * @package Date
- *
- * @TODO in format():
- * http://php.net/intldateformatter
- *
- * @TODO on timezones:
- * http://trac.agavi.org/ticket/1008
- * http://trac.agavi.org/changeset/3659
- *
- * @TODO on switching to PHP::DateTime:
- * The only thing ever stored in the database *IS* Unix timestamps. Doing
- * anything other than that is unmanageable, yet some frameworks use 'server
- * based' times in their systems, simply because they do not bother with
- * daylight saving and only 'serve' one timezone!
- *
- * The second you have to manage 'real' time across timezones then daylight
- * saving becomes essential, BUT only on the display side! Since the browser
- * only provides a time offset, this is useless and to be honest should simply
- * be ignored ( until it is upgraded to provide the correct information ;)
- * ). So we need a 'display' function that takes a simple numeric epoch, and a
- * separate timezone id into which the epoch is to be 'converted'. My W3C
- * mapping works simply because ADOdb then converts that to it's own simple
- * offset abbreviation - in my case GMT or BST. As long as DateTime passes the
- * full 64 bit number the date range from 100AD is also preserved ( and
- * further back if 2 digit years are disabled ). If I want to display the
- * 'real' timezone with this 'time' then I just add it in place of ADOdb's
- * 'timezone'. I am tempted to simply adjust the ADOdb class to take a
- * timezone in place of the simple GMT switch it currently uses.
- *
- * The return path is just the reverse and simply needs to take the client
- * display offset off prior to storage of the UTC epoch. SO we use
- * DateTimeZone to get an offset value for the clients timezone and simply add
- * or subtract this from a timezone agnostic display on the client end when
- * entering new times.
- *
- *
- * It's not really feasible to store dates in specific timezone, as most
- * national/local timezones support DST - and that is a pain to support, as
- * eg. sorting breaks when some timestamps get repeated. That's why it's
- * usually better to store datetimes as either UTC datetime or plain unix
- * timestamp. I usually go with the former - using database datetime type.
- */
-
-/**
- * @category Horde
- * @package Date
- */
-class Horde_Date
-{
- const DATE_SUNDAY = 0;
- const DATE_MONDAY = 1;
- const DATE_TUESDAY = 2;
- const DATE_WEDNESDAY = 3;
- const DATE_THURSDAY = 4;
- const DATE_FRIDAY = 5;
- const DATE_SATURDAY = 6;
-
- const MASK_SUNDAY = 1;
- const MASK_MONDAY = 2;
- const MASK_TUESDAY = 4;
- const MASK_WEDNESDAY = 8;
- const MASK_THURSDAY = 16;
- const MASK_FRIDAY = 32;
- const MASK_SATURDAY = 64;
- const MASK_WEEKDAYS = 62;
- const MASK_WEEKEND = 65;
- const MASK_ALLDAYS = 127;
-
- const MASK_SECOND = 1;
- const MASK_MINUTE = 2;
- const MASK_HOUR = 4;
- const MASK_DAY = 8;
- const MASK_MONTH = 16;
- const MASK_YEAR = 32;
- const MASK_ALLPARTS = 63;
-
- const DATE_DEFAULT = 'Y-m-d H:i:s';
- const DATE_JSON = 'Y-m-d\TH:i:s';
-
- /**
- * Year
- *
- * @var integer
- */
- protected $_year;
-
- /**
- * Month
- *
- * @var integer
- */
- protected $_month;
-
- /**
- * Day
- *
- * @var integer
- */
- protected $_mday;
-
- /**
- * Hour
- *
- * @var integer
- */
- protected $_hour = 0;
-
- /**
- * Minute
- *
- * @var integer
- */
- protected $_min = 0;
-
- /**
- * Second
- *
- * @var integer
- */
- protected $_sec = 0;
-
- /**
- * String representation of the date's timezone.
- *
- * @var string
- */
- protected $_timezone;
-
- /**
- * Default format for __toString()
- *
- * @var string
- */
- protected $_defaultFormat = self::DATE_DEFAULT;
-
- /**
- * Default specs that are always supported.
- * @var string
- */
- protected static $_defaultSpecs = '%CdDeHImMnRStTyY';
-
- /**
- * Internally supported strftime() specifiers.
- * @var string
- */
- protected static $_supportedSpecs = '';
-
- /**
- * Map of required correction masks.
- *
- * @see __set()
- *
- * @var array
- */
- protected static $_corrections = array(
- 'year' => self::MASK_YEAR,
- 'month' => self::MASK_MONTH,
- 'mday' => self::MASK_DAY,
- 'hour' => self::MASK_HOUR,
- 'min' => self::MASK_MINUTE,
- 'sec' => self::MASK_SECOND,
- );
-
- protected $_formatCache = array();
-
- /**
- * Builds a new date object. If $date contains date parts, use them to
- * initialize the object.
- *
- * Recognized formats:
- * - arrays with keys 'year', 'month', 'mday', 'day'
- * 'hour', 'min', 'minute', 'sec'
- * - objects with properties 'year', 'month', 'mday', 'hour', 'min', 'sec'
- * - yyyy-mm-dd hh:mm:ss
- * - yyyymmddhhmmss
- * - yyyymmddThhmmssZ
- * - yyyymmdd (might conflict with unix timestamps between 31 Oct 1966 and
- * 03 Mar 1973)
- * - unix timestamps
- * - anything parsed by strtotime()/DateTime.
- *
- * @throws Horde_Date_Exception
- */
- public function __construct($date = null, $timezone = null)
- {
- if (!self::$_supportedSpecs) {
- self::$_supportedSpecs = self::$_defaultSpecs;
- if (function_exists('nl_langinfo')) {
- self::$_supportedSpecs .= 'bBpxX';
- }
- }
-
- if (func_num_args() > 2) {
- // Handle args in order: year month day hour min sec tz
- $this->_initializeFromArgs(func_get_args());
- return;
- }
-
- $this->_initializeTimezone($timezone);
-
- if (is_null($date)) {
- return;
- }
-
- if (is_string($date)) {
- $date = trim($date, '"');
- }
-
- if (is_object($date)) {
- $this->_initializeFromObject($date);
- } elseif (is_array($date)) {
- $this->_initializeFromArray($date);
- } elseif (preg_match('/^(\d{4})-?(\d{2})-?(\d{2})T? ?(\d{2}):?(\d{2}):?(\d{2})(?:\.\d+)?(Z?)$/', $date, $parts)) {
- $this->_year = (int)$parts[1];
- $this->_month = (int)$parts[2];
- $this->_mday = (int)$parts[3];
- $this->_hour = (int)$parts[4];
- $this->_min = (int)$parts[5];
- $this->_sec = (int)$parts[6];
- if ($parts[7]) {
- $this->_initializeTimezone('UTC');
- }
- } elseif (preg_match('/^(\d{4})-?(\d{2})-?(\d{2})$/', $date, $parts) &&
- $parts[2] > 0 && $parts[2] <= 12 &&
- $parts[3] > 0 && $parts[3] <= 31) {
- $this->_year = (int)$parts[1];
- $this->_month = (int)$parts[2];
- $this->_mday = (int)$parts[3];
- $this->_hour = $this->_min = $this->_sec = 0;
- } elseif ((string)(int)$date == $date) {
- // Try as a timestamp.
- $parts = @getdate($date);
- if ($parts) {
- $this->_year = $parts['year'];
- $this->_month = $parts['mon'];
- $this->_mday = $parts['mday'];
- $this->_hour = $parts['hours'];
- $this->_min = $parts['minutes'];
- $this->_sec = $parts['seconds'];
- }
- } else {
- // Use date_create() so we can catch errors with PHP 5.2. Use
- // "new DateTime() once we require 5.3.
- $parsed = date_create($date);
- if (!$parsed) {
- throw new Horde_Date_Exception(sprintf(Horde_Date_Translation::t("Failed to parse time string (%s)"), $date));
- }
- $parsed->setTimezone(new DateTimeZone(date_default_timezone_get()));
- $this->_year = (int)$parsed->format('Y');
- $this->_month = (int)$parsed->format('m');
- $this->_mday = (int)$parsed->format('d');
- $this->_hour = (int)$parsed->format('H');
- $this->_min = (int)$parsed->format('i');
- $this->_sec = (int)$parsed->format('s');
- $this->_initializeTimezone(date_default_timezone_get());
- }
- }
-
- /**
- * Returns a simple string representation of the date object
- *
- * @return string This object converted to a string.
- */
- public function __toString()
- {
- try {
- return $this->format($this->_defaultFormat);
- } catch (Exception $e) {
- return '';
- }
- }
-
- /**
- * Returns a DateTime object representing this object.
- *
- * @return DateTime
- */
- public function toDateTime()
- {
- $date = new DateTime(null, new DateTimeZone($this->_timezone));
- $date->setDate($this->_year, $this->_month, $this->_mday);
- $date->setTime($this->_hour, $this->_min, $this->_sec);
- return $date;
- }
-
- /**
- * Converts a date in the proleptic Gregorian calendar to the no of days
- * since 24th November, 4714 B.C.
- *
- * Returns the no of days since Monday, 24th November, 4714 B.C. in the
- * proleptic Gregorian calendar (which is 24th November, -4713 using
- * 'Astronomical' year numbering, and 1st January, 4713 B.C. in the
- * proleptic Julian calendar). This is also the first day of the 'Julian
- * Period' proposed by Joseph Scaliger in 1583, and the number of days
- * since this date is known as the 'Julian Day'. (It is not directly
- * to do with the Julian calendar, although this is where the name
- * is derived from.)
- *
- * The algorithm is valid for all years (positive and negative), and
- * also for years preceding 4714 B.C.
- *
- * Algorithm is from PEAR::Date_Calc
- *
- * @author Monte Ohrt <monte at ispi.net>
- * @author Pierre-Alain Joye <pajoye at php.net>
- * @author Daniel Convissor <danielc at php.net>
- * @author C.A. Woodcock <c01234 at netcomuk.co.uk>
- *
- * @return integer The number of days since 24th November, 4714 B.C.
- */
- public function toDays()
- {
- if (function_exists('GregorianToJD')) {
- return gregoriantojd($this->_month, $this->_mday, $this->_year);
- }
-
- $day = $this->_mday;
- $month = $this->_month;
- $year = $this->_year;
-
- if ($month > 2) {
- // March = 0, April = 1, ..., December = 9,
- // January = 10, February = 11
- $month -= 3;
- } else {
- $month += 9;
- --$year;
- }
-
- $hb_negativeyear = $year < 0;
- $century = intval($year / 100);
- $year = $year % 100;
-
- if ($hb_negativeyear) {
- // Subtract 1 because year 0 is a leap year;
- // And N.B. that we must treat the leap years as occurring
- // one year earlier than they do, because for the purposes
- // of calculation, the year starts on 1st March:
- //
- return intval((14609700 * $century + ($year == 0 ? 1 : 0)) / 400) +
- intval((1461 * $year + 1) / 4) +
- intval((153 * $month + 2) / 5) +
- $day + 1721118;
- } else {
- return intval(146097 * $century / 4) +
- intval(1461 * $year / 4) +
- intval((153 * $month + 2) / 5) +
- $day + 1721119;
- }
- }
-
- /**
- * Converts number of days since 24th November, 4714 B.C. (in the proleptic
- * Gregorian calendar, which is year -4713 using 'Astronomical' year
- * numbering) to Gregorian calendar date.
- *
- * Returned date belongs to the proleptic Gregorian calendar, using
- * 'Astronomical' year numbering.
- *
- * The algorithm is valid for all years (positive and negative), and
- * also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'),
- * and so the only limitation is platform-dependent (for 32-bit systems
- * the maximum year would be something like about 1,465,190 A.D.).
- *
- * N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.
- *
- * Algorithm is from PEAR::Date_Calc
- *
- * @author Monte Ohrt <monte at ispi.net>
- * @author Pierre-Alain Joye <pajoye at php.net>
- * @author Daniel Convissor <danielc at php.net>
- * @author C.A. Woodcock <c01234 at netcomuk.co.uk>
- *
- * @param int $days the number of days since 24th November, 4714 B.C.
- * @param string $format the string indicating how to format the output
- *
- * @return Horde_Date A Horde_Date object representing the date.
- */
- public static function fromDays($days)
- {
- if (function_exists('JDToGregorian')) {
- list($month, $day, $year) = explode('/', JDToGregorian($days));
- } else {
- $days = intval($days);
-
- $days -= 1721119;
- $century = floor((4 * $days - 1) / 146097);
- $days = floor(4 * $days - 1 - 146097 * $century);
- $day = floor($days / 4);
-
- $year = floor((4 * $day + 3) / 1461);
- $day = floor(4 * $day + 3 - 1461 * $year);
- $day = floor(($day + 4) / 4);
-
- $month = floor((5 * $day - 3) / 153);
- $day = floor(5 * $day - 3 - 153 * $month);
- $day = floor(($day + 5) / 5);
-
- $year = $century * 100 + $year;
- if ($month < 10) {
- $month +=3;
- } else {
- $month -=9;
- ++$year;
- }
- }
-
- return new Horde_Date($year, $month, $day);
- }
-
- /**
- * Getter for the date and time properties.
- *
- * @param string $name One of 'year', 'month', 'mday', 'hour', 'min' or
- * 'sec'.
- *
- * @return integer The property value, or null if not set.
- */
- public function __get($name)
- {
- if ($name == 'day') {
- $name = 'mday';
- }
-
- return $this->{'_' . $name};
- }
-
- /**
- * Setter for the date and time properties.
- *
- * @param string $name One of 'year', 'month', 'mday', 'hour', 'min' or
- * 'sec'.
- * @param integer $value The property value.
- */
- public function __set($name, $value)
- {
- if ($name == 'timezone') {
- $this->_initializeTimezone($value);
- return;
- }
- if ($name == 'day') {
- $name = 'mday';
- }
-
- if ($name != 'year' && $name != 'month' && $name != 'mday' &&
- $name != 'hour' && $name != 'min' && $name != 'sec') {
- throw new InvalidArgumentException('Undefined property ' . $name);
- }
-
- $down = $value < $this->{'_' . $name};
- $this->{'_' . $name} = $value;
- $this->_correct(self::$_corrections[$name], $down);
- $this->_formatCache = array();
- }
-
- /**
- * Returns whether a date or time property exists.
- *
- * @param string $name One of 'year', 'month', 'mday', 'hour', 'min' or
- * 'sec'.
- *
- * @return boolen True if the property exists and is set.
- */
- public function __isset($name)
- {
- if ($name == 'day') {
- $name = 'mday';
- }
- return ($name == 'year' || $name == 'month' || $name == 'mday' ||
- $name == 'hour' || $name == 'min' || $name == 'sec') &&
- isset($this->{'_' . $name});
- }
-
- /**
- * Adds a number of seconds or units to this date, returning a new Date
- * object.
- */
- public function add($factor)
- {
- $d = clone($this);
- if (is_array($factor) || is_object($factor)) {
- foreach ($factor as $property => $value) {
- $d->$property += $value;
- }
- } else {
- $d->sec += $factor;
- }
-
- return $d;
- }
-
- /**
- * Subtracts a number of seconds or units from this date, returning a new
- * Horde_Date object.
- */
- public function sub($factor)
- {
- if (is_array($factor)) {
- foreach ($factor as &$value) {
- $value *= -1;
- }
- } else {
- $factor *= -1;
- }
-
- return $this->add($factor);
- }
-
- /**
- * Converts this object to a different timezone.
- *
- * @param string $timezone The new timezone.
- *
- * @return Horde_Date This object.
- */
- public function setTimezone($timezone)
- {
- $date = $this->toDateTime();
- $date->setTimezone(new DateTimeZone($timezone));
- $this->_timezone = $timezone;
- $this->_year = (int)$date->format('Y');
- $this->_month = (int)$date->format('m');
- $this->_mday = (int)$date->format('d');
- $this->_hour = (int)$date->format('H');
- $this->_min = (int)$date->format('i');
- $this->_sec = (int)$date->format('s');
- $this->_formatCache = array();
- return $this;
- }
-
- /**
- * Sets the default date format used in __toString()
- *
- * @param string $format
- */
- public function setDefaultFormat($format)
- {
- $this->_defaultFormat = $format;
- }
-
- /**
- * Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
- *
- * @return integer The day of the week.
- */
- public function dayOfWeek()
- {
- if ($this->_month > 2) {
- $month = $this->_month - 2;
- $year = $this->_year;
- } else {
- $month = $this->_month + 10;
- $year = $this->_year - 1;
- }
-
- $day = (floor((13 * $month - 1) / 5) +
- $this->_mday + ($year % 100) +
- floor(($year % 100) / 4) +
- floor(($year / 100) / 4) - 2 *
- floor($year / 100) + 77);
-
- return (int)($day - 7 * floor($day / 7));
- }
-
- /**
- * Returns the day number of the year (1 to 365/366).
- *
- * @return integer The day of the year.
- */
- public function dayOfYear()
- {
- return $this->format('z') + 1;
- }
-
- /**
- * Returns the week of the month.
- *
- * @return integer The week number.
- */
- public function weekOfMonth()
- {
- return ceil($this->_mday / 7);
- }
-
- /**
- * Returns the week of the year, first Monday is first day of first week.
- *
- * @return integer The week number.
- */
- public function weekOfYear()
- {
- return $this->format('W');
- }
-
- /**
- * Returns the number of weeks in the given year (52 or 53).
- *
- * @param integer $year The year to count the number of weeks in.
- *
- * @return integer $numWeeks The number of weeks in $year.
- */
- public static function weeksInYear($year)
- {
- // Find the last Thursday of the year.
- $date = new Horde_Date($year . '-12-31');
- while ($date->dayOfWeek() != self::DATE_THURSDAY) {
- --$date->mday;
- }
- return $date->weekOfYear();
- }
-
- /**
- * Sets the date of this object to the $nth weekday of $weekday.
- *
- * @param integer $weekday The day of the week (0 = Sunday, etc).
- * @param integer $nth The $nth $weekday to set to (defaults to 1).
- */
- public function setNthWeekday($weekday, $nth = 1)
- {
- if ($weekday < self::DATE_SUNDAY || $weekday > self::DATE_SATURDAY) {
- return;
- }
-
- if ($nth < 0) { // last $weekday of month
- $this->_mday = $lastday = Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
- $last = $this->dayOfWeek();
- $this->_mday += ($weekday - $last);
- if ($this->_mday > $lastday)
- $this->_mday -= 7;
- }
- else {
- $this->_mday = 1;
- $first = $this->dayOfWeek();
- if ($weekday < $first) {
- $this->_mday = 8 + $weekday - $first;
- } else {
- $this->_mday = $weekday - $first + 1;
- }
- $diff = 7 * $nth - 7;
- $this->_mday += $diff;
- $this->_correct(self::MASK_DAY, $diff < 0);
- }
- }
-
- /**
- * Is the date currently represented by this object a valid date?
- *
- * @return boolean Validity, counting leap years, etc.
- */
- public function isValid()
- {
- return ($this->_year >= 0 && $this->_year <= 9999);
- }
-
- /**
- * Compares this date to another date object to see which one is
- * greater (later). Assumes that the dates are in the same
- * timezone.
- *
- * @param mixed $other The date to compare to.
- *
- * @return integer == 0 if they are on the same date
- * >= 1 if $this is greater (later)
- * <= -1 if $other is greater (later)
- */
- public function compareDate($other)
- {
- if (!($other instanceof Horde_Date)) {
- $other = new Horde_Date($other);
- }
-
- if ($this->_year != $other->year) {
- return $this->_year - $other->year;
- }
- if ($this->_month != $other->month) {
- return $this->_month - $other->month;
- }
-
- return $this->_mday - $other->mday;
- }
-
- /**
- * Returns whether this date is after the other.
- *
- * @param mixed $other The date to compare to.
- *
- * @return boolean True if this date is after the other.
- */
- public function after($other)
- {
- return $this->compareDate($other) > 0;
- }
-
- /**
- * Returns whether this date is before the other.
- *
- * @param mixed $other The date to compare to.
- *
- * @return boolean True if this date is before the other.
- */
- public function before($other)
- {
- return $this->compareDate($other) < 0;
- }
-
- /**
- * Returns whether this date is the same like the other.
- *
- * @param mixed $other The date to compare to.
- *
- * @return boolean True if this date is the same like the other.
- */
- public function equals($other)
- {
- return $this->compareDate($other) == 0;
- }
-
- /**
- * Compares this to another date object by time, to see which one
- * is greater (later). Assumes that the dates are in the same
- * timezone.
- *
- * @param mixed $other The date to compare to.
- *
- * @return integer == 0 if they are at the same time
- * >= 1 if $this is greater (later)
- * <= -1 if $other is greater (later)
- */
- public function compareTime($other)
- {
- if (!($other instanceof Horde_Date)) {
- $other = new Horde_Date($other);
- }
-
- if ($this->_hour != $other->hour) {
- return $this->_hour - $other->hour;
- }
- if ($this->_min != $other->min) {
- return $this->_min - $other->min;
- }
-
- return $this->_sec - $other->sec;
- }
-
- /**
- * Compares this to another date object, including times, to see
- * which one is greater (later). Assumes that the dates are in the
- * same timezone.
- *
- * @param mixed $other The date to compare to.
- *
- * @return integer == 0 if they are equal
- * >= 1 if $this is greater (later)
- * <= -1 if $other is greater (later)
- */
- public function compareDateTime($other)
- {
- if (!($other instanceof Horde_Date)) {
- $other = new Horde_Date($other);
- }
-
- if ($diff = $this->compareDate($other)) {
- return $diff;
- }
-
- return $this->compareTime($other);
- }
-
- /**
- * Returns number of days between this date and another.
- *
- * @param Horde_Date $other The other day to diff with.
- *
- * @return integer The absolute number of days between the two dates.
- */
- public function diff($other)
- {
- return abs($this->toDays() - $other->toDays());
- }
-
- /**
- * Returns the time offset for local time zone.
- *
- * @param boolean $colon Place a colon between hours and minutes?
- *
- * @return string Timezone offset as a string in the format +HH:MM.
- */
- public function tzOffset($colon = true)
- {
- return $colon ? $this->format('P') : $this->format('O');
- }
-
- /**
- * Returns the unix timestamp representation of this date.
- *
- * @return integer A unix timestamp.
- */
- public function timestamp()
- {
- if ($this->_year >= 1970 && $this->_year < 2038) {
- return mktime($this->_hour, $this->_min, $this->_sec,
- $this->_month, $this->_mday, $this->_year);
- }
- return $this->format('U');
- }
-
- /**
- * Returns the unix timestamp representation of this date, 12:00am.
- *
- * @return integer A unix timestamp.
- */
- public function datestamp()
- {
- if ($this->_year >= 1970 && $this->_year < 2038) {
- return mktime(0, 0, 0, $this->_month, $this->_mday, $this->_year);
- }
- $date = new DateTime($this->format('Y-m-d'));
- return $date->format('U');
- }
-
- /**
- * Formats date and time to be passed around as a short url parameter.
- *
- * @return string Date and time.
- */
- public function dateString()
- {
- return sprintf('%04d%02d%02d', $this->_year, $this->_month, $this->_mday);
- }
-
- /**
- * Formats date and time to the ISO format used by JSON.
- *
- * @return string Date and time.
- */
- public function toJson()
- {
- return $this->format(self::DATE_JSON);
- }
-
- /**
- * Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
- *
- * @param boolean $floating Whether to return a floating date-time
- * (without time zone information).
- *
- * @return string Date and time.
- */
- public function toiCalendar($floating = false)
- {
- if ($floating) {
- return $this->format('Ymd\THis');
- }
- $dateTime = $this->toDateTime();
- $dateTime->setTimezone(new DateTimeZone('UTC'));
- return $dateTime->format('Ymd\THis\Z');
- }
-
- /**
- * Formats time using the specifiers available in date() or in the DateTime
- * class' format() method.
- *
- * To format in languages other than English, use strftime() instead.
- *
- * @param string $format
- *
- * @return string Formatted time.
- */
- public function format($format)
- {
- if (!isset($this->_formatCache[$format])) {
- $this->_formatCache[$format] = $this->toDateTime()->format($format);
- }
- return $this->_formatCache[$format];
- }
-
- /**
- * Formats date and time using strftime() format.
- *
- * @return string strftime() formatted date and time.
- */
- public function strftime($format)
- {
- if (preg_match('/%[^' . self::$_supportedSpecs . ']/', $format)) {
- return strftime($format, $this->timestamp());
- } else {
- return $this->_strftime($format);
- }
- }
-
- /**
- * Formats date and time using a limited set of the strftime() format.
- *
- * @return string strftime() formatted date and time.
- */
- protected function _strftime($format)
- {
- return preg_replace(
- array('/%b/e',
- '/%B/e',
- '/%C/e',
- '/%d/e',
- '/%D/e',
- '/%e/e',
- '/%H/e',
- '/%I/e',
- '/%m/e',
- '/%M/e',
- '/%n/',
- '/%p/e',
- '/%R/e',
- '/%S/e',
- '/%t/',
- '/%T/e',
- '/%x/e',
- '/%X/e',
- '/%y/e',
- '/%Y/',
- '/%%/'),
- array('$this->_strftime(Horde_Nls::getLangInfo(constant(\'ABMON_\' . (int)$this->_month)))',
- '$this->_strftime(Horde_Nls::getLangInfo(constant(\'MON_\' . (int)$this->_month)))',
- '(int)($this->_year / 100)',
- 'sprintf(\'%02d\', $this->_mday)',
- '$this->_strftime(\'%m/%d/%y\')',
- 'sprintf(\'%2d\', $this->_mday)',
- 'sprintf(\'%02d\', $this->_hour)',
- 'sprintf(\'%02d\', $this->_hour == 0 ? 12 : ($this->_hour > 12 ? $this->_hour - 12 : $this->_hour))',
- 'sprintf(\'%02d\', $this->_month)',
- 'sprintf(\'%02d\', $this->_min)',
- "\n",
- '$this->_strftime(Horde_Nls::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR))',
- '$this->_strftime(\'%H:%M\')',
- 'sprintf(\'%02d\', $this->_sec)',
- "\t",
- '$this->_strftime(\'%H:%M:%S\')',
- '$this->_strftime(Horde_Nls::getLangInfo(D_FMT))',
- '$this->_strftime(Horde_Nls::getLangInfo(T_FMT))',
- 'substr(sprintf(\'%04d\', $this->_year), -2)',
- (int)$this->_year,
- '%'),
- $format);
- }
-
- /**
- * Corrects any over- or underflows in any of the date's members.
- *
- * @param integer $mask We may not want to correct some overflows.
- * @param integer $down Whether to correct the date up or down.
- */
- protected function _correct($mask = self::MASK_ALLPARTS, $down = false)
- {
- if ($mask & self::MASK_SECOND) {
- if ($this->_sec < 0 || $this->_sec > 59) {
- $mask |= self::MASK_MINUTE;
-
- $this->_min += (int)($this->_sec / 60);
- $this->_sec %= 60;
- if ($this->_sec < 0) {
- $this->_min--;
- $this->_sec += 60;
- }
- }
- }
-
- if ($mask & self::MASK_MINUTE) {
- if ($this->_min < 0 || $this->_min > 59) {
- $mask |= self::MASK_HOUR;
-
- $this->_hour += (int)($this->_min / 60);
- $this->_min %= 60;
- if ($this->_min < 0) {
- $this->_hour--;
- $this->_min += 60;
- }
- }
- }
-
- if ($mask & self::MASK_HOUR) {
- if ($this->_hour < 0 || $this->_hour > 23) {
- $mask |= self::MASK_DAY;
-
- $this->_mday += (int)($this->_hour / 24);
- $this->_hour %= 24;
- if ($this->_hour < 0) {
- $this->_mday--;
- $this->_hour += 24;
- }
- }
- }
-
- if ($mask & self::MASK_MONTH) {
- $this->_correctMonth($down);
- /* When correcting the month, always correct the day too. Months
- * have different numbers of days. */
- $mask |= self::MASK_DAY;
- }
-
- if ($mask & self::MASK_DAY) {
- while ($this->_mday > 28 &&
- $this->_mday > Horde_Date_Utils::daysInMonth($this->_month, $this->_year)) {
- if ($down) {
- $this->_mday -= Horde_Date_Utils::daysInMonth($this->_month + 1, $this->_year) - Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
- } else {
- $this->_mday -= Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
- $this->_month++;
- }
- $this->_correctMonth($down);
- }
- while ($this->_mday < 1) {
- --$this->_month;
- $this->_correctMonth($down);
- $this->_mday += Horde_Date_Utils::daysInMonth($this->_month, $this->_year);
- }
- }
- }
-
- /**
- * Corrects the current month.
- *
- * This cannot be done in _correct() because that would also trigger a
- * correction of the day, which would result in an infinite loop.
- *
- * @param integer $down Whether to correct the date up or down.
- */
- protected function _correctMonth($down = false)
- {
- $this->_year += (int)($this->_month / 12);
- $this->_month %= 12;
- if ($this->_month < 1) {
- $this->_year--;
- $this->_month += 12;
- }
- }
-
- /**
- * Handles args in order: year month day hour min sec tz
- */
- protected function _initializeFromArgs($args)
- {
- $tz = (isset($args[6])) ? array_pop($args) : null;
- $this->_initializeTimezone($tz);
-
- $args = array_slice($args, 0, 6);
- $keys = array('year' => 1, 'month' => 1, 'mday' => 1, 'hour' => 0, 'min' => 0, 'sec' => 0);
- $date = array_combine(array_slice(array_keys($keys), 0, count($args)), $args);
- $date = array_merge($keys, $date);
-
- $this->_initializeFromArray($date);
- }
-
- protected function _initializeFromArray($date)
- {
- if (isset($date['year']) && is_string($date['year']) && strlen($date['year']) == 2) {
- if ($date['year'] > 70) {
- $date['year'] += 1900;
- } else {
- $date['year'] += 2000;
- }
- }
-
- foreach ($date as $key => $val) {
- if (in_array($key, array('year', 'month', 'mday', 'hour', 'min', 'sec'))) {
- $this->{'_'. $key} = (int)$val;
- }
- }
-
- // If $date['day'] is present and numeric we may have been passed
- // a Horde_Form_datetime array.
- if (isset($date['day']) &&
- (string)(int)$date['day'] == $date['day']) {
- $this->_mday = (int)$date['day'];
- }
- // 'minute' key also from Horde_Form_datetime
- if (isset($date['minute']) &&
- (string)(int)$date['minute'] == $date['minute']) {
- $this->_min = (int)$date['minute'];
- }
-
- $this->_correct();
- }
-
- protected function _initializeFromObject($date)
- {
- if ($date instanceof DateTime) {
- $this->_year = (int)$date->format('Y');
- $this->_month = (int)$date->format('m');
- $this->_mday = (int)$date->format('d');
- $this->_hour = (int)$date->format('H');
- $this->_min = (int)$date->format('i');
- $this->_sec = (int)$date->format('s');
- $this->_initializeTimezone($date->getTimezone()->getName());
- } else {
- $is_horde_date = $date instanceof Horde_Date;
- foreach (array('year', 'month', 'mday', 'hour', 'min', 'sec') as $key) {
- if ($is_horde_date || isset($date->$key)) {
- $this->{'_' . $key} = (int)$date->$key;
- }
- }
- if (!$is_horde_date) {
- $this->_correct();
- } else {
- $this->_initializeTimezone($date->timezone);
- }
- }
- }
-
- protected function _initializeTimezone($timezone)
- {
- if (empty($timezone)) {
- $timezone = date_default_timezone_get();
- }
- $this->_timezone = $timezone;
- }
-
-}
-
-/**
- * @category Horde
- * @package Date
- */
-
-/**
- * Horde Date wrapper/logic class, including some calculation
- * functions.
- *
- * @category Horde
- * @package Date
- */
-class Horde_Date_Utils
-{
- /**
- * Returns whether a year is a leap year.
- *
- * @param integer $year The year.
- *
- * @return boolean True if the year is a leap year.
- */
- public static function isLeapYear($year)
- {
- if (strlen($year) != 4 || preg_match('/\D/', $year)) {
- return false;
- }
-
- return (($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0);
- }
-
- /**
- * Returns the date of the year that corresponds to the first day of the
- * given week.
- *
- * @param integer $week The week of the year to find the first day of.
- * @param integer $year The year to calculate for.
- *
- * @return Horde_Date The date of the first day of the given week.
- */
- public static function firstDayOfWeek($week, $year)
- {
- return new Horde_Date(sprintf('%04dW%02d', $year, $week));
- }
-
- /**
- * Returns the number of days in the specified month.
- *
- * @param integer $month The month
- * @param integer $year The year.
- *
- * @return integer The number of days in the month.
- */
- public static function daysInMonth($month, $year)
- {
- static $cache = array();
- if (!isset($cache[$year][$month])) {
- $date = new DateTime(sprintf('%04d-%02d-01', $year, $month));
- $cache[$year][$month] = $date->format('t');
- }
- return $cache[$year][$month];
- }
-
- /**
- * Returns a relative, natural language representation of a timestamp
- *
- * @todo Wider range of values ... maybe future time as well?
- * @todo Support minimum resolution parameter.
- *
- * @param mixed $time The time. Any format accepted by Horde_Date.
- * @param string $date_format Format to display date if timestamp is
- * more then 1 day old.
- * @param string $time_format Format to display time if timestamp is 1
- * day old.
- *
- * @return string The relative time (i.e. 2 minutes ago)
- */
- public static function relativeDateTime($time, $date_format = '%x',
- $time_format = '%X')
- {
- $date = new Horde_Date($time);
-
- $delta = time() - $date->timestamp();
- if ($delta < 60) {
- return sprintf(Horde_Date_Translation::ngettext("%d second ago", "%d seconds ago", $delta), $delta);
- }
-
- $delta = round($delta / 60);
- if ($delta < 60) {
- return sprintf(Horde_Date_Translation::ngettext("%d minute ago", "%d minutes ago", $delta), $delta);
- }
-
- $delta = round($delta / 60);
- if ($delta < 24) {
- return sprintf(Horde_Date_Translation::ngettext("%d hour ago", "%d hours ago", $delta), $delta);
- }
-
- if ($delta > 24 && $delta < 48) {
- $date = new Horde_Date($time);
- return sprintf(Horde_Date_Translation::t("yesterday at %s"), $date->strftime($time_format));
- }
-
- $delta = round($delta / 24);
- if ($delta < 7) {
- return sprintf(Horde_Date_Translation::t("%d days ago"), $delta);
- }
-
- if (round($delta / 7) < 5) {
- $delta = round($delta / 7);
- return sprintf(Horde_Date_Translation::ngettext("%d week ago", "%d weeks ago", $delta), $delta);
- }
-
- // Default to the user specified date format.
- return $date->strftime($date_format);
- }
-
- /**
- * Tries to convert strftime() formatters to date() formatters.
- *
- * Unsupported formatters will be removed.
- *
- * @param string $format A strftime() formatting string.
- *
- * @return string A date() formatting string.
- */
- public static function strftime2date($format)
- {
- $replace = array(
- '/%a/' => 'D',
- '/%A/' => 'l',
- '/%d/' => 'd',
- '/%e/' => 'j',
- '/%j/' => 'z',
- '/%u/' => 'N',
- '/%w/' => 'w',
- '/%U/' => '',
- '/%V/' => 'W',
- '/%W/' => '',
- '/%b/' => 'M',
- '/%B/' => 'F',
- '/%h/' => 'M',
- '/%m/' => 'm',
- '/%C/' => '',
- '/%g/' => '',
- '/%G/' => 'o',
- '/%y/' => 'y',
- '/%Y/' => 'Y',
- '/%H/' => 'H',
- '/%I/' => 'h',
- '/%i/' => 'g',
- '/%M/' => 'i',
- '/%p/' => 'A',
- '/%P/' => 'a',
- '/%r/' => 'h:i:s A',
- '/%R/' => 'H:i',
- '/%S/' => 's',
- '/%T/' => 'H:i:s',
- '/%X/e' => 'Horde_Date_Utils::strftime2date(Horde_Nls::getLangInfo(T_FMT))',
- '/%z/' => 'O',
- '/%Z/' => '',
- '/%c/' => '',
- '/%D/' => 'm/d/y',
- '/%F/' => 'Y-m-d',
- '/%s/' => 'U',
- '/%x/e' => 'Horde_Date_Utils::strftime2date(Horde_Nls::getLangInfo(D_FMT))',
- '/%n/' => "\n",
- '/%t/' => "\t",
- '/%%/' => '%'
- );
-
- return preg_replace(array_keys($replace), array_values($replace), $format);
- }
-
-}
diff --git a/plugins/libkolab/lib/Horde_Date_Recurrence.php b/plugins/libkolab/lib/Horde_Date_Recurrence.php
deleted file mode 100644
index 81f0857..0000000
--- a/plugins/libkolab/lib/Horde_Date_Recurrence.php
+++ /dev/null
@@ -1,1673 +0,0 @@
-<?php
-
-/**
- * This is a modified copy of Horde/Date/Recurrence.php
- * Pull the latest version of this file from the PEAR channel of the Horde
- * project at http://pear.horde.org by installing the Horde_Date package.
- */
-
-if (!class_exists('Horde_Date'))
- require_once(dirname(__FILE__) . '/Horde_Date.php');
-
-// minimal required implementation of Horde_Date_Translation to avoid a huge dependency nightmare
-class Horde_Date_Translation
-{
- function t($arg) { return $arg; }
- function ngettext($sing, $plur, $num) { return ($num > 1 ? $plur : $sing); }
-}
-
-
-/**
- * This file contains the Horde_Date_Recurrence class and according constants.
- *
- * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.horde.org/licenses/lgpl21.
- *
- * @category Horde
- * @package Date
- */
-
-/**
- * The Horde_Date_Recurrence class implements algorithms for calculating
- * recurrences of events, including several recurrence types, intervals,
- * exceptions, and conversion from and to vCalendar and iCalendar recurrence
- * rules.
- *
- * All methods expecting dates as parameters accept all values that the
- * Horde_Date constructor accepts, i.e. a timestamp, another Horde_Date
- * object, an ISO time string or a hash.
- *
- * @author Jan Schneider <jan at horde.org>
- * @category Horde
- * @package Date
- */
-class Horde_Date_Recurrence
-{
- /** No Recurrence **/
- const RECUR_NONE = 0;
-
- /** Recurs daily. */
- const RECUR_DAILY = 1;
-
- /** Recurs weekly. */
- const RECUR_WEEKLY = 2;
-
- /** Recurs monthly on the same date. */
- const RECUR_MONTHLY_DATE = 3;
-
- /** Recurs monthly on the same week day. */
- const RECUR_MONTHLY_WEEKDAY = 4;
-
- /** Recurs yearly on the same date. */
- const RECUR_YEARLY_DATE = 5;
-
- /** Recurs yearly on the same day of the year. */
- const RECUR_YEARLY_DAY = 6;
-
- /** Recurs yearly on the same week day. */
- const RECUR_YEARLY_WEEKDAY = 7;
-
- /**
- * The start time of the event.
- *
- * @var Horde_Date
- */
- public $start;
-
- /**
- * The end date of the recurrence interval.
- *
- * @var Horde_Date
- */
- public $recurEnd = null;
-
- /**
- * The number of recurrences.
- *
- * @var integer
- */
- public $recurCount = null;
-
- /**
- * The type of recurrence this event follows. RECUR_* constant.
- *
- * @var integer
- */
- public $recurType = self::RECUR_NONE;
-
- /**
- * The length of time between recurrences. The time unit depends on the
- * recurrence type.
- *
- * @var integer
- */
- public $recurInterval = 1;
-
- /**
- * Any additional recurrence data.
- *
- * @var integer
- */
- public $recurData = null;
-
- /**
- * BYDAY recurrence number
- *
- * @var integer
- */
- public $recurNthDay = null;
-
- /**
- * BYMONTH recurrence data
- *
- * @var array
- */
- public $recurMonths = array();
-
- /**
- * All the exceptions from recurrence for this event.
- *
- * @var array
- */
- public $exceptions = array();
-
- /**
- * All the dates this recurrence has been marked as completed.
- *
- * @var array
- */
- public $completions = array();
-
- /**
- * Constructor.
- *
- * @param Horde_Date $start Start of the recurring event.
- */
- public function __construct($start)
- {
- $this->start = new Horde_Date($start);
- }
-
- /**
- * Resets the class properties.
- */
- public function reset()
- {
- $this->recurEnd = null;
- $this->recurCount = null;
- $this->recurType = self::RECUR_NONE;
- $this->recurInterval = 1;
- $this->recurData = null;
- $this->exceptions = array();
- $this->completions = array();
- }
-
- /**
- * Checks if this event recurs on a given day of the week.
- *
- * @param integer $dayMask A mask consisting of Horde_Date::MASK_*
- * constants specifying the day(s) to check.
- *
- * @return boolean True if this event recurs on the given day(s).
- */
- public function recurOnDay($dayMask)
- {
- return ($this->recurData & $dayMask);
- }
-
- /**
- * Specifies the days this event recurs on.
- *
- * @param integer $dayMask A mask consisting of Horde_Date::MASK_*
- * constants specifying the day(s) to recur on.
- */
- public function setRecurOnDay($dayMask)
- {
- $this->recurData = $dayMask;
- }
-
- /**
- *
- * @param integer $nthDay The nth weekday of month to repeat events on
- */
- public function setRecurNthWeekday($nth)
- {
- $this->recurNthDay = (int)$nth;
- }
-
- /**
- *
- * @return integer The nth weekday of month to repeat events.
- */
- public function getRecurNthWeekday()
- {
- return isset($this->recurNthDay) ? $this->recurNthDay : ceil($this->start->mday / 7);
- }
-
- /**
- * Specifies the months for yearly (weekday) recurrence
- *
- * @param array $months List of months (integers) this event recurs on.
- */
- function setRecurByMonth($months)
- {
- $this->recurMonths = (array)$months;
- }
-
- /**
- * Returns a list of months this yearly event recurs on
- *
- * @return array List of months (integers) this event recurs on.
- */
- function getRecurByMonth()
- {
- return $this->recurMonths;
- }
-
- /**
- * Returns the days this event recurs on.
- *
- * @return integer A mask consisting of Horde_Date::MASK_* constants
- * specifying the day(s) this event recurs on.
- */
- public function getRecurOnDays()
- {
- return $this->recurData;
- }
-
- /**
- * Returns whether this event has a specific recurrence type.
- *
- * @param integer $recurrence RECUR_* constant of the
- * recurrence type to check for.
- *
- * @return boolean True if the event has the specified recurrence type.
- */
- public function hasRecurType($recurrence)
- {
- return ($recurrence == $this->recurType);
- }
-
- /**
- * Sets a recurrence type for this event.
- *
- * @param integer $recurrence A RECUR_* constant.
- */
- public function setRecurType($recurrence)
- {
- $this->recurType = $recurrence;
- }
-
- /**
- * Returns recurrence type of this event.
- *
- * @return integer A RECUR_* constant.
- */
- public function getRecurType()
- {
- return $this->recurType;
- }
-
- /**
- * Returns a description of this event's recurring type.
- *
- * @return string Human readable recurring type.
- */
- public function getRecurName()
- {
- switch ($this->getRecurType()) {
- case self::RECUR_NONE: return Horde_Date_Translation::t("No recurrence");
- case self::RECUR_DAILY: return Horde_Date_Translation::t("Daily");
- case self::RECUR_WEEKLY: return Horde_Date_Translation::t("Weekly");
- case self::RECUR_MONTHLY_DATE:
- case self::RECUR_MONTHLY_WEEKDAY: return Horde_Date_Translation::t("Monthly");
- case self::RECUR_YEARLY_DATE:
- case self::RECUR_YEARLY_DAY:
- case self::RECUR_YEARLY_WEEKDAY: return Horde_Date_Translation::t("Yearly");
- }
- }
-
- /**
- * Sets the length of time between recurrences of this event.
- *
- * @param integer $interval The time between recurrences.
- */
- public function setRecurInterval($interval)
- {
- if ($interval > 0) {
- $this->recurInterval = $interval;
- }
- }
-
- /**
- * Retrieves the length of time between recurrences of this event.
- *
- * @return integer The number of seconds between recurrences.
- */
- public function getRecurInterval()
- {
- return $this->recurInterval;
- }
-
- /**
- * Sets the number of recurrences of this event.
- *
- * @param integer $count The number of recurrences.
- */
- public function setRecurCount($count)
- {
- if ($count > 0) {
- $this->recurCount = (int)$count;
- // Recurrence counts and end dates are mutually exclusive.
- $this->recurEnd = null;
- } else {
- $this->recurCount = null;
- }
- }
-
- /**
- * Retrieves the number of recurrences of this event.
- *
- * @return integer The number recurrences.
- */
- public function getRecurCount()
- {
- return $this->recurCount;
- }
-
- /**
- * Returns whether this event has a recurrence with a fixed count.
- *
- * @return boolean True if this recurrence has a fixed count.
- */
- public function hasRecurCount()
- {
- return isset($this->recurCount);
- }
-
- /**
- * Sets the start date of the recurrence interval.
- *
- * @param Horde_Date $start The recurrence start.
- */
- public function setRecurStart($start)
- {
- $this->start = clone $start;
- }
-
- /**
- * Retrieves the start date of the recurrence interval.
- *
- * @return Horde_Date The recurrence start.
- */
- public function getRecurStart()
- {
- return $this->start;
- }
-
- /**
- * Sets the end date of the recurrence interval.
- *
- * @param Horde_Date $end The recurrence end.
- */
- public function setRecurEnd($end)
- {
- if (!empty($end)) {
- // Recurrence counts and end dates are mutually exclusive.
- $this->recurCount = null;
- $this->recurEnd = clone $end;
- } else {
- $this->recurEnd = $end;
- }
- }
-
- /**
- * Retrieves the end date of the recurrence interval.
- *
- * @return Horde_Date The recurrence end.
- */
- public function getRecurEnd()
- {
- return $this->recurEnd;
- }
-
- /**
- * Returns whether this event has a recurrence end.
- *
- * @return boolean True if this recurrence ends.
- */
- public function hasRecurEnd()
- {
- return isset($this->recurEnd) && isset($this->recurEnd->year) &&
- $this->recurEnd->year != 9999;
- }
-
- /**
- * Finds the next recurrence of this event that's after $afterDate.
- *
- * @param Horde_Date|string $after Return events after this date.
- *
- * @return Horde_Date|boolean The date of the next recurrence or false
- * if the event does not recur after
- * $afterDate.
- */
- public function nextRecurrence($after)
- {
- if (!($after instanceof Horde_Date)) {
- $after = new Horde_Date($after);
- } else {
- $after = clone($after);
- }
-
- // Make sure $after and $this->start are in the same TZ
- $after->setTimezone($this->start->timezone);
- if ($this->start->compareDateTime($after) >= 0) {
- return clone $this->start;
- }
-
- if ($this->recurInterval == 0) {
- return false;
- }
-
- switch ($this->getRecurType()) {
- case self::RECUR_DAILY:
- $diff = $this->start->diff($after);
- $recur = ceil($diff / $this->recurInterval);
- if ($this->recurCount && $recur >= $this->recurCount) {
- return false;
- }
-
- $recur *= $this->recurInterval;
- $next = $this->start->add(array('day' => $recur));
- if ((!$this->hasRecurEnd() ||
- $next->compareDateTime($this->recurEnd) <= 0) &&
- $next->compareDateTime($after) >= 0) {
- return $next;
- }
- break;
-
- case self::RECUR_WEEKLY:
- if (empty($this->recurData)) {
- return false;
- }
-
- $start_week = Horde_Date_Utils::firstDayOfWeek($this->start->format('W'),
- $this->start->year);
- $start_week->timezone = $this->start->timezone;
- $start_week->hour = $this->start->hour;
- $start_week->min = $this->start->min;
- $start_week->sec = $this->start->sec;
-
- // Make sure we are not at the ISO-8601 first week of year while
- // still in month 12...OR in the ISO-8601 last week of year while
- // in month 1 and adjust the year accordingly.
- $week = $after->format('W');
- if ($week == 1 && $after->month == 12) {
- $theYear = $after->year + 1;
- } elseif ($week >= 52 && $after->month == 1) {
- $theYear = $after->year - 1;
- } else {
- $theYear = $after->year;
- }
-
- $after_week = Horde_Date_Utils::firstDayOfWeek($week, $theYear);
- $after_week->timezone = $this->start->timezone;
- $after_week_end = clone $after_week;
- $after_week_end->mday += 7;
-
- $diff = $start_week->diff($after_week);
- $interval = $this->recurInterval * 7;
- $repeats = floor($diff / $interval);
- if ($diff % $interval < 7) {
- $recur = $diff;
- } else {
- /**
- * If the after_week is not in the first week interval the
- * search needs to skip ahead a complete interval. The way it is
- * calculated here means that an event that occurs every second
- * week on Monday and Wednesday with the event actually starting
- * on Tuesday or Wednesday will only have one incidence in the
- * first week.
- */
- $recur = $interval * ($repeats + 1);
- }
-
- if ($this->hasRecurCount()) {
- $recurrences = 0;
- /**
- * Correct the number of recurrences by the number of events
- * that lay between the start of the start week and the
- * recurrence start.
- */
- $next = clone $start_week;
- while ($next->compareDateTime($this->start) < 0) {
- if ($this->recurOnDay((int)pow(2, $next->dayOfWeek()))) {
- $recurrences--;
- }
- ++$next->mday;
- }
- if ($repeats > 0) {
- $weekdays = $this->recurData;
- $total_recurrences_per_week = 0;
- while ($weekdays > 0) {
- if ($weekdays % 2) {
- $total_recurrences_per_week++;
- }
- $weekdays = ($weekdays - ($weekdays % 2)) / 2;
- }
- $recurrences += $total_recurrences_per_week * $repeats;
- }
- }
-
- $next = clone $start_week;
- $next->mday += $recur;
- while ($next->compareDateTime($after) < 0 &&
- $next->compareDateTime($after_week_end) < 0) {
- if ($this->hasRecurCount()
- && $next->compareDateTime($after) < 0
- && $this->recurOnDay((int)pow(2, $next->dayOfWeek()))) {
- $recurrences++;
- }
- ++$next->mday;
- }
- if ($this->hasRecurCount() &&
- $recurrences >= $this->recurCount) {
- return false;
- }
- if (!$this->hasRecurEnd() ||
- $next->compareDateTime($this->recurEnd) <= 0) {
- if ($next->compareDateTime($after_week_end) >= 0) {
- return $this->nextRecurrence($after_week_end);
- }
- while (!$this->recurOnDay((int)pow(2, $next->dayOfWeek())) &&
- $next->compareDateTime($after_week_end) < 0) {
- ++$next->mday;
- }
- if (!$this->hasRecurEnd() ||
- $next->compareDateTime($this->recurEnd) <= 0) {
- if ($next->compareDateTime($after_week_end) >= 0) {
- return $this->nextRecurrence($after_week_end);
- } else {
- return $next;
- }
- }
- }
- break;
-
- case self::RECUR_MONTHLY_DATE:
- $start = clone $this->start;
- if ($after->compareDateTime($start) < 0) {
- $after = clone $start;
- } else {
- $after = clone $after;
- }
-
- // If we're starting past this month's recurrence of the event,
- // look in the next month on the day the event recurs.
- if ($after->mday > $start->mday) {
- ++$after->month;
- $after->mday = $start->mday;
- }
-
- // Adjust $start to be the first match.
- $offset = ($after->month - $start->month) + ($after->year - $start->year) * 12;
- $offset = floor(($offset + $this->recurInterval - 1) / $this->recurInterval) * $this->recurInterval;
-
- if ($this->recurCount &&
- ($offset / $this->recurInterval) >= $this->recurCount) {
- return false;
- }
- $start->month += $offset;
- $count = $offset / $this->recurInterval;
-
- do {
- if ($this->recurCount &&
- $count++ >= $this->recurCount) {
- return false;
- }
-
- // Bail if we've gone past the end of recurrence.
- if ($this->hasRecurEnd() &&
- $this->recurEnd->compareDateTime($start) < 0) {
- return false;
- }
- if ($start->isValid()) {
- return $start;
- }
-
- // If the interval is 12, and the date isn't valid, then we
- // need to see if February 29th is an option. If not, then the
- // event will _never_ recur, and we need to stop checking to
- // avoid an infinite loop.
- if ($this->recurInterval == 12 && ($start->month != 2 || $start->mday > 29)) {
- return false;
- }
-
- // Add the recurrence interval.
- $start->month += $this->recurInterval;
- } while (true);
-
- break;
-
- case self::RECUR_MONTHLY_WEEKDAY:
- // Start with the start date of the event.
- $estart = clone $this->start;
-
- // What day of the week, and week of the month, do we recur on?
- if (isset($this->recurNthDay)) {
- $nth = $this->recurNthDay;
- $weekday = log($this->recurData, 2);
- } else {
- $nth = ceil($this->start->mday / 7);
- $weekday = $estart->dayOfWeek();
- }
-
- // Adjust $estart to be the first candidate.
- $offset = ($after->month - $estart->month) + ($after->year - $estart->year) * 12;
- $offset = floor(($offset + $this->recurInterval - 1) / $this->recurInterval) * $this->recurInterval;
-
- // Adjust our working date until it's after $after.
- $estart->month += $offset - $this->recurInterval;
-
- $count = $offset / $this->recurInterval;
- do {
- if ($this->recurCount &&
- $count++ >= $this->recurCount) {
- return false;
- }
-
- $estart->month += $this->recurInterval;
-
- $next = clone $estart;
- $next->setNthWeekday($weekday, $nth);
-
- if ($next->compareDateTime($after) < 0) {
- // We haven't made it past $after yet, try again.
- continue;
- }
- if ($this->hasRecurEnd() &&
- $next->compareDateTime($this->recurEnd) > 0) {
- // We've gone past the end of recurrence; we can give up
- // now.
- return false;
- }
-
- // We have a candidate to return.
- break;
- } while (true);
-
- return $next;
-
- case self::RECUR_YEARLY_DATE:
- // Start with the start date of the event.
- $estart = clone $this->start;
- $after = clone $after;
-
- if ($after->month > $estart->month ||
- ($after->month == $estart->month && $after->mday > $estart->mday)) {
- ++$after->year;
- $after->month = $estart->month;
- $after->mday = $estart->mday;
- }
-
- // Seperate case here for February 29th
- if ($estart->month == 2 && $estart->mday == 29) {
- while (!Horde_Date_Utils::isLeapYear($after->year)) {
- ++$after->year;
- }
- }
-
- // Adjust $estart to be the first candidate.
- $offset = $after->year - $estart->year;
- if ($offset > 0) {
- $offset = floor(($offset + $this->recurInterval - 1) / $this->recurInterval) * $this->recurInterval;
- $estart->year += $offset;
- }
-
- // We've gone past the end of recurrence; give up.
- if ($this->recurCount &&
- $offset >= $this->recurCount) {
- return false;
- }
- if ($this->hasRecurEnd() &&
- $this->recurEnd->compareDateTime($estart) < 0) {
- return false;
- }
-
- return $estart;
-
- case self::RECUR_YEARLY_DAY:
- // Check count first.
- $dayofyear = $this->start->dayOfYear();
- $count = ($after->year - $this->start->year) / $this->recurInterval + 1;
- if ($this->recurCount &&
- ($count > $this->recurCount ||
- ($count == $this->recurCount &&
- $after->dayOfYear() > $dayofyear))) {
- return false;
- }
-
- // Start with a rough interval.
- $estart = clone $this->start;
- $estart->year += floor($count - 1) * $this->recurInterval;
-
- // Now add the difference to the required day of year.
- $estart->mday += $dayofyear - $estart->dayOfYear();
-
- // Add an interval if the estimation was wrong.
- if ($estart->compareDate($after) < 0) {
- $estart->year += $this->recurInterval;
- $estart->mday += $dayofyear - $estart->dayOfYear();
- }
-
- // We've gone past the end of recurrence; give up.
- if ($this->hasRecurEnd() &&
- $this->recurEnd->compareDateTime($estart) < 0) {
- return false;
- }
-
- return $estart;
-
- case self::RECUR_YEARLY_WEEKDAY:
- // Start with the start date of the event.
- $estart = clone $this->start;
-
- // What day of the week, and week of the month, do we recur on?
- if (isset($this->recurNthDay)) {
- $nth = $this->recurNthDay;
- $weekday = log($this->recurData, 2);
- } else {
- $nth = ceil($this->start->mday / 7);
- $weekday = $estart->dayOfWeek();
- }
-
- // Adjust $estart to be the first candidate.
- $offset = floor(($after->year - $estart->year + $this->recurInterval - 1) / $this->recurInterval) * $this->recurInterval;
-
- // Adjust our working date until it's after $after.
- $estart->year += $offset - $this->recurInterval;
-
- $count = $offset / $this->recurInterval;
- do {
- if ($this->recurCount &&
- $count++ >= $this->recurCount) {
- return false;
- }
-
- $estart->year += $this->recurInterval;
-
- $next = clone $estart;
- $next->setNthWeekday($weekday, $nth);
-
- if ($next->compareDateTime($after) < 0) {
- // We haven't made it past $after yet, try again.
- continue;
- }
- if ($this->hasRecurEnd() &&
- $next->compareDateTime($this->recurEnd) > 0) {
- // We've gone past the end of recurrence; we can give up
- // now.
- return false;
- }
-
- // We have a candidate to return.
- break;
- } while (true);
-
- return $next;
- }
-
- // We didn't find anything, the recurType was bad, or something else
- // went wrong - return false.
- return false;
- }
-
- /**
- * Returns whether this event has any date that matches the recurrence
- * rules and is not an exception.
- *
- * @return boolean True if an active recurrence exists.
- */
- public function hasActiveRecurrence()
- {
- if (!$this->hasRecurEnd()) {
- return true;
- }
-
- $next = $this->nextRecurrence(new Horde_Date($this->start));
- while (is_object($next)) {
- if (!$this->hasException($next->year, $next->month, $next->mday) &&
- !$this->hasCompletion($next->year, $next->month, $next->mday)) {
- return true;
- }
-
- $next = $this->nextRecurrence($next->add(array('day' => 1)));
- }
-
- return false;
- }
-
- /**
- * Returns the next active recurrence.
- *
- * @param Horde_Date $afterDate Return events after this date.
- *
- * @return Horde_Date|boolean The date of the next active
- * recurrence or false if the event
- * has no active recurrence after
- * $afterDate.
- */
- public function nextActiveRecurrence($afterDate)
- {
- $next = $this->nextRecurrence($afterDate);
- while (is_object($next)) {
- if (!$this->hasException($next->year, $next->month, $next->mday) &&
- !$this->hasCompletion($next->year, $next->month, $next->mday)) {
- return $next;
- }
- $next->mday++;
- $next = $this->nextRecurrence($next);
- }
-
- return false;
- }
-
- /**
- * Adds an exception to a recurring event.
- *
- * @param integer $year The year of the execption.
- * @param integer $month The month of the execption.
- * @param integer $mday The day of the month of the exception.
- */
- public function addException($year, $month, $mday)
- {
- $this->exceptions[] = sprintf('%04d%02d%02d', $year, $month, $mday);
- }
-
- /**
- * Deletes an exception from a recurring event.
- *
- * @param integer $year The year of the execption.
- * @param integer $month The month of the execption.
- * @param integer $mday The day of the month of the exception.
- */
- public function deleteException($year, $month, $mday)
- {
- $key = array_search(sprintf('%04d%02d%02d', $year, $month, $mday), $this->exceptions);
- if ($key !== false) {
- unset($this->exceptions[$key]);
- }
- }
-
- /**
- * Checks if an exception exists for a given reccurence of an event.
- *
- * @param integer $year The year of the reucrance.
- * @param integer $month The month of the reucrance.
- * @param integer $mday The day of the month of the reucrance.
- *
- * @return boolean True if an exception exists for the given date.
- */
- public function hasException($year, $month, $mday)
- {
- return in_array(sprintf('%04d%02d%02d', $year, $month, $mday),
- $this->getExceptions());
- }
-
- /**
- * Retrieves all the exceptions for this event.
- *
- * @return array Array containing the dates of all the exceptions in
- * YYYYMMDD form.
- */
- public function getExceptions()
- {
- return $this->exceptions;
- }
-
- /**
- * Adds a completion to a recurring event.
- *
- * @param integer $year The year of the execption.
- * @param integer $month The month of the execption.
- * @param integer $mday The day of the month of the completion.
- */
- public function addCompletion($year, $month, $mday)
- {
- $this->completions[] = sprintf('%04d%02d%02d', $year, $month, $mday);
- }
-
- /**
- * Deletes a completion from a recurring event.
- *
- * @param integer $year The year of the execption.
- * @param integer $month The month of the execption.
- * @param integer $mday The day of the month of the completion.
- */
- public function deleteCompletion($year, $month, $mday)
- {
- $key = array_search(sprintf('%04d%02d%02d', $year, $month, $mday), $this->completions);
- if ($key !== false) {
- unset($this->completions[$key]);
- }
- }
-
- /**
- * Checks if a completion exists for a given reccurence of an event.
- *
- * @param integer $year The year of the reucrance.
- * @param integer $month The month of the recurrance.
- * @param integer $mday The day of the month of the recurrance.
- *
- * @return boolean True if a completion exists for the given date.
- */
- public function hasCompletion($year, $month, $mday)
- {
- return in_array(sprintf('%04d%02d%02d', $year, $month, $mday),
- $this->getCompletions());
- }
-
- /**
- * Retrieves all the completions for this event.
- *
- * @return array Array containing the dates of all the completions in
- * YYYYMMDD form.
- */
- public function getCompletions()
- {
- return $this->completions;
- }
-
- /**
- * Parses a vCalendar 1.0 recurrence rule.
- *
- * @link http://www.imc.org/pdi/vcal-10.txt
- * @link http://www.shuchow.com/vCalAddendum.html
- *
- * @param string $rrule A vCalendar 1.0 conform RRULE value.
- */
- public function fromRRule10($rrule)
- {
- $this->reset();
-
- if (!$rrule) {
- return;
- }
-
- if (!preg_match('/([A-Z]+)(\d+)?(.*)/', $rrule, $matches)) {
- // No recurrence data - event does not recur.
- $this->setRecurType(self::RECUR_NONE);
- }
-
- // Always default the recurInterval to 1.
- $this->setRecurInterval(!empty($matches[2]) ? $matches[2] : 1);
-
- $remainder = trim($matches[3]);
-
- switch ($matches[1]) {
- case 'D':
- $this->setRecurType(self::RECUR_DAILY);
- break;
-
- case 'W':
- $this->setRecurType(self::RECUR_WEEKLY);
- if (!empty($remainder)) {
- $mask = 0;
- while (preg_match('/^ ?[A-Z]{2} ?/', $remainder, $matches)) {
- $day = trim($matches[0]);
- $remainder = substr($remainder, strlen($matches[0]));
- $mask |= $maskdays[$day];
- }
- $this->setRecurOnDay($mask);
- } else {
- // Recur on the day of the week of the original recurrence.
- $maskdays = array(
- Horde_Date::DATE_SUNDAY => Horde_Date::MASK_SUNDAY,
- Horde_Date::DATE_MONDAY => Horde_Date::MASK_MONDAY,
- Horde_Date::DATE_TUESDAY => Horde_Date::MASK_TUESDAY,
- Horde_Date::DATE_WEDNESDAY => Horde_Date::MASK_WEDNESDAY,
- Horde_Date::DATE_THURSDAY => Horde_Date::MASK_THURSDAY,
- Horde_Date::DATE_FRIDAY => Horde_Date::MASK_FRIDAY,
- Horde_Date::DATE_SATURDAY => Horde_Date::MASK_SATURDAY,
- );
- $this->setRecurOnDay($maskdays[$this->start->dayOfWeek()]);
- }
- break;
-
- case 'MP':
- $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
- break;
-
- case 'MD':
- $this->setRecurType(self::RECUR_MONTHLY_DATE);
- break;
-
- case 'YM':
- $this->setRecurType(self::RECUR_YEARLY_DATE);
- break;
-
- case 'YD':
- $this->setRecurType(self::RECUR_YEARLY_DAY);
- break;
- }
-
- // We don't support modifiers at the moment, strip them.
- while ($remainder && !preg_match('/^(#\d+|\d{8})($| |T\d{6})/', $remainder)) {
- $remainder = substr($remainder, 1);
- }
- if (!empty($remainder)) {
- if (strpos($remainder, '#') === 0) {
- $this->setRecurCount(substr($remainder, 1));
- } else {
- list($year, $month, $mday) = sscanf($remainder, '%04d%02d%02d');
- $this->setRecurEnd(new Horde_Date(array('year' => $year,
- 'month' => $month,
- 'mday' => $mday,
- 'hour' => 23,
- 'min' => 59,
- 'sec' => 59)));
- }
- }
- }
-
- /**
- * Creates a vCalendar 1.0 recurrence rule.
- *
- * @link http://www.imc.org/pdi/vcal-10.txt
- * @link http://www.shuchow.com/vCalAddendum.html
- *
- * @param Horde_Icalendar $calendar A Horde_Icalendar object instance.
- *
- * @return string A vCalendar 1.0 conform RRULE value.
- */
- public function toRRule10($calendar)
- {
- switch ($this->recurType) {
- case self::RECUR_NONE:
- return '';
-
- case self::RECUR_DAILY:
- $rrule = 'D' . $this->recurInterval;
- break;
-
- case self::RECUR_WEEKLY:
- $rrule = 'W' . $this->recurInterval;
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
-
- for ($i = 0; $i <= 7; ++$i) {
- if ($this->recurOnDay(pow(2, $i))) {
- $rrule .= ' ' . $vcaldays[$i];
- }
- }
- break;
-
- case self::RECUR_MONTHLY_DATE:
- $rrule = 'MD' . $this->recurInterval . ' ' . trim($this->start->mday);
- break;
-
- case self::RECUR_MONTHLY_WEEKDAY:
- $nth_weekday = (int)($this->start->mday / 7);
- if (($this->start->mday % 7) > 0) {
- $nth_weekday++;
- }
-
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- $rrule = 'MP' . $this->recurInterval . ' ' . $nth_weekday . '+ ' . $vcaldays[$this->start->dayOfWeek()];
-
- break;
-
- case self::RECUR_YEARLY_DATE:
- $rrule = 'YM' . $this->recurInterval . ' ' . trim($this->start->month);
- break;
-
- case self::RECUR_YEARLY_DAY:
- $rrule = 'YD' . $this->recurInterval . ' ' . $this->start->dayOfYear();
- break;
-
- default:
- return '';
- }
-
- if ($this->hasRecurEnd()) {
- $recurEnd = clone $this->recurEnd;
- return $rrule . ' ' . $calendar->_exportDateTime($recurEnd);
- }
-
- return $rrule . ' #' . (int)$this->getRecurCount();
- }
-
- /**
- * Parses an iCalendar 2.0 recurrence rule.
- *
- * @link http://rfc.net/rfc2445.html#s4.3.10
- * @link http://rfc.net/rfc2445.html#s4.8.5
- * @link http://www.shuchow.com/vCalAddendum.html
- *
- * @param string $rrule An iCalendar 2.0 conform RRULE value.
- */
- public function fromRRule20($rrule)
- {
- $this->reset();
-
- // Parse the recurrence rule into keys and values.
- $rdata = array();
- $parts = explode(';', $rrule);
- foreach ($parts as $part) {
- list($key, $value) = explode('=', $part, 2);
- $rdata[strtoupper($key)] = $value;
- }
-
- if (isset($rdata['FREQ'])) {
- // Always default the recurInterval to 1.
- $this->setRecurInterval(isset($rdata['INTERVAL']) ? $rdata['INTERVAL'] : 1);
-
- $maskdays = array(
- 'SU' => Horde_Date::MASK_SUNDAY,
- 'MO' => Horde_Date::MASK_MONDAY,
- 'TU' => Horde_Date::MASK_TUESDAY,
- 'WE' => Horde_Date::MASK_WEDNESDAY,
- 'TH' => Horde_Date::MASK_THURSDAY,
- 'FR' => Horde_Date::MASK_FRIDAY,
- 'SA' => Horde_Date::MASK_SATURDAY,
- );
-
- switch (strtoupper($rdata['FREQ'])) {
- case 'DAILY':
- $this->setRecurType(self::RECUR_DAILY);
- break;
-
- case 'WEEKLY':
- $this->setRecurType(self::RECUR_WEEKLY);
- if (isset($rdata['BYDAY'])) {
- $days = explode(',', $rdata['BYDAY']);
- $mask = 0;
- foreach ($days as $day) {
- $mask |= $maskdays[$day];
- }
- $this->setRecurOnDay($mask);
- } else {
- // Recur on the day of the week of the original
- // recurrence.
- $maskdays = array(
- Horde_Date::DATE_SUNDAY => Horde_Date::MASK_SUNDAY,
- Horde_Date::DATE_MONDAY => Horde_Date::MASK_MONDAY,
- Horde_Date::DATE_TUESDAY => Horde_Date::MASK_TUESDAY,
- Horde_Date::DATE_WEDNESDAY => Horde_Date::MASK_WEDNESDAY,
- Horde_Date::DATE_THURSDAY => Horde_Date::MASK_THURSDAY,
- Horde_Date::DATE_FRIDAY => Horde_Date::MASK_FRIDAY,
- Horde_Date::DATE_SATURDAY => Horde_Date::MASK_SATURDAY);
- $this->setRecurOnDay($maskdays[$this->start->dayOfWeek()]);
- }
- break;
-
- case 'MONTHLY':
- if (isset($rdata['BYDAY'])) {
- $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
- if (preg_match('/(-?[1-4])([A-Z]+)/', $rdata['BYDAY'], $m)) {
- $this->setRecurOnDay($maskdays[$m[2]]);
- $this->setRecurNthWeekday($m[1]);
- }
- } else {
- $this->setRecurType(self::RECUR_MONTHLY_DATE);
- }
- break;
-
- case 'YEARLY':
- if (isset($rdata['BYYEARDAY'])) {
- $this->setRecurType(self::RECUR_YEARLY_DAY);
- } elseif (isset($rdata['BYDAY'])) {
- $this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
- if (preg_match('/(-?[1-4])([A-Z]+)/', $rdata['BYDAY'], $m)) {
- $this->setRecurOnDay($maskdays[$m[2]]);
- $this->setRecurNthWeekday($m[1]);
- }
- if ($rdata['BYMONTH']) {
- $months = explode(',', $rdata['BYMONTH']);
- $this->setRecurByMonth($months);
- }
- } else {
- $this->setRecurType(self::RECUR_YEARLY_DATE);
- }
- break;
- }
-
- if (isset($rdata['UNTIL'])) {
- list($year, $month, $mday) = sscanf($rdata['UNTIL'],
- '%04d%02d%02d');
- $this->setRecurEnd(new Horde_Date(array('year' => $year,
- 'month' => $month,
- 'mday' => $mday,
- 'hour' => 23,
- 'min' => 59,
- 'sec' => 59)));
- }
- if (isset($rdata['COUNT'])) {
- $this->setRecurCount($rdata['COUNT']);
- }
- } else {
- // No recurrence data - event does not recur.
- $this->setRecurType(self::RECUR_NONE);
- }
- }
-
- /**
- * Creates an iCalendar 2.0 recurrence rule.
- *
- * @link http://rfc.net/rfc2445.html#s4.3.10
- * @link http://rfc.net/rfc2445.html#s4.8.5
- * @link http://www.shuchow.com/vCalAddendum.html
- *
- * @param Horde_Icalendar $calendar A Horde_Icalendar object instance.
- *
- * @return string An iCalendar 2.0 conform RRULE value.
- */
- public function toRRule20($calendar)
- {
- switch ($this->recurType) {
- case self::RECUR_NONE:
- return '';
-
- case self::RECUR_DAILY:
- $rrule = 'FREQ=DAILY;INTERVAL=' . $this->recurInterval;
- break;
-
- case self::RECUR_WEEKLY:
- $rrule = 'FREQ=WEEKLY;INTERVAL=' . $this->recurInterval . ';BYDAY=';
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
-
- for ($i = $flag = 0; $i <= 7; ++$i) {
- if ($this->recurOnDay(pow(2, $i))) {
- if ($flag) {
- $rrule .= ',';
- }
- $rrule .= $vcaldays[$i];
- $flag = true;
- }
- }
- break;
-
- case self::RECUR_MONTHLY_DATE:
- $rrule = 'FREQ=MONTHLY;INTERVAL=' . $this->recurInterval;
- break;
-
- case self::RECUR_MONTHLY_WEEKDAY:
- if (isset($this->recurNthDay)) {
- $nth_weekday = $this->recurNthDay;
- $day_of_week = log($this->recurData, 2);
- } else {
- $day_of_week = $this->start->dayOfWeek();
- $nth_weekday = (int)($this->start->mday / 7);
- if (($this->start->mday % 7) > 0) {
- $nth_weekday++;
- }
- }
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- $rrule = 'FREQ=MONTHLY;INTERVAL=' . $this->recurInterval
- . ';BYDAY=' . $nth_weekday . $vcaldays[$day_of_week];
- break;
-
- case self::RECUR_YEARLY_DATE:
- $rrule = 'FREQ=YEARLY;INTERVAL=' . $this->recurInterval;
- break;
-
- case self::RECUR_YEARLY_DAY:
- $rrule = 'FREQ=YEARLY;INTERVAL=' . $this->recurInterval
- . ';BYYEARDAY=' . $this->start->dayOfYear();
- break;
-
- case self::RECUR_YEARLY_WEEKDAY:
- if (isset($this->recurNthDay)) {
- $nth_weekday = $this->recurNthDay;
- $day_of_week = log($this->recurData, 2);
- } else {
- $day_of_week = $this->start->dayOfWeek();
- $nth_weekday = (int)($this->start->mday / 7);
- if (($this->start->mday % 7) > 0) {
- $nth_weekday++;
- }
- }
- $months = !empty($this->recurMonths) ? join(',', $this->recurMonths) : $this->start->month;
- $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
- $rrule = 'FREQ=YEARLY;INTERVAL=' . $this->recurInterval
- . ';BYDAY='
- . $nth_weekday
- . $vcaldays[$day_of_week]
- . ';BYMONTH=' . $this->start->month;
- break;
- }
-
- if ($this->hasRecurEnd()) {
- $recurEnd = clone $this->recurEnd;
- $rrule .= ';UNTIL=' . $calendar->_exportDateTime($recurEnd);
- }
- if ($count = $this->getRecurCount()) {
- $rrule .= ';COUNT=' . $count;
- }
- return $rrule;
- }
-
- /**
- * Parses the recurrence data from a hash.
- *
- * @param array $hash The hash to convert.
- *
- * @return boolean True if the hash seemed valid, false otherwise.
- */
- public function fromHash($hash)
- {
- $this->reset();
-
- if (!isset($hash['interval']) || !isset($hash['cycle'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- $this->setRecurInterval((int)$hash['interval']);
-
- $month2number = array(
- 'january' => 1,
- 'february' => 2,
- 'march' => 3,
- 'april' => 4,
- 'may' => 5,
- 'june' => 6,
- 'july' => 7,
- 'august' => 8,
- 'september' => 9,
- 'october' => 10,
- 'november' => 11,
- 'december' => 12,
- );
-
- $parse_day = false;
- $set_daymask = false;
- $update_month = false;
- $update_daynumber = false;
- $update_weekday = false;
- $nth_weekday = -1;
-
- switch ($hash['cycle']) {
- case 'daily':
- $this->setRecurType(self::RECUR_DAILY);
- break;
-
- case 'weekly':
- $this->setRecurType(self::RECUR_WEEKLY);
- $parse_day = true;
- $set_daymask = true;
- break;
-
- case 'monthly':
- if (!isset($hash['daynumber'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- switch ($hash['type']) {
- case 'daynumber':
- $this->setRecurType(self::RECUR_MONTHLY_DATE);
- $update_daynumber = true;
- break;
-
- case 'weekday':
- $this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
- $this->setRecurNthWeekday($hash['daynumber']);
- $parse_day = true;
- $set_daymask = true;
- break;
- }
- break;
-
- case 'yearly':
- if (!isset($hash['type'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- switch ($hash['type']) {
- case 'monthday':
- $this->setRecurType(self::RECUR_YEARLY_DATE);
- $update_month = true;
- $update_daynumber = true;
- break;
-
- case 'yearday':
- if (!isset($hash['month'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- $this->setRecurType(self::RECUR_YEARLY_DAY);
- // Start counting days in January.
- $hash['month'] = 'january';
- $update_month = true;
- $update_daynumber = true;
- break;
-
- case 'weekday':
- if (!isset($hash['daynumber'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- $this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
- $this->setRecurNthWeekday($hash['daynumber']);
- $parse_day = true;
- $set_daymask = true;
-
- if ($hash['month'] && isset($month2number[$hash['month']])) {
- $this->setRecurByMonth($month2number[$hash['month']]);
- }
- break;
- }
- }
-
- if (isset($hash['range-type']) && isset($hash['range'])) {
- switch ($hash['range-type']) {
- case 'number':
- $this->setRecurCount((int)$hash['range']);
- break;
-
- case 'date':
- $recur_end = new Horde_Date($hash['range']);
- $recur_end->hour = 23;
- $recur_end->min = 59;
- $recur_end->sec = 59;
- $this->setRecurEnd($recur_end);
- break;
- }
- }
-
- // Need to parse <day>?
- $last_found_day = -1;
- if ($parse_day) {
- if (!isset($hash['day'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- $mask = 0;
- $bits = array(
- 'monday' => Horde_Date::MASK_MONDAY,
- 'tuesday' => Horde_Date::MASK_TUESDAY,
- 'wednesday' => Horde_Date::MASK_WEDNESDAY,
- 'thursday' => Horde_Date::MASK_THURSDAY,
- 'friday' => Horde_Date::MASK_FRIDAY,
- 'saturday' => Horde_Date::MASK_SATURDAY,
- 'sunday' => Horde_Date::MASK_SUNDAY,
- );
- $days = array(
- 'monday' => Horde_Date::DATE_MONDAY,
- 'tuesday' => Horde_Date::DATE_TUESDAY,
- 'wednesday' => Horde_Date::DATE_WEDNESDAY,
- 'thursday' => Horde_Date::DATE_THURSDAY,
- 'friday' => Horde_Date::DATE_FRIDAY,
- 'saturday' => Horde_Date::DATE_SATURDAY,
- 'sunday' => Horde_Date::DATE_SUNDAY,
- );
-
- foreach ($hash['day'] as $day) {
- // Validity check.
- if (empty($day) || !isset($bits[$day])) {
- continue;
- }
-
- $mask |= $bits[$day];
- $last_found_day = $days[$day];
- }
-
- if ($set_daymask) {
- $this->setRecurOnDay($mask);
- }
- }
-
- if ($update_month || $update_daynumber || $update_weekday) {
- if ($update_month) {
- if (isset($month2number[$hash['month']])) {
- $this->start->month = $month2number[$hash['month']];
- }
- }
-
- if ($update_daynumber) {
- if (!isset($hash['daynumber'])) {
- $this->setRecurType(self::RECUR_NONE);
- return false;
- }
-
- $this->start->mday = $hash['daynumber'];
- }
-
- if ($update_weekday) {
- $this->setNthWeekday($nth_weekday);
- }
- }
-
- // Exceptions.
- if (isset($hash['exceptions'])) {
- $this->exceptions = $hash['exceptions'];
- }
-
- if (isset($hash['completions'])) {
- $this->completions = $hash['completions'];
- }
-
- return true;
- }
-
- /**
- * Export this object into a hash.
- *
- * @return array The recurrence hash.
- */
- public function toHash()
- {
- if ($this->getRecurType() == self::RECUR_NONE) {
- return array();
- }
-
- $day2number = array(
- 0 => 'sunday',
- 1 => 'monday',
- 2 => 'tuesday',
- 3 => 'wednesday',
- 4 => 'thursday',
- 5 => 'friday',
- 6 => 'saturday'
- );
- $month2number = array(
- 1 => 'january',
- 2 => 'february',
- 3 => 'march',
- 4 => 'april',
- 5 => 'may',
- 6 => 'june',
- 7 => 'july',
- 8 => 'august',
- 9 => 'september',
- 10 => 'october',
- 11 => 'november',
- 12 => 'december'
- );
-
- $hash = array('interval' => $this->getRecurInterval());
- $start = $this->getRecurStart();
-
- switch ($this->getRecurType()) {
- case self::RECUR_DAILY:
- $hash['cycle'] = 'daily';
- break;
-
- case self::RECUR_WEEKLY:
- $hash['cycle'] = 'weekly';
- $bits = array(
- 'monday' => Horde_Date::MASK_MONDAY,
- 'tuesday' => Horde_Date::MASK_TUESDAY,
- 'wednesday' => Horde_Date::MASK_WEDNESDAY,
- 'thursday' => Horde_Date::MASK_THURSDAY,
- 'friday' => Horde_Date::MASK_FRIDAY,
- 'saturday' => Horde_Date::MASK_SATURDAY,
- 'sunday' => Horde_Date::MASK_SUNDAY,
- );
- $days = array();
- foreach ($bits as $name => $bit) {
- if ($this->recurOnDay($bit)) {
- $days[] = $name;
- }
- }
- $hash['day'] = $days;
- break;
-
- case self::RECUR_MONTHLY_DATE:
- $hash['cycle'] = 'monthly';
- $hash['type'] = 'daynumber';
- $hash['daynumber'] = $start->mday;
- break;
-
- case self::RECUR_MONTHLY_WEEKDAY:
- $hash['cycle'] = 'monthly';
- $hash['type'] = 'weekday';
- $hash['daynumber'] = $start->weekOfMonth();
- $hash['day'] = array ($day2number[$start->dayOfWeek()]);
- break;
-
- case self::RECUR_YEARLY_DATE:
- $hash['cycle'] = 'yearly';
- $hash['type'] = 'monthday';
- $hash['daynumber'] = $start->mday;
- $hash['month'] = $month2number[$start->month];
- break;
-
- case self::RECUR_YEARLY_DAY:
- $hash['cycle'] = 'yearly';
- $hash['type'] = 'yearday';
- $hash['daynumber'] = $start->dayOfYear();
- break;
-
- case self::RECUR_YEARLY_WEEKDAY:
- $hash['cycle'] = 'yearly';
- $hash['type'] = 'weekday';
- $hash['daynumber'] = $start->weekOfMonth();
- $hash['day'] = array ($day2number[$start->dayOfWeek()]);
- $hash['month'] = $month2number[$start->month];
- }
-
- if ($this->hasRecurCount()) {
- $hash['range-type'] = 'number';
- $hash['range'] = $this->getRecurCount();
- } elseif ($this->hasRecurEnd()) {
- $date = $this->getRecurEnd();
- $hash['range-type'] = 'date';
- $hash['range'] = $date->datestamp();
- } else {
- $hash['range-type'] = 'none';
- $hash['range'] = '';
- }
-
- // Recurrence exceptions
- $hash['exceptions'] = $this->exceptions;
- $hash['completions'] = $this->completions;
-
- return $hash;
- }
-
- /**
- * Returns a simple object suitable for json transport representing this
- * object.
- *
- * Possible properties are:
- * - t: type
- * - i: interval
- * - e: end date
- * - c: count
- * - d: data
- * - co: completions
- * - ex: exceptions
- *
- * @return object A simple object.
- */
- public function toJson()
- {
- $json = new stdClass;
- $json->t = $this->recurType;
- $json->i = $this->recurInterval;
- if ($this->hasRecurEnd()) {
- $json->e = $this->recurEnd->toJson();
- }
- if ($this->recurCount) {
- $json->c = $this->recurCount;
- }
- if ($this->recurData) {
- $json->d = $this->recurData;
- }
- if ($this->completions) {
- $json->co = $this->completions;
- }
- if ($this->exceptions) {
- $json->ex = $this->exceptions;
- }
- return $json;
- }
-
-}
diff --git a/plugins/libkolab/lib/Horde_Kolab_Format_XML_configuration.php b/plugins/libkolab/lib/Horde_Kolab_Format_XML_configuration.php
deleted file mode 100644
index c80fbd3..0000000
--- a/plugins/libkolab/lib/Horde_Kolab_Format_XML_configuration.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-/**
- * Kolab XML handler for configuration (KEP:9).
- *
- * @author Aleksander Machniak <machniak at kolabsys.com>
- *
- * Copyright (C) 2011, Kolab Systems AG <contact at kolabsys.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Horde_Kolab_Format_XML_configuration extends Horde_Kolab_Format_XML {
- /**
- * Specific data fields for the configuration object
- *
- * @var Kolab
- */
- var $_fields_specific;
-
- var $_root_version = 2.1;
-
- /**
- * Constructor
- */
- function Horde_Kolab_Format_XML_configuration($params = array())
- {
- $this->_root_name = 'configuration';
-
- // Specific configuration fields, in kolab format specification order
- $this->_fields_specific = array(
- 'application' => array (
- 'type' => HORDE_KOLAB_XML_TYPE_STRING,
- 'value' => HORDE_KOLAB_XML_VALUE_MAYBE_MISSING,
- ),
- 'type' => array(
- 'type' => HORDE_KOLAB_XML_TYPE_STRING,
- 'value' => HORDE_KOLAB_XML_VALUE_NOT_EMPTY,
- ),
- );
-
- // Dictionary fields
- if (!empty($params['subtype']) && preg_match('/^dictionary.*/', $params['subtype'])) {
- $this->_fields_specific = array_merge($this->_fields_specific, array(
- 'language' => array (
- 'type' => HORDE_KOLAB_XML_TYPE_STRING,
- 'value' => HORDE_KOLAB_XML_VALUE_NOT_EMPTY,
- ),
- 'e' => array(
- 'type' => HORDE_KOLAB_XML_TYPE_MULTIPLE,
- 'value' => HORDE_KOLAB_XML_VALUE_NOT_EMPTY,
- 'array' => array(
- 'type' => HORDE_KOLAB_XML_TYPE_STRING,
- 'value' => HORDE_KOLAB_XML_VALUE_NOT_EMPTY,
- ),
- ),
- ));
- }
-
- parent::Horde_Kolab_Format_XML($params);
-
- unset($this->_fields_basic['body']);
- unset($this->_fields_basic['categories']);
- unset($this->_fields_basic['sensitivity']);
- }
-}
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index a414781..c3c1b12 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -391,13 +391,6 @@ abstract class kolab_format
abstract public function to_array();
/**
- * Load object data from Kolab2 format
- *
- * @param array Hash array with object properties (produced by Horde Kolab_Format classes)
- */
- abstract public function fromkolab2($object);
-
- /**
* Callback for kolab_storage_cache to get object specific tags to cache
*
* @return array List of tags to save in cache
diff --git a/plugins/libkolab/lib/kolab_format_configuration.php b/plugins/libkolab/lib/kolab_format_configuration.php
index 918928b..0edc6a2 100644
--- a/plugins/libkolab/lib/kolab_format_configuration.php
+++ b/plugins/libkolab/lib/kolab_format_configuration.php
@@ -129,19 +129,6 @@ class kolab_format_configuration extends kolab_format
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
- $this->data = $object + $record;
- }
-
- /**
* Callback for kolab_storage_cache to get object specific tags to cache
*
* @return array List of tags to save in cache
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index b147c38..39e579c 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -65,45 +65,6 @@ class kolab_format_contact extends kolab_format
'children' => Related::Child,
);
- // old Kolab 2 format field map
- private $kolab2_fieldmap = array(
- // kolab => roundcube
- 'full-name' => 'name',
- 'given-name' => 'firstname',
- 'middle-names' => 'middlename',
- 'last-name' => 'surname',
- 'prefix' => 'prefix',
- 'suffix' => 'suffix',
- 'nick-name' => 'nickname',
- 'organization' => 'organization',
- 'department' => 'department',
- 'job-title' => 'jobtitle',
- 'birthday' => 'birthday',
- 'anniversary' => 'anniversary',
- 'phone' => 'phone',
- 'im-address' => 'im',
- 'web-page' => 'website',
- 'profession' => 'profession',
- 'manager-name' => 'manager',
- 'assistant' => 'assistant',
- 'spouse-name' => 'spouse',
- 'children' => 'children',
- 'body' => 'notes',
- 'pgp-publickey' => 'pgppublickey',
- 'free-busy-url' => 'freebusyurl',
- 'picture' => 'photo',
- );
- private $kolab2_phonetypes = array(
- 'home1' => 'home',
- 'business1' => 'work',
- 'business2' => 'work',
- 'businessfax' => 'workfax',
- );
- private $kolab2_addresstypes = array(
- 'business' => 'work'
- );
- private $kolab2_gender = array(0 => 'male', 1 => 'female');
-
/**
* Default constructor
@@ -417,58 +378,6 @@ class kolab_format_contact extends kolab_format
}
/**
- * Load data from old Kolab2 format
- *
- * @param array Hash array with object properties
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'email' => array(),
- 'phone' => array(),
- );
-
- foreach ($this->kolab2_fieldmap as $kolab => $rcube) {
- if (is_array($record[$kolab]) || strlen($record[$kolab]))
- $object[$rcube] = $record[$kolab];
- }
-
- if (isset($record['gender']))
- $object['gender'] = $this->kolab2_gender[$record['gender']];
-
- foreach ((array)$record['email'] as $i => $email)
- $object['email'][] = $email['smtp-address'];
-
- if (!$record['email'] && $record['emails'])
- $object['email'] = preg_split('/,\s*/', $record['emails']);
-
- if (is_array($record['address'])) {
- foreach ($record['address'] as $i => $adr) {
- $object['address'][] = array(
- 'type' => $this->kolab2_addresstypes[$adr['type']] ? $this->kolab2_addresstypes[$adr['type']] : $adr['type'],
- 'street' => $adr['street'],
- 'locality' => $adr['locality'],
- 'code' => $adr['postal-code'],
- 'region' => $adr['region'],
- 'country' => $adr['country'],
- );
- }
- }
-
- // office location goes into an address block
- if ($record['office-location'])
- $object['address'][] = array('type' => 'office', 'locality' => $record['office-location']);
-
- // merge initials into nickname
- if ($record['initials'])
- $object['nickname'] = trim($object['nickname'] . ', ' . $record['initials'], ', ');
-
- // remove empty fields
- $this->data = array_filter($object);
- }
-
- /**
* Helper method to copy contents of an Address vector to the contact data object
*/
private function read_addresses($addresses, &$object, $type = null)
diff --git a/plugins/libkolab/lib/kolab_format_distributionlist.php b/plugins/libkolab/lib/kolab_format_distributionlist.php
index ba54742..5622fc5 100644
--- a/plugins/libkolab/lib/kolab_format_distributionlist.php
+++ b/plugins/libkolab/lib/kolab_format_distributionlist.php
@@ -81,29 +81,6 @@ class kolab_format_distributionlist extends kolab_format
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- 'name' => $record['last-name'],
- 'member' => array(),
- );
-
- foreach ((array)$record['member'] as $member) {
- $object['member'][] = array(
- 'email' => $member['smtp-address'],
- 'name' => $member['display-name'],
- 'uid' => $member['uid'],
- );
- }
-
- $this->data = $object;
- }
-
- /**
* Convert the Distlist object into a hash array data structure
*
* @return array Distribution list data as hash array
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index bcd6de1..4ef6735 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -30,20 +30,6 @@ class kolab_format_event extends kolab_format_xcal
protected $read_func = 'readEvent';
protected $write_func = 'writeEvent';
- private $kolab2_rolemap = array(
- 'required' => 'REQ-PARTICIPANT',
- 'optional' => 'OPT-PARTICIPANT',
- 'resource' => 'CHAIR',
- );
- private $kolab2_statusmap = array(
- 'none' => 'NEEDS-ACTION',
- 'tentative' => 'TENTATIVE',
- 'accepted' => 'CONFIRMED',
- 'accepted' => 'ACCEPTED',
- 'declined' => 'DECLINED',
- );
- private $kolab2_monthmap = array('', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december');
-
/**
* Clones into an instance of libcalendaring's extended EventCal class
@@ -196,125 +182,4 @@ class kolab_format_event extends kolab_format_xcal
return $tags;
}
- /**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($rec)
- {
- if (PEAR::isError($rec))
- return;
-
- $start_time = date('H:i:s', $rec['start-date']);
- $allday = $rec['_is_all_day'] || ($start_time == '00:00:00' && $start_time == date('H:i:s', $rec['end-date']));
-
- // in Roundcube all-day events go from 12:00 to 13:00
- if ($allday) {
- $now = new DateTime('now', self::$timezone);
- $gmt_offset = $now->getOffset();
-
- $rec['start-date'] += 12 * 3600;
- $rec['end-date'] -= 11 * 3600;
- $rec['end-date'] -= $gmt_offset - date('Z', $rec['end-date']); // shift times from server's timezone to user's timezone
- $rec['start-date'] -= $gmt_offset - date('Z', $rec['start-date']); // because generated with mktime() in Horde_Kolab_Format_Date::decodeDate()
- // sanity check
- if ($rec['end-date'] <= $rec['start-date'])
- $rec['end-date'] += 86400;
- }
-
- // convert alarm time into internal format
- if ($rec['alarm']) {
- $alarm_value = $rec['alarm'];
- $alarm_unit = 'M';
- if ($rec['alarm'] % 1440 == 0) {
- $alarm_value /= 1440;
- $alarm_unit = 'D';
- }
- else if ($rec['alarm'] % 60 == 0) {
- $alarm_value /= 60;
- $alarm_unit = 'H';
- }
- $alarm_value *= -1;
- }
-
- // convert recurrence rules into internal pseudo-vcalendar format
- if ($recurrence = $rec['recurrence']) {
- $rrule = array(
- 'FREQ' => strtoupper($recurrence['cycle']),
- 'INTERVAL' => intval($recurrence['interval']),
- );
-
- if ($recurrence['range-type'] == 'number')
- $rrule['COUNT'] = intval($recurrence['range']);
- else if ($recurrence['range-type'] == 'date')
- $rrule['UNTIL'] = date_create('@'.$recurrence['range']);
-
- if ($recurrence['day']) {
- $byday = array();
- $prefix = ($rrule['FREQ'] == 'MONTHLY' || $rrule['FREQ'] == 'YEARLY') ? intval($recurrence['daynumber'] ? $recurrence['daynumber'] : 1) : '';
- foreach ($recurrence['day'] as $day)
- $byday[] = $prefix . substr(strtoupper($day), 0, 2);
- $rrule['BYDAY'] = join(',', $byday);
- }
- if ($recurrence['daynumber']) {
- if ($recurrence['type'] == 'monthday' || $recurrence['type'] == 'daynumber')
- $rrule['BYMONTHDAY'] = $recurrence['daynumber'];
- else if ($recurrence['type'] == 'yearday')
- $rrule['BYYEARDAY'] = $recurrence['daynumber'];
- }
- if ($recurrence['month']) {
- $monthmap = array_flip($this->kolab2_monthmap);
- $rrule['BYMONTH'] = strtolower($monthmap[$recurrence['month']]);
- }
-
- if ($recurrence['exclusion']) {
- foreach ((array)$recurrence['exclusion'] as $excl)
- $rrule['EXDATE'][] = date_create($excl . date(' H:i:s', $rec['start-date'])); // use time of event start
- }
- }
-
- $attendees = array();
- if ($rec['organizer']) {
- $attendees[] = array(
- 'role' => 'ORGANIZER',
- 'name' => $rec['organizer']['display-name'],
- 'email' => $rec['organizer']['smtp-address'],
- 'status' => 'ACCEPTED',
- );
- $_attendees .= $rec['organizer']['display-name'] . ' ' . $rec['organizer']['smtp-address'] . ' ';
- }
-
- foreach ((array)$rec['attendee'] as $attendee) {
- $attendees[] = array(
- 'role' => $this->kolab2_rolemap[$attendee['role']],
- 'name' => $attendee['display-name'],
- 'email' => $attendee['smtp-address'],
- 'status' => $this->kolab2_statusmap[$attendee['status']],
- 'rsvp' => $attendee['request-response'],
- );
- $_attendees .= $rec['organizer']['display-name'] . ' ' . $rec['organizer']['smtp-address'] . ' ';
- }
-
- $this->data = array(
- 'uid' => $rec['uid'],
- 'title' => $rec['summary'],
- 'location' => $rec['location'],
- 'description' => $rec['body'],
- 'start' => new DateTime('@'.$rec['start-date']),
- 'end' => new DateTime('@'.$rec['end-date']),
- 'allday' => $allday,
- 'recurrence' => $rrule,
- 'alarms' => $alarm_value . $alarm_unit,
- 'categories' => explode(',', $rec['categories']),
- 'attachments' => $attachments,
- 'attendees' => $attendees,
- 'free_busy' => $rec['show-time-as'],
- 'priority' => $rec['priority'],
- 'sensitivity' => $rec['sensitivity'],
- 'changed' => $rec['last-modification-date'],
- );
-
- // assign current timezone to event start/end
- $this->data['start']->setTimezone(self::$timezone);
- $this->data['end']->setTimezone(self::$timezone);
- }
}
diff --git a/plugins/libkolab/lib/kolab_format_file.php b/plugins/libkolab/lib/kolab_format_file.php
index 1560c46..b3ab158 100644
--- a/plugins/libkolab/lib/kolab_format_file.php
+++ b/plugins/libkolab/lib/kolab_format_file.php
@@ -99,19 +99,6 @@ class kolab_format_file extends kolab_format
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
- $this->data = $object;
- }
-
- /**
* Convert the Configuration object into a hash array data structure
*
* @return array Config object data as hash array
diff --git a/plugins/libkolab/lib/kolab_format_journal.php b/plugins/libkolab/lib/kolab_format_journal.php
index 9144ea2..daab1ac 100644
--- a/plugins/libkolab/lib/kolab_format_journal.php
+++ b/plugins/libkolab/lib/kolab_format_journal.php
@@ -64,21 +64,6 @@ class kolab_format_journal extends kolab_format
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
- // TODO: implement this
-
- $this->data = $object;
- }
-
- /**
* Convert the Configuration object into a hash array data structure
*
* @return array Config object data as hash array
diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php
index 48e963e..5af9343 100644
--- a/plugins/libkolab/lib/kolab_format_note.php
+++ b/plugins/libkolab/lib/kolab_format_note.php
@@ -64,20 +64,6 @@ class kolab_format_note extends kolab_format
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
-
- $this->data = $object;
- }
-
- /**
* Convert the Configuration object into a hash array data structure
*
* @return array Config object data as hash array
diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index 0bfac3d..77870c7 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -102,21 +102,6 @@ class kolab_format_task extends kolab_format_xcal
}
/**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
- // TODO: implement this
-
- $this->data = $object;
- }
-
- /**
* Callback for kolab_storage_cache to get object specific tags to cache
*
* @return array List of tags to save in cache
commit 4c44264940360247527280a8ba60e939977fc4ad
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Nov 21 11:14:11 2012 +0100
Added package.xml and LICENSE
diff --git a/plugins/libkolab/LICENSE b/plugins/libkolab/LICENSE
new file mode 100644
index 0000000..dba13ed
--- /dev/null
+++ b/plugins/libkolab/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.
diff --git a/plugins/libkolab/libkolab.php b/plugins/libkolab/libkolab.php
index 887d308..2d03733 100644
--- a/plugins/libkolab/libkolab.php
+++ b/plugins/libkolab/libkolab.php
@@ -49,17 +49,6 @@ class libkolab extends rcube_plugin
rcube::raise_error($e, true);
kolab_format::$timezone = new DateTimeZone('GMT');
}
-
- // load (old) dependencies if available
- if (@include_once('Horde/Util.php')) {
- include_once 'Horde/Kolab/Format.php';
- include_once 'Horde/Kolab/Format/XML.php';
- include_once 'Horde/Kolab/Format/XML/contact.php';
- include_once 'Horde/Kolab/Format/XML/event.php';
- include_once 'Horde_Kolab_Format_XML_configuration.php';
-
- String::setDefaultCharset('UTF-8');
- }
}
/**
diff --git a/plugins/libkolab/package.xml b/plugins/libkolab/package.xml
new file mode 100644
index 0000000..69b2b6f
--- /dev/null
+++ b/plugins/libkolab/package.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>libkolab</name>
+ <uri>http://git.kolab.org/roundcubemail-plugins-kolab/</uri>
+ <summary>Kolab core library</summary>
+ <description>Plugin to setup a basic environment for the interaction with a Kolab server.</description>
+ <lead>
+ <name>Thomas Bruederli</name>
+ <user>bruederli</user>
+ <email>bruederli at kolabsys.com</email>
+ <active>yes</active>
+ </lead>
+ <developer>
+ <name>Alensader Machniak</name>
+ <user>machniak</user>
+ <email>machniak at kolabsys.com</email>
+ <active>yes</active>
+ </developer>
+ <date>2012-11-21</date>
+ <version>
+ <release>0.9-beta</release>
+ <api>0.9-beta</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/agpl.html">GNU AGPLv3</license>
+ <notes>-</notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <file name="libkolab.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_configuration.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_contact.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_distributionlist.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_event.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_file.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_journal.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_note.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_task.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_format_xcal.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_storage.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_storage_cache.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_storage_folder.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="lib/kolab_date_recurrence.php" role="php">
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+
+ <file name="bin/modcache.php" role="php"></file>
+
+ <file name="config.inc.php.dist" role="data"></file>
+ <file name="LICENSE" role="data"></file>
+ <file name="README" role="data"></file>
+ </dir>
+ <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.3.1</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease/>
+</package>
More information about the commits
mailing list