Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.8.5 (Unreleased)
------------------------
- Fix #630: Fix sidebar widget issue

1.8.4 (October 23, 2025)
------------------------
- Fix #609: Fix for PHP 8.4
Expand Down
34 changes: 20 additions & 14 deletions interfaces/event/AbstractCalendarQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use yii\base\Component;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
use yii\db\Query;

/**
* Created by PhpStorm.
Expand Down Expand Up @@ -785,11 +786,7 @@ protected function setupCriteria()
}
}

/**
* Sets up the date interval filter with respect to the openRange setting.
* This will also include all recurrent event roots if $expand is true and recurrence evets are supported
*/
protected function setupDateCriteria()
protected function createDateCriteriaQuery(Query $query)
{
if ($this->_from) {
$fromTime = clone $this->_from;
Expand All @@ -805,21 +802,21 @@ protected function setupDateCriteria()
//Search for all dates with start and/or end within the given range

if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) {
$this->_query->andFilterWhere(['or',
$query->andFilterWhere(['or',
['and', $this->getStartCriteria($this->_from, '<'), $this->getEndCriteria($this->_to, '>')],
['and', $this->getStartCriteria($this->_from, '>='), $this->getStartCriteria($this->_to, '<')],
['and', $this->getEndCriteria($this->_from, '>'), $this->getEndCriteria($this->_to, '<=')],
$this->isRecurrenceRootCondition(),
]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) {
$this->_query->andFilterWhere(['or',
$query->andFilterWhere(['or',
['and', $this->getStartCriteria($fromTime, '<'), $this->getEndCriteria($toTime, '>')],
['and', $this->getStartCriteria($fromTime, '>='), $this->getStartCriteria($toTime, '<')],
['and', $this->getEndCriteria($fromTime, '>'), $this->getEndCriteria($toTime, '<=')],
$this->isRecurrenceRootCondition(),
]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) {
$this->_query->andFilterWhere(
$query->andFilterWhere(
['or',
['or',
['and',
Expand All @@ -846,11 +843,11 @@ protected function setupDateCriteria()
} else {
if ($this->_from) {
if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) {
$this->_query->andWhere(['or', $this->getStartCriteria($this->_from, '>='), $this->isRecurrenceRootCondition()]);
$query->andWhere(['or', $this->getStartCriteria($this->_from, '>='), $this->isRecurrenceRootCondition()]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) {
$this->_query->andWhere(['or', $this->getStartCriteria($fromTime, '>='), $this->isRecurrenceRootCondition()]);
$query->andWhere(['or', $this->getStartCriteria($fromTime, '>='), $this->isRecurrenceRootCondition()]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) {
$this->_query->andWhere(
$query->andWhere(
['or',
['and', [$this->allDayField => 0], $this->getStartCriteria($fromTime, '>=')],
['and', [$this->allDayField => 1], $this->getStartCriteria($this->_from, '>=')],
Expand All @@ -862,11 +859,11 @@ protected function setupDateCriteria()

if ($this->_to) {
if ($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) {
$this->_query->andWhere(['or', $this->getEndCriteria($this->_to, '<='), $this->isRecurrenceRootCondition()]);
$query->andWhere(['or', $this->getEndCriteria($this->_to, '<='), $this->isRecurrenceRootCondition()]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) {
$this->_query->andWhere(['or', $this->getEndCriteria($toTime, '<='), $this->isRecurrenceRootCondition()]);
$query->andWhere(['or', $this->getEndCriteria($toTime, '<='), $this->isRecurrenceRootCondition()]);
} elseif ($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) {
$this->_query->andWhere(
$query->andWhere(
['or',
['and', [$this->allDayField => 0], $this->getEndCriteria($toTime, '<=')],
['and', [$this->allDayField => 1], $this->getEndCriteria($this->_to, '<=')],
Expand All @@ -879,6 +876,15 @@ protected function setupDateCriteria()
}
}

/**
* Sets up the date interval filter with respect to the openRange setting.
* This will also include all recurrent event roots if $expand is true and recurrence evets are supported
*/
protected function setupDateCriteria()
{
$this->createDateCriteriaQuery($this->_query);
}

/**
* Returns a sql condition filtering recurrent root events if supported. Returns empty string if not supported.
*
Expand Down
16 changes: 12 additions & 4 deletions models/CalendarEntryQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use humhub\modules\calendar\interfaces\recurrence\AbstractRecurrenceQuery;
use humhub\modules\content\components\ContentContainerActiveRecord;
use DateTime;
use yii\db\Query;

/**
* CalendarEntryQuery class can be used for creating filter queries for [[CalendarEntry]] models.
Expand Down Expand Up @@ -95,10 +96,17 @@ public function filterIsParticipant()
public function filterOrIsParticipant()
{
$this->participantJoin();
$this->_query->orWhere(['calendar_entry_participant.participation_state' => [
CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED,
CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE,
]]);
$onlyParticipatingQuery = new Query();
$this->createDateCriteriaQuery($onlyParticipatingQuery);

$this->_query->orWhere([
'AND',
['IN', 'calendar_entry_participant.participation_state', [
CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED,
CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE,
]],
$onlyParticipatingQuery->where
]);
}

private function participantJoin()
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Calendar",
"description": "Create one-time or recurring events, invite and manage attendees, and keep track of all your events with the Calendar module.",
"keywords": ["calendar"],
"version": "1.8.4",
"version": "1.8.5",
"humhub": {
"minVersion": "1.18"
},
Expand Down