Skip to content

Commit 140a51c

Browse files
authored
Merge pull request #2114 from LuckyCyborg/4.0
Overall improvements
2 parents a41ec6f + 474d032 commit 140a51c

File tree

5 files changed

+8
-61
lines changed

5 files changed

+8
-61
lines changed

app/Platform/Bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Define The Application Version
1515
//--------------------------------------------------------------------------
1616

17-
define('VERSION', '4.0.91');
17+
define('VERSION', '4.0.92');
1818

1919
//--------------------------------------------------------------------------
2020
// Set PHP Error Reporting Options

modules/Users/Controllers/Admin/Users.php

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function store(Request $request)
271271

272272
// Update the Custom Fields.
273273
foreach ($items as $item) {
274-
$value = Arr::get($input, $name = $item->name);
274+
$value = Arr::get($input, $name = $item->getAttribute('name'));
275275

276276
$field = Field::create(array(
277277
'name' => $name,
@@ -393,9 +393,11 @@ public function update(Request $request, $id)
393393

394394
// Update the Custom Fields.
395395
foreach ($items as $item) {
396-
$value = Arr::get($input, $name = $item->name);
396+
$value = Arr::get($input, $name = $item->getAttribute('name'));
397397

398-
if (! is_null($field = $user->fields->findBy('name', $name))) {
398+
$field = $user->fields->findBy('name', $name);
399+
400+
if (! is_null($field)) {
399401
$field->value = $value;
400402

401403
$field->save();
@@ -451,56 +453,4 @@ public function destroy($id)
451453
return Redirect::to('admin/users')
452454
->with('success', __d('users', 'The User <b>{0}</b> was successfully deleted.', $user->username));
453455
}
454-
455-
public function search()
456-
{
457-
// Authorize the current User.
458-
if (Gate::denies('lists', User::class)) {
459-
throw new AuthorizationException();
460-
}
461-
462-
// Validation rules
463-
$rules = array(
464-
'query' => 'required|min:4|valid_query'
465-
);
466-
467-
$messages = array(
468-
'valid_query' => __d('users', 'The :attribute field is not a valid query string.'),
469-
);
470-
471-
$attributes = array(
472-
'query' => __('Search Query'),
473-
);
474-
475-
// Add the custom Validation Rule commands.
476-
Validator::extend('valid_query', function($attribute, $value, $parameters)
477-
{
478-
return (preg_match('/^[\p{L}\p{N}_\-\s]+$/', $value) === 1);
479-
});
480-
481-
// Validate the Input data.
482-
$input = Input::only('query');
483-
484-
$validator = Validator::make($input, $rules, $messages, $attributes);
485-
486-
if($validator->fails()) {
487-
return Redirect::back()->withErrors($validator->errors());
488-
}
489-
490-
// Search the Records on Database.
491-
$search = $input['query'];
492-
493-
$users = User::where('username', 'LIKE', '%' .$search .'%')
494-
->orWhere('email', 'LIKE', '%' .$search .'%')
495-
->orWhere('realname', 'LIKE', '%' .$search .'%')
496-
->paginate(15);
497-
498-
// Prepare the Query for displaying.
499-
$search = htmlentities($search);
500-
501-
return $this->createView()
502-
->shares('title', __d('users', 'Searching Users for: {0}', $search))
503-
->with('search', $search)
504-
->with('users', $users);
505-
}
506456
}

modules/Users/Models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class User extends BaseModel implements UserInterface, RemindableInterface
2929
/**
3030
* @var array
3131
*/
32-
protected $fillable = array('username', 'password', 'email', 'remember_token', 'api_token');
32+
protected $fillable = array('username', 'realname', 'password', 'email', 'remember_token', 'api_token');
3333

3434
/**
3535
* @var array

modules/Users/Routes/Web.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
Route::post('users/fields/{id}', 'FieldItems@update');
2525
Route::post('users/fields/{id}/destroy', 'FieldItems@destroy');
2626

27-
// The Users Search.
28-
Route::get('users/search', 'Users@search');
29-
3027
// Server Side Processor for Users DataTable.
3128
Route::post('users/data', 'Users@data');
3229

themes/AdminLite/Views/Layouts/Backend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
<!-- sidebar: style can be found in sidebar.less -->
169169
<section class="sidebar">
170170
<!-- search form -->
171-
<form action="<?= site_url('admin/users/search'); ?>" method="GET" class="sidebar-form">
171+
<form action="#" method="GET" class="sidebar-form">
172172
<div class="input-group">
173173
<input type="text" name="query" class="form-control" placeholder="<?= __d('admin_lite', 'Search...'); ?>">
174174
<span class="input-group-btn">

0 commit comments

Comments
 (0)