From a678ec41714f5d7f77418b5933bc112aa67eae9c Mon Sep 17 00:00:00 2001 From: Gil Rutkowski Date: Sun, 1 Dec 2013 17:11:44 -0600 Subject: [PATCH 1/2] Fixed Gravatar Hash --- app/models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/User.php b/app/models/User.php index d1e4fae82bae..1c348dcc608d 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -30,7 +30,7 @@ public function fullName() public function gravatar() { // Generate the Gravatar hash - $gravatar = md5(strtolower(trim($this->gravatar))); + $gravatar = md5(strtolower(trim($this->email))); // Return the Gravatar url return "//gravatar.com/avatar/{$gravatar}"; From a0267db8328802abe27cc81414c32ab0f077f0d9 Mon Sep 17 00:00:00 2001 From: Gil Rutkowski Date: Mon, 2 Dec 2013 00:21:04 -0600 Subject: [PATCH 2/2] Datatables partially implemented on user table. --- .gitignore | 36 +++++++++++++++++++++++ app/controllers/admin/UsersController.php | 35 ++++++++++++++++++++++ app/routes.php | 2 ++ app/views/backend/users/index.blade.php | 16 +++++++++- 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a287f464899a..c5a54990552c 100755 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,39 @@ composer.phar /app/config/*/app.php /app/config/testing/database.php +public/packages/barryvdh/laravel-debugbar/debugbar.css +public/packages/barryvdh/laravel-debugbar/debugbar.js +public/packages/barryvdh/laravel-debugbar/icons.png +public/packages/barryvdh/laravel-debugbar/openhandler.css +public/packages/barryvdh/laravel-debugbar/openhandler.js +public/packages/barryvdh/laravel-debugbar/php-icon.png +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome-ie7.css +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome-ie7.min.css +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome.css +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome.min.css +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/FontAwesome.otf +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.eot +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.svg +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.ttf +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.woff +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/bootstrap.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/core.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/extras.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/font-awesome-ie7.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/font-awesome.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/icons.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/mixins.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/path.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/variables.less +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_bootstrap.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_core.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_extras.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_icons.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_mixins.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_path.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_variables.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/font-awesome-ie7.scss +public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/font-awesome.scss +public/packages/barryvdh/laravel-debugbar/vendor/jquery-1.8.3.min.js +public/packages/barryvdh/laravel-debugbar/widgets.css +public/packages/barryvdh/laravel-debugbar/widgets.js diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index ad64792fa36c..714a8b98f1ad 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -5,6 +5,8 @@ use Cartalyst\Sentry\Users\PasswordRequiredException; use Cartalyst\Sentry\Users\UserExistsException; use Cartalyst\Sentry\Users\UserNotFoundException; +use HTML; +use URL; use Config; use DB; use Input; @@ -18,6 +20,7 @@ use Sentry; use Validator; use View; +use Chumper\Datatable\Facades\Datatable; class UsersController extends AdminController { @@ -448,4 +451,36 @@ public function getView($userId = null) } + public function getDatatable() + { + return Datatable::collection(User::all()) + ->addColumn('name',function($model) + { + $name = HTML::image($model->gravatar(), $model->first_name, array('class'=>'img-circle avatar hidden-phone', 'style'=>'max-width: 45px')); + $name .= HTML::link(URL::action('Controllers\Admin\UsersController@getView', $model->id), $model->first_name . ' ' . $model->last_name, array('class' => 'name')); + return $name; + } + ) + ->showColumns('email') + ->addColumn('assets', function($model) + { + $assets = $model->assets->count(); + return $assets; + } + ) + ->addColumn('licenses', function($model) + { + $licenses = $model->licenses->count(); + return $licenses; + } + ) + ->addColumn('activated', function($model) + { + $activated = $model->isActivated() ? '' : ''; + return $activated; + } + ) + ->make(); + } + } diff --git a/app/routes.php b/app/routes.php index 71cebb330795..4fbd8dfbb56c 100755 --- a/app/routes.php +++ b/app/routes.php @@ -162,6 +162,8 @@ Route::get('{userId}/delete', array('as' => 'delete/user', 'uses' => 'Controllers\Admin\UsersController@getDelete')); Route::get('{userId}/restore', array('as' => 'restore/user', 'uses' => 'Controllers\Admin\UsersController@getRestore')); Route::get('{userId}/view', array('as' => 'view/user', 'uses' => 'Controllers\Admin\UsersController@getView')); + + Route::get('datatable', array('as'=>'api.users', 'uses'=>'Controllers\Admin\UsersController@getDatatable')); }); # Group Management diff --git a/app/views/backend/users/index.blade.php b/app/views/backend/users/index.blade.php index d50f19705460..bdfd0aebb53f 100755 --- a/app/views/backend/users/index.blade.php +++ b/app/views/backend/users/index.blade.php @@ -32,7 +32,7 @@
@if ($users->getTotal() > 0) -
+ +{{ + Datatable::table() + ->addColumn(Lang::get('name')) + ->addColumn(Lang::get('email')) + ->addColumn('Assets') + ->addColumn('Licenses') + ->addColumn(Lang::get('activated')) + ->setUrl(route('api.users')) + ->render() +}} + @else + +