From 474d032fc4df657304e6789385693fe8c47e2c7d Mon Sep 17 00:00:00 2001 From: Virgil-Adrian Teaca Date: Sun, 9 Sep 2018 20:03:40 +0300 Subject: [PATCH] Overall improvements --- app/Platform/Bootstrap.php | 2 +- modules/Users/Controllers/Admin/Users.php | 60 ++-------------------- modules/Users/Models/User.php | 2 +- modules/Users/Routes/Web.php | 3 -- themes/AdminLite/Views/Layouts/Backend.php | 2 +- 5 files changed, 8 insertions(+), 61 deletions(-) diff --git a/app/Platform/Bootstrap.php b/app/Platform/Bootstrap.php index ca111a0d02..a23b1a7aa2 100644 --- a/app/Platform/Bootstrap.php +++ b/app/Platform/Bootstrap.php @@ -14,7 +14,7 @@ // Define The Application Version //-------------------------------------------------------------------------- -define('VERSION', '4.0.91'); +define('VERSION', '4.0.92'); //-------------------------------------------------------------------------- // Set PHP Error Reporting Options diff --git a/modules/Users/Controllers/Admin/Users.php b/modules/Users/Controllers/Admin/Users.php index 3eb739be13..30c5bf3a3e 100644 --- a/modules/Users/Controllers/Admin/Users.php +++ b/modules/Users/Controllers/Admin/Users.php @@ -271,7 +271,7 @@ public function store(Request $request) // Update the Custom Fields. foreach ($items as $item) { - $value = Arr::get($input, $name = $item->name); + $value = Arr::get($input, $name = $item->getAttribute('name')); $field = Field::create(array( 'name' => $name, @@ -393,9 +393,11 @@ public function update(Request $request, $id) // Update the Custom Fields. foreach ($items as $item) { - $value = Arr::get($input, $name = $item->name); + $value = Arr::get($input, $name = $item->getAttribute('name')); - if (! is_null($field = $user->fields->findBy('name', $name))) { + $field = $user->fields->findBy('name', $name); + + if (! is_null($field)) { $field->value = $value; $field->save(); @@ -451,56 +453,4 @@ public function destroy($id) return Redirect::to('admin/users') ->with('success', __d('users', 'The User {0} was successfully deleted.', $user->username)); } - - public function search() - { - // Authorize the current User. - if (Gate::denies('lists', User::class)) { - throw new AuthorizationException(); - } - - // Validation rules - $rules = array( - 'query' => 'required|min:4|valid_query' - ); - - $messages = array( - 'valid_query' => __d('users', 'The :attribute field is not a valid query string.'), - ); - - $attributes = array( - 'query' => __('Search Query'), - ); - - // Add the custom Validation Rule commands. - Validator::extend('valid_query', function($attribute, $value, $parameters) - { - return (preg_match('/^[\p{L}\p{N}_\-\s]+$/', $value) === 1); - }); - - // Validate the Input data. - $input = Input::only('query'); - - $validator = Validator::make($input, $rules, $messages, $attributes); - - if($validator->fails()) { - return Redirect::back()->withErrors($validator->errors()); - } - - // Search the Records on Database. - $search = $input['query']; - - $users = User::where('username', 'LIKE', '%' .$search .'%') - ->orWhere('email', 'LIKE', '%' .$search .'%') - ->orWhere('realname', 'LIKE', '%' .$search .'%') - ->paginate(15); - - // Prepare the Query for displaying. - $search = htmlentities($search); - - return $this->createView() - ->shares('title', __d('users', 'Searching Users for: {0}', $search)) - ->with('search', $search) - ->with('users', $users); - } } diff --git a/modules/Users/Models/User.php b/modules/Users/Models/User.php index c5c68a520c..ce8284d920 100644 --- a/modules/Users/Models/User.php +++ b/modules/Users/Models/User.php @@ -29,7 +29,7 @@ class User extends BaseModel implements UserInterface, RemindableInterface /** * @var array */ - protected $fillable = array('username', 'password', 'email', 'remember_token', 'api_token'); + protected $fillable = array('username', 'realname', 'password', 'email', 'remember_token', 'api_token'); /** * @var array diff --git a/modules/Users/Routes/Web.php b/modules/Users/Routes/Web.php index bfd389d824..82d5a2a38f 100644 --- a/modules/Users/Routes/Web.php +++ b/modules/Users/Routes/Web.php @@ -24,9 +24,6 @@ Route::post('users/fields/{id}', 'FieldItems@update'); Route::post('users/fields/{id}/destroy', 'FieldItems@destroy'); - // The Users Search. - Route::get('users/search', 'Users@search'); - // Server Side Processor for Users DataTable. Route::post('users/data', 'Users@data'); diff --git a/themes/AdminLite/Views/Layouts/Backend.php b/themes/AdminLite/Views/Layouts/Backend.php index a9f78337ff..8cfd466bde 100644 --- a/themes/AdminLite/Views/Layouts/Backend.php +++ b/themes/AdminLite/Views/Layouts/Backend.php @@ -168,7 +168,7 @@