diff --git a/Admin/Install/db.json b/Admin/Install/db.json index fb1364d..17f9ab3 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -55,22 +55,20 @@ "schedule_date": { "name": "schedule_date", "type": "DATETIME", - "null": false + "null": true, + "default": null }, "schedule_start": { "name": "schedule_start", "type": "DATETIME", - "null": false + "null": true, + "default": null }, "schedule_end": { "name": "schedule_end", "type": "DATETIME", - "null": false - }, - "schedule_numberofoccurrences": { - "name": "schedule_numberofoccurrences", - "type": "TINYINT(1)", - "null": false + "null": true, + "default": null }, "schedule_pattern_numberofoccurrences": { "name": "schedule_pattern_numberofoccurrences", @@ -233,6 +231,13 @@ "foreignTable": "calendar_event", "foreignKey": "calendar_event_id" }, + "calendar_event_calendar": { + "name": "calendar_event_calendar", + "type": "INT", + "null": false, + "foreignTable": "calendar", + "foreignKey": "calendar_id" + }, "calendar_event_created_at": { "name": "calendar_event_created_at", "type": "DATETIME", diff --git a/Models/CalendarMapper.php b/Models/CalendarMapper.php index b24c1e0..0a38f04 100755 --- a/Models/CalendarMapper.php +++ b/Models/CalendarMapper.php @@ -42,7 +42,7 @@ final class CalendarMapper extends DataMapperFactory /** * Has many relation. * - * @var array + * @var array * @since 1.0.0 */ public const HAS_MANY = [ diff --git a/Models/Event.php b/Models/Event.php index b057f42..c8ec405 100755 --- a/Models/Event.php +++ b/Models/Event.php @@ -106,6 +106,25 @@ class Event */ public Location $location; + public \DateTime $start; + public \DateTime $end; + + public int $showAs = 0; + + public bool $hiddenAttendees = false; + + public bool $isAllDay = true; + + public bool $isCancelled = false; + + public bool $isDraft = false; + + public bool $isOnlineMeeting = false; + + public string $webLink = ''; + + public string $externalId = ''; + /** * Calendar * @@ -142,6 +161,8 @@ class Event $this->location = new Location(); $this->schedule = new Schedule(); $this->calendar = 0; + $this->start = new \DateTime('now'); + $this->end = new \DateTime('now'); } /** diff --git a/Models/EventMapper.php b/Models/EventMapper.php index c1cfd02..2498301 100755 --- a/Models/EventMapper.php +++ b/Models/EventMapper.php @@ -41,8 +41,18 @@ final class EventMapper extends DataMapperFactory 'calendar_event_location' => ['name' => 'calendar_event_location', 'type' => 'Serializable', 'internal' => 'location'], 'calendar_event_type' => ['name' => 'calendar_event_type', 'type' => 'int', 'internal' => 'type'], 'calendar_event_status' => ['name' => 'calendar_event_status', 'type' => 'int', 'internal' => 'status'], + 'calendar_event_show_as' => ['name' => 'calendar_event_show_as', 'type' => 'int', 'internal' => 'showAs'], + 'calendar_event_hidden_attendees' => ['name' => 'calendar_event_hidden_attendees', 'type' => 'bool', 'internal' => 'hiddenAttendees'], + 'calendar_event_is_all_day' => ['name' => 'calendar_event_is_all_day', 'type' => 'bool', 'internal' => 'isAllDay'], + 'calendar_event_is_cancelled' => ['name' => 'calendar_event_is_cancelled', 'type' => 'bool', 'internal' => 'isCancelled'], + 'calendar_event_is_draft' => ['name' => 'calendar_event_is_draft', 'type' => 'bool', 'internal' => 'isDraft'], + 'calendar_event_is_online_meeting' => ['name' => 'calendar_event_is_online_meeting', 'type' => 'bool', 'internal' => 'isOnlineMeeting'], + 'calendar_event_web_link' => ['name' => 'calendar_event_web_link', 'type' => 'string', 'internal' => 'webLink'], + 'calendar_event_external_id' => ['name' => 'calendar_event_external_id', 'type' => 'string', 'internal' => 'externalId'], 'calendar_event_schedule' => ['name' => 'calendar_event_schedule', 'type' => 'int', 'internal' => 'schedule'], 'calendar_event_calendar' => ['name' => 'calendar_event_calendar', 'type' => 'int', 'internal' => 'calendar'], + 'calendar_event_start' => ['name' => 'calendar_event_start', 'type' => 'DateTime', 'internal' => 'start'], + 'calendar_event_end' => ['name' => 'calendar_event_end', 'type' => 'DateTime', 'internal' => 'end'], 'calendar_event_created_by' => ['name' => 'calendar_event_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'calendar_event_created_at' => ['name' => 'calendar_event_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], ]; @@ -50,7 +60,7 @@ final class EventMapper extends DataMapperFactory /** * Has one relation. * - * @var array + * @var array * @since 1.0.0 */ public const OWNS_ONE = [ @@ -63,7 +73,7 @@ final class EventMapper extends DataMapperFactory /** * Belongs to. * - * @var array + * @var array * @since 1.0.0 */ public const BELONGS_TO = [ @@ -76,7 +86,7 @@ final class EventMapper extends DataMapperFactory /** * Has many relation. * - * @var array + * @var array * @since 1.0.0 */ public const HAS_MANY = [ diff --git a/Models/Schedule.php b/Models/Schedule.php index 171df8a..cfd36ad 100755 --- a/Models/Schedule.php +++ b/Models/Schedule.php @@ -60,21 +60,15 @@ class Schedule */ private int $freqType = FrequencyType::ONCE; - /** - * Frequency interval. - * - * @var int - * @since 1.0.0 - */ - private int $freqInterval = FrequencyInterval::DAY; + public int $dayOfMonth = 0; - /** - * Frequency relative. - * - * @var int - * @since 1.0.0 - */ - private int $relativeInternal = FrequencyRelative::FIRST; + public int $daysOfWeek = 0; + + public int $patternIndex = 0; + + public int $patternMonth = 0; + + public int $intervalType = 0; /** * Interval type. @@ -82,7 +76,7 @@ class Schedule * @var int * @since 1.0.0 */ - private int $intervalType = IntervalType::ABSOLUTE; + private int $patternInterval = IntervalType::ABSOLUTE; /** * Recurrence factor. @@ -90,31 +84,31 @@ class Schedule * @var int * @since 1.0.0 */ - public int $recurrenceFactor = 0; + public int $numberOfOccurrences = 0; + + /** + * Date. + * + * @var null|\DateTime + * @since 1.0.0 + */ + public ?\DateTime $date = null; /** * Start. * - * @var \DateTime + * @var null|\DateTime * @since 1.0.0 */ - public \DateTime $start; - - /** - * Duration. - * - * @var int - * @since 1.0.0 - */ - public int $duration = 3600; + public ?\DateTime $start = null; /** * End. * - * @var \DateTime + * @var null|\DateTime * @since 1.0.0 */ - public \DateTime $end; + public ?\DateTime $end = null; /** * Created at. @@ -141,9 +135,6 @@ class Schedule { $this->createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable('now'); - $this->start = new \DateTime('now'); - $this->end = new \DateTime('now'); - $this->end->setTimestamp($this->end->getTimestamp() + $this->duration); } /** @@ -219,83 +210,27 @@ class Schedule */ public function getIntervalType() : int { - return $this->intervalType; + return $this->patternInterval; } /** - * @param int $intervalType Interval type + * @param int $patternInterval Interval type * * @return $this * * @since 1.0.0 */ - public function setIntervalType(int $intervalType) : self + public function setIntervalType(int $patternInterval) : self { - if (!IntervalType::isValidValue($intervalType)) { - throw new InvalidEnumValue($intervalType); + if (!IntervalType::isValidValue($patternInterval)) { + throw new InvalidEnumValue($patternInterval); } - $this->intervalType = $intervalType; + $this->patternInterval = $patternInterval; return $this; } - /** - * @return int - * - * @since 1.0.0 - */ - public function getFrequencyRelative() : int - { - return $this->relativeInternal; - } - - /** - * @param int $relativeInterval Relative interval - * - * @return $this - * - * @since 1.0.0 - */ - public function setFrequencyRelative(int $relativeInterval) : self - { - if (!FrequencyRelative::isValidValue($relativeInterval)) { - throw new InvalidEnumValue($relativeInterval); - } - - $this->relativeInternal = $relativeInterval; - - return $this; - } - - /** - * @param int $freqInterval Frequency interval - * - * @return $this - * - * @since 1.0.0 - */ - public function setFreqInterval(int $freqInterval) : self - { - if (!FrequencyInterval::isValidValue($freqInterval)) { - throw new InvalidEnumValue($freqInterval); - } - - $this->freqInterval = $freqInterval; - - return $this; - } - - /** - * @return int - * - * @since 1.0.0 - */ - public function getFreqInterval() : int - { - return $this->freqInterval; - } - /** * {@inheritdoc} */ @@ -306,10 +241,7 @@ class Schedule 'uuid' => $this->uid, 'status' => $this->status, 'freqType' => $this->freqType, - 'freqInterval' => $this->freqInterval, - 'relativeInternal' => $this->relativeInternal, - 'intervalType' => $this->intervalType, - 'recurrenceFactor' => $this->recurrenceFactor, + 'patternInterval' => $this->patternInterval, 'start' => $this->start, 'createdAt' => $this->createdAt, ]; diff --git a/Models/ScheduleMapper.php b/Models/ScheduleMapper.php index 02016e5..fcaae6f 100755 --- a/Models/ScheduleMapper.php +++ b/Models/ScheduleMapper.php @@ -34,25 +34,28 @@ final class ScheduleMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'schedule_id' => ['name' => 'schedule_id', 'type' => 'int', 'internal' => 'id'], - 'schedule_uid' => ['name' => 'schedule_uid', 'type' => 'string', 'internal' => 'uid'], - 'schedule_status' => ['name' => 'schedule_status', 'type' => 'int', 'internal' => 'status'], - 'schedule_freq_type' => ['name' => 'schedule_freq_type', 'type' => 'int', 'internal' => 'freqType'], - 'schedule_freq_interval' => ['name' => 'schedule_freq_interval', 'type' => 'int', 'internal' => 'freqInterval'], - 'schedule_freq_interval_type' => ['name' => 'schedule_freq_interval_type', 'type' => 'int', 'internal' => 'intervalType'], - 'schedule_freq_relative_interval' => ['name' => 'schedule_freq_relative_interval', 'type' => 'int', 'internal' => 'relativeInternal'], - 'schedule_freq_recurrence_factor' => ['name' => 'schedule_freq_recurrence_factor', 'type' => 'int', 'internal' => 'recurrenceFactor'], - 'schedule_start' => ['name' => 'schedule_start', 'type' => 'DateTime', 'internal' => 'start'], - 'schedule_duration' => ['name' => 'schedule_duration', 'type' => 'int', 'internal' => 'duration'], - 'schedule_end' => ['name' => 'schedule_end', 'type' => 'DateTime', 'internal' => 'end'], - 'schedule_created_at' => ['name' => 'schedule_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], - 'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], + 'schedule_id' => ['name' => 'schedule_id', 'type' => 'int', 'internal' => 'id'], + 'schedule_uid' => ['name' => 'schedule_uid', 'type' => 'string', 'internal' => 'uid'], + 'schedule_status' => ['name' => 'schedule_status', 'type' => 'int', 'internal' => 'status'], + 'schedule_freq_type' => ['name' => 'schedule_freq_type', 'type' => 'int', 'internal' => 'freqType'], + 'schedule_date' => ['name' => 'schedule_date', 'type' => 'DateTime', 'internal' => 'date'], + 'schedule_start' => ['name' => 'schedule_start', 'type' => 'DateTime', 'internal' => 'start'], + 'schedule_end' => ['name' => 'schedule_end', 'type' => 'DateTime', 'internal' => 'end'], + 'schedule_pattern_numberofoccurrences' => ['name' => 'schedule_pattern_numberofoccurrences', 'type' => 'int', 'internal' => 'numberOfOccurrences'], + 'schedule_pattern_type' => ['name' => 'schedule_pattern_type', 'type' => 'int', 'internal' => 'intervalType'], + 'schedule_pattern_pattern_interval' => ['name' => 'schedule_pattern_pattern_interval', 'type' => 'int', 'internal' => 'patternInterval'], + 'schedule_pattern_dayofmonth' => ['name' => 'schedule_pattern_dayofmonth', 'type' => 'int', 'internal' => 'dayOfMonth'], + 'schedule_pattern_daysofweek' => ['name' => 'schedule_pattern_daysofweek', 'type' => 'int', 'internal' => 'daysOfWeek'], + 'schedule_pattern_index' => ['name' => 'schedule_pattern_index', 'type' => 'int', 'internal' => 'patternIndex'], + 'schedule_pattern_month' => ['name' => 'schedule_pattern_month', 'type' => 'int', 'internal' => 'patternMonth'], + 'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'schedule_created_at' => ['name' => 'schedule_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; /** * Belongs to. * - * @var array + * @var array * @since 1.0.0 */ public const BELONGS_TO = [ diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php deleted file mode 100755 index 0c289d6..0000000 --- a/Theme/Backend/Lang/api.en.lang.php +++ /dev/null @@ -1,16 +0,0 @@ - [ -]]; diff --git a/tests/Models/ScheduleTest.php b/tests/Models/ScheduleTest.php index 9e49c2b..fe13b07 100755 --- a/tests/Models/ScheduleTest.php +++ b/tests/Models/ScheduleTest.php @@ -46,8 +46,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase self::assertEquals(ScheduleStatus::ACTIVE, $this->schedule->getStatus()); self::assertEquals(FrequencyType::ONCE, $this->schedule->getFreqType()); self::assertEquals(IntervalType::ABSOLUTE, $this->schedule->getIntervalType()); - self::assertEquals(FrequencyRelative::FIRST, $this->schedule->getFrequencyRelative()); - self::assertEquals(FrequencyInterval::DAY, $this->schedule->getFreqInterval()); self::assertInstanceOf('\Modules\Admin\Models\NullAccount', $this->schedule->createdBy); } @@ -71,26 +69,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase $this->schedule->setStatus(999); } - /** - * @covers Modules\Calendar\Models\Schedule - * @group module - */ - public function testFreqIntervalInputOutput() : void - { - $this->schedule->setFreqInterval(FrequencyInterval::DAY); - self::assertEquals(FrequencyInterval::DAY, $this->schedule->getFreqInterval()); - } - - /** - * @covers Modules\Calendar\Models\Schedule - * @group module - */ - public function testInvalidFreqInterval() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - $this->schedule->setFreqInterval(999); - } - /** * @covers Modules\Calendar\Models\Schedule * @group module @@ -111,26 +89,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase $this->schedule->setFreqType(999); } - /** - * @covers Modules\Calendar\Models\Schedule - * @group module - */ - public function testFrequencyRelativeInputOutput() : void - { - $this->schedule->setFrequencyRelative(FrequencyRelative::LAST); - self::assertEquals(FrequencyRelative::LAST, $this->schedule->getFrequencyRelative()); - } - - /** - * @covers Modules\Calendar\Models\Schedule - * @group module - */ - public function testInvalidFrequencyRelative() : void - { - $this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class); - $this->schedule->setFrequencyRelative(999); - } - /** * @covers Modules\Calendar\Models\Schedule * @group module @@ -159,8 +117,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase { $this->schedule->setStatus(ScheduleStatus::INACTIVE); $this->schedule->setFreqType(FrequencyType::YEARLY); - $this->schedule->setFreqInterval(FrequencyInterval::DAY); - $this->schedule->setFrequencyRelative(FrequencyRelative::LAST); $this->schedule->setIntervalType(IntervalType::RELATIVE); $serialized = $this->schedule->jsonSerialize(); @@ -173,10 +129,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase 'uuid' => '', 'status' => ScheduleStatus::INACTIVE, 'freqType' => FrequencyType::YEARLY, - 'freqInterval' => FrequencyInterval::DAY, - 'relativeInternal' => FrequencyRelative::LAST, - 'intervalType' => IntervalType::RELATIVE, - 'recurrenceFactor' => 0, ], $serialized );