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.7.21 (Unreleased)
-------------------------
- Fix #629: Fix sidebar widget issue

1.7.20 (October 20, 2025)
-------------------------
- Enh #608: Improved `Upcoming events` widget to include events from followed spaces and profiles
Expand Down
40 changes: 25 additions & 15 deletions interfaces/event/AbstractCalendarQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use Exception;
use humhub\modules\calendar\helpers\CalendarUtils;
use humhub\modules\calendar\models\CalendarEntry;
use humhub\modules\calendar\models\CalendarEntryParticipant;
use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\user\models\User;
use humhub\modules\content\components\ActiveQueryContent;
use Yii;
use yii\base\Component;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
use yii\db\Query;

/**
* Created by PhpStorm.
Expand Down Expand Up @@ -786,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 @@ -806,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 @@ -847,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 @@ -863,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 @@ -880,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 Expand Up @@ -1128,6 +1133,11 @@ public function filterIsParticipant()
throw new FilterNotSupportedException('Participant filter not supported for this query');
}

public function filterOrIsParticipant()
{
throw new FilterNotSupportedException('Participant filter not supported for this query');
}

/**
* Can be used to pre filter the result list
* @param $result
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.7.20",
"version": "1.7.21",
"humhub": {
"minVersion": "1.17.0-beta.4"
},
Expand Down
Loading