mirror of
https://github.com/humhub/humhub.git
synced 2025-02-23 02:32:37 +01:00
Minor improvements of Space visibility query
This commit is contained in:
parent
1820a734fd
commit
a9e4998b75
@ -52,18 +52,17 @@ class ActiveQuerySpace extends ActiveQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($user !== null) {
|
if ($user !== null) {
|
||||||
|
|
||||||
$spaceIds = array_map(function (Membership $membership) {
|
|
||||||
return $membership->space_id;
|
|
||||||
}, Membership::findAll(['user_id' => $user->id]));
|
|
||||||
|
|
||||||
$this->andWhere(['OR',
|
$this->andWhere(['OR',
|
||||||
['!=', 'space.visibility', Space::VISIBILITY_NONE],
|
['IN', 'space.visibility', [Space::VISIBILITY_ALL, Space::VISIBILITY_REGISTERED_ONLY]],
|
||||||
['IN', 'space.id', $spaceIds]
|
['AND',
|
||||||
|
['=', 'space.visibility', Space::VISIBILITY_NONE],
|
||||||
|
['IN', 'space.id', Membership::find()->select('id')->where(['user_id' => $user->id])]
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->andWhere(['space.visibility' => Space::VISIBILITY_ALL]);
|
$this->andWhere(['!=', 'space.visibility', Space::VISIBILITY_NONE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user