diff --git a/integration/BirthdayCalendarQuery.php b/integration/BirthdayCalendarQuery.php index 4da80258..4d46b992 100644 --- a/integration/BirthdayCalendarQuery.php +++ b/integration/BirthdayCalendarQuery.php @@ -1,4 +1,5 @@ _from ?: (new \DateTime())->setTime(0,0,0); - $to = $this->_to ?: (new \DateTime())->setTime(0,0,0)->modify('+2 year'); + $from = $this->_from ?: (new \DateTime())->setTime(0, 0, 0); + $to = $this->_to ?: (new \DateTime())->setTime(0, 0, 0)->modify('+2 year'); $fromYear = (int)$from->format('Y'); $toYear = (int)$to->format('Y'); @@ -65,23 +67,28 @@ protected function setupDateCriteria() $this->_query->joinWith('profile'); $this->_query->addSelect(['profile.*', 'user.*']); $this->_query->addSelect(new Expression($toOrFromBirthday . ' AS next_birthday')); - $this->_query->andWhere(new Expression($toOrFromBirthday . ' BETWEEN :fromDate AND :toDate'), + $this->_query->andWhere( + new Expression($toOrFromBirthday . ' BETWEEN :fromDate AND :toDate'), [ ':fromDate' => $from->format('Y-m-d'), ':toDate' => $to->format('Y-m-d') - ]); - + ] + ); } protected function filterDashboard() { - if(SnippetModuleSettings::instance()->includeBirthdayToDashboard()) { + if (SnippetModuleSettings::instance()->includeBirthdayToDashboard()) { return; } - if (!Yii::$app->user->isGuest && Yii::$app->getModule('friendship')->isEnabled) { - $this->_query->innerJoin('user_friendship', 'user.id=user_friendship.friend_user_id AND user_friendship.user_id=:userId', - [':userId' => Yii::$app->user->id]); + $module = Yii::$app->getModule('friendship'); + if (!Yii::$app->user->isGuest && $module instanceof FriendshipModule && $module->isFriendshipEnabled()) { + $this->_query->innerJoin( + 'user_friendship', + 'user.id=user_friendship.friend_user_id AND user_friendship.user_id=:userId', + [':userId' => Yii::$app->user->id] + ); } else { throw new FilterNotSupportedException('Global filter not supported for this query'); } @@ -115,7 +122,8 @@ protected function filterFollowedUsersCondition(&$conditions = []) $friendshipSubQuery = (new Query())->select('user_friendship.friend_user_id')->from('user_friendship')->where(['user_friendship.user_id' => Yii::$app->user->id]); $followerSubQuery = (new Query())->select('user_follow.object_id')->from('user_follow')->where(['user_follow.user_id' => Yii::$app->user->id])->andWhere(['object_model' => User::class]); - if (!Yii::$app->user->isGuest && Yii::$app->getModule('friendship')->isEnabled) { + $module = Yii::$app->getModule('friendship'); + if (!Yii::$app->user->isGuest && $module instanceof FriendshipModule && $module->isFriendshipEnabled()) { $conditions[] = ['in', 'profile.user_id', $friendshipSubQuery]; $conditions[] = ['in', 'profile.user_id', $followerSubQuery]; } else { @@ -145,4 +153,4 @@ public function filterMine() { $this->_query->andWhere(['profile.user_id' => Yii::$app->user->id]); } -} \ No newline at end of file +} diff --git a/module.json b/module.json index 463af842..483df749 100644 --- a/module.json +++ b/module.json @@ -5,7 +5,7 @@ "keywords": ["calendar"], "version": "1.5.7", "humhub": { - "minVersion": "1.14" + "minVersion": "1.16" }, "homepage": "https://github.com/humhub/calendar", "authors": [