mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Fix user visibility filter for guest (#6036)
This commit is contained in:
parent
85767eb055
commit
a37e6f78ea
@ -74,6 +74,8 @@ class ActiveQueryUser extends AbstractActiveQueryContentContainer
|
|||||||
{
|
{
|
||||||
$this->trigger(self::EVENT_CHECK_VISIBILITY, new ActiveQueryEvent(['query' => $this]));
|
$this->trigger(self::EVENT_CHECK_VISIBILITY, new ActiveQueryEvent(['query' => $this]));
|
||||||
|
|
||||||
|
$this->active();
|
||||||
|
|
||||||
if ($user === null && !Yii::$app->user->isGuest) {
|
if ($user === null && !Yii::$app->user->isGuest) {
|
||||||
try {
|
try {
|
||||||
$user = Yii::$app->user->getIdentity();
|
$user = Yii::$app->user->getIdentity();
|
||||||
@ -83,19 +85,22 @@ class ActiveQueryUser extends AbstractActiveQueryContentContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
$allowedVisibilities = [UserModel::VISIBILITY_ALL];
|
$allowedVisibilities = [UserModel::VISIBILITY_ALL];
|
||||||
if ($user !== null) {
|
if ($user === null) {
|
||||||
if ((new PermissionManager(['subject' => $user]))->can(ManageUsers::class)) {
|
// Guest can view only public users
|
||||||
return $this;
|
return $this->andWhere(['IN', 'user.visibility', $allowedVisibilities]);
|
||||||
}
|
|
||||||
|
|
||||||
$allowedVisibilities[] = UserModel::VISIBILITY_REGISTERED_ONLY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->active()
|
if ((new PermissionManager(['subject' => $user]))->can(ManageUsers::class)) {
|
||||||
->andWhere(['OR',
|
// Admin/manager can view users with any visibility status
|
||||||
['user.id' => $user->id], // User can view own profile
|
return $this;
|
||||||
['IN', 'user.visibility', $allowedVisibilities]
|
}
|
||||||
]);
|
|
||||||
|
$allowedVisibilities[] = UserModel::VISIBILITY_REGISTERED_ONLY;
|
||||||
|
|
||||||
|
return $this->andWhere(['OR',
|
||||||
|
['user.id' => $user->id], // User also can view own profile
|
||||||
|
['IN', 'user.visibility', $allowedVisibilities]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user