diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 90023c4a91..ad64792fa3 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -353,6 +353,7 @@ class UsersController extends AdminController { return Redirect::route('users')->with('error', $error); } + // Do we have permission to delete this user? if ($user->isSuperUser() and ! Sentry::getUser()->isSuperUser()) { @@ -360,6 +361,18 @@ class UsersController extends AdminController { return Redirect::route('users')->with('error', 'Insufficient permissions!'); } + if (count($user->assets) > 0) { + + // Redirect to the user management page + return Redirect::route('users')->with('error', 'This user still has '.count($user->assets).' assets associated with them.'); + } + + if (count($user->licenses) > 0) { + + // Redirect to the user management page + return Redirect::route('users')->with('error', 'This user still has '.count($user->licenses).' licenses associated with them.'); + } + // Delete the user $user->delete(); diff --git a/app/models/Asset.php b/app/models/Asset.php index 9ffe50744b..bd4fc09c64 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -83,7 +83,6 @@ class Asset extends Elegant { public static function assetcount() { return DB::table('assets') - ->where('physical', '=', '1') ->whereNull('deleted_at','and') ->count(); diff --git a/app/views/backend/users/view.blade.php b/app/views/backend/users/view.blade.php index 9214da40c8..f9c5cb1409 100644 --- a/app/views/backend/users/view.blade.php +++ b/app/views/backend/users/view.blade.php @@ -17,7 +17,13 @@ View User {{ $user->fullName() }} ::