Skip to content
15 changes: 15 additions & 0 deletions controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Lang;
use Flash;
use Response;
use Redirect;
use BackendMenu;
use BackendAuth;
use Backend\Classes\Controller;
Expand Down Expand Up @@ -221,6 +222,20 @@ public function preview_onImpersonateUser($recordId)
Flash::success(Lang::get('rainlab.user::lang.users.impersonate_success'));
}

/**
* Unsuspend this user
*/
public function preview_onUnsuspendUser($recordId)
{
$model = $this->formFindModelObject($recordId);

$model->unsuspend();

Flash::success(Lang::get('rainlab.user::lang.users.unsuspend_success'));

return Redirect::refresh();
}

/**
* Force delete a user.
*/
Expand Down
11 changes: 11 additions & 0 deletions controllers/users/_preview_toolbar.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
<?= e(trans('rainlab.user::lang.users.impersonate_user')) ?>
</a>
<?php endif ?>

<?php if ($formModel->isSuspended()): ?>
<a
href="javascript:;"
data-request="onUnsuspendUser"
data-request-confirm="<?= e(trans('rainlab.user::lang.users.unsuspend_confirm')) ?>"
class="btn btn-default oc-icon-unlock-alt">
<?= e(trans('rainlab.user::lang.users.unsuspend')) ?>
</a>
<?php endif ?>

<?php
/* @todo
<div class="btn-group">
Expand Down
3 changes: 3 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
'unban_selected_confirm' => 'Unban the selected users?',
'unban_selected_empty' => 'There are no selected users to unban.',
'unban_selected_success' => 'Successfully unbanned the selected users.',
'unsuspend' => 'Unsuspend',
'unsuspend_success' => 'User has been unsuspended.',
'unsuspend_confirm' => 'Unsuspend this user?'
],
'settings' => [
'users' => 'Users',
Expand Down
22 changes: 22 additions & 0 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,28 @@ public function isBanned()
return $throttle ? $throttle->is_banned : false;
}

//
// Suspending
//

/**
* Check if the user is suspended.
* @return bool
*/
public function isSuspended()
{
return Auth::findThrottleByUserId($this->id)->checkSuspended();
}

/**
* Remove the suspension on this user.
* @return void
*/
public function unsuspend()
{
Auth::findThrottleByUserId($this->id)->unsuspend();
}

//
// IP Recording and Throttle
//
Expand Down