Finally remove the remaining Horde stuff after switching to libkolab for recurrence and format v2 support
This commit is contained in:
parent
4c44264940
commit
025a388ba5
15 changed files with 0 additions and 3805 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
|
@ -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
|
||||
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Kolab XML handler for configuration (KEP:9).
|
||||
*
|
||||
* @author Aleksander Machniak <machniak@kolabsys.com>
|
||||
*
|
||||
* Copyright (C) 2011, Kolab Systems AG <contact@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']);
|
||||
}
|
||||
}
|
|
@ -390,13 +390,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
|
||||
*
|
||||
|
|
|
@ -128,19 +128,6 @@ class kolab_format_configuration extends kolab_format
|
|||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
@ -416,58 +377,6 @@ class kolab_format_contact extends kolab_format
|
|||
return array_unique(rcube_utils::normalize_string($data, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
|
@ -80,29 +80,6 @@ class kolab_format_distributionlist extends kolab_format
|
|||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,19 +98,6 @@ class kolab_format_file extends kolab_format
|
|||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -63,21 +63,6 @@ class kolab_format_journal extends kolab_format
|
|||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -63,20 +63,6 @@ class kolab_format_note extends kolab_format
|
|||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -101,21 +101,6 @@ class kolab_format_task extends kolab_format_xcal
|
|||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue