Try to support PHP >= 7.2, small refactoring
This commit is contained in:
parent
f5d95d5a92
commit
1b33810f71
20 changed files with 97 additions and 82 deletions
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"php": ">=7.2.0",
|
||||
"roundcube/plugin-installer": ">=0.1.3",
|
||||
"kolab/libcalendaring": ">=3.4.0",
|
||||
"kolab/libkolab": ">=3.4.0"
|
||||
|
|
|
@ -755,7 +755,7 @@ class caldav_calendar extends kolab_storage_dav_folder
|
|||
) {
|
||||
$record['_instance'] = $record['start']->format($recurrence_id_format);
|
||||
}
|
||||
else if (isset($record['recurrence_date']) && is_a($record['recurrence_date'], 'DateTime')) {
|
||||
else if (isset($record['recurrence_date']) && $record['recurrence_date'] instanceof DateTimeInterface) {
|
||||
$record['_instance'] = $record['recurrence_date']->format($recurrence_id_format);
|
||||
}
|
||||
|
||||
|
|
|
@ -362,11 +362,11 @@ abstract class calendar_driver
|
|||
{
|
||||
$valid = true;
|
||||
|
||||
if (empty($event['start']) || !is_object($event['start']) || !is_a($event['start'], 'DateTime')) {
|
||||
if (empty($event['start']) || !is_object($event['start']) || !($event['start'] instanceof DateTimeInterface)) {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if (empty($event['end']) || !is_object($event['end']) || !is_a($event['end'], 'DateTime')) {
|
||||
if (empty($event['end']) || !is_object($event['end']) || !($event['end'] instanceof DateTimeInterface)) {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -821,7 +821,7 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
if (!$noinst && !empty($record['recurrence']) && empty($record['recurrence_id']) && empty($record['_instance'])) {
|
||||
$record['_instance'] = $record['start']->format($recurrence_id_format);
|
||||
}
|
||||
else if (isset($record['recurrence_date']) && is_a($record['recurrence_date'], 'DateTime')) {
|
||||
else if (isset($record['recurrence_date']) && $record['recurrence_date'] instanceof DateTimeInterface) {
|
||||
$record['_instance'] = $record['recurrence_date']->format($recurrence_id_format);
|
||||
}
|
||||
|
||||
|
|
|
@ -1332,7 +1332,7 @@ class kolab_driver extends calendar_driver
|
|||
$recurrence_id_format = libcalendaring::recurrence_id_format($event);
|
||||
|
||||
foreach ($event['recurrence']['EXCEPTIONS'] as $i => $exception) {
|
||||
if (isset($exception['recurrence_date']) && is_a($exception['recurrence_date'], 'DateTime')) {
|
||||
if (isset($exception['recurrence_date']) && $exception['recurrence_date'] instanceof DateTimeInterface) {
|
||||
$recurrence_id = $exception['recurrence_date'];
|
||||
}
|
||||
else {
|
||||
|
@ -1530,7 +1530,7 @@ class kolab_driver extends calendar_driver
|
|||
$event['recurrence_date'] = $event['start'];
|
||||
}
|
||||
|
||||
if (empty($event['_instance']) && is_a($event['recurrence_date'], 'DateTime')) {
|
||||
if (empty($event['_instance']) && $event['recurrence_date'] instanceof DateTimeInterface) {
|
||||
$event['_instance'] = libcalendaring::recurrence_instance_identifier($event, !empty($master['allday']));
|
||||
}
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ class kolab_driver extends calendar_driver
|
|||
}
|
||||
|
||||
// all-day events go from 12:00 - 13:00
|
||||
if (is_a($record['start'], 'DateTime') && $record['end'] <= $record['start'] && !empty($record['allday'])) {
|
||||
if ($record['start'] instanceof DateTimeInterface && $record['end'] <= $record['start'] && !empty($record['allday'])) {
|
||||
$record['end'] = clone $record['start'];
|
||||
$record['end']->add(new DateInterval('PT1H'));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": ">=7.2.0",
|
||||
"roundcube/plugin-installer": ">=0.1.3",
|
||||
"kolab/libkolab": ">=3.4.0"
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"php": ">=7.2.0",
|
||||
"roundcube/plugin-installer": ">=0.1.3",
|
||||
"sabre/vobject": "~4.5.1"
|
||||
}
|
||||
|
|
|
@ -63,14 +63,14 @@ class libcalendaring_recurrence
|
|||
|
||||
if (!empty($recurrence['EXDATE'])) {
|
||||
foreach ((array) $recurrence['EXDATE'] as $exdate) {
|
||||
if (is_a($exdate, 'DateTime')) {
|
||||
if ($exdate instanceof DateTimeInterface) {
|
||||
$this->engine->addException($exdate->format('Y'), $exdate->format('n'), $exdate->format('j'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($recurrence['RDATE'])) {
|
||||
foreach ((array) $recurrence['RDATE'] as $rdate) {
|
||||
if (is_a($rdate, 'DateTime')) {
|
||||
if ($rdate instanceof DateTimeInterface) {
|
||||
$this->engine->addRDate($rdate->format('Y'), $rdate->format('n'), $rdate->format('j'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,15 +24,13 @@
|
|||
use \Sabre\VObject;
|
||||
use \Sabre\VObject\DateTimeParser;
|
||||
|
||||
require_once __DIR__ . '/lib/libcalendaring_datetime.php';
|
||||
|
||||
/**
|
||||
* Class to parse and build vCalendar (iCalendar) files
|
||||
*
|
||||
* Uses the Sabre VObject library, version 3.x.
|
||||
*
|
||||
*/
|
||||
class libvcalendar implements Iterator
|
||||
class libcalendaring_vcalendar implements Iterator
|
||||
{
|
||||
private $timezone;
|
||||
private $attach_uri = null;
|
||||
|
@ -1525,7 +1523,7 @@ class vobject_location_property extends VObject\Property\Text
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $structuredValues = array(
|
||||
protected $structuredValues = [
|
||||
// vCard
|
||||
'N',
|
||||
'ADR',
|
||||
|
@ -1534,5 +1532,5 @@ class vobject_location_property extends VObject\Property\Text
|
|||
'LOCATION',
|
||||
// iCalendar
|
||||
'REQUEST-STATUS',
|
||||
);
|
||||
];
|
||||
}
|
|
@ -105,6 +105,10 @@ class libcalendaring extends rcube_plugin
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
// extend include path to load bundled lib classes
|
||||
$include_path = $this->home . '/lib' . PATH_SEPARATOR . ini_get('include_path');
|
||||
set_include_path($include_path);
|
||||
|
||||
self::$instance = $this;
|
||||
|
||||
$this->rc = rcube::get_instance();
|
||||
|
@ -155,8 +159,7 @@ class libcalendaring extends rcube_plugin
|
|||
public static function get_ical()
|
||||
{
|
||||
$self = self::get_instance();
|
||||
require_once __DIR__ . '/libvcalendar.php';
|
||||
return new libvcalendar();
|
||||
return new libcalendaring_vcalendar();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +168,6 @@ class libcalendaring extends rcube_plugin
|
|||
public static function get_itip($domain = 'libcalendaring')
|
||||
{
|
||||
$self = self::get_instance();
|
||||
require_once __DIR__ . '/lib/libcalendaring_itip.php';
|
||||
return new libcalendaring_itip($self, $domain);
|
||||
}
|
||||
|
||||
|
@ -175,7 +177,6 @@ class libcalendaring extends rcube_plugin
|
|||
public static function get_recurrence()
|
||||
{
|
||||
$self = self::get_instance();
|
||||
require_once __DIR__ . '/lib/libcalendaring_recurrence.php';
|
||||
return new libcalendaring_recurrence($self);
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1162,7 @@ class libcalendaring extends rcube_plugin
|
|||
/**
|
||||
* Getter for the parsed iCal objects attached to the current email message
|
||||
*
|
||||
* @return object libvcalendar parser instance with the parsed objects
|
||||
* @return object libcalendaring_vcalendar parser instance with the parsed objects
|
||||
*/
|
||||
public function get_mail_ical_objects()
|
||||
{
|
||||
|
|
|
@ -27,8 +27,9 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
|
||||
function setUp(): void
|
||||
{
|
||||
require_once __DIR__ . '/../libvcalendar.php';
|
||||
require_once __DIR__ . '/../libcalendaring.php';
|
||||
require_once __DIR__ . '/../lib/libcalendaring_vcalendar.php';
|
||||
require_once __DIR__ . '/../lib/libcalendaring_datetime.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_import()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$ics = file_get_contents(__DIR__ . '/resources/snd.ics');
|
||||
$events = $ical->import($ics, 'UTF-8');
|
||||
|
||||
|
@ -67,7 +68,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_import_from_file()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/multiple.ics', 'UTF-8');
|
||||
$this->assertEquals(2, count($events));
|
||||
|
@ -81,7 +82,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_import_from_file_multiple()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$ical->fopen(__DIR__ . '/resources/multiple-rdate.ics', 'UTF-8');
|
||||
$events = [];
|
||||
foreach ($ical as $event) {
|
||||
|
@ -95,7 +96,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
|
||||
function test_invalid_dates()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/invalid-dates.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
||||
|
@ -109,7 +110,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_extended()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/itip.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
@ -184,7 +185,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_alarms()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/recurring.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
@ -237,7 +238,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_attachment()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/attachment.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
@ -253,7 +254,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_apple_alarms()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/apple-alarms.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
||||
|
@ -274,7 +275,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_escaped_values()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/escaped.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
||||
|
@ -291,7 +292,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_rdate()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/multiple-rdate.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
||||
|
@ -305,7 +306,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_freebusy()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$ical->import_from_file(__DIR__ . '/resources/freebusy.ifb', 'UTF-8');
|
||||
$freebusy = $ical->freebusy;
|
||||
|
||||
|
@ -322,7 +323,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_freebusy_dummy()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$ical->import_from_file(__DIR__ . '/resources/dummy.ifb', 'UTF-8');
|
||||
$freebusy = $ical->freebusy;
|
||||
|
||||
|
@ -332,7 +333,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
|
||||
function test_vtodo()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$tasks = $ical->import_from_file(__DIR__ . '/resources/vtodo.ics', 'UTF-8', true);
|
||||
$task = $tasks[0];
|
||||
|
||||
|
@ -357,7 +358,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_export()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/itip.ics', 'UTF-8');
|
||||
$event = $events[0];
|
||||
|
@ -367,7 +368,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
$this->attachment_data = $event['attachments'][0]['data'];
|
||||
unset($event['attachments'][0]['data']);
|
||||
$event['attachments'][0]['id'] = '1';
|
||||
$event['description'] = '*Exported by libvcalendar*';
|
||||
$event['description'] = '*Exported by libcalendaring_vcalendar*';
|
||||
|
||||
$event['start']->setTimezone(new DateTimezone('America/Montreal'));
|
||||
$event['end']->setTimezone(new DateTimezone('Europe/Berlin'));
|
||||
|
@ -420,7 +421,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_export_multiple()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = array_merge(
|
||||
$ical->import_from_file(__DIR__ . '/resources/snd.ics', 'UTF-8'),
|
||||
$ical->import_from_file(__DIR__ . '/resources/multiple.ics', 'UTF-8')
|
||||
|
@ -440,7 +441,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_export_recurrence_exceptions()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/recurring.ics', 'UTF-8');
|
||||
|
||||
// add exceptions
|
||||
|
@ -488,7 +489,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
'RDATE' => [],
|
||||
],
|
||||
];
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$ics = $ical->export([$event], null, false, null, false);
|
||||
|
||||
$this->assertStringNotContainsString('EXDATE=', $ics);
|
||||
|
@ -500,7 +501,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_export_rdate()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/multiple-rdate.ics', 'UTF-8');
|
||||
$ics = $ical->export($events, null, false);
|
||||
|
||||
|
@ -512,7 +513,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
*/
|
||||
function test_export_direct()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$events = $ical->import_from_file(__DIR__ . '/resources/multiple.ics', 'UTF-8');
|
||||
$num = count($events);
|
||||
|
||||
|
@ -530,7 +531,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
|
||||
function test_datetime()
|
||||
{
|
||||
$ical = new libvcalendar();
|
||||
$ical = new libcalendaring_vcalendar();
|
||||
$cal = new \Sabre\VObject\Component\VCalendar();
|
||||
$localtime = $ical->datetime_prop($cal, 'DTSTART', new DateTime('2013-09-01 12:00:00', new DateTimeZone('Europe/Berlin')));
|
||||
$localdate = $ical->datetime_prop($cal, 'DTSTART', new DateTime('2013-09-01', new DateTimeZone('Europe/Berlin')), false, true);
|
||||
|
@ -545,7 +546,7 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
|
||||
function test_get_vtimezone()
|
||||
{
|
||||
$vtz = libvcalendar::get_vtimezone('Europe/Berlin', strtotime('2014-08-22T15:00:00+02:00'));
|
||||
$vtz = libcalendaring_vcalendar::get_vtimezone('Europe/Berlin', strtotime('2014-08-22T15:00:00+02:00'));
|
||||
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz, "VTIMEZONE is a Component object");
|
||||
$this->assertEquals('Europe/Berlin', $vtz->TZID);
|
||||
$this->assertEquals('4', $vtz->{'X-MICROSOFT-CDO-TZID'});
|
||||
|
@ -568,22 +569,22 @@ class LibvcalendarTest extends PHPUnit\Framework\TestCase
|
|||
$this->assertEquals('CET', $std->TZNAME);
|
||||
|
||||
// unknown timezone
|
||||
$vtz = libvcalendar::get_vtimezone('America/Foo Bar');
|
||||
$vtz = libcalendaring_vcalendar::get_vtimezone('America/Foo Bar');
|
||||
$this->assertEquals(false, $vtz);
|
||||
|
||||
// invalid input data
|
||||
$vtz = libvcalendar::get_vtimezone(new DateTime());
|
||||
$vtz = libcalendaring_vcalendar::get_vtimezone(new DateTime());
|
||||
$this->assertEquals(false, $vtz);
|
||||
|
||||
// DateTimezone as input data
|
||||
$vtz = libvcalendar::get_vtimezone(new DateTimezone('Pacific/Chatham'));
|
||||
$vtz = libcalendaring_vcalendar::get_vtimezone(new DateTimezone('Pacific/Chatham'));
|
||||
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz);
|
||||
$this->assertStringContainsString('TZOFFSETFROM:+1245', $vtz->serialize());
|
||||
$this->assertStringContainsString('TZOFFSETTO:+1345', $vtz->serialize());
|
||||
|
||||
// Making sure VTIMEZOONE contains at least one STANDARD/DAYLIGHT component
|
||||
// when there's only one transition in specified time period (T5626)
|
||||
$vtz = libvcalendar::get_vtimezone('Europe/Istanbul', strtotime('2019-10-04T15:00:00'));
|
||||
$vtz = libcalendaring_vcalendar::get_vtimezone('Europe/Istanbul', strtotime('2019-10-04T15:00:00'));
|
||||
|
||||
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz);
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.4.0",
|
||||
"php": ">=7.2.0",
|
||||
"roundcube/plugin-installer": ">=0.1.3",
|
||||
"kolab/libcalendaring": ">=3.4.0",
|
||||
"pear/http_request2": "~2.3.0",
|
||||
"pear/http_request2": "~2.5.0",
|
||||
"caxy/php-htmldiff": "~0.1.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../libcalendaring/lib/libcalendaring_datetime.php';
|
||||
|
||||
abstract class kolab_format
|
||||
{
|
||||
public static $timezone;
|
||||
|
|
|
@ -87,7 +87,7 @@ class kolab_format_event extends kolab_format_xcal
|
|||
|
||||
// get value for recurrence-id
|
||||
$recurrence_id = null;
|
||||
if (!empty($exception['recurrence_date']) && is_a($exception['recurrence_date'], 'DateTime')) {
|
||||
if (!empty($exception['recurrence_date']) && $exception['recurrence_date'] instanceof DateTimeInterface) {
|
||||
$recurrence_id = $exception['recurrence_date'];
|
||||
$compacted['_instance'] = $recurrence_id->format($recurrence_id_format);
|
||||
}
|
||||
|
|
|
@ -48,13 +48,13 @@ class kolab_storage_cache_event extends kolab_storage_cache
|
|||
// extend start/end dates to spawn all exceptions
|
||||
if (is_array($object['exceptions'])) {
|
||||
foreach ($object['exceptions'] as $exception) {
|
||||
if (is_a($exception['start'], 'DateTime')) {
|
||||
if ($exception['start'] instanceof DateTimeInterface) {
|
||||
$exstart = $this->_convert_datetime($exception['start']);
|
||||
if ($exstart < $sql_data['dtstart']) {
|
||||
$sql_data['dtstart'] = $exstart;
|
||||
}
|
||||
}
|
||||
if (is_a($exception['end'], 'DateTime')) {
|
||||
if ($exception['end'] instanceof DateTimeInterface) {
|
||||
$exend = $this->_convert_datetime($exception['end']);
|
||||
if ($exend > $sql_data['dtend']) {
|
||||
$sql_data['dtend'] = $exend;
|
||||
|
|
|
@ -55,13 +55,13 @@ class kolab_storage_dav_cache_event extends kolab_storage_dav_cache
|
|||
// extend start/end dates to spawn all exceptions
|
||||
if (is_array($object['exceptions'])) {
|
||||
foreach ($object['exceptions'] as $exception) {
|
||||
if (is_a($exception['start'], 'DateTime')) {
|
||||
if ($exception['start'] instanceof DateTimeInterface) {
|
||||
$exstart = $this->_convert_datetime($exception['start']);
|
||||
if ($exstart < $sql_data['dtstart']) {
|
||||
$sql_data['dtstart'] = $exstart;
|
||||
}
|
||||
}
|
||||
if (is_a($exception['end'], 'DateTime')) {
|
||||
if ($exception['end'] instanceof DateTimeInterface) {
|
||||
$exend = $this->_convert_datetime($exception['end']);
|
||||
if ($exend > $sql_data['dtend']) {
|
||||
$sql_data['dtend'] = $exend;
|
||||
|
|
|
@ -625,7 +625,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
|
|||
list($field, $section) = rcube_utils::explode(':', $key);
|
||||
|
||||
// avoid casting DateTime objects to array
|
||||
if (is_object($values) && is_a($values, 'DateTime')) {
|
||||
if (is_object($values) && $values instanceof DateTimeInterface) {
|
||||
$values = [$values];
|
||||
}
|
||||
|
||||
|
|
|
@ -353,10 +353,12 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
|||
unset($query[$i]);
|
||||
}
|
||||
else if (($param[0] == 'dtstart' || $param[0] == 'dtend' || $param[0] == 'changed')) {
|
||||
if (is_object($param[2]) && is_a($param[2], 'DateTime'))
|
||||
if (is_object($param[2]) && $param[2] instanceof DateTimeInterface) {
|
||||
$param[2] = $param[2]->format('U');
|
||||
if (is_numeric($param[2]))
|
||||
}
|
||||
if (is_numeric($param[2])) {
|
||||
$query[$i][2] = date('Y-m-d H:i:s', $param[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,14 +736,14 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
|||
private function save_recurrence_exceptions(&$object, $type = null)
|
||||
{
|
||||
if ($object['recurrence']['EXCEPTIONS']) {
|
||||
$exdates = array();
|
||||
foreach ((array)$object['recurrence']['EXDATE'] as $exdate) {
|
||||
$key = is_a($exdate, 'DateTime') ? $exdate->format('Y-m-d') : strval($exdate);
|
||||
$exdates = [];
|
||||
foreach ((array) $object['recurrence']['EXDATE'] as $exdate) {
|
||||
$key = $exdate instanceof DateTimeInterface ? $exdate->format('Y-m-d') : strval($exdate);
|
||||
$exdates[$key] = 1;
|
||||
}
|
||||
|
||||
// save every exception as individual object
|
||||
foreach((array)$object['recurrence']['EXCEPTIONS'] as $exception) {
|
||||
foreach ((array) $object['recurrence']['EXCEPTIONS'] as $exception) {
|
||||
$exception['uid'] = self::recurrence_exception_uid($object['uid'], $exception['start']->format('Ymd'));
|
||||
$exception['sequence'] = $object['sequence'] + 1;
|
||||
|
||||
|
@ -1114,8 +1116,9 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
|||
}
|
||||
|
||||
if ($result && is_object($result) && is_a($result, 'PEAR_Error')) {
|
||||
return PEAR::raiseError(sprintf("Failed triggering folder %s. Error was: %s",
|
||||
$this->name, $result->getMessage()));
|
||||
return PEAR::raiseError(
|
||||
sprintf("Failed triggering folder %s. Error was: %s", $this->name, $result->getMessage())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": ">=7.2.0",
|
||||
"roundcube/plugin-installer": ">=0.1.3",
|
||||
"kolab/libcalendaring": ">=3.4.0",
|
||||
"kolab/libkolab": ">=3.4.0"
|
||||
|
|
|
@ -1280,23 +1280,25 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
}
|
||||
|
||||
// convert from DateTime to internal date format
|
||||
if (is_a($record['due'], 'DateTime')) {
|
||||
if ($record['due'] instanceof DateTimeInterface) {
|
||||
$due = $this->plugin->lib->adjust_timezone($record['due']);
|
||||
$task['date'] = $due->format('Y-m-d');
|
||||
if (!$record['due']->_dateonly)
|
||||
if (empty($record['due']->_dateonly)) {
|
||||
$task['time'] = $due->format('H:i');
|
||||
}
|
||||
}
|
||||
// convert from DateTime to internal date format
|
||||
if (is_a($record['start'], 'DateTime')) {
|
||||
if ($record['start'] instanceof DateTimeInterface) {
|
||||
$start = $this->plugin->lib->adjust_timezone($record['start']);
|
||||
$task['startdate'] = $start->format('Y-m-d');
|
||||
if (!$record['start']->_dateonly)
|
||||
if (empty($record['start']->_dateonly)) {
|
||||
$task['starttime'] = $start->format('H:i');
|
||||
}
|
||||
}
|
||||
if (is_a($record['changed'], 'DateTime')) {
|
||||
if ($record['changed'] instanceof DateTimeInterface) {
|
||||
$task['changed'] = $record['changed'];
|
||||
}
|
||||
if (is_a($record['created'], 'DateTime')) {
|
||||
if ($record['created'] instanceof DateTimeInterface) {
|
||||
$task['created'] = $record['created'];
|
||||
}
|
||||
|
||||
|
@ -1309,10 +1311,10 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
|
||||
if (!empty($task['attendees'])) {
|
||||
foreach ((array)$task['attendees'] as $i => $attendee) {
|
||||
if (is_array($attendee['delegated-from'])) {
|
||||
if (isset($attendee['delegated-from']) && is_array($attendee['delegated-from'])) {
|
||||
$task['attendees'][$i]['delegated-from'] = join(', ', $attendee['delegated-from']);
|
||||
}
|
||||
if (is_array($attendee['delegated-to'])) {
|
||||
if (isset($attendee['delegated-to']) && is_array($attendee['delegated-to'])) {
|
||||
$task['attendees'][$i]['delegated-to'] = join(', ', $attendee['delegated-to']);
|
||||
}
|
||||
}
|
||||
|
@ -1321,8 +1323,9 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
if (!empty($record['_attachments'])) {
|
||||
foreach ($record['_attachments'] as $key => $attachment) {
|
||||
if ($attachment !== false) {
|
||||
if (!$attachment['name'])
|
||||
if (empty($attachment['name'])) {
|
||||
$attachment['name'] = $key;
|
||||
}
|
||||
$attachments[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
@ -1337,22 +1340,33 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
* Convert the given task record into a data structure that can be passed to kolab_storage backend for saving
|
||||
* (opposite of self::_to_rcube_event())
|
||||
*/
|
||||
private function _from_rcube_task($task, $old = array())
|
||||
private function _from_rcube_task($task, $old = [])
|
||||
{
|
||||
$object = $task;
|
||||
$id_prefix = $task['list'] . ':';
|
||||
|
||||
$toDT = function($date) {
|
||||
// Convert DateTime into libcalendaring_datetime
|
||||
return libcalendaring_datetime::createFromFormat(
|
||||
'Y-m-d\\TH:i:s',
|
||||
$date->format('Y-m-d\\TH:i:s'),
|
||||
$date->getTimezone()
|
||||
);
|
||||
};
|
||||
|
||||
if (!empty($task['date'])) {
|
||||
$object['due'] = rcube_utils::anytodatetime($task['date'].' '.$task['time'], $this->plugin->timezone);
|
||||
if (empty($task['time']))
|
||||
$object['due'] = $toDT(rcube_utils::anytodatetime($task['date'].' '.$task['time'], $this->plugin->timezone));
|
||||
if (empty($task['time'])) {
|
||||
$object['due']->_dateonly = true;
|
||||
}
|
||||
unset($object['date']);
|
||||
}
|
||||
|
||||
if (!empty($task['startdate'])) {
|
||||
$object['start'] = rcube_utils::anytodatetime($task['startdate'].' '.$task['starttime'], $this->plugin->timezone);
|
||||
if (empty($task['starttime']))
|
||||
$object['start'] = $toDT(rcube_utils::anytodatetime($task['startdate'].' '.$task['starttime'], $this->plugin->timezone));
|
||||
if (empty($task['starttime'])) {
|
||||
$object['start']->_dateonly = true;
|
||||
}
|
||||
unset($object['startdate']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue