Skip to content

Commit

Permalink
Fixes (#31)
Browse files Browse the repository at this point in the history
* fix: update form registration type

* feat: implement registration delete

* feat: send welcome email
  • Loading branch information
andreiio authored Nov 11, 2022
1 parent e1316b1 commit 196f891
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
5 changes: 5 additions & 0 deletions plugins/genuineq/user/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@
'fail' => 'Failed to activate that account',
],

'flash_delete' => [
'success' => 'Account was successfully deleted',
'fail' => 'Failed to delete that account',
],

'columns' => [
'id' => 'Id',
'name' => 'Name',
Expand Down
5 changes: 5 additions & 0 deletions plugins/genuineq/user/lang/ro/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@
'fail' => 'Nu s-a activat contul respectiv',
],

'flash_delete' => [
'success' => 'Contul a fost șters cu succes',
'fail' => 'Nu s-a șters contul respectiv',
],

'columns' => [
'id' => 'Id',
'name' => 'Prenume',
Expand Down
39 changes: 36 additions & 3 deletions plugins/genuineq/user/reportwidgets/RegRequestsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Redirect;
use Exception;
use Backend\Classes\ReportWidgetBase;
use Genuineq\User\Helpers\EmailHelper;
use Genuineq\User\Models\User as UserModel;

/**
Expand All @@ -24,7 +25,6 @@ public function render()

/** Get no of inactive user accounts (== user requests) from database */
$this->vars['userRequests'] = UserModel::where('is_activated', 0)->orderBy('created_at', 'DESC')->get();

} catch (Exception $ex) {
$this->vars['error'] = $ex->getMessage();
}
Expand Down Expand Up @@ -97,8 +97,41 @@ public function onRequest()
private function activateUser($accountId)
{
$userModel = UserModel::find($accountId);
$userModel->is_activated = 1;
$userModel->save();

$userModel->attemptActivation($userModel->getActivationCode());

/** Inform user via email of account activation. */
EmailHelper::sendWelcomeEmail($userModel);
}

public function onDelete()
{
if ([] != post('record_id')) {
$this->deleteUser(post('record_id'));
} elseif ([] != post('checked')) {
/** Iterate IDs and get the corresponding user, then activate it */
foreach (post('checked') as $accountId) {
$this->deleteUser($accountId);
}
} else {
Flash::error(Lang::get('genuineq.user::lang.reportwidgets.reg_requests_table.flash_delete.fail'));

return;
}

Flash::success(Lang::get('genuineq.user::lang.reportwidgets.reg_requests_table.flash_delete.success'));

/* Refreshing the page */
return Redirect::refresh();
}


private function deleteUser($accountId)
{
$userModel = UserModel::find($accountId);

if (!is_null($userModel)) {
$userModel->delete();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ <h4 class="modal-title"><?= e(trans('genuineq.user::lang.reportwidgets.reg_reque
</button>

<button
type="button"
class="btn btn-default"
data-dismiss="popup">
<?= e(trans('backend::lang.form.cancel')) ?>
type="submit"
data-request="onDelete"
onclick="$(this).data('request-data', {
redirect: 0
})"
data-hotkey="ctrl+d, cmd+d"
data-popup-load-indicator
class="btn btn-default">
<?= e(trans('genuineq.user::lang.reportwidgets.reg_requests_table.delete_selected')) ?>
</button>
</div>

Expand Down
1 change: 1 addition & 0 deletions themes/esense/pages/authentification/register-form.htm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ <h3 class="text-primary-dark font-weight-light mb-3" style="line-height: 38px;">

$('#teacherForm').toggleClass('d-none', isSchoolForm);
$('#schoolForm').toggleClass('d-none', !isSchoolForm);
$('#type').val(target);
}

$(document).ready(function () {
Expand Down

0 comments on commit 196f891

Please sign in to comment.