Skip to content

Commit

Permalink
v2.0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Aug 1, 2019
1 parent 9132e40 commit 01e28ca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Solspace Calendar Changelog

## 2.0.22 - 2019-07-31
### Fixed
- Fixed a bug where newly created events were not respecting the default site status setting in each calendar.
- Fixed a bug where events that were disabled couldn't be deleted from inside the edit event page.

## 2.0.21 - 2019-07-26
### Changed
- Updated `carbon` dependency to `^1.22.1|^2.19` for better compatibility with other plugins, and to reduce the chances of seeing deprecation notice.
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.21",
"version": "2.0.22",
"type": "craft-plugin",
"authors": [
{
Expand Down
4 changes: 3 additions & 1 deletion src/Controllers/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ public function actionSaveEvent()

$this->handleRepeatRules($event, $values);

$event->enabledForSite = (bool) \Craft::$app->request->post('enabledForSite', $event->enabledForSite);
$enabledForSite = (bool) \Craft::$app->request->post('enabledForSite', $event->enabledForSite);

$event->enabledForSite = $enabledForSite ? '1' : '0';
$event->title = \Craft::$app->request->post('title', $event->title);
$event->slug = \Craft::$app->request->post('slug', $event->slug);
$event->setFieldValuesFromRequest('fields');
Expand Down
10 changes: 9 additions & 1 deletion src/Elements/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ public static function create(int $siteId = null, int $calendarId = null): Event

if ($siteId) {
$element->siteId = $siteId;

$siteSettings = $element->getCalendar()->getSiteSettingsForSite($siteId);
if ($siteSettings) {
$element->enabledForSite = $siteSettings->enabledByDefault;
}
}

return $element;
Expand Down Expand Up @@ -384,7 +389,10 @@ public function getSupportedSites(): array

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

return $supportedSites;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function saveEvent(Event $event, bool $validateContent = true, bool $bypa
*/
public function deleteEventById(int $eventId): bool
{
$event = $this->getEventById($eventId);
$event = $this->getEventById($eventId, null, true);

if (!$event) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/templates/events/_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
label: "Enabled for site"|t('app'),
id: 'enabledForSite',
name: 'enabledForSite',
on: event.enabledForSite,
on: event.siteId in enabledSiteIds,
}) }}
{% endif %}

Expand Down

0 comments on commit 01e28ca

Please sign in to comment.