diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e5fa0043..8aa711fa90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ HumHub Changelog - Enh #7129: Link `wall-entry-controls`- color to `--text-color-soft` - Chg #7136: When opening a modal box, don't autofocus automatically on the first form input - Enh #7138: Added missing DB relations to UserInvite model +- Enh #7139: Export `confirmUnload` function from `humhub.client.js` +- Enh #7068: Bulk re-send email invites - Enh #7139 : Export `confirmUnload` function from `humhub.client.js` - Enh #7144: Add `DeviceDetectorHelper` class to detect devices such as the mobile app - Fix #7149: Fixed dropdown issue on mobile diff --git a/protected/humhub/modules/admin/controllers/PendingRegistrationsController.php b/protected/humhub/modules/admin/controllers/PendingRegistrationsController.php index ccf2984278..10e2e6331c 100644 --- a/protected/humhub/modules/admin/controllers/PendingRegistrationsController.php +++ b/protected/humhub/modules/admin/controllers/PendingRegistrationsController.php @@ -144,6 +144,29 @@ class PendingRegistrationsController extends Controller return $this->render('delete', ['model' => $invite]); } + /** + * Delete all invitations + * + * @param int $id + * @return string + * @throws HttpException + * @throws Throwable + */ + public function actionResendAll() + { + if (Yii::$app->request->isPost) { + foreach (Invite::find()->each() as $invite) { + $invite->sendInviteMail(); + } + + $this->view->success(Yii::t( + 'AdminModule.user', + 'All open registration invitations were successfully re-sent.', + )); + } + return $this->redirect(['index']); + } + /** * Delete all invitations * @@ -173,15 +196,39 @@ class PendingRegistrationsController extends Controller * @throws HttpException * @throws Throwable */ - public function actionDeleteAllSelected() + public function actionResendAllSelected() { if (Yii::$app->request->isPost) { $ids = Yii::$app->request->post('id'); if (!empty($ids)) { - foreach ($ids as $id) { - $invitation = Invite::findOne(['id' => $id]); - $invitation->delete(); + foreach (Invite::findAll(['id' => $ids]) as $invite) { + $invite->sendInviteMail(); + } + $this->view->success(Yii::t( + 'AdminModule.user', + 'The selected invitations have been successfully re-sent!', + )); + } + } + return $this->redirect(['index']); + } + + /** + * Delete all or selected invitation + * + * @param int $id + * @return string + * @throws HttpException + * @throws Throwable + */ + public function actionDeleteAllSelected() + { + if (Yii::$app->request->isPost) { + $ids = Yii::$app->request->post('id'); + if (!empty($ids)) { + foreach (Invite::findAll(['id' => $ids]) as $invite) { + $invite->delete(); } $this->view->success(Yii::t( 'AdminModule.user', diff --git a/protected/humhub/modules/admin/resources/js/humhub.admin.PendingRegistrations.js b/protected/humhub/modules/admin/resources/js/humhub.admin.PendingRegistrations.js index c9add1005c..04aceff180 100644 --- a/protected/humhub/modules/admin/resources/js/humhub.admin.PendingRegistrations.js +++ b/protected/humhub/modules/admin/resources/js/humhub.admin.PendingRegistrations.js @@ -5,6 +5,20 @@ humhub.module('admin.PendingRegistrations', function (module, require, $) { var PendingRegistrations = Widget.extend(); + PendingRegistrations.prototype.resendAllSelected = function (evt) { + var that = this; + client.post(evt).then(function () { + var keys = $("#grid").yiiGridView("getSelectedRows"); + $.ajax({ + url: that.options.urlResendSelected, + type: "POST", + data: {id: keys}, + }) + }).catch(function (e) { + module.log.error(e, true); + }) + }; + PendingRegistrations.prototype.deleteAllSelected = function (evt) { var that = this; client.post(evt).then(function () { @@ -19,6 +33,12 @@ humhub.module('admin.PendingRegistrations', function (module, require, $) { }) }; + PendingRegistrations.prototype.resendAll = function (evt) { + client.post(evt).catch(function () { + module.log.error(e, true); + }) + }; + PendingRegistrations.prototype.deleteAll = function (evt) { client.post(evt).catch(function () { module.log.error(e, true); @@ -30,10 +50,16 @@ humhub.module('admin.PendingRegistrations', function (module, require, $) { this.$.find("input").change(function () { var $selection = that.$.find(':checked') if ($selection.length > 1) { + $('.resend-all').html(that.options.noteResendSelected); + $('.resend-all').attr('data-action-click', 'resendAllSelected'); + $('.resend-all').attr('data-action-click-url', that.options.urlResendSelected); $('.delete-all').html(that.options.noteDeleteSelected); $('.delete-all').attr('data-action-click', 'deleteAllSelected'); $('.delete-all').attr('data-action-click-url', that.options.urlDeleteSelected); } else { + $('.resend-all').html(that.options.noteResendAll); + $('.resend-all').attr('data-action-click', 'resendAll'); + $('.resend-all').attr('data-action-click-url', that.options.urlResendAll); $('.delete-all').html(that.options.noteDeleteAll); $('.delete-all').attr('data-action-click', 'deleteAll'); $('.delete-all').attr('data-action-click-url', that.options.urlDeleteAll); diff --git a/protected/humhub/modules/admin/widgets/PendingRegistrations.php b/protected/humhub/modules/admin/widgets/PendingRegistrations.php index 9c5e970e44..967801d972 100644 --- a/protected/humhub/modules/admin/widgets/PendingRegistrations.php +++ b/protected/humhub/modules/admin/widgets/PendingRegistrations.php @@ -9,10 +9,10 @@ namespace humhub\modules\admin\widgets; use humhub\modules\admin\models\PendingRegistrationSearch; -use yii\helpers\Url; use humhub\widgets\JsWidget; use Yii; use yii\data\ActiveDataProvider; +use yii\helpers\Url; /** * PendingRegistrations shows a grid view of all open/pending UserInvites @@ -80,6 +80,10 @@ class PendingRegistrations extends JsWidget public function getData() { return [ + 'url-resend-selected' => Url::to(['pending-registrations/resend-all-selected']), + 'url-resend-all' => Url::to(['pending-registrations/resend-all']), + 'note-resend-selected' => Yii::t('AdminModule.base', 'Resend to selected rows'), + 'note-resend-all' => Yii::t('AdminModule.base', 'Resend to all'), 'url-delete-selected' => Url::to(['pending-registrations/delete-all-selected']), 'url-delete-all' => Url::to(['pending-registrations/delete-all']), 'note-delete-selected' => Yii::t('AdminModule.base', 'Delete selected rows'), diff --git a/protected/humhub/modules/admin/widgets/views/pending-registrations.php b/protected/humhub/modules/admin/widgets/views/pending-registrations.php index 97016a504b..f4ab678973 100644 --- a/protected/humhub/modules/admin/widgets/views/pending-registrations.php +++ b/protected/humhub/modules/admin/widgets/views/pending-registrations.php @@ -15,28 +15,33 @@ use yii\helpers\Url; AdminPendingRegistrationsAsset::register($this); ?> -

- -
- -
- -
+

Yii::t('AdminModule.base', 'Back to user overview'), - 'class' => 'btn-sm' - ] + 'class' => 'btn-sm pull-right', + ], ) ?> + +

+ +
+ +
+ +
totalCount > 0): ?> + icon('paper-plane') + ->action('resendAll', Url::toRoute(['/admin/pending-registrations/resend-all'])) + ->cssClass('resend-all btn-sm')-> + confirm(Yii::t('AdminModule.user', 'Resend invitations?'), Yii::t('AdminModule.user', 'Do you really want to re-send the invitations to pending registration users?')) ?> icon('trash') ->action('deleteAll', Url::toRoute(['/admin/pending-registrations/delete-all'])) ->cssClass('delete-all btn-sm')-> - confirm('Delete pending registrations?', 'Do you really want to delete pending registrations?'); ?> + confirm(Yii::t('AdminModule.user', 'Delete pending registrations?'), Yii::t('AdminModule.user', 'Do you really want to delete pending registrations?')) ?> 'PendingRegistrationSearch']) ?>
@@ -82,19 +87,21 @@ AdminPendingRegistrationsAsset::register($this); 'resend' => function ($url, $model, $key) { return Button::primary() ->action('client.post', Url::to(['resend', 'id' => $model->id])) - ->icon('envelope') + ->icon('paper-plane') + ->confirm(Yii::t('AdminModule.user', 'Resend invitation?')) ->xs(); }, 'delete' => function ($url, $model, $key) { return - Button::primary() + Button::danger() ->action('client.post', Url::to(['delete', 'id' => $model->id])) ->icon('trash') + ->confirm(Yii::t('AdminModule.user', 'Delete pending registrations?')) ->xs(); }, ], ], - ] + ], ]) ?>