From 2c6cce1707d7c052b1f5c9613e37978f5463cbf8 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 11 Feb 2015 14:39:00 +0200 Subject: [PATCH] Enable restoring users and re-sending invitations --- app/controllers/AccountController.php | 6 +- app/controllers/UserController.php | 63 ++++++++++++++++---- app/lang/en/texts.php | 8 ++- app/routes.php | 2 + app/views/accounts/user_management.blade.php | 40 +++++++++---- 5 files changed, 92 insertions(+), 27 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 48ebccd6b4..3309923c50 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -85,7 +85,11 @@ class AccountController extends \BaseController { Session::put("show_trash:{$entityType}", $visible == 'true'); - return Redirect::to("{$entityType}s"); + if ($entityType == 'user') { + return Redirect::to('company/'.ACCOUNT_ADVANCED_SETTINGS.'/'.ACCOUNT_USER_MANAGEMENT); + } else { + return Redirect::to("{$entityType}s"); + } } public function getSearchData() diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 79d8a5d1a5..ec6b701c29 100755 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -31,26 +31,43 @@ class UserController extends BaseController public function getDatatable() { $query = DB::table('users') - ->where('users.account_id', '=', Auth::user()->account_id) - ->where('users.deleted_at', '=', null) - ->where('users.public_id', '>', 0) - ->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id'); + ->where('users.account_id', '=', Auth::user()->account_id); + + if (!Session::get('show_trash:user')) { + $query->where('users.deleted_at', '=', null); + } + + $query->where('users.public_id', '>', 0) + ->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id', 'users.deleted_at'); return Datatable::query($query) ->addColumn('first_name', function ($model) { return link_to('users/'.$model->public_id.'/edit', $model->first_name.' '.$model->last_name); }) ->addColumn('email', function ($model) { return $model->email; }) - ->addColumn('confirmed', function ($model) { return $model->confirmed ? trans('texts.active') : trans('texts.pending'); }) + ->addColumn('confirmed', function ($model) { return $model->deleted_at ? trans('texts.deleted') : ($model->confirmed ? trans('texts.active') : trans('texts.pending')); }) ->addColumn('dropdown', function ($model) { - return '