Skip to content

Commit 2932e1b

Browse files
committed
Overall improvements
1 parent f42038c commit 2932e1b

40 files changed

Lines changed: 1020 additions & 322 deletions

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.1.10');
17+
define('VERSION', '4.1.11');
1818

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

modules/Platform/Routes/Web.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,6 @@
1313

1414
/** Define static routes. */
1515

16-
// The default Auth Routes.
17-
Route::get( 'login', array('middleware' => 'guest', 'uses' => 'Authorize@index'));
18-
Route::post('login', array('middleware' => 'guest', 'uses' => 'Authorize@process'));
19-
Route::post('logout', array('middleware' => 'auth', 'uses' => 'Authorize@logout'));
20-
21-
// The Public Area Routes.
22-
Route::group(array('middleware' => 'guest'), function ()
23-
{
24-
// The One-Time Authentication.
25-
Route::get( 'authorize', 'TokenLogins@index');
26-
Route::post('authorize', 'TokenLogins@process');
27-
28-
Route::get('authorize/{hash}/{time}/{token}', 'TokenLogins@login')->where('time', '\d+');
29-
30-
// The Password Reminder.
31-
Route::get( 'password/remind', 'PasswordReminders@remind');
32-
Route::post('password/remind', 'PasswordReminders@postRemind');
33-
34-
// The Password Reset.
35-
Route::post('password/reset', 'PasswordReminders@postReset');
36-
37-
Route::get('password/reset/{hash}/{time}/{token}', 'PasswordReminders@reset')->where('time', '\d+');
38-
39-
// The Account Registration.
40-
Route::get( 'register', 'Registrar@create');
41-
Route::post('register', 'Registrar@store');
42-
Route::get( 'register/status', 'Registrar@status');
43-
Route::get( 'register/verify', 'Registrar@verify');
44-
Route::post('register/verify', 'Registrar@verifyPost');
45-
46-
Route::get('register/{hash}/{token?}', 'Registrar@tokenVerify');
47-
});
48-
4916
// The Frontend Area Routes.
5017
Route::group(array('middleware' => 'auth'), function ()
5118
{
@@ -54,11 +21,6 @@
5421

5522
Route::get('dashboard/notify', 'Dashboard@notify');
5623

57-
// The User's Account.
58-
Route::get( 'account', 'Account@index');
59-
Route::post('account', 'Account@update');
60-
Route::post('account/picture', 'Account@picture');
61-
6224
// The User's Notifications.
6325
Route::get( 'notifications', 'Notifications@index');
6426
Route::post('notifications', 'Notifications@update');
@@ -67,6 +29,7 @@
6729
Route::post('heartbeat', 'Heartbeat@update');
6830
});
6931

32+
7033
// The Adminstration Routes.
7134
Route::get('admin', function ()
7235
{

modules/Platform/Views/PasswordReminders/Reset.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

modules/Platform/Views/Reminders/Remind.php

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @version 3.0
77
*/
88

9-
namespace Modules\Platform\Controllers;
9+
namespace Modules\Users\Controllers;
1010

1111
use Nova\Database\ORM\Collection;
1212
use Nova\Http\Request;
@@ -45,14 +45,14 @@ protected function validator(array $data, User $user, Collection $items)
4545
);
4646

4747
$messages = array(
48-
'valid_name' => __d('platform', 'The :attribute field is not a valid name.'),
49-
'strong_password' => __d('platform', 'The :attribute field is not strong enough.'),
48+
'valid_name' => __d('users', 'The :attribute field is not a valid name.'),
49+
'strong_password' => __d('users', 'The :attribute field is not strong enough.'),
5050
);
5151

5252
$attributes = array(
53-
'password' => __d('platform', 'New Password'),
54-
'password_confirmation' => __d('platform', 'Password Confirmation'),
55-
'realname' => __d('platform', 'Name and Surname'),
53+
'password' => __d('users', 'New Password'),
54+
'password_confirmation' => __d('users', 'Password Confirmation'),
55+
'realname' => __d('users', 'Name and Surname'),
5656
);
5757

5858
// Prepare the dynamic rules and attributes for Field Items.
@@ -70,15 +70,14 @@ protected function validator(array $data, User $user, Collection $items)
7070
$options = $item->options ?: array();
7171

7272
if ($item->type == 'checkbox') {
73-
$choices = array_filter(explode("\n", trim(
73+
$choices = explode("\n", trim(
7474
Arr::get($options, 'choices')
75+
));
7576

76-
)), function ($value)
77+
$count = count($choices = array_filter($choices, function ($value)
7778
{
7879
return ! empty($value);
79-
});
80-
81-
$count = count($choices);
80+
}));
8281

8382
if ($count > 1) {
8483
foreach (range(0, $count - 1) as $index) {
@@ -90,11 +89,7 @@ protected function validator(array $data, User $user, Collection $items)
9089
$attributes[$name] = $item->title;
9190
}
9291

93-
if (Str::contains($rule, 'required')) {
94-
$rule = 'required|array';
95-
} else {
96-
$rule = 'array';
97-
}
92+
$rule = Str::contains($rule, 'required') ? 'required|array' : 'array';
9893
}
9994
}
10095

@@ -131,7 +126,7 @@ public function index(Request $request)
131126
$items = FieldItem::all();
132127

133128
return $this->createView()
134-
->shares('title', __d('platform', 'Account'))
129+
->shares('title', __d('users', 'Account'))
135130
->with(compact('user', 'items'));
136131
}
137132

@@ -167,11 +162,36 @@ public function update(Request $request)
167162

168163
$user->save();
169164

165+
//
166+
// Update the Custom Fields.
167+
168+
foreach ($items as $item) {
169+
$value = Arr::get($input, $name = $item->name);
170+
171+
if (! is_null($field = $user->fields->findBy('name', $name))) {
172+
$field->value = $value;
173+
174+
$field->save();
175+
176+
continue;
177+
}
178+
179+
$field = Field::create(array(
180+
'name' => $name,
181+
'type' => $item->type,
182+
'value' => $value,
183+
184+
// Resolve the relationships.
185+
'field_item_id' => $item->id,
186+
'user_id' => $user->id,
187+
));
188+
}
189+
170190
//
171191
// Use a Redirect to avoid the reposting the data.
172192

173193
return Redirect::back()
174-
->with('success', __d('platform', 'You have successfully updated your Account information.'));
194+
->with('success', __d('users', 'You have successfully updated your Account information.'));
175195
}
176196

177197
public function picture(Request $request)
@@ -183,7 +203,7 @@ public function picture(Request $request)
183203
$request->only('image'),
184204
array('image' => 'required|max:1024|mimes:png,jpg,jpeg,gif'),
185205
array(),
186-
array('image' => __d('platform', 'Image'))
206+
array('image' => __d('users', 'Image'))
187207
);
188208

189209
// Validate the Input.
@@ -196,7 +216,7 @@ public function picture(Request $request)
196216
$user->save();
197217

198218
// Prepare the flash message.
199-
$status = __d('platform', 'The Profile Picture was successfully updated.');
219+
$status = __d('users', 'The Profile Picture was successfully updated.');
200220

201221
return Redirect::to('account')->withStatus($status);
202222
}

modules/Users/Controllers/Admin/Users.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ protected function validator(array $data, Collection $items, $id = null)
9393
$options = $item->options ?: array();
9494

9595
if ($item->type == 'checkbox') {
96-
$choices = array_filter(explode("\n", trim(
96+
$choices = explode("\n", trim(
9797
Arr::get($options, 'choices')
98+
));
9899

99-
)), function ($value)
100+
$count = count($choices = array_filter($choices, function ($value)
100101
{
101102
return ! empty($value);
102-
});
103-
104-
$count = count($choices);
103+
}));
105104

106105
if ($count > 1) {
107106
foreach (range(0, $count - 1) as $index) {
@@ -113,11 +112,7 @@ protected function validator(array $data, Collection $items, $id = null)
113112
$attributes[$name] = $item->title;
114113
}
115114

116-
if (Str::contains($rule, 'required')) {
117-
$rule = 'required|array';
118-
} else {
119-
$rule = 'array';
120-
}
115+
$rule = Str::contains($rule, 'required') ? 'required|array' : 'array';
121116
}
122117
}
123118

@@ -271,7 +266,7 @@ public function store(Request $request)
271266

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

276271
$field = Field::create(array(
277272
'name' => $name,
@@ -391,13 +386,13 @@ public function update(Request $request, $id)
391386
// Sync the Roles.
392387
$user->roles()->sync($input['roles']);
393388

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

398-
$field = $user->fields->findBy('name', $name);
392+
foreach ($items as $item) {
393+
$value = Arr::get($input, $name = $item->name);
399394

400-
if (! is_null($field)) {
395+
if (! is_null($field = $user->fields->findBy('name', $name))) {
401396
$field->value = $value;
402397

403398
$field->save();

0 commit comments

Comments
 (0)