Skip to content

Commit

Permalink
Update method of checking friendship humhub/humhub#6745
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-rueegg committed Jan 17, 2024
1 parent 9a43a5c commit 4b2924f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions integration/BirthdayCalendarQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use humhub\modules\calendar\interfaces\event\FilterNotSupportedException;
use humhub\modules\calendar\models\SnippetModuleSettings;
use humhub\modules\content\components\ActiveQueryContent;
use humhub\modules\friendship\Module;
use humhub\modules\friendship\Module as FriendshipModule;
use humhub\modules\space\models\Membership;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
Expand Down Expand Up @@ -79,7 +81,8 @@ protected function filterDashboard()
return;
}

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()) {
$this->_query->innerJoin('user_friendship', 'user.id=user_friendship.friend_user_id AND user_friendship.user_id=:userId',
[':userId' => Yii::$app->user->id]);
} else {
Expand Down Expand Up @@ -115,7 +118,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 {
Expand Down Expand Up @@ -145,4 +149,4 @@ public function filterMine()
{
$this->_query->andWhere(['profile.user_id' => Yii::$app->user->id]);
}
}
}
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": ["calendar"],
"version": "1.5.7",
"humhub": {
"minVersion": "1.14"
"minVersion": "1.16"
},
"homepage": "https://github.com/humhub/calendar",
"authors": [
Expand Down

0 comments on commit 4b2924f

Please sign in to comment.