diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e20a743e..f602d5c9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/interfaces/event/AbstractCalendarQuery.php b/interfaces/event/AbstractCalendarQuery.php index b4f691c6..588957fc 100644 --- a/interfaces/event/AbstractCalendarQuery.php +++ b/interfaces/event/AbstractCalendarQuery.php @@ -14,7 +14,6 @@ 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; @@ -22,6 +21,7 @@ use yii\base\Component; use yii\db\ActiveQuery; use yii\db\ActiveRecord; +use yii\db\Query; /** * Created by PhpStorm. @@ -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; @@ -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', @@ -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, '>=')], @@ -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, '<=')], @@ -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. * @@ -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 diff --git a/models/CalendarEntryQuery.php b/models/CalendarEntryQuery.php index 06b924c5..b78176c8 100644 --- a/models/CalendarEntryQuery.php +++ b/models/CalendarEntryQuery.php @@ -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. @@ -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() diff --git a/module.json b/module.json index 3705bdc0..1dee67c7 100644 --- a/module.json +++ b/module.json @@ -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" },