diff --git a/controllers/Users.php b/controllers/Users.php index a31cf2de..159e4eff 100644 --- a/controllers/Users.php +++ b/controllers/Users.php @@ -4,6 +4,7 @@ use Lang; use Flash; use Response; +use Redirect; use BackendMenu; use BackendAuth; use Backend\Classes\Controller; @@ -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. */ diff --git a/controllers/users/_preview_toolbar.htm b/controllers/users/_preview_toolbar.htm index 1390b368..dd25e4f9 100644 --- a/controllers/users/_preview_toolbar.htm +++ b/controllers/users/_preview_toolbar.htm @@ -17,6 +17,17 @@ + +isSuspended()): ?> + + + + + diff --git a/lang/en/lang.php b/lang/en/lang.php index 7bcfda7c..7baa76fe 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -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', diff --git a/models/User.php b/models/User.php index 9278a92e..4bd01d9b 100644 --- a/models/User.php +++ b/models/User.php @@ -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 //