mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix update user with not existing group (#6105)
* Fix update user with not existing group * Restrict group selector only with existing groups --------- Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
parent
ecf7e616e8
commit
433a78a1c2
@ -5,6 +5,7 @@ HumHub Changelog
|
||||
-------------------------
|
||||
- Fix #5965: Suppress log warning 'Invalid session auth key attempted for user'
|
||||
- Fix #6084: Automatic LDAP user registration broken when not all req. attributes provided
|
||||
- Fix #6104: Fix update user with not existing group
|
||||
- Fix #6103: Fix null passing to parse_str()
|
||||
|
||||
1.13.1 (January 25, 2023)
|
||||
|
@ -148,7 +148,8 @@ class UserController extends Controller
|
||||
'items' => UserEditForm::getGroupItems(),
|
||||
'options' => [
|
||||
'data-placeholder' => Yii::t('AdminModule.user', 'Select Groups'),
|
||||
'data-placeholder-more' => Yii::t('AdminModule.user', 'Add Groups...')
|
||||
'data-placeholder-more' => Yii::t('AdminModule.user', 'Add Groups...'),
|
||||
'data-tags' => 'false'
|
||||
],
|
||||
'maxSelection' => 250,
|
||||
'isVisible' => Yii::$app->user->can(new ManageGroups())
|
||||
|
@ -2,12 +2,11 @@
|
||||
|
||||
namespace humhub\modules\admin\models\forms;
|
||||
|
||||
use humhub\libs\Html;
|
||||
use humhub\modules\user\models\GroupUser;
|
||||
use Yii;
|
||||
use humhub\modules\user\models\User;
|
||||
use humhub\modules\user\models\Group;
|
||||
use humhub\modules\admin\permissions\ManageGroups;
|
||||
use humhub\modules\user\models\Group;
|
||||
use humhub\modules\user\models\GroupUser;
|
||||
use humhub\modules\user\models\User;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* Description of UserEditForm
|
||||
@ -18,14 +17,13 @@ class UserEditForm extends User
|
||||
{
|
||||
/**
|
||||
* GroupId selection array of the form.
|
||||
* @var type
|
||||
* @var array
|
||||
*/
|
||||
public $groupSelection;
|
||||
|
||||
/**
|
||||
* Current member groups (models) of the given $user
|
||||
* @var type
|
||||
*
|
||||
* @var Group[]
|
||||
*/
|
||||
public $currentGroups;
|
||||
|
||||
@ -103,19 +101,19 @@ class UserEditForm extends User
|
||||
if (!$this->isCurrentlyMemberOf($groupId)) {
|
||||
/* @var $group Group */
|
||||
$group = Group::findOne(['id' => $groupId]);
|
||||
if(!$group->is_admin_group || Yii::$app->user->isAdmin()) {
|
||||
if ($group && (!$group->is_admin_group || Yii::$app->user->isAdmin())) {
|
||||
$group->addUser($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::afterSave($insert, $changedAttributes);
|
||||
parent::afterSave($insert, $changedAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given group (id or model object) is contained in the form selection
|
||||
* @param integer $groupId groupId or Group model object
|
||||
* @param int|Group $groupId groupId or Group model object
|
||||
* @return boolean true if contained in selection else false
|
||||
*/
|
||||
private function isInGroupSelection($groupId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user