diff --git a/.github/workflows/php-test-develop.yml b/.github/workflows/php-test-develop.yml index 4b659f3..fa67b05 100644 --- a/.github/workflows/php-test-develop.yml +++ b/.github/workflows/php-test-develop.yml @@ -9,7 +9,7 @@ jobs: tests: uses: humhub/actions/.github/workflows/module-tests-develop.yml@main with: - module-id: external_calendar + module-id: external-calendar install-composer: true additional-module-id: calendar - additional-module-composer: true \ No newline at end of file + additional-module-composer: true diff --git a/.github/workflows/php-test-master.yml b/.github/workflows/php-test-master.yml index fc9e95f..ca09e85 100644 --- a/.github/workflows/php-test-master.yml +++ b/.github/workflows/php-test-master.yml @@ -7,7 +7,7 @@ jobs: tests: uses: humhub/actions/.github/workflows/module-tests-master.yml@main with: - module-id: external_calendar + module-id: external-calendar install-composer: true additional-module-id: calendar additional-module-composer: true diff --git a/.github/workflows/php-test-next.yml b/.github/workflows/php-test-next.yml index 0427696..e851a3f 100644 --- a/.github/workflows/php-test-next.yml +++ b/.github/workflows/php-test-next.yml @@ -1,15 +1,15 @@ -name: PHP Codeception Tests - next - -on: - push: - schedule: - - cron: "0 0 * * 0" - -jobs: - tests: - uses: humhub/actions/.github/workflows/module-tests-next.yml@main - with: - module-id: external_calendar - install-composer: true - additional-module-id: calendar - additional-module-composer: true +name: PHP Codeception Tests - next + +on: + push: + schedule: + - cron: "0 0 * * 0" + +jobs: + tests: + uses: humhub/actions/.github/workflows/module-tests-next.yml@main + with: + module-id: external-calendar + install-composer: true + additional-module-id: calendar + additional-module-composer: true diff --git a/Events.php b/Events.php index 7aca598..9713743 100644 --- a/Events.php +++ b/Events.php @@ -41,7 +41,7 @@ public static function registerAutoloader() return; } - require Yii::getAlias('@external_calendar/vendor/autoload.php'); + require Yii::getAlias('@external-calendar/vendor/autoload.php'); } /** @@ -55,7 +55,7 @@ public static function onGetCalendarItemTypes($event) try { $contentContainer = $event->contentContainer; - if (!$contentContainer || $contentContainer->moduleManager->isEnabled('external_calendar')) { + if (!$contentContainer || $contentContainer->moduleManager->isEnabled('external-calendar')) { CalendarExtension::addItemTypes($event); } } catch (\Throwable $e) { @@ -71,14 +71,14 @@ public static function onContainerConfigMenuInit($event) try { /* @var $container ContentContainerActiveRecord */ $container = $event->sender->contentContainer; - if($container && $container->moduleManager->isEnabled('external_calendar')) { + if($container && $container->moduleManager->isEnabled('external-calendar')) { $event->sender->addItem([ 'label' => Yii::t('ExternalCalendarModule.base', 'External Calendars'), 'id' => 'tab-calendar-external', - 'url' => $container->createUrl('/external_calendar/calendar/index'), + 'url' => $container->createUrl('/external-calendar/calendar/index'), 'visible' => $container->can(ManageEntry::class), 'isActive' => (Yii::$app->controller->module - && Yii::$app->controller->module->id === 'external_calendar'), + && Yii::$app->controller->module->id === 'external-calendar'), ]); } } catch (\Throwable $e) { @@ -92,7 +92,7 @@ public static function onFindCalendarItems($event) /* @var ContentContainerActiveRecord $contentContainer */ $contentContainer = $event->contentContainer; - if (!$contentContainer || $contentContainer->moduleManager->isEnabled('external_calendar')) { + if (!$contentContainer || $contentContainer->moduleManager->isEnabled('external-calendar')) { CalendarExtension::addItems($event); } } catch (\Throwable $e) { @@ -124,10 +124,10 @@ public static function onAdminMenuInit($event) try { $event->sender->addItem([ 'label' => "external_calendar", - 'url' => Url::to(['/external_calendar/admin']), + 'url' => Url::to(['/external-calendar/admin']), 'group' => 'manage', 'icon' => '', - 'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'external_calendar' && Yii::$app->controller->id == 'admin'), + 'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'external-calendar' && Yii::$app->controller->id == 'admin'), 'sortOrder' => 99999, ]); } catch (\Throwable $e) { diff --git a/Module.php b/Module.php index 5c0169c..48df662 100644 --- a/Module.php +++ b/Module.php @@ -101,13 +101,13 @@ public function disableContentContainer(ContentContainerActiveRecord $container) public function getConfigUrl() { - return Url::to(['/external_calendar/config/index']); + return Url::to(['/external-calendar/config/index']); } public function getContentContainerConfigUrl(ContentContainerActiveRecord $container) { if ($container->permissionManager->can(ManageCalendar::class)) { - return $container->createUrl('/external_calendar/calendar/index'); + return $container->createUrl('/external-calendar/calendar/index'); } else { return; } diff --git a/assets/Assets.php b/assets/Assets.php index e8b998b..3b8cdcf 100644 --- a/assets/Assets.php +++ b/assets/Assets.php @@ -1,30 +1,30 @@ - View::POS_END]; - - public $publishOptions = [ - 'forceCopy' => false - ]; - - public $css = [ - 'css/humhub.external_calendar.css' - ]; - - public $js = [ - 'js/humhub.external_calendar.js' - ]; -} + View::POS_END]; + + public $publishOptions = [ + 'forceCopy' => false + ]; + + public $css = [ + 'css/humhub.external_calendar.css' + ]; + + public $js = [ + 'js/humhub.external_calendar.js' + ]; +} diff --git a/components/PageUrlRule.php b/components/PageUrlRule.php index 463e725..6afa701 100644 --- a/components/PageUrlRule.php +++ b/components/PageUrlRule.php @@ -22,7 +22,7 @@ class PageUrlRule extends Component implements UrlRuleInterface /** * @var string default route to page home */ - public $searchRoute = 'external_calendar/export/export'; + public $searchRoute = 'external-calendar/export/export'; /** * @var array map with space guid/url pairs diff --git a/config.php b/config.php index faa648d..9588ef9 100644 --- a/config.php +++ b/config.php @@ -9,7 +9,7 @@ use humhub\components\Application; return [ - 'id' => 'external_calendar', + 'id' => 'external-calendar', 'class' => Module::class, 'namespace' => 'humhub\modules\external_calendar', 'urlManagerRules' => [ @@ -28,4 +28,3 @@ ], ]; ?> - diff --git a/controllers/EntryController.php b/controllers/EntryController.php index db5e0e2..df380b1 100644 --- a/controllers/EntryController.php +++ b/controllers/EntryController.php @@ -62,7 +62,7 @@ private function renderModal($model, $cal) { return $this->renderAjax('modal', [ 'model' => $model, - 'editUrl' => $this->contentContainer->createUrl('/external_calendar/entry/update', ['id' => $model->id, 'cal' => $cal]), + 'editUrl' => $this->contentContainer->createUrl('/external-calendar/entry/update', ['id' => $model->id, 'cal' => $cal]), 'canManageEntries' => $model->content->canEdit(), 'contentContainer' => $this->contentContainer, ]); @@ -123,7 +123,7 @@ public function actionUpdate($id, $cal = null) return $this->renderAjax('update', [ 'model' => $model, 'contentContainer' => $this->contentContainer, - 'editUrl' => $this->contentContainer->createUrl('/external_calendar/entry/update', ['id' => $model->id, 'cal' => $cal]), + 'editUrl' => $this->contentContainer->createUrl('/external-calendar/entry/update', ['id' => $model->id, 'cal' => $cal]), ]); } diff --git a/controllers/ExportController.php b/controllers/ExportController.php index a59cb7d..519b43c 100644 --- a/controllers/ExportController.php +++ b/controllers/ExportController.php @@ -57,7 +57,7 @@ public function actionExport($token, $from = null, $to = null) $ics = $this->exportService->createIcsByExportToken($token, $from, $to); /** @var Module $module */ - $module = Yii::$app->getModule('external_calendar'); + $module = Yii::$app->getModule('external-calendar'); return Yii::$app->response->sendContentAsFile($ics, $module->exportFileName, ['mimeType' => $module->exportFileMime]); } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 64cc574..101da3a 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,7 @@ Changelog - Fix #76: Disabling the module in a container (Space or User) - Fix #78: Remove module name translation - Enh #79: Replace theme variables with CSS variables +- Fix #80: Fix module ID 1.4.2 (January 19, 2023) ----------------------- diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 14ebd0d..12cb160 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -4,9 +4,9 @@ then go to `Administration -> Modules` and **Enable** the **External Calendar** module. -**_Note:_** You need to enable the [original calendar module](https://github.com/humhub/humhub-modules-calendar) first. The external_calendar module only works if it is activated! +**_Note:_** You need to enable the [original calendar module](https://github.com/humhub/humhub-modules-calendar) first. The external calendar module only works if it is activated! -If you want to add external calendars, go to a specific space (or your own profile), activate the external_calendar module in the space settings (or profile settings) and start the configuration of the module here. +If you want to add external calendars, go to a specific space (or your own profile), activate the external calendar module in the space settings (or profile settings) and start the configuration of the module here. **If there is an error, something went wrong with your sync.** ## Settings diff --git a/models/CalendarExport.php b/models/CalendarExport.php index 419e2f7..b0eafe1 100644 --- a/models/CalendarExport.php +++ b/models/CalendarExport.php @@ -119,7 +119,7 @@ public function getContainers() public function getExportUrl() { - return Url::to(['/external_calendar/export/export', 'token' => $this->token], true); + return Url::to(['/external-calendar/export/export', 'token' => $this->token], true); } /** @@ -161,4 +161,4 @@ public function attributeLabels() 'filter_only_public' => Yii::t('ExternalCalendarModule.export', 'Only include public events') ]; } -} \ No newline at end of file +} diff --git a/models/ExternalCalendar.php b/models/ExternalCalendar.php index e5bd2b7..c2cf224 100644 --- a/models/ExternalCalendar.php +++ b/models/ExternalCalendar.php @@ -66,7 +66,7 @@ class ExternalCalendar extends ContentActiveRecord implements Searchable /** * @inheritdoc */ - public $moduleId = 'external_calendar'; + public $moduleId = 'external-calendar'; /** * @inheritdoc */ @@ -288,7 +288,7 @@ public function afterMove(ContentContainerActiveRecord $container = null) public function getUrl() { - return $this->content->container->createUrl('//external_calendar/calendar/view', ['id' => $this->id]); + return $this->content->container->createUrl('/external-calendar/calendar/view', ['id' => $this->id]); } diff --git a/models/ExternalCalendarEntry.php b/models/ExternalCalendarEntry.php index 702ce84..368329a 100644 --- a/models/ExternalCalendarEntry.php +++ b/models/ExternalCalendarEntry.php @@ -1,574 +1,574 @@ -formatter = new CalendarDateFormatter(['calendarItem' => $this]); - } - - /** - * @inheritdoc - */ - public function getContentName() - { - return Yii::t('ExternalCalendarModule.base', "External Event"); - } - - /** - * @inheritdoc - */ - public function getContentDescription() - { - return $this->title; - } - - /** - * @inheritdoc - */ - public function getIcon() - { - return 'fa-calendar'; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['title', 'start_datetime', 'end_datetime'], 'required'], - [['start_datetime', 'end_datetime', 'dtstamp', 'last_modified'], 'validateDate'], - [['all_day'], 'integer'], - [['title'], 'string', 'max' => 200], - [['location'], 'string'], - [['end_datetime'], 'validateEndTime'], - [['description'], 'safe'], - ]; - } - - public function validateDate($attribute) - { - if(!empty($this->$attribute) && !CalendarUtils::isInDbFormat($this->$attribute)) { - $this->addError($attribute, "Invalid Date format used for $attribute: ".$this->$attribute); - } - } - - /** - * Validator for the end_datetime field. - * Execute this after DbDateValidator - * - * @param string $attribute attribute name - * @param array $params parameters - * @throws \Exception - */ - public function validateEndTime($attribute, $params) - { - if (new DateTime($this->start_datetime) > new DateTime($this->end_datetime)) { - $this->addError($attribute, Yii::t('ExternalCalendarModule.base', "End time must be after start time!")); - } - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'ID'), - 'uid' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'UID'), - 'calendar_id' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Calendar'), - 'title' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Title'), - 'description' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Description'), - 'location' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Location'), - 'last_modified' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Last Modified'), - 'dtstamp' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'DT Stamp'), - 'start_datetime' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Start Datetime'), - 'end_datetime' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'End Datetime'), - 'all_day' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'All Day'), - ]; - } - - /** - * @inheritdoc - */ - public function getSearchAttributes() - { - return [ - 'title' => $this->title, - 'description' => $this->description, - 'location' => $this->location, - 'calendar' => $this->calendar->title, - ]; - } - - public function beforeSave($insert) - { - $this->process(); - return parent::beforeSave($insert); - } - - private function process() - { - $this->setSettings(); - - - // We removed this since the sync logic is responsible for checking full day events - /*if (!$this->all_day && CalendarUtils::isFullDaySpan(new DateTime($this->start_datetime), new DateTime($this->end_datetime))) { - $this->all_day = 1; - }*/ - - $end = new DateTime($this->end_datetime, new DateTimeZone(Yii::$app->timeZone)); - - if($this->all_day && ($this->end_datetime === $this->start_datetime)) { - $end->modify('+1 day'); - } - - if ($this->all_day && $end->format('H:i:s') === '00:00:00') { - $end->modify('-1 second'); - } - - $this->end_datetime = $end->format('Y-m-d H:i:s'); - } - - public function setSettings() - { - $settings = ConfigForm::instantiate(); - - if ($settings->autopost_entries && (!$this->isRecurringInstance() || $this->is_altered)) { - // set back to autopost true - $this->streamChannel = 'default'; - - // Only create activities etc for upcoming events - if($this->getStartDateTime() >= new DateTime('now')) { - $this->silentContentCreation = false; - } - } - } - - public function beforeDelete() - { - $this->deleteRecurringInstances(); - return parent::beforeDelete(); // TODO: Change the autogenerated stub - } - - /** - * @inheritdoc - */ - public function getFullCalendarArray() - { - $start = $this->getStartDateTime(); - $end = $this->getEndDateTime(); - - if ($this->all_day) { - $end = $end->modify('+1 second'); - } - - if($this->isRecurringInstance() && empty($this->id)) { - $viewUrl = $this->content->container->createUrl('/external_calendar/entry/view-recurrence', ['parent_id' => $this->parent_event_id, 'recurrence_id' => $this->recurrence_id, 'cal' => '1']); - $openUrl = $this->content->container->createUrl('/external_calendar/entry/view-recurrence', ['parent_id' => $this->parent_event_id, 'recurrence_id' => $this->recurrence_id]); - } else { - $viewUrl = $this->content->container->createUrl('/external_calendar/entry/view', ['id' => $this->id, 'cal' => '1']); - $openUrl = $this->content->container->createUrl('/external_calendar/entry/view', ['id' => $this->id]); - } - - return [ - 'uid' => $this->uid, - 'start' => $start, - 'end' => $end, - 'title' => Html::encode($this->getTitle()), - 'editable' => false, - 'allDay' => $this->isAllDay(), - 'rrule' => $this->rrule, - 'exdate' => $this->exdate, - 'viewUrl' => $viewUrl, - 'viewMode' => 'redirect', - 'openUrl' => $openUrl, - 'badge' => Label::asColor($this->calendar->color, $this->getContentName())->icon('fa-calendar-o')->right() - ]; - } - - public function getUrl() - { - return $this->content->container->createUrl('/external_calendar/entry/view', ['id' => $this->id]); - } - - /** - * @inheritdoc - */ - public function getTimezone() - { - return $this->time_zone; - } - - public function getStartDateTime() - { - return new DateTime($this->start_datetime, CalendarUtils::getSystemTimeZone()); - } - - public function getEndDateTime() - { - return new DateTime($this->end_datetime, CalendarUtils::getSystemTimeZone()); - } - - public function getLastModifiedDateTime() - { - return new DateTime($this->last_modified,CalendarUtils::getSystemTimeZone()); - } - - public function getFormattedTime($format = 'long') - { - return $this->formatter->getFormattedTime($format); - } - - /** - * @return boolean weather or not this item spans exactly over a whole day - */ - public function isAllDay() - { - if ($this->all_day === null) { - return true; - } - - return (boolean)$this->all_day; - } - - public function isRecurringRoot() - { - return $this->isRecurring() && !$this->isRecurringInstance(); - } - - public function isRecurring() - { - return !empty($this->rrule); - } - - public function isRecurringInstance() - { - return $this->parent_event_id !== null; - } - - /** - * - * @return string the timezone this item was originally saved, note this is - */ - public function getTitle() - { - return $this->title; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getParent() - { - return $this->hasOne(self::class, ['id' => 'parent_event_id']); - } - - /** - * @param null|array|string $recurrenceIds Filters the result by either an array of recurrence ids or a single recurrence id - * @return \yii\db\ActiveQuery - */ - public function getRecurrences($recurrenceIds = null) - { - if (is_string($recurrenceIds)) { - $recurrenceIds = [$recurrenceIds]; - } elseif (is_array($recurrenceIds) && empty($recurrenceIds)) { - return; - } - - $query = $this->hasMany(self::class, ['parent_event_id' => 'id']) - ->andWhere(['calendar_id' => $this->calendar_id]) - ->andWhere(['uid' => $this->uid]); - - if(is_array($recurrenceIds)) { - array_walk($recurrenceIds, function(&$item) { - $item = CalendarUtils::cleanRecurrentId($item); - }); - $query->andWhere(['IN', 'recurrence_id', $recurrenceIds]); - } - - return $query; - } - - /** - * Deletes all recurrent instances of this recurrence root. - * - * The $filter parameter can be used to either filter the recurrence instances to delete - * by - * - * - DateTimeInterFace object in order to delete instances starting after the given date. - * - Array of recurrence ids in order to delete specific recurrences - * - String of a single recurrence id - * - * @param null|\DateTimeInterFace|array|string $filter - * @throws \Throwable - * @throws StaleObjectExceptionAlias - */ - public function deleteRecurringInstances($filter = null) - { - if (!$this->isRecurringRoot()) { - return; - } - - if (is_array($filter) || is_string($filter)) { - $instances = $this->getRecurrences($filter)->all(); - } else if ($filter instanceof \DateTimeInterface) { - $instances = $this->getRecurrences()->andFilterWhere(['>', 'start_datetime', $filter->format('Y-m-d H:i:s')])->all(); - } else { - $instances = $this->recurrences; - } - - foreach ($instances as $recurrence) { - $recurrence->hardDelete(); - } - } - - /** - * @param $recurrenceId - * @return ExternalCalendarEntry - */ - public function getRecurrenceInstance($recurrenceId) - { - if ($this->recurrence_id === $recurrenceId) { - return $this; - } - return $this->getRecurrences()->andWhere(['recurrence_id' => CalendarUtils::cleanRecurrentId($recurrenceId)])->one(); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getAlteredRecurrences() - { - return $this->getRecurrences()->andWhere(['is_altered' => 1]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCalendar() - { - return $this->hasOne(ExternalCalendar::class, ['id' => 'calendar_id']); - } - - public function generateIcs() - { - $module = Yii::$app; - $timezone = $module->settings->get('defaultTimeZone'); - $ics = new ICS($this->title, $this->description, $this->start_datetime, $this->end_datetime, $this->location, null, $timezone, $this->all_day); - return $ics; - } - - public function getRecurrenceUntil() - { - if (empty($this->rrule)) { - return null; - } - - return (new Rule($this->rrule))->getUntil(); - } - - /** - * @return ExternalCalendarEntry - */ - public function syncWithICal(ICalEventIF $icalEvent, $timeZone = null, $save = true) - { - $this->uid = $icalEvent->getUid(); - $this->title = $icalEvent->getTitle(); - $this->description = $icalEvent->getDescription(); - - if (!empty($icalEvent->getRrule())) { - $this->setRRule(($icalEvent->getRrule())); - - if (!$this->recurrence_id && !$icalEvent->getRecurrenceId()) { - $this->recurrence_id = CalendarUtils::cleanRecurrentId($icalEvent->getStart()); - } - } - - if ($icalEvent->getRecurrenceId()) { - $this->recurrence_id = $icalEvent->getRecurrenceId(); - } - - $this->location = $icalEvent->getLocation(); - $this->last_modified = CalendarUtils::toDBDateFormat($icalEvent->getLastModified()); - $this->dtstamp = CalendarUtils::toDBDateFormat($icalEvent->getTimeStamp()); - $this->start_datetime = CalendarUtils::toDBDateformat($icalEvent->getStartDateTime()); - $this->end_datetime = CalendarUtils::toDBDateFormat($icalEvent->getEndDateTime()); - $this->exdate = $icalEvent->getExdate(); - - if ($timeZone) { - $this->time_zone = $timeZone; - } - - $this->all_day = (int) $icalEvent->isAllDay(); - - if ($save && !$this->save()) { - Yii::error('Could not save ical event '.$icalEvent->getUid()); - Yii::error($this->getErrors()); - } - - return $this; - } - - public function createRecurrence($start, $end, $recurrenceId, $save = true) - { - $instance = new static($this->content->container, $this->content->visibility); - $instance->content->created_by = $this->content->created_by; - $instance->uid = $this->uid; - $instance->parent_event_id = $this->id; - $instance->start_datetime = CalendarUtils::toDBDateFormat($start); - $instance->end_datetime = CalendarUtils::toDBDateFormat($end); - $instance->title = $this->title; - $instance->rrule = $this->rrule; - $instance->calendar_id = $this->calendar_id; - $instance->description = $this->description; - $instance->location = $this->location; - $instance->last_modified = $this->last_modified; - $instance->dtstamp = $this->dtstamp; - $instance->all_day = $this->all_day; - $instance->time_zone = $this->time_zone; - $instance->recurrence_id = CalendarUtils::cleanRecurrentId($recurrenceId); - - if($save) { - $instance->save(); - } else { - // We at least have to validate in order to trigger date validation/transformation - $instance->validate(); - $this->process(); - } - return $instance; - } - - public function setRRule($rrule) - { - if (!empty($rrule)) { - $this->rrule = $rrule; - $until = $this->getRecurrenceUntil(); - if ($until) { - $this->recurrence_until = $until->format('Y-m-d H:i:s'); - } else { - $this->recurrence_until = null; - } - } else { - $this->rrule = null; - $this->recurrence_until = null; - } - } - - public function wasModifiedSince(ICalEventIF $icalEvent) - { - if(!$icalEvent->getLastModified()) { - return false; - } - - return !$this->last_modified || CalendarUtils::formatDateTimeToAppTime($icalEvent->getLastModified()) > $this->getLastModifiedDateTime(); - } - - /** - * Get location of this external calendar entry - * - * @return string - */ - public function getLocation(bool $asHtml = false) - { - if (!$asHtml) { - return $this->location; - } - if ( - filter_var($this->location, FILTER_VALIDATE_URL) !== false - && strpos($this->location, 'https://') === 0 // restrict to secure URLs (and not HTTP, SSF, FTP, etc.) - ) { - return Button::asLink($this->location)->link($this->location)->options(['target' => '_blank']); - } - return Html::encode($this->location); - } -} +formatter = new CalendarDateFormatter(['calendarItem' => $this]); + } + + /** + * @inheritdoc + */ + public function getContentName() + { + return Yii::t('ExternalCalendarModule.base', "External Event"); + } + + /** + * @inheritdoc + */ + public function getContentDescription() + { + return $this->title; + } + + /** + * @inheritdoc + */ + public function getIcon() + { + return 'fa-calendar'; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [['title', 'start_datetime', 'end_datetime'], 'required'], + [['start_datetime', 'end_datetime', 'dtstamp', 'last_modified'], 'validateDate'], + [['all_day'], 'integer'], + [['title'], 'string', 'max' => 200], + [['location'], 'string'], + [['end_datetime'], 'validateEndTime'], + [['description'], 'safe'], + ]; + } + + public function validateDate($attribute) + { + if(!empty($this->$attribute) && !CalendarUtils::isInDbFormat($this->$attribute)) { + $this->addError($attribute, "Invalid Date format used for $attribute: ".$this->$attribute); + } + } + + /** + * Validator for the end_datetime field. + * Execute this after DbDateValidator + * + * @param string $attribute attribute name + * @param array $params parameters + * @throws \Exception + */ + public function validateEndTime($attribute, $params) + { + if (new DateTime($this->start_datetime) > new DateTime($this->end_datetime)) { + $this->addError($attribute, Yii::t('ExternalCalendarModule.base', "End time must be after start time!")); + } + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'ID'), + 'uid' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'UID'), + 'calendar_id' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Calendar'), + 'title' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Title'), + 'description' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Description'), + 'location' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Location'), + 'last_modified' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Last Modified'), + 'dtstamp' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'DT Stamp'), + 'start_datetime' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'Start Datetime'), + 'end_datetime' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'End Datetime'), + 'all_day' => Yii::t('ExternalCalendarModule.model_calendar_entry', 'All Day'), + ]; + } + + /** + * @inheritdoc + */ + public function getSearchAttributes() + { + return [ + 'title' => $this->title, + 'description' => $this->description, + 'location' => $this->location, + 'calendar' => $this->calendar->title, + ]; + } + + public function beforeSave($insert) + { + $this->process(); + return parent::beforeSave($insert); + } + + private function process() + { + $this->setSettings(); + + + // We removed this since the sync logic is responsible for checking full day events + /*if (!$this->all_day && CalendarUtils::isFullDaySpan(new DateTime($this->start_datetime), new DateTime($this->end_datetime))) { + $this->all_day = 1; + }*/ + + $end = new DateTime($this->end_datetime, new DateTimeZone(Yii::$app->timeZone)); + + if($this->all_day && ($this->end_datetime === $this->start_datetime)) { + $end->modify('+1 day'); + } + + if ($this->all_day && $end->format('H:i:s') === '00:00:00') { + $end->modify('-1 second'); + } + + $this->end_datetime = $end->format('Y-m-d H:i:s'); + } + + public function setSettings() + { + $settings = ConfigForm::instantiate(); + + if ($settings->autopost_entries && (!$this->isRecurringInstance() || $this->is_altered)) { + // set back to autopost true + $this->streamChannel = 'default'; + + // Only create activities etc for upcoming events + if($this->getStartDateTime() >= new DateTime('now')) { + $this->silentContentCreation = false; + } + } + } + + public function beforeDelete() + { + $this->deleteRecurringInstances(); + return parent::beforeDelete(); // TODO: Change the autogenerated stub + } + + /** + * @inheritdoc + */ + public function getFullCalendarArray() + { + $start = $this->getStartDateTime(); + $end = $this->getEndDateTime(); + + if ($this->all_day) { + $end = $end->modify('+1 second'); + } + + if($this->isRecurringInstance() && empty($this->id)) { + $viewUrl = $this->content->container->createUrl('/external-calendar/entry/view-recurrence', ['parent_id' => $this->parent_event_id, 'recurrence_id' => $this->recurrence_id, 'cal' => '1']); + $openUrl = $this->content->container->createUrl('/external-calendar/entry/view-recurrence', ['parent_id' => $this->parent_event_id, 'recurrence_id' => $this->recurrence_id]); + } else { + $viewUrl = $this->content->container->createUrl('/external-calendar/entry/view', ['id' => $this->id, 'cal' => '1']); + $openUrl = $this->content->container->createUrl('/external-calendar/entry/view', ['id' => $this->id]); + } + + return [ + 'uid' => $this->uid, + 'start' => $start, + 'end' => $end, + 'title' => Html::encode($this->getTitle()), + 'editable' => false, + 'allDay' => $this->isAllDay(), + 'rrule' => $this->rrule, + 'exdate' => $this->exdate, + 'viewUrl' => $viewUrl, + 'viewMode' => 'redirect', + 'openUrl' => $openUrl, + 'badge' => Label::asColor($this->calendar->color, $this->getContentName())->icon('fa-calendar-o')->right() + ]; + } + + public function getUrl() + { + return $this->content->container->createUrl('/external-calendar/entry/view', ['id' => $this->id]); + } + + /** + * @inheritdoc + */ + public function getTimezone() + { + return $this->time_zone; + } + + public function getStartDateTime() + { + return new DateTime($this->start_datetime, CalendarUtils::getSystemTimeZone()); + } + + public function getEndDateTime() + { + return new DateTime($this->end_datetime, CalendarUtils::getSystemTimeZone()); + } + + public function getLastModifiedDateTime() + { + return new DateTime($this->last_modified,CalendarUtils::getSystemTimeZone()); + } + + public function getFormattedTime($format = 'long') + { + return $this->formatter->getFormattedTime($format); + } + + /** + * @return boolean weather or not this item spans exactly over a whole day + */ + public function isAllDay() + { + if ($this->all_day === null) { + return true; + } + + return (boolean)$this->all_day; + } + + public function isRecurringRoot() + { + return $this->isRecurring() && !$this->isRecurringInstance(); + } + + public function isRecurring() + { + return !empty($this->rrule); + } + + public function isRecurringInstance() + { + return $this->parent_event_id !== null; + } + + /** + * + * @return string the timezone this item was originally saved, note this is + */ + public function getTitle() + { + return $this->title; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getParent() + { + return $this->hasOne(self::class, ['id' => 'parent_event_id']); + } + + /** + * @param null|array|string $recurrenceIds Filters the result by either an array of recurrence ids or a single recurrence id + * @return \yii\db\ActiveQuery + */ + public function getRecurrences($recurrenceIds = null) + { + if (is_string($recurrenceIds)) { + $recurrenceIds = [$recurrenceIds]; + } elseif (is_array($recurrenceIds) && empty($recurrenceIds)) { + return; + } + + $query = $this->hasMany(self::class, ['parent_event_id' => 'id']) + ->andWhere(['calendar_id' => $this->calendar_id]) + ->andWhere(['uid' => $this->uid]); + + if(is_array($recurrenceIds)) { + array_walk($recurrenceIds, function(&$item) { + $item = CalendarUtils::cleanRecurrentId($item); + }); + $query->andWhere(['IN', 'recurrence_id', $recurrenceIds]); + } + + return $query; + } + + /** + * Deletes all recurrent instances of this recurrence root. + * + * The $filter parameter can be used to either filter the recurrence instances to delete + * by + * + * - DateTimeInterFace object in order to delete instances starting after the given date. + * - Array of recurrence ids in order to delete specific recurrences + * - String of a single recurrence id + * + * @param null|\DateTimeInterFace|array|string $filter + * @throws \Throwable + * @throws StaleObjectExceptionAlias + */ + public function deleteRecurringInstances($filter = null) + { + if (!$this->isRecurringRoot()) { + return; + } + + if (is_array($filter) || is_string($filter)) { + $instances = $this->getRecurrences($filter)->all(); + } else if ($filter instanceof \DateTimeInterface) { + $instances = $this->getRecurrences()->andFilterWhere(['>', 'start_datetime', $filter->format('Y-m-d H:i:s')])->all(); + } else { + $instances = $this->recurrences; + } + + foreach ($instances as $recurrence) { + $recurrence->hardDelete(); + } + } + + /** + * @param $recurrenceId + * @return ExternalCalendarEntry + */ + public function getRecurrenceInstance($recurrenceId) + { + if ($this->recurrence_id === $recurrenceId) { + return $this; + } + return $this->getRecurrences()->andWhere(['recurrence_id' => CalendarUtils::cleanRecurrentId($recurrenceId)])->one(); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAlteredRecurrences() + { + return $this->getRecurrences()->andWhere(['is_altered' => 1]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getCalendar() + { + return $this->hasOne(ExternalCalendar::class, ['id' => 'calendar_id']); + } + + public function generateIcs() + { + $module = Yii::$app; + $timezone = $module->settings->get('defaultTimeZone'); + $ics = new ICS($this->title, $this->description, $this->start_datetime, $this->end_datetime, $this->location, null, $timezone, $this->all_day); + return $ics; + } + + public function getRecurrenceUntil() + { + if (empty($this->rrule)) { + return null; + } + + return (new Rule($this->rrule))->getUntil(); + } + + /** + * @return ExternalCalendarEntry + */ + public function syncWithICal(ICalEventIF $icalEvent, $timeZone = null, $save = true) + { + $this->uid = $icalEvent->getUid(); + $this->title = $icalEvent->getTitle(); + $this->description = $icalEvent->getDescription(); + + if (!empty($icalEvent->getRrule())) { + $this->setRRule(($icalEvent->getRrule())); + + if (!$this->recurrence_id && !$icalEvent->getRecurrenceId()) { + $this->recurrence_id = CalendarUtils::cleanRecurrentId($icalEvent->getStart()); + } + } + + if ($icalEvent->getRecurrenceId()) { + $this->recurrence_id = $icalEvent->getRecurrenceId(); + } + + $this->location = $icalEvent->getLocation(); + $this->last_modified = CalendarUtils::toDBDateFormat($icalEvent->getLastModified()); + $this->dtstamp = CalendarUtils::toDBDateFormat($icalEvent->getTimeStamp()); + $this->start_datetime = CalendarUtils::toDBDateformat($icalEvent->getStartDateTime()); + $this->end_datetime = CalendarUtils::toDBDateFormat($icalEvent->getEndDateTime()); + $this->exdate = $icalEvent->getExdate(); + + if ($timeZone) { + $this->time_zone = $timeZone; + } + + $this->all_day = (int) $icalEvent->isAllDay(); + + if ($save && !$this->save()) { + Yii::error('Could not save ical event '.$icalEvent->getUid()); + Yii::error($this->getErrors()); + } + + return $this; + } + + public function createRecurrence($start, $end, $recurrenceId, $save = true) + { + $instance = new static($this->content->container, $this->content->visibility); + $instance->content->created_by = $this->content->created_by; + $instance->uid = $this->uid; + $instance->parent_event_id = $this->id; + $instance->start_datetime = CalendarUtils::toDBDateFormat($start); + $instance->end_datetime = CalendarUtils::toDBDateFormat($end); + $instance->title = $this->title; + $instance->rrule = $this->rrule; + $instance->calendar_id = $this->calendar_id; + $instance->description = $this->description; + $instance->location = $this->location; + $instance->last_modified = $this->last_modified; + $instance->dtstamp = $this->dtstamp; + $instance->all_day = $this->all_day; + $instance->time_zone = $this->time_zone; + $instance->recurrence_id = CalendarUtils::cleanRecurrentId($recurrenceId); + + if($save) { + $instance->save(); + } else { + // We at least have to validate in order to trigger date validation/transformation + $instance->validate(); + $this->process(); + } + return $instance; + } + + public function setRRule($rrule) + { + if (!empty($rrule)) { + $this->rrule = $rrule; + $until = $this->getRecurrenceUntil(); + if ($until) { + $this->recurrence_until = $until->format('Y-m-d H:i:s'); + } else { + $this->recurrence_until = null; + } + } else { + $this->rrule = null; + $this->recurrence_until = null; + } + } + + public function wasModifiedSince(ICalEventIF $icalEvent) + { + if(!$icalEvent->getLastModified()) { + return false; + } + + return !$this->last_modified || CalendarUtils::formatDateTimeToAppTime($icalEvent->getLastModified()) > $this->getLastModifiedDateTime(); + } + + /** + * Get location of this external calendar entry + * + * @return string + */ + public function getLocation(bool $asHtml = false) + { + if (!$asHtml) { + return $this->location; + } + if ( + filter_var($this->location, FILTER_VALIDATE_URL) !== false + && strpos($this->location, 'https://') === 0 // restrict to secure URLs (and not HTTP, SSF, FTP, etc.) + ) { + return Button::asLink($this->location)->link($this->location)->options(['target' => '_blank']); + } + return Html::encode($this->location); + } +} diff --git a/models/ExternalCalendarEntryQuery.php b/models/ExternalCalendarEntryQuery.php index feed50c..2b4da54 100644 --- a/models/ExternalCalendarEntryQuery.php +++ b/models/ExternalCalendarEntryQuery.php @@ -83,7 +83,7 @@ public function init() { parent::init(); if($this->autoSaveExtensions === null) { - $this->autoSaveExtensions = Yii::$app->getModule('external_calendar')->autoSaveExpansions; + $this->autoSaveExtensions = Yii::$app->getModule('external-calendar')->autoSaveExpansions; } } diff --git a/models/ICalSync.php b/models/ICalSync.php index 143b138..68dd3ca 100644 --- a/models/ICalSync.php +++ b/models/ICalSync.php @@ -148,7 +148,7 @@ private function syncICalEvents() $this->syncNonRecurringEvents(); $this->syncRecurringEvents(); } catch (\Exception $e) { - $this->error(Yii::t('ExternalCalendarModule.base', 'There was an error while synchronizing an ical calendar') . ': ' . $this->calendarModel->content->container->createUrl('/external_calendar/calendar/view', ['id' => $this->calendarModel->id]), $e); + $this->error(Yii::t('ExternalCalendarModule.base', 'There was an error while synchronizing an ical calendar') . ': ' . $this->calendarModel->content->container->createUrl('/external-calendar/calendar/view', ['id' => $this->calendarModel->id]), $e); } } diff --git a/models/forms/ConfigForm.php b/models/forms/ConfigForm.php index d82d6ba..0a6b0f8 100644 --- a/models/forms/ConfigForm.php +++ b/models/forms/ConfigForm.php @@ -1,85 +1,85 @@ -getModule('external_calendar')->settings; - $this->autopost_calendar = $settings->get('autopost_calendar', $this->autopost_calendar); - $this->autopost_entries = $settings->get('autopost_entries', $this->autopost_entries); - } - - /** - * Static initializer - * @return \self - */ - public static function instantiate() - { - return new self; - } - - /** - * Declares the validation rules. - */ - public function rules() - { - return [ - [['autopost_calendar', 'autopost_entries'], 'required'], - [['autopost_calendar', 'autopost_entries'], 'boolean'], - ]; - } - - /** - * Declares customized attribute labels. - * If not declared here, an attribute would have a label that is - * the same as its name with the first letter in upper case. - */ - public function attributeLabels() - { - return array( - 'autopost_calendar' => Yii::t('ExternalCalendarModule.model_config', 'Post new calendar on stream'), - 'autopost_entries' => Yii::t('ExternalCalendarModule.model_config', 'Post new entries on stream'), - ); - } - - /** - * Saves the given form settings. - */ - public function save() - { - if(!$this->validate()) { - return false; - } - - $settings = Yii::$app->getModule('external_calendar')->settings; - $settings->set('autopost_calendar', $this->autopost_calendar); - $settings->set('autopost_entries', $this->autopost_entries); - - return true; - - } - -} +getModule('external-calendar')->settings; + $this->autopost_calendar = $settings->get('autopost_calendar', $this->autopost_calendar); + $this->autopost_entries = $settings->get('autopost_entries', $this->autopost_entries); + } + + /** + * Static initializer + * @return \self + */ + public static function instantiate() + { + return new self; + } + + /** + * Declares the validation rules. + */ + public function rules() + { + return [ + [['autopost_calendar', 'autopost_entries'], 'required'], + [['autopost_calendar', 'autopost_entries'], 'boolean'], + ]; + } + + /** + * Declares customized attribute labels. + * If not declared here, an attribute would have a label that is + * the same as its name with the first letter in upper case. + */ + public function attributeLabels() + { + return array( + 'autopost_calendar' => Yii::t('ExternalCalendarModule.model_config', 'Post new calendar on stream'), + 'autopost_entries' => Yii::t('ExternalCalendarModule.model_config', 'Post new entries on stream'), + ); + } + + /** + * Saves the given form settings. + */ + public function save() + { + if(!$this->validate()) { + return false; + } + + $settings = Yii::$app->getModule('external-calendar')->settings; + $settings->set('autopost_calendar', $this->autopost_calendar); + $settings->set('autopost_entries', $this->autopost_entries); + + return true; + + } + +} diff --git a/module.json b/module.json index 2008ebe..0ac9361 100644 --- a/module.json +++ b/module.json @@ -1,5 +1,5 @@ { - "id": "external_calendar", + "id": "external-calendar", "name": "External Calendar", "description": "Extends the Calendar-Module to show external Calendars with iCal", "keywords": [ diff --git a/permissions/ManageCalendar.php b/permissions/ManageCalendar.php index 0dfe28d..891495d 100644 --- a/permissions/ManageCalendar.php +++ b/permissions/ManageCalendar.php @@ -1,56 +1,56 @@ -becomeUser('Admin'); diff --git a/tests/codeception/fixtures/ExternalCalendarEntryFixture.php b/tests/codeception/fixtures/ExternalCalendarEntryFixture.php index d9de657..eac4d23 100644 --- a/tests/codeception/fixtures/ExternalCalendarEntryFixture.php +++ b/tests/codeception/fixtures/ExternalCalendarEntryFixture.php @@ -15,7 +15,7 @@ class ExternalCalendarEntryFixture extends ActiveFixture { public $modelClass = ExternalCalendarEntry::class; - public $dataFile = '@external_calendar/tests/codeception/fixtures/data/externalCalendarEntry.php'; + public $dataFile = '@external-calendar/tests/codeception/fixtures/data/externalCalendarEntry.php'; public $depends = [ ExternalCalendarFixture::class diff --git a/tests/codeception/fixtures/ExternalCalendarFixture.php b/tests/codeception/fixtures/ExternalCalendarFixture.php index c52a21f..97af0b7 100644 --- a/tests/codeception/fixtures/ExternalCalendarFixture.php +++ b/tests/codeception/fixtures/ExternalCalendarFixture.php @@ -14,6 +14,6 @@ class ExternalCalendarFixture extends ActiveFixture { public $modelClass = ExternalCalendar::class; - public $dataFile = '@external_calendar/tests/codeception/fixtures/data/externalCalendar.php'; + public $dataFile = '@external-calendar/tests/codeception/fixtures/data/externalCalendar.php'; } diff --git a/tests/codeception/unit/ICalImportTest.php b/tests/codeception/unit/ICalImportTest.php index 1ac390f..b6b8d93 100644 --- a/tests/codeception/unit/ICalImportTest.php +++ b/tests/codeception/unit/ICalImportTest.php @@ -29,7 +29,7 @@ class ICalImportTest extends ExternalCalendarTest { public function testDuration() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/testDuration.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/testDuration.ics'); $event = $externalCalendar->entries[0]; $this->assertFalse($event->isAllDay()); @@ -38,7 +38,7 @@ public function testDuration() } public function testStartWithoutTimeNoEnd() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/startWithoutTimeNoEnd.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/startWithoutTimeNoEnd.ics'); $event = $externalCalendar->entries[0]; $this->assertTrue($event->isAllDay()); @@ -48,7 +48,7 @@ public function testStartWithoutTimeNoEnd() public function testStartWithTimeNoEnd() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/startWithTimeNoEnd.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/startWithTimeNoEnd.ics'); $event = $externalCalendar->entries[0]; $this->assertFalse($event->isAllDay()); @@ -58,7 +58,7 @@ public function testStartWithTimeNoEnd() public function testStartEqEndNoTime() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/startEqEndNoTime.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/startEqEndNoTime.ics'); $event = $externalCalendar->entries[0]; $this->assertTrue($event->isAllDay()); @@ -68,7 +68,7 @@ public function testStartEqEndNoTime() public function testStartEqEndZeroTime() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/startEqEndWithZeroTime.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/startEqEndWithZeroTime.ics'); $event = $externalCalendar->entries[0]; $this->assertFalse($event->isAllDay()); @@ -78,7 +78,7 @@ public function testStartEqEndZeroTime() public function testStartEqEndWithTime() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/startEqEndWithTime.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/startEqEndWithTime.ics'); $event = $externalCalendar->entries[0]; $this->assertFalse($event->isAllDay()); $this->assertFalse($event->isAllDay()); @@ -117,7 +117,7 @@ public function testSimpleCalendarUpdate() $firstEvent = $externalCalendar->entries[0]; - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/test1Update.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/test1Update.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $this->assertEquals(2, ExternalCalendarEntry::find()->count()); @@ -146,12 +146,12 @@ public function testSimpleCalendarUpdate() public function testImportAndDeleteEvent() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/test1Update2.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/test1Update2.ics'); $this->assertEquals(2, ExternalCalendarEntry::find()->count()); $this->assertCount(2, $externalCalendar->entries); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/test1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/test1.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); @@ -165,7 +165,7 @@ public function testImportAndDeleteEvent() public function testImportAndDeleteEvent2() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/test2.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/test2.ics'); $externalCalendar->sync( DateTime::createFromFormat('!Ymd', '20190101'), DateTime::createFromFormat('!Ymd', '2021101')); $this->assertEquals(1, ExternalCalendarEntry::find()->count()); @@ -182,14 +182,14 @@ public function testImportPublicVisibility() 'allowFiles' => true, 'title' => 'test', 'public' => Content::VISIBILITY_PUBLIC, - 'url' => $this->getFileAlias('@external_calendar/tests/codeception/data/test1.ics') + 'url' => $this->getFileAlias('@external-calendar/tests/codeception/data/test1.ics') ]); $externalCalendar->save(); $this->assertVisibility($externalCalendar, Content::VISIBILITY_PUBLIC); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/test1Update.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/test1Update.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $externalCalendar->refresh(); @@ -204,14 +204,14 @@ public function testImportPrivateVisibility() 'allowFiles' => true, 'title' => 'test', 'public' => Content::VISIBILITY_PRIVATE, - 'url' => Yii::getAlias('@external_calendar/tests/codeception/data/test1.ics') + 'url' => Yii::getAlias('@external-calendar/tests/codeception/data/test1.ics') ]); $externalCalendar->save(); $this->assertVisibility($externalCalendar, Content::VISIBILITY_PRIVATE); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/test1Update.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/test1Update.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $externalCalendar->refresh(); @@ -225,7 +225,7 @@ public function testImportPrivateVisibility() public function testImportChangeVisibility() { $this->becomeUser('Admin'); - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/test1.ics', [ + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/test1.ics', [ 'public' => Content::VISIBILITY_PRIVATE, 'event_mode' => ExternalCalendar::EVENT_MODE_ALL, ])->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); @@ -241,7 +241,7 @@ public function testImportChangeVisibility() public function testTimezone1() { - $this->initCalendar('@external_calendar/tests/codeception/data/timezone.ics'); + $this->initCalendar('@external-calendar/tests/codeception/data/timezone.ics'); /** @var $events ExternalCalendarEntry[] */ $events = ExternalCalendarEntryQuery::findForFilter( @@ -256,7 +256,7 @@ public function testTimezone1() public function testTimezone2() { - $this->initCalendar('@external_calendar/tests/codeception/data/timezone.ics'); + $this->initCalendar('@external-calendar/tests/codeception/data/timezone.ics'); /** @var $events ExternalCalendarEntry[] */ $events = ExternalCalendarEntryQuery::findForFilter( diff --git a/tests/codeception/unit/ICalWrapperTest.php b/tests/codeception/unit/ICalWrapperTest.php index 73beb05..c852984 100644 --- a/tests/codeception/unit/ICalWrapperTest.php +++ b/tests/codeception/unit/ICalWrapperTest.php @@ -31,7 +31,7 @@ class ICalWrapperTest extends ExternalCalendarTest */ public function testIncludingRecurringEvent() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Split.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Split.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20191212', new \DateTimeZone('Europe/Berlin'))); @@ -50,7 +50,7 @@ public function testIncludingRecurringEvent() */ public function testRecurringEventAfterRange() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Split.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Split.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20190912', new \DateTimeZone('Europe/Berlin'))); @@ -69,7 +69,7 @@ public function testRecurringEventAfterRange() */ public function testRecurringEventStopsBeforeRange() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Split.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Split.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20191003', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20191005', new \DateTimeZone('Europe/Berlin'))); @@ -88,7 +88,7 @@ public function testRecurringEventStopsBeforeRange() */ public function testIncludeStartingRecurrenceOutsideOfRange() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/twoIndependentRecurrences.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/twoIndependentRecurrences.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20191003', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20191005', new \DateTimeZone('Europe/Berlin'))); @@ -108,7 +108,7 @@ public function testIncludeStartingRecurrenceOutsideOfRange() public function testICalEventAllDay() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/twoIndependentRecurrences.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/twoIndependentRecurrences.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20191003', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20191005', new \DateTimeZone('Europe/Berlin'))); @@ -118,7 +118,7 @@ public function testICalEventAllDay() public function testICalEventNonAllDay() { - $cal = new ICalFile(Yii::getAlias('@external_calendar/tests/codeception/data/test1WithTime.ics')); + $cal = new ICalFile(Yii::getAlias('@external-calendar/tests/codeception/data/test1WithTime.ics')); $events = $cal->getEventsFromRange( DateTime::createFromFormat('!Ymd', '20190816', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20190817', new \DateTimeZone('Europe/Berlin'))); @@ -129,4 +129,4 @@ public function testICalEventNonAllDay() $this->assertEquals('2019-08-16 20:30:00', CalendarUtils::toDBDateFormat($events[0]->getEndDateTime())); $this->assertFalse($events[0]->isAllDay()); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/RecurrenceExpandTest.php b/tests/codeception/unit/RecurrenceExpandTest.php index 39bcd56..15a419a 100644 --- a/tests/codeception/unit/RecurrenceExpandTest.php +++ b/tests/codeception/unit/RecurrenceExpandTest.php @@ -24,7 +24,7 @@ class RecurrenceExpandTest extends ExternalCalendarTest { public function testExpandSingle() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $recurrenceEvent = $externalCalendar->getRecurringEventRoots()[0]; $recurrence = ICalExpand::expandSingle($recurrenceEvent, '20190808'); $this->assertNotNull($recurrence); @@ -33,7 +33,7 @@ public function testExpandSingle() public function testExpandSingleExistingEvent() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $recurrenceEvent = $externalCalendar->getRecurringEventRoots()[0]; $recurrence = ICalExpand::expandSingle($recurrenceEvent, '20190808'); @@ -45,7 +45,7 @@ public function testExpandSingleExistingEvent() public function testExpandExistingEvent() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $recurrenceEvent = $externalCalendar->getRecurringEventRoots()[0]; $recurrence = ICalExpand::expandSingle($recurrenceEvent, '20190808'); @@ -59,4 +59,4 @@ public function testExpandExistingEvent() // Test deletion of altered recurrence root // Test delete exdate // Very complex test -} \ No newline at end of file +} diff --git a/tests/codeception/unit/RecurrentImportTest.php b/tests/codeception/unit/RecurrentImportTest.php index 34130d7..b66750f 100644 --- a/tests/codeception/unit/RecurrentImportTest.php +++ b/tests/codeception/unit/RecurrentImportTest.php @@ -35,9 +35,9 @@ class RecurrentImportTest extends ExternalCalendarTest */ public function testSimpleRecurrenceEventImport() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $this->assertEquals(1, ExternalCalendarEntry::find()->count()); $this->assertCount(1, $externalCalendar->entries); @@ -81,9 +81,9 @@ public function testSimpleRecurrenceEventImport() public function testRecurrentEvent1Until() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $oldEvents = ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20190930', new \DateTimeZone('Europe/Berlin')), @@ -93,7 +93,7 @@ public function testRecurrentEvent1Until() $this->assertCount(9, ExternalCalendarEntry::find()->all()); // Stop the recurrence on 01-09-2019 - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Until.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Until.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); // Make sure all overlapping recurrence instances were deleted and other existing ones remained @@ -143,9 +143,9 @@ public function testRecurrentEvent1Until() */ public function testSplitRecurringEvent1() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), @@ -154,7 +154,7 @@ public function testSplitRecurringEvent1() $this->assertCount(22, ExternalCalendarEntry::find()->all()); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Split.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Split.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); // Make sure old overlapping recurrences are deleted @@ -276,10 +276,10 @@ public function testSplitRecurringEvent1() */ public function testSplitRecurringEvent2() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1Split.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1Split.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); /** @var $events ExternalCalendarEntry[] * */ @@ -348,9 +348,9 @@ public function testSplitRecurringEvent2() public function testEndSplittedRecurringEvent() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1Split.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1Split.ics'); /** @var $events ExternalCalendarEntry[] * */ $events = ExternalCalendarEntryQuery::findForFilter( @@ -361,7 +361,7 @@ public function testEndSplittedRecurringEvent() $this->assertCount(35, ExternalCalendarEntry::find()->all()); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1SplitLimited.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1SplitLimited.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); /** @var $events ExternalCalendarEntry[] * */ @@ -436,9 +436,9 @@ public function testEndSplittedRecurringEvent() */ public function testDeleteRecurrence1() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1Split.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1Split.ics'); // Make sure the sync is not skipped $recurrence1 = $externalCalendar->entries[0]; @@ -455,7 +455,7 @@ public function testDeleteRecurrence1() $this->assertCount(35, ExternalCalendarEntry::find()->all()); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $this->assertCount(1, ExternalCalendarEntry::find()->all()); @@ -469,7 +469,7 @@ public function testDeleteRecurrence1() */ public function testDeleteRecurrenceOutOfRange() { - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1Split.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1Split.ics'); $this->assertCount(2, ExternalCalendarEntry::find()->all()); // Change start/end and RRULE->until of first event to a date before sync range @@ -502,7 +502,7 @@ public function testDeleteRecurrenceOutOfRange() $this->assertNotEmpty($events); // Sync with empty ical, this should remove all entries and recurrences - $externalCalendar->url = $this->getFileAlias('@external_calendar/tests/codeception/data/empty.ics'); + $externalCalendar->url = $this->getFileAlias('@external-calendar/tests/codeception/data/empty.ics'); $externalCalendar->save(); $externalCalendar->refresh(); @@ -525,9 +525,9 @@ public function testDeleteRecurrenceOutOfRange() */ public function testRecurrenceWithAlteredEvent1Simple() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $events = ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), @@ -543,7 +543,7 @@ public function testRecurrenceWithAlteredEvent1Simple() $recurrentEvent = $externalCalendar->getRecurringEventRoots()[0]; $this->assertEquals('20190808T000000', $recurrentEvent->recurrences[0]->recurrence_id); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurrentEvent = $externalCalendar->getRecurringEventRoots()[0]; @@ -577,10 +577,10 @@ public function testRecurrenceWithAlteredEvent1Simple() */ public function testRecurrenceWithAlteredEvent1NoExpansion() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurrentEvent = $externalCalendar->getRecurringEventRoots()[0]; @@ -616,10 +616,10 @@ public function testRecurrenceWithAlteredEvent1NoExpansion() */ public function testRecurrenceWithAlteredEvent1NonExpanded() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurrentEvent = $externalCalendar->getRecurringEventRoots()[0]; @@ -646,13 +646,13 @@ public function testRecurrenceWithAlteredEvent1NonExpanded() public function testAlteredEvent1Deletion() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $events = ExternalCalendarEntryQuery::findForFilter( @@ -673,16 +673,16 @@ public function testAlteredEvent1Deletion() */ public function testRecurrenceWithAlteredEvent2() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20190830', new \DateTimeZone('Europe/Berlin')), Space::findOne(1)); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $events = ExternalCalendarEntryQuery::findForFilter( @@ -723,16 +723,16 @@ public function testRecurrenceWithAlteredEvent2() */ public function testAlteredEvent2Deletion() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), DateTime::createFromFormat('!Ymd', '20190830', new \DateTimeZone('Europe/Berlin')), Space::findOne(1)); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); ExternalCalendarEntryQuery::findForFilter( @@ -740,7 +740,7 @@ public function testAlteredEvent2Deletion() DateTime::createFromFormat('!Ymd', '20190830', new \DateTimeZone('Europe/Berlin')), Space::findOne(1)); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurrenceRoot = $externalCalendar->getRecurringEventRoots()[0]; @@ -772,9 +772,9 @@ public function testAlteredEvent2Deletion() public function testRecurrentEventWithAlteredEvent2Edited() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent2.ics'); $events = ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), @@ -787,7 +787,7 @@ public function testRecurrentEventWithAlteredEvent2Edited() $this->assertEquals('2019-08-22 00:00:00', $events[3]->getStartDateTime()->format('Y-m-d H:i:s')); $this->assertEquals('2019-08-29 00:00:00', $events[4]->getStartDateTime()->format('Y-m-d H:i:s')); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithAlteredEvent2Edited.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithAlteredEvent2Edited.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $events = ExternalCalendarEntryQuery::findForFilter( @@ -818,9 +818,9 @@ public function testRecurrentEventWithAlteredEvent2Edited() public function testRecurrentEvent1WithExdate() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $recurrentEvent = $externalCalendar->getRecurringEventRoots()[0]; @@ -832,7 +832,7 @@ public function testRecurrentEvent1WithExdate() $this->assertNotNull($recurrentEvent->getRecurrenceInstance('20190815')); $this->assertNotNull($recurrentEvent->getRecurrenceInstance('20190822')); - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1WithExdate.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1WithExdate.ics'); $externalCalendar->sync($this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $this->assertNull($recurrentEvent->getRecurrenceInstance('20190815')); @@ -854,7 +854,7 @@ public function testRecurrentEvent1WithExdate() public function testTimezone1() { - $this->initCalendar('@external_calendar/tests/codeception/data/timezone.ics'); + $this->initCalendar('@external-calendar/tests/codeception/data/timezone.ics'); /** @var $events ExternalCalendarEntry[] */ $events = ExternalCalendarEntryQuery::findForFilter( @@ -879,7 +879,7 @@ public function testTimezone1() public function testTimezone2() { Yii::$app->timeZone = 'Europe/Berlin'; - $this->initCalendar('@external_calendar/tests/codeception/data/timezone.ics'); + $this->initCalendar('@external-calendar/tests/codeception/data/timezone.ics'); /** @var $events ExternalCalendarEntry[] */ $events = ExternalCalendarEntryQuery::findForFilter( @@ -903,8 +903,8 @@ public function testTimezone2() public function testRecurrenceStartChange() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $events = ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), @@ -915,7 +915,7 @@ public function testRecurrenceStartChange() $this->assertCount(5, ExternalCalendarEntry::find()->all()); // Make sure all recurrence instances are deleted after start ganged - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1ChangedStart.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1ChangedStart.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurringEvent = $externalCalendar->getRecurringEventRoots()[0]; @@ -926,8 +926,8 @@ public function testRecurrenceStartChange() public function testRecurrenceEndChange() { - Yii::$app->getModule('external_calendar')->autoSaveExpansions = true; - $externalCalendar = $this->initCalendar('@external_calendar/tests/codeception/data/recurrence1.ics'); + Yii::$app->getModule('external-calendar')->autoSaveExpansions = true; + $externalCalendar = $this->initCalendar('@external-calendar/tests/codeception/data/recurrence1.ics'); $events = ExternalCalendarEntryQuery::findForFilter( DateTime::createFromFormat('!Ymd', '20190801', new \DateTimeZone('Europe/Berlin')), @@ -938,7 +938,7 @@ public function testRecurrenceEndChange() $this->assertCount(5, ExternalCalendarEntry::find()->all()); // Make sure all recurrence instances are deleted after start ganged - $externalCalendar->url = Yii::getAlias('@external_calendar/tests/codeception/data/recurrence1ChangedEnd.ics'); + $externalCalendar->url = Yii::getAlias('@external-calendar/tests/codeception/data/recurrence1ChangedEnd.ics'); $externalCalendar->sync( $this->defaultSyncRangeStart, $this->defaultSyncRangeEnd); $recurringEvent = $externalCalendar->getRecurringEventRoots()[0]; diff --git a/tests/config/test.php b/tests/config/test.php index bb888b5..ae71315 100644 --- a/tests/config/test.php +++ b/tests/config/test.php @@ -1,12 +1,9 @@ ['calendar', 'external_calendar'], + 'modules' => ['calendar', 'external-calendar'], 'fixtures' => [ 'default', - 'external_calendar' => 'humhub\modules\external_calendar\tests\codeception\fixtures\ExternalCalendarEntryFixture' + 'external-calendar' => 'humhub\modules\external_calendar\tests\codeception\fixtures\ExternalCalendarEntryFixture' ] ]; - - - diff --git a/views/calendar/view.php b/views/calendar/view.php index 549f217..f009495 100644 --- a/views/calendar/view.php +++ b/views/calendar/view.php @@ -45,7 +45,7 @@ 'class' => 'btn btn-danger', 'title' => Yii::t('ExternalCalendarModule.base', 'Delete'), 'data' => [ - 'action-click' => 'external_calendar.removeCalendar', + 'action-click' => 'external-calendar.removeCalendar', 'action-confirm-header' => Yii::t('ExternalCalendarModule.base', 'Confirm deleting'), 'action-confirm' => Yii::t('ExternalCalendarModule.base', 'Are you sure you want to delete this item?'), 'action-confirm-text' => Yii::t('ExternalCalendarModule.base', 'Delete'), diff --git a/views/export/config.php b/views/export/config.php index 3273bbc..c46193a 100644 --- a/views/export/config.php +++ b/views/export/config.php @@ -18,7 +18,7 @@ Yii::t('ExternalCalendarModule.base', 'Calendar export'), 'size' => 'large']) ?> '@external_calendar/views/export', + 'viewPath' => '@external-calendar/views/export', 'params' => ['model' => $model], 'items' => [ ['label' => Yii::t('ExternalCalendarModule.base', 'New export'), 'view' => 'tab-edit'], diff --git a/views/export/tab-edit.php b/views/export/tab-edit.php index 2e5a519..44dd4c6 100644 --- a/views/export/tab-edit.php +++ b/views/export/tab-edit.php @@ -47,7 +47,7 @@ ], ['separator'=> '
']); ?> field($model, 'spaceSelection')->widget(SpacePickerField::class, - ['defaultResults' => CalendarExportSpaces::getCalendarMemberSpaces(), 'url' => Url::to(['/external_calendar/export/search-space'])])->label(false) ?> + ['defaultResults' => CalendarExportSpaces::getCalendarMemberSpaces(), 'url' => Url::to(['/external-calendar/export/search-space'])])->label(false) ?>
field($model, 'filter_participating')->checkbox() ?> @@ -59,7 +59,7 @@
- \ No newline at end of file + diff --git a/views/export/tab-overview.php b/views/export/tab-overview.php index 1f64f34..c349fec 100644 --- a/views/export/tab-overview.php +++ b/views/export/tab-overview.php @@ -51,11 +51,11 @@ Yii::t('ExternalCalendarModule.export', 'Edit') => ['edit', 'linkOptions' => [ 'data-action-click' => 'ui.modal.load', - 'data-action-url' => Url::to(['/external_calendar/export/edit', 'id' => $key]), + 'data-action-url' => Url::to(['/external-calendar/export/edit', 'id' => $key]), ]], Yii::t('ExternalCalendarModule.export', 'Delete') => ['edit', 'linkOptions' => [ 'data-action-click' => 'ui.modal.post', - 'data-action-url' => Url::to(['/external_calendar/export/delete', 'id' => $key]), + 'data-action-url' => Url::to(['/external-calendar/export/delete', 'id' => $key]), 'data-action-confirm' => true ]], ]; @@ -66,4 +66,3 @@ ]); ?> - diff --git a/widgets/DownloadIcsLink.php b/widgets/DownloadIcsLink.php index 8ad1478..ec6b89e 100644 --- a/widgets/DownloadIcsLink.php +++ b/widgets/DownloadIcsLink.php @@ -1,36 +1,36 @@ -calendarEntry === null) { - return; - } - - return Html::a(Yii::t('ExternalCalendarModule.base', 'Download as ICS file'), $this->calendarEntry->content->container->createUrl('/external_calendar/entry/generateics', ['id' => $this->calendarEntry->id]), ['target' => '_blank']); - } -} \ No newline at end of file +calendarEntry === null) { + return; + } + + return Html::a(Yii::t('ExternalCalendarModule.base', 'Download as ICS file'), $this->calendarEntry->content->container->createUrl('/external-calendar/entry/generateics', ['id' => $this->calendarEntry->id]), ['target' => '_blank']); + } +} diff --git a/widgets/ExportButton.php b/widgets/ExportButton.php index 9293fc0..d69669d 100644 --- a/widgets/ExportButton.php +++ b/widgets/ExportButton.php @@ -28,8 +28,8 @@ public function run() return ModalButton::defaultType() ->icon('download') - ->load(Yii::$app->user->getIdentity()->createUrl('/external_calendar/export/edit')) + ->load(Yii::$app->user->getIdentity()->createUrl('/external-calendar/export/edit')) ->tooltip(Yii::t('ExternalCalendarModule.base', 'Export')); } -} \ No newline at end of file +} diff --git a/widgets/WallEntry.php b/widgets/WallEntry.php index 3a47042..8c3799a 100644 --- a/widgets/WallEntry.php +++ b/widgets/WallEntry.php @@ -1,61 +1,61 @@ -renderOptions->disableControlsEntrySwitchVisibility(); - return parent::getControlsMenuEntries(); - } - - /** - * @return string returns the content type specific part of this wall entry (e.g. post content) - */ - protected function renderContent() - { - Assets::register($this->getView()); - - $entry = $this->model; - - return $this->render('wallEntry', [ - 'calendarEntry' => $entry, - 'contentContainer' => $entry->content->container - ]); - } - - /** - * @return string a non encoded plain text title (no html allowed) used in the header of the widget - */ - protected function getTitle() - { - return $this->model->title; - } -} +renderOptions->disableControlsEntrySwitchVisibility(); + return parent::getControlsMenuEntries(); + } + + /** + * @return string returns the content type specific part of this wall entry (e.g. post content) + */ + protected function renderContent() + { + Assets::register($this->getView()); + + $entry = $this->model; + + return $this->render('wallEntry', [ + 'calendarEntry' => $entry, + 'contentContainer' => $entry->content->container + ]); + } + + /** + * @return string a non encoded plain text title (no html allowed) used in the header of the widget + */ + protected function getTitle() + { + return $this->model->title; + } +} diff --git a/widgets/WallEntryCalendar.php b/widgets/WallEntryCalendar.php index 86e1b7d..48c3542 100644 --- a/widgets/WallEntryCalendar.php +++ b/widgets/WallEntryCalendar.php @@ -1,55 +1,55 @@ -getView()); - - return $this->render('wallEntryCalendar', [ - 'calendar' => $this->model - ]); - } - - public function getControlsMenuEntries() - { - $this->renderOptions->disableControlsEntrySwitchVisibility(); - return parent::getControlsMenuEntries(); - } - - - /** - * @return string a non encoded plain text title (no html allowed) used in the header of the widget - */ - protected function getTitle() - { - return $this->model->title; - } -} +getView()); + + return $this->render('wallEntryCalendar', [ + 'calendar' => $this->model + ]); + } + + public function getControlsMenuEntries() + { + $this->renderOptions->disableControlsEntrySwitchVisibility(); + return parent::getControlsMenuEntries(); + } + + + /** + * @return string a non encoded plain text title (no html allowed) used in the header of the widget + */ + protected function getTitle() + { + return $this->model->title; + } +}