Skip to content

Commit

Permalink
v2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Jul 27, 2018
1 parent 5c17b9a commit 7c1cc4d
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Solspace Calendar Changelog

## 2.0.5 - 2018-07-26
### Fixed
- Fixed a bug where disabled events would error when being viewed/edited.
- Fixed a bug where Guest access for submitting events on front end was broken.
- Fixed a bug where Live Preview was not correctly showing some repeat rule options.

## 2.0.4 - 2018-07-04
### Added
- Added `endsBefore`, `endsBeforeOrAt`, `startsAfter` and `startsAfterOrAt` 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.4",
"version": "2.0.5",
"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 @@ -50,7 +50,7 @@ public function actionListContents(): Response
'calendar/codepack',
[
'codePack' => $codePack,
'prefix' => 'calendar_demo',
'prefix' => 'calendar-demo',
]
);
}
Expand Down
19 changes: 15 additions & 4 deletions src/Controllers/EventsController.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\db\Query;
use craft\elements\User;
use craft\events\ElementEvent;
use craft\helpers\Json;
Expand All @@ -28,7 +29,7 @@ class EventsController extends BaseController
const EVENT_FIELD_NAME = 'calendarEvent';
const EVENT_PREVIEW_EVENT = 'previewEvent';

protected $allowAnonymous = ['actionSaveEvent'];
protected $allowAnonymous = ['save-event'];

/**
* @return Response
Expand Down Expand Up @@ -118,7 +119,7 @@ public function actionEditEvent(int $id, string $siteHandle = null): Response
EventEditBundle::$locale = $locale;
}

$event = $this->getEventsService()->getEventById($id, $siteId);
$event = $this->getEventsService()->getEventById($id, $siteId, true);

if (!$event) {
throw new HttpException(
Expand Down Expand Up @@ -177,6 +178,16 @@ public function actionSaveEvent()
}
}

if (!$event->authorId) {
$event->authorId = (int) (new Query())
->select('id')
->from('{{%users}}')
->where(['admin' => 1])
->limit(1)
->orderBy(['id' => SORT_ASC])
->scalar();
}

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

Expand Down Expand Up @@ -452,7 +463,7 @@ private function getEventModel(): Event
$calendarId = \Craft::$app->getRequest()->getBodyParam('calendarId');

if ($eventId) {
$entry = $this->getEventsService()->getEventById($eventId, $siteId);
$entry = $this->getEventsService()->getEventById($eventId, $siteId, true);

if (!$eventId) {
throw new NotFoundHttpException('Event not found');
Expand Down Expand Up @@ -600,7 +611,7 @@ private function showEvent(Event $event): Response
private function getExistingOrNewEvent(int $eventId = null, int $siteId = null): Event
{
if ($eventId) {
$event = $this->getEventsService()->getEventById($eventId, $siteId);
$event = $this->getEventsService()->getEventById($eventId, $siteId, true);

if (!$event) {
throw new HttpException(
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/css/src/event-edit.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Services/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class EventsService extends Component
* @param int $siteId
* @param bool $includeDisabled
*
* @return Event|ElementInterface
* @return Event|ElementInterface|null
*/
public function getEventById(int $eventId, int $siteId = null, bool $includeDisabled = false): Event
public function getEventById(int $eventId, int $siteId = null, bool $includeDisabled = false)
{
$query = Event::find()
->setAllowedCalendarsOnly(false)
Expand All @@ -56,9 +56,9 @@ public function getEventById(int $eventId, int $siteId = null, bool $includeDisa
* @param int $siteId
* @param bool $includeDisabled
*
* @return Event|ElementInterface
* @return Event|ElementInterface|null
*/
public function getEventBySlug(string $slug, int $siteId = null, bool $includeDisabled = false): Event
public function getEventBySlug(string $slug, int $siteId = null, bool $includeDisabled = false)
{
return Event::find()
->slug($slug)
Expand Down Expand Up @@ -385,7 +385,7 @@ public function canEditEvent($event): bool
$eventModel = $this->getEventById($event);
}

if (null === $eventModel && null !== $guestAccess) {
if ((null === $eventModel || !$eventModel->id) && null !== $guestAccess) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/codepack/templates/layouts/_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

{% block footer %}
<div class="footer">
<p>&copy; {{ "now".format('Y') }} Solspace, Inc.</p>
<p>&copy; {{ "now"|date('Y') }} Solspace, Inc.</p>
</div>
{% endblock %}
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/templates/codepack/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
{% endmacro %}
{% import _self as dir %}

{% block actionButton %}{% endblock %}

{% block content %}

<h2>{{ "Demo Templates"|t('calendar') }}</h2>
Expand All @@ -34,7 +36,7 @@ <h2>{{ "Demo Templates"|t('calendar') }}</h2>
<tr>
<td width="95%">
{{ forms.textField({
label: "Prefix"|t('calendar'),
label: "Install Path"|t('calendar'),
id: 'prefix',
name: 'prefix',
value: prefix,
Expand Down
10 changes: 9 additions & 1 deletion src/templates/layouts/_settings.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "calendar/layouts/_layoutWithoutSettings" %}

{% set selectedSubnavItem = 'settings' %}

{% set title = "Calendar Settings"|t('calendar') %}
{% set fullPageForm = true %}

{% set navItems = {
'hd': { heading: "Settings"|t('calendar') },
Expand All @@ -15,6 +15,14 @@
{% set selectedItem = craft.app.request.getSegment(3)|default %}
{% set docTitle = navItems[selectedItem].title~' - '~title %}

{% block actionButton %}
<div class="buttons">
<div class="btngroup submit">
<input type="submit" class="btn submit" value="{{ 'Save'|t('freeform') }}">
</div>
</div>
{% endblock %}

{% block sidebar %}
<nav>
<ul>
Expand Down
2 changes: 0 additions & 2 deletions src/templates/settings/_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ <h2>{{ "Event Settings"|t('calendar') }}</h2>
value: settings.overlapThreshold,
errors: settings.getErrors('overlapThreshold')
}) }}

<input type="submit" class="btn submit" value="{{ "Save"|t('calendar') }}">
</form>

{% endblock %}
2 changes: 0 additions & 2 deletions src/templates/settings/_general.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ <h2>{{ "General Settings"|t('calendar') }}</h2>
on: settings.demoBannerDisabled,
errors: settings.getErrors('demoBannerDisabled')
}) }}

<input type="submit" class="btn submit" value="{{ "Save"|t('calendar') }}">
</form>

{% endblock %}
2 changes: 0 additions & 2 deletions src/templates/settings/_guest_access.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ <h2>{{ "Guest Access"|t('calendar') }}</h2>
errors: settings.getErrors('guestAccess'),
}) }}
</div>

<input type="submit" class="btn submit" value="{{ "Save"|t('calendar') }}">
</form>

{% endblock %}
2 changes: 1 addition & 1 deletion src/translations/en-US/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
];

$demoTemplates = [
'Prefix' => 'Prefix',
'Install Path' => 'Install Path',
'Install' => 'Install',
'Templates' => 'Templates',
'Assets' => 'Assets',
Expand Down

0 comments on commit 7c1cc4d

Please sign in to comment.