Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Calendar/Export): make recur exceptions and alarms work in ics
Browse files Browse the repository at this point in the history
... by using the MSEventFacade controller which
 makes sure that the view on the event is correct and the recur
 exceptions are added

Change-Id: I0d02bb811af81e4c397c857cbaa5eef7e172dbbc
Reviewed-on: http://gerrit.tine20.com/customers/17105
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
  • Loading branch information
pschuele committed Jun 30, 2020
1 parent b069e26 commit e5a915f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
39 changes: 39 additions & 0 deletions tests/tine20/Calendar/Export/VCalendarTest.php
Expand Up @@ -61,6 +61,45 @@ public function testExportRecurEvent()
self::assertContains('RRULE:FREQ=DAILY', $result);
}

public function testExportRecurEventWithException()
{
$this->_testNeedsTransaction();

$event = $this->_getRecurEvent();
$event->rrule = 'FREQ=DAILY;INTERVAL=1';

$persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
$exceptions = new Tinebase_Record_RecordSet('Calendar_Model_Event');
$nextOccurance = Calendar_Model_Rrule::computeNextOccurrence($persistentEvent, $exceptions, Tinebase_DateTime::now());
$nextOccurance->summary = 'hard working woman needs some silence';
Calendar_Controller_Event::getInstance()->createRecurException($nextOccurance);

$result = $this->_export('stdout=1');

self::assertContains('hard working man needs some silence', $result);
self::assertContains('hard working woman needs some silence', $result);
self::assertContains('RRULE:FREQ=DAILY', $result);
self::assertContains('RECURRENCE-ID', $result);
}

public function testExportEventWithAlarm()
{
$this->_testNeedsTransaction();

$event = $this->_getEvent();
$event->alarms = new Tinebase_Record_RecordSet('Tinebase_Model_Alarm', array(
new Tinebase_Model_Alarm(array(
'minutes_before' => 30
), TRUE)
));
Calendar_Controller_Event::getInstance()->create($event);

$result = $this->_export('stdout=1');

self::assertContains('Early to bed and early to rise', $result);
self::assertContains('VALARM', $result);
}

public function testExportEventWithAttachment()
{
$this->_testNeedsTransaction();
Expand Down
17 changes: 17 additions & 0 deletions tine20/Calendar/Export/VCalendar.php
Expand Up @@ -29,6 +29,23 @@ public function getDownloadContentType()
return 'text/calendar';
}

/**
* need to use ms-event-facade to make sure we have the correct "view" on alarms and recur exceptions
*
* @param bool $ignoreAcl
* @return Calendar_Controller_MSEventFacade
*
* TODO support $ignoreAcl param?
*/
protected function _getController($ignoreAcl = false)
{
if ($ignoreAcl && Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Ignore ACL is not supported in this export.');
}

return Calendar_Controller_MSEventFacade::getInstance();
}

/**
* @return string|null
*/
Expand Down
15 changes: 13 additions & 2 deletions tine20/Tinebase/Export/Abstract.php
Expand Up @@ -276,8 +276,10 @@ public function __construct(
$this->_applicationName = $this->_filter->getApplicationName();
}

$this->_controller = ($_controller !== null) ? $_controller :
Tinebase_Core::getApplicationInstance($this->_applicationName, $this->_modelName, isset($_additionalOptions['ignoreACL']) && $_additionalOptions['ignoreACL']);
$this->_controller = ($_controller !== null)
? $_controller
: $this->_getController(isset($_additionalOptions['ignoreACL']) && $_additionalOptions['ignoreACL']);

$this->_translate = Tinebase_Translation::getTranslation($this->_applicationName);
$this->_tinebaseTranslate = Tinebase_Translation::getTranslation('Tinebase');
$this->_locale = Tinebase_Core::getLocale();
Expand Down Expand Up @@ -447,6 +449,15 @@ public function __construct(
}
}

protected function _getController($ignoreAcl = false)
{
return Tinebase_Core::getApplicationInstance(
$this->_applicationName,
$this->_modelName,
$ignoreAcl
);
}

protected function _parseTemplatePath($_path)
{
if (strpos($_path, 'tine20://') !== 0) {
Expand Down

0 comments on commit e5a915f

Please sign in to comment.