Skip to content

Commit

Permalink
v2.0.0-beta.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Mar 14, 2018
1 parent b332d8f commit 26f015e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Solspace Freeform Changelog

## 2.0.0-beta.3 - 2018-03-14
### Fixed
- Fixed a bug where the `calendar.events` function was not correctly filtering events by start and end date ranges.
- Fixed a bug where the Events service was calling `site` instead of `siteId`.
- Fixed a bug where CP Month/Week/Day views where events that were disabled for some sites were still being included when filtering by those sites.
- Fixed a bug where the Quick Create events feature in CP Month/Week/Day views was not correctly creating slugs.

## 2.0.0-beta.2 - 2018-03-13
### Fixed
- Fixed a bug where the `calendar.events` function was not displaying events in order.
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.0-beta.2",
"version": "2.0.0-beta.3",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/EventsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Solspace\Calendar\Controllers;

use Carbon\Carbon;
use craft\helpers\ElementHelper;
use Solspace\Calendar\Calendar;
use Solspace\Calendar\Elements\Event;
use Solspace\Calendar\Library\CalendarPermissionHelper;
Expand Down Expand Up @@ -209,7 +210,7 @@ public function actionCreate(): Response

$event = Event::create($siteId, $calendar->id);
$event->title = $eventData['title'];
$event->slug = DatabaseHelper::getSuitableSlug($eventData['title']);
$event->slug = ElementHelper::createSlug($event->title ?? '');
$event->enabled = true;
$event->authorId = \Craft::$app->user->id;

Expand Down
18 changes: 17 additions & 1 deletion src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,22 @@ protected function beforePrepare(): bool
);
}

if ($this->rangeStart) {
$rangeStartString = $this->extractDateAsFormattedString($this->rangeStart);
$this->subQuery->andWhere(
"($table.rrule IS NULL AND $table.startDate >= :rangeStart) OR ($table.rrule IS NOT NULL)",
['rangeStart' => $rangeStartString]
);
}

if ($this->rangeEnd) {
$rangeEndString = $this->extractDateAsFormattedString($this->rangeEnd);
$this->subQuery->andWhere(
"$table.endDate <= :rangeEnd",
['rangeEnd' => $rangeEndString]
);
}

if ($this->allDay) {
$this->subQuery->andWhere(Db::parseParam($table . '.allDay', (bool) $this->allDay));
}
Expand Down Expand Up @@ -852,7 +868,7 @@ function (array $arrayA, array $arrayB) use ($modifier) {
private function orderEvents(array &$events)
{
$modifier = $this->getSortModifier();
$orderBy = $this->getOrderByField();
$orderBy = $this->getOrderByField() ?? 'startDate';

usort(
$events,
Expand Down
20 changes: 20 additions & 0 deletions src/Elements/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,26 @@ protected function tableAttributeHtml(string $attribute): string
}
}

/**
* @return array
* @throws \craft\errors\SiteNotFoundException
*/
public function getSupportedSites(): array
{
if (static::isLocalized()) {
$siteSettings = $this->getCalendar()->getSiteSettings();

$supportedSites = [];
foreach ($siteSettings as $site) {
$supportedSites[] = $site->siteId;
}

return $supportedSites;
}

return [\Craft::$app->getSites()->getPrimarySite()->id];
}

/**
* Event constructor.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/css/src/calendar.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/css/src/widget/agenda.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Services/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ public function getEventById(int $eventId, int $siteId = null): Event
* Returns an event by its slug.
*
* @param string $slug
* @param string $site
* @param int $siteId
*
* @return Event|ElementInterface
*/
public function getEventBySlug(string $slug, string $site = null): Event
public function getEventBySlug(string $slug, int $siteId = null): Event
{
return Event::find()
->slug($slug)
->setAllowedCalendarsOnly(false)
->enabledForSite(false)
->site($site)
->siteId($siteId)
->one();
}

Expand Down

0 comments on commit 26f015e

Please sign in to comment.