Skip to content

Commit

Permalink
v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Jun 12, 2018
1 parent 5a75245 commit e630756
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 49 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Solspace Calendar Changelog

## 2.0.3 - 2018-06-12
### Changed
- Updated Demo Templates routes to be extension agnostic (no longer specifically include `.html` in route path).

### Fixed
- Fixed a bug where default start times would show a localized time when creating new events.
- Fixed a bug where excluding multiple calendar ID's in the `calendar.calendars` function would not work.
- Fixed a bug where the CP Events list page was not displaying status indicators.
- Fixed a bug where Demo Templates would strip dashes from specified URI path.

## 2.0.2 - 2018-06-05
### Added
- Added `startsBefore`, `endsAfter`, `startsBeforeOrAt`, and `endsAfterOrAt` parameters to `calendar.events` function, for more flexibility to narrow down results.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solspace/craft3-calendar",
"description": "The most powerful event management plugin for Craft.",
"version": "2.0.2",
"version": "2.0.3",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/CodePackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function actionInstall(): Response
$codePack = $this->getCodePack();
$prefix = \Craft::$app->request->post('prefix');

$prefix = preg_replace('/[^a-zA-Z_0-9\/]/', '', $prefix);
$prefix = preg_replace('/[^a-zA-Z_0-9-\/]/', '', $prefix);

try {
$codePack->install($prefix);
Expand Down
14 changes: 14 additions & 0 deletions src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ protected function beforePrepare(): bool
$this->joinElementTable($table);
$hasCalendarsJoined = false;
$hasRelations = false;
$hasUsers = false;

if (!empty($this->join)) {
foreach ($this->join as $join) {
Expand All @@ -528,6 +529,10 @@ protected function beforePrepare(): bool
if ($join[1] === '{{%relations}} relations') {
$hasRelations = true;
}

if ($join[1] === '{{%users}}') {
$hasUsers = true;
}
}
}

Expand All @@ -539,6 +544,14 @@ protected function beforePrepare(): bool
$this->join[] = ['INNER JOIN', $calendarTable, "$calendarTable.[[id]] = $table.[[calendarId]]"];
}

if (!$hasUsers) {
if (null === $this->join) {
$this->join = [];
}

$this->join[] = ['INNER JOIN', '{{%users}}', "{{%users}}.[[id]] = $table.[[authorId]]"];
}

$select = [
$table . '.[[calendarId]]',
$table . '.[[authorId]]',
Expand All @@ -554,6 +567,7 @@ protected function beforePrepare(): bool
$table . '.[[byYearDay]]',
$table . '.[[byMonthDay]]',
$table . '.[[byDay]]',
'{{%users}}.[[username]]',
$calendarTable . '.[[name]]',
];

Expand Down
25 changes: 18 additions & 7 deletions src/Elements/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class Event extends Element implements \JsonSerializable
/** @var int */
public $score;

/** @var string */
public $username;

/**
* @return EventQuery|ElementQueryInterface
*/
Expand Down Expand Up @@ -143,6 +146,14 @@ public static function hasUris(): bool
return true;
}

/**
* @return bool
*/
public static function hasStatuses(): bool
{
return true;
}

/**
* @param array $config
*
Expand Down Expand Up @@ -258,7 +269,7 @@ protected static function defineSortOptions(): array
'startDate' => Calendar::t('Start Date'),
'endDate' => Calendar::t('End Date'),
'allDay' => Calendar::t('All Day'),
'users.username' => Calendar::t('Author'),
'username' => Calendar::t('Author'),
'dateCreated' => Calendar::t('Post Date'),
];
}
Expand Down Expand Up @@ -326,8 +337,8 @@ protected function tableAttributeHtml(string $attribute): string
case 'rrule':
return $this->repeats() ? Calendar::t('Yes') : Calendar::t('No');

case 'field:1':
return parent::tableAttributeHtml($attribute);
case 'status':
return Calendar::t(ucfirst($this->getStatus()));

default:
return parent::tableAttributeHtml($attribute);
Expand Down Expand Up @@ -363,13 +374,13 @@ public function __construct(array $config = [])
{
parent::__construct($config);

$this->startDate = new Carbon($this->startDate, DateHelper::UTC);
$this->startDateLocalized = new Carbon($this->startDate);
$this->endDate = new Carbon($this->endDate, DateHelper::UTC);
$this->startDateLocalized = new Carbon($this->startDate ?? 'now');
$this->startDate = new Carbon($this->startDate ?? 'now', DateHelper::UTC);
$this->endDateLocalized = new Carbon($this->endDate);
$this->endDate = new Carbon($this->endDate, DateHelper::UTC);
if (null !== $this->until) {
$this->until = new Carbon($this->until, DateHelper::UTC);
$this->untilLocalized = new Carbon($this->until);
$this->until = new Carbon($this->until, DateHelper::UTC);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Library/DatabaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static function prepareOperator($value): array
$value = substr($value, $length + 1);

if ($operator === self::OPERATOR_NOT_IN) {
$operator = 'NOT IN';
$value = explode(',', $value);
}

Expand Down
40 changes: 20 additions & 20 deletions src/codepack/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,101 @@
{
"urlParts": ["mini_cal\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"]],
"urlPattern": "mini_cal/{year}/{month}",
"template": "/mini_cal.html"
"template": "/mini_cal"
},
{
"urlParts": ["month\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"]],
"urlPattern": "month/{year}/{month}",
"template": "/month.html"
"template": "/month"
},
{
"urlParts": ["month\\/calendar\\/",["slug","[^\\\\\\/]+"]],
"urlPattern": "month/calendar/{slug}",
"template": "/month.html"
"template": "/month"
},
{
"urlParts": ["month\\/calendar\\/",["slug","[^\\\\\\/]+"],"\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"]],
"urlPattern": "month/calendar/{slug}/{year}/{month}",
"template": "/month.html"
"template": "/month"
},
{
"urlParts": ["week\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "week/{year}/{month}/{day}",
"template": "/week.html"
"template": "/week"
},
{
"urlParts": ["week\\/calendar\\/",["slug","[^\\\\\\/]+"]],
"urlPattern": "week/calendar/{slug}",
"template": "/week.html"
"template": "/week"
},
{
"urlParts": ["week\\/calendar\\/",["slug","[^\\\\\\/]+"],"\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "week/calendar/{slug}/{year}/{month}/{day}",
"template": "/week.html"
"template": "/week"
},
{
"urlParts": ["day\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "day/{year}/{month}/{day}",
"template": "/day.html"
"template": "/day"
},
{
"urlParts": ["day\\/calendar\\/",["slug","[^\\\\\\/]+"]],
"urlPattern": "day/calendar/{slug}",
"template": "/day.html"
"template": "/day"
},
{
"urlParts": ["day\\/calendar\\/",["slug","[^\\\\\\/]+"],"\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "day/calendar/{slug}/{year}/{month}/{day}",
"template": "/day.html"
"template": "/day"
},
{
"urlParts": ["calendars\\/",["slug","[^\\\\\\/]+"]],
"urlPattern": "calendars/{slug}",
"template": "/calendars.html"
"template": "/calendars"
},
{
"urlParts": ["event\\/",["number","\\\\d+"]],
"urlPattern": "event/{id}",
"template": "/event.html"
"template": "/event"
},
{
"urlParts": ["event\\/",["number","\\\\d+"],"\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "event/{id}/{year}/{month}/{day}",
"template": "/event.html"
"template": "/event"
},
{
"urlParts": ["events\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "events/{year}/{month}/{day}",
"template": "/events.html"
"template": "/events"
},
{
"urlParts": ["export\\/event\\/",["number","\\\\d+"]],
"urlPattern": "export/event/{id}",
"template": "/export.html"
"template": "/export"
},
{
"urlParts": ["edit\\/event\\/",["number","\\\\d+"]],
"urlPattern": "edit/event/{id}",
"template": "/edit.html"
"template": "/edit"
},
{
"urlParts": ["edit\\/event\\/new"],
"urlPattern": "edit/event/new",
"template": "/edit.html"
"template": "/edit"
},
{
"urlParts": ["export\\/calendar\\/",["number","\\\\d+"]],
"urlPattern": "export/calendar/{id}",
"template": "/export.html"
"template": "/export"
},
{
"urlParts": ["fullcalendar\\/",["slug","[^\\\\\\/]+"],"\\/",["year","\\\\d{4}"],"\\/",["month","(?:0?[1-9]|1[012])"],"\\/",["day","(?:0?[1-9]|[12][0-9]|3[01])"]],
"urlPattern": "fullcalendar/{slug}/{year}/{month}/{day}",
"template": "/fullcalendar.html"
"template": "/fullcalendar"
},
{
"urlParts": ["resources\\/event_data\\/",["number","\\\\d+"]],
"urlPattern": "resources/event_data/{id}",
"template": "/resources/event_data.html"
"template": "/resources/event_data"
}
]
40 changes: 20 additions & 20 deletions src/codepack/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
*/

return array(
'demo/mini_cal/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/mini_cal.html',
'demo/month/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/month.html',
'demo/month/calendar/(?P<slug>[^\/]+)' => 'demo/month.html',
'demo/month/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/month.html',
'demo/week/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/week.html',
'demo/week/calendar/(?P<slug>[^\/]+)' => 'demo/week.html',
'demo/week/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/week.html',
'demo/day/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/day.html',
'demo/day/calendar/(?P<slug>[^\/]+)' => 'demo/day.html',
'demo/day/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/day.html',
'demo/calendars/(?P<slug>[^\/]+)' => 'demo/calendars.html',
'demo/event/(?P<id>\d+)' => 'demo/event.html',
'demo/event/(?P<id>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/event.html',
'demo/events/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/events.html',
'demo/export/event/(?P<id>\d+)' => 'demo/export.html',
'demo/edit/event/(?P<id>\d+)' => 'demo/edit.html',
'demo/edit/event/new' => 'demo/edit.html',
'demo/export/calendar/(?P<id>\d+)' => 'demo/export.html',
'demo/fullcalendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/fullcalendar.html',
'demo/resources/event_data/(?P<id>\d+)' => 'demo/resources/event_data.html',
'demo/mini_cal/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/mini_cal',
'demo/month/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/month',
'demo/month/calendar/(?P<slug>[^\/]+)' => 'demo/month',
'demo/month/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})' => 'demo/month',
'demo/week/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/week',
'demo/week/calendar/(?P<slug>[^\/]+)' => 'demo/week',
'demo/week/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/week',
'demo/day/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/day',
'demo/day/calendar/(?P<slug>[^\/]+)' => 'demo/day',
'demo/day/calendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/day',
'demo/calendars/(?P<slug>[^\/]+)' => 'demo/calendars',
'demo/event/(?P<id>\d+)' => 'demo/event',
'demo/event/(?P<id>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/event',
'demo/events/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/events',
'demo/export/event/(?P<id>\d+)' => 'demo/export',
'demo/edit/event/(?P<id>\d+)' => 'demo/edit',
'demo/edit/event/new' => 'demo/edit',
'demo/export/calendar/(?P<id>\d+)' => 'demo/export',
'demo/fullcalendar/(?P<slug>[^\/]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' => 'demo/fullcalendar',
'demo/resources/event_data/(?P<id>\d+)' => 'demo/resources/event_data',
);

0 comments on commit e630756

Please sign in to comment.