Allow to add a space as default for new users from "Invite members" modal window (#7280)

This commit is contained in:
Yuriy Bakhtin 2024-10-29 20:59:02 +01:00 committed by GitHub
parent e10bd87a12
commit f80a75f0ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 20 deletions

View File

@ -1,6 +1,10 @@
HumHub Changelog
================
1.17.0-beta.2 (Unreleased)
--------------------------------
- Enh #7280: Allow to add a space as default for new users from "Invite members" modal window
1.17.0-beta.1 (October 28, 2024)
--------------------------------
- Enh #7070: Add GitHub action for PHP CS Fixer

View File

@ -2,7 +2,6 @@
namespace humhub\modules\space\models\forms;
use humhub\libs\UUID;
use humhub\modules\admin\permissions\ManageUsers;
use humhub\modules\space\jobs\AddUsersToSpaceJob;
use humhub\modules\space\models\Membership;
@ -64,12 +63,22 @@ class InviteForm extends Model
*/
public $withoutInvite = false;
public $allRegisteredUsers = false;
public $addDefaultSpace = false;
/**
* Parsed list of E-Mails of field inviteEmails
*/
protected $_inviteEmails = [];
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->addDefaultSpace = $this->space->auto_add_new_members;
}
/**
* Declares the validation rules.
* The rules state that username and password are required,
@ -78,7 +87,7 @@ class InviteForm extends Model
public function rules()
{
return [
[['withoutInvite', 'allRegisteredUsers'], 'boolean'],
[['withoutInvite', 'allRegisteredUsers', 'addDefaultSpace'], 'boolean'],
['invite', 'checkInvite'],
['inviteEmails', 'checkInviteExternal'],
];
@ -92,6 +101,9 @@ class InviteForm extends Model
return [
'invite' => Yii::t('SpaceModule.base', 'Invites'),
'inviteEmails' => Yii::t('SpaceModule.base', 'New user by e-mail (comma separated)'),
'allRegisteredUsers' => Yii::t('SpaceModule.base', 'Select all registered users'),
'withoutInvite' => Yii::t('SpaceModule.base', 'Add users without invitation'),
'addDefaultSpace' => Yii::t('SpaceModule.base', 'Add as Default Space for new users'),
];
}
@ -115,6 +127,9 @@ class InviteForm extends Model
$this->inviteExternalByEmail();
$this->space->auto_add_new_members = $this->addDefaultSpace ? 1 : null;
$this->space->save();
return true;
}

View File

@ -7,14 +7,12 @@
/* @var $submitAction string */
/* @var $model InviteForm */
/* @var $attribute string */
/* @var $searchUrl string */
use humhub\modules\space\models\forms\InviteForm;
use humhub\modules\ui\view\components\View;
use humhub\modules\user\widgets\UserPickerField;
use humhub\widgets\Button;
use humhub\widgets\ModalButton;
use humhub\widgets\ModalDialog;
use yii\bootstrap\ActiveForm;
use humhub\libs\Html;
@ -79,26 +77,16 @@ $form = ActiveForm::begin([
<?= $form->field($model, 'invite')
->widget(UserPickerField::class, ['disabledItems' => [Yii::$app->user->guid], 'url' => $searchUrl, 'focus' => true, 'id' => 'space-invite-user-picker']); ?>
<br/>
<?= $form->field($model, 'allRegisteredUsers')->checkbox() ?>
<?php if ($canAddWithoutInvite) : ?>
<br/>
<?= $form
->field($model, 'withoutInvite')
->label(Yii::t(
'SpaceModule.base',
'Add users without invitation'
))
->checkbox() ?>
<br/>
<?= $form
->field($model, 'allRegisteredUsers')
->label(Yii::t(
'SpaceModule.base',
'Select all registered users'
))
->checkbox() ?>
<?= $form->field($model, 'withoutInvite')->checkbox() ?>
<?php endif; ?>
<br/>
<?= $form->field($model, 'addDefaultSpace')->checkbox() ?>
</div>
<?php if ($canInviteByEmail) : ?>