mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix #2400: Space ownership transfer form shows wrong users
This commit is contained in:
parent
dd7ae7ae97
commit
297135069d
@ -8,6 +8,7 @@ HumHub Change Log
|
||||
- Fix #2393: Markdown h4,h5,h6 broken
|
||||
- Fix #2389: calculate max upload file size on PHP 7.1 (githubjeka)
|
||||
- Fix: LDAP - Lost authclient ldap class configuration on user update
|
||||
- Fix #2400: Space ownership transfer form shows wrong users
|
||||
|
||||
1.2.0-beta.3 (March 20, 2017)
|
||||
--------------------------------
|
||||
|
@ -2,22 +2,19 @@
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\space\modules\manage\controllers;
|
||||
|
||||
use Yii;
|
||||
|
||||
|
||||
use yii\web\HttpException;
|
||||
|
||||
use humhub\modules\space\modules\manage\components\Controller;
|
||||
use humhub\modules\space\modules\manage\models\MembershipSearch;
|
||||
use humhub\modules\user\models\User;
|
||||
use humhub\modules\space\models\Membership;
|
||||
|
||||
use humhub\modules\space\modules\manage\models\ChangeOwnerForm;
|
||||
|
||||
/**
|
||||
* Member Controller
|
||||
@ -163,18 +160,21 @@ class MemberController extends Controller
|
||||
$this->ownerOnly();
|
||||
$space = $this->getSpace();
|
||||
|
||||
$model = new \humhub\modules\space\modules\manage\models\ChangeOwnerForm();
|
||||
$model->ownerId = $space->getSpaceOwner()->id;
|
||||
$model = new ChangeOwnerForm([
|
||||
'space' => $space,
|
||||
'ownerId' => $space->getSpaceOwner()->id
|
||||
]);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
$space->setSpaceOwner($model->ownerId);
|
||||
|
||||
return $this->redirect($space->getUrl());
|
||||
}
|
||||
|
||||
return $this->render('change-owner', array(
|
||||
return $this->render('change-owner', [
|
||||
'space' => $space,
|
||||
'model' => $model
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
@ -35,10 +35,10 @@ class ChangeOwnerForm extends Model
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('ownerId', 'required'),
|
||||
array('ownerId', 'in', 'range' => array_keys($this->getNewOwnerArray()))
|
||||
);
|
||||
return [
|
||||
['ownerId', 'required'],
|
||||
['ownerId', 'in', 'range' => array_keys($this->getNewOwnerArray())]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,19 +46,21 @@ class ChangeOwnerForm extends Model
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'ownerId' => Yii::t('SpaceModule.manage', 'Space owner'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all possible space owners
|
||||
*
|
||||
* @return array containing the user id as key and display name as value
|
||||
*/
|
||||
public function getNewOwnerArray()
|
||||
{
|
||||
$possibleOwners = [];
|
||||
|
||||
$query = Membership::find()->joinWith(['user', 'user.profile'])->andWhere(['space_membership.group_id' => 'admin']);
|
||||
$query = Membership::find()->joinWith(['user', 'user.profile'])->andWhere(['space_membership.group_id' => 'admin', 'space_membership.space_id' => $this->space->id]);
|
||||
foreach ($query->all() as $membership) {
|
||||
$possibleOwners[$membership->user->id] = $membership->user->displayName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user