Completed
Push — master ( 27d4d0...9e9ea6 )
by Joao
03:11
created
src/Controllers/GroupsController.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * Group update form processing page.
88 88
      *
89 89
      * @param  int      $id
90
-     * @return Redirect
90
+     * @return \Illuminate\Http\RedirectResponse
91 91
      */
92 92
     public function postEdit($id = null)
93 93
     {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     /**
165 165
      * Group create form processing.
166 166
      *
167
-     * @return Redirect
167
+     * @return \Illuminate\Http\RedirectResponse
168 168
      */
169 169
     public function postCreate()
170 170
     {
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * Delete the given group.
233 233
      *
234 234
      * @param  int      $id
235
-     * @return Redirect
235
+     * @return \Illuminate\Http\RedirectResponse
236 236
      */
237 237
     public function getDelete($id = null)
238 238
     {
Please login to merge, or discard this patch.
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -1,11 +1,7 @@
 block discarded – undo
1 1
 <?php namespace jlourenco\base\Controllers;
2 2
 
3
-use Illuminate\Http\Request;
4
-use App\Http\Requests;
5 3
 use App\Http\Controllers\Controller;
6
-use Blog;
7 4
 use Sentinel;
8
-use Searchy;
9 5
 use Validator;
10 6
 use Input;
11 7
 use Base;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $group = Sentinel::getRoleRepository()->find($id);
64 64
 
65 65
         // Get the group's information
66
-        if($group == null)
66
+        if ($group == null)
67 67
         {
68 68
             // Prepare the error message
69 69
             $error = Lang::get('base.groups.not_found');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         // Was the post updated?
129 129
         if ($group->save())
130 130
         {
131
-            Base::Log('Group (' . $group->id . ' - ' . $group->name . ') was edited.');
131
+            Base::Log('Group ('.$group->id.' - '.$group->name.') was edited.');
132 132
 
133 133
             // Prepare the success message
134 134
             $success = Lang::get('base.groups.changed');
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
         $group->save();
197 197
 
198
-        Base::Log('A new group (' . $group->id . ' - ' . $group->name . ') was created.');
198
+        Base::Log('A new group ('.$group->id.' - '.$group->name.') was created.');
199 199
 
200 200
         // Redirect to the home page with success menu
201 201
         return Redirect::route("groups")->with('success', Lang::get('base.groups.created'));
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             return Redirect::route('groups')->with('error', $error);
249 249
         }
250 250
 
251
-        Base::Log('Group (' . $group->id . ' - ' . $group->name . ') was deleted.');
251
+        Base::Log('Group ('.$group->id.' - '.$group->name.') was deleted.');
252 252
 
253 253
         // Delete the group
254 254
         $group->delete();
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,8 +76,9 @@  discard block
 block discarded – undo
76 76
 
77 77
         $groups2 = Sentinel::getRoleRepository()->all(['id', 'name']);
78 78
 
79
-        foreach ($groups2 as $g)
80
-            $groups[$g->id] = $g->name;
79
+        foreach ($groups2 as $g) {
80
+                    $groups[$g->id] = $g->name;
81
+        }
81 82
 
82 83
         // Show the page
83 84
         return View('admin.groups.edit', compact('group', 'groups'));
@@ -154,8 +155,9 @@  discard block
 block discarded – undo
154 155
 
155 156
         $groups2 = Sentinel::getRoleRepository()->all(['id', 'name']);
156 157
 
157
-        foreach ($groups2 as $g)
158
-            $groups[$g->id] = $g->name;
158
+        foreach ($groups2 as $g) {
159
+                    $groups[$g->id] = $g->name;
160
+        }
159 161
 
160 162
         // Show the page
161 163
         return View('admin.groups.create', compact('groups'));
@@ -184,8 +186,9 @@  discard block
 block discarded – undo
184 186
 
185 187
         $group = Sentinel::getRoleRepository()->findBySlug($slug);
186 188
 
187
-        if ($group != null)
188
-            return Redirect::route("groups")->with('error', Lang::get('base.groups.already_exists'));
189
+        if ($group != null) {
190
+                    return Redirect::route("groups")->with('error', Lang::get('base.groups.already_exists'));
191
+        }
189 192
 
190 193
         $group = Sentinel::getRoleRepository()->create([
191 194
             'name' => Input::get('name'),
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * All the "restricted area" routes
7 7
  * are defined here.
8 8
  */
9
-Route::group(array('prefix' => '/', 'middleware' => 'webPublic'), function ()
9
+Route::group(array('prefix' => '/', 'middleware' => 'webPublic'), function()
10 10
 {
11 11
 
12 12
     /**
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     /* POST */ Route::post('login', 'jlourenco\base\Controllers\AuthController@postSignin');
39 39
 
40 40
     /* GET  */ Route::get('register', array('as' => 'register', 'uses' => 'jlourenco\base\Controllers\AuthController@getSignup'));
41
-    /* POST */ Route::post('register', array('as' => 'register','uses' => 'jlourenco\base\Controllers\AuthController@postSignup'));
41
+    /* POST */ Route::post('register', array('as' => 'register', 'uses' => 'jlourenco\base\Controllers\AuthController@postSignup'));
42 42
 
43 43
     /* GET  */ Route::get('forgot-password', array('as' => 'forgot-password', 'uses' => 'jlourenco\base\Controllers\AuthController@getLostPassword'));
44
-    /* POST */ Route::post('forgot-password', array('as' => 'forgot-password','uses' => 'jlourenco\base\Controllers\AuthController@postForgotPassword'));
44
+    /* POST */ Route::post('forgot-password', array('as' => 'forgot-password', 'uses' => 'jlourenco\base\Controllers\AuthController@postForgotPassword'));
45 45
 
46 46
     # Forgot Password Confirmation
47 47
     Route::get('forgot-password/{userId}/{passwordResetCode}', array('as' => 'forgot-password-confirm', 'uses' => 'jlourenco\base\Controllers\AuthController@getForgotPasswordConfirm'));
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     Route::get('activate/{userId}/{activationCode}', array('as' => 'activate', 'uses' => 'jlourenco\base\Controllers\AuthController@getActivate'));
55 55
 
56 56
     # User account
57
-    Route::group(array('middleware' => 'auth'), function () {
57
+    Route::group(array('middleware' => 'auth'), function() {
58 58
         Route::get('profile', array('as' => 'profile', 'uses' => 'jlourenco\base\Controllers\UsersController@myAccount'));
59 59
         Route::post('profile', 'jlourenco\base\Controllers\UsersController@updateAccount');
60 60
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
  * All the "restricted area" routes
71 71
  * are defined here.
72 72
  */
73
-Route::group(array('prefix' => '/admin', 'middleware' => ['webAdmin', 'auth']), function ()
73
+Route::group(array('prefix' => '/admin', 'middleware' => ['webAdmin', 'auth']), function()
74 74
 {
75 75
 
76 76
     # Dashboard
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     /* POST */ Route::post('settings/{id}/edit', array('as' => 'settings.update', 'uses' => 'jlourenco\base\Controllers\SettingsController@update'));
90 90
 
91 91
     # User Management
92
-    Route::group(array('prefix' => 'users'), function () {
92
+    Route::group(array('prefix' => 'users'), function() {
93 93
         Route::get('/list', array('as' => 'users', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminIndex'));
94 94
         Route::get('/pending', array('as' => 'users.pending', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminPending'));
95 95
         Route::get('/blocked', array('as' => 'users.blocked', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminBlocked'));
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         Route::get('/list/{userId}/delete', array('as' => 'delete/user', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminDelete'));
103 103
         Route::get('/list/{userId}/confirm-delete', array('as' => 'confirm-delete/user', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminModalDelete'));
104 104
         Route::get('/list/{userId}/restore', array('as' => 'restore/user', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminRestore'));
105
-        Route::get('deleted',array('as' => 'users.deleted', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminDeletedUsers'));
105
+        Route::get('deleted', array('as' => 'users.deleted', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminDeletedUsers'));
106 106
         Route::get('/list/{userId}', array('as' => 'users.show', 'uses' => 'jlourenco\base\Controllers\UsersController@adminShow'));
107 107
 
108 108
         Route::get('/list/{userId}/confirm-remove/{groupId}', array('as' => 'confirm-remove/group', 'uses' => 'jlourenco\base\Controllers\UsersController@getAdminModalRemoveGroup'));
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     });
113 113
 
114 114
     # Groups Management
115
-    Route::group(array('prefix' => 'groups'), function () {
115
+    Route::group(array('prefix' => 'groups'), function() {
116 116
         Route::get('/list', array('as' => 'groups', 'uses' => 'jlourenco\base\Controllers\GroupsController@index'));
117 117
         Route::get('/create', array('as' => 'create.group', 'uses' => 'jlourenco\base\Controllers\GroupsController@getCreate'));
118 118
         Route::post('/create', 'jlourenco\base\Controllers\GroupsController@postCreate');
Please login to merge, or discard this patch.
src/Controllers/UsersController.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         // Do we want to update the user password?
139 139
         if ($password = Input::get('password'))
140 140
         {
141
-            if (Sentinel::validateCredentials($user, [ 'email' => $email, 'password' => Input::get('old-password')]))
141
+            if (Sentinel::validateCredentials($user, ['email' => $email, 'password' => Input::get('old-password')]))
142 142
             {
143 143
                 $passwordChanged = true;
144 144
                 $user->password = Hash::make($password);
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         if ($file = Input::file('pic')) {
158 158
             $extension = $file->getClientOriginalExtension() ?: 'png';
159 159
             $folderName = '/uploads/users/';
160
-            $destinationPath = public_path() . $folderName;
161
-            $safeName = str_random(10) . '.' . $extension;
160
+            $destinationPath = public_path().$folderName;
161
+            $safeName = str_random(10).'.'.$extension;
162 162
             $file->move($destinationPath, $safeName);
163 163
 
164 164
             //delete old pic if exists
165
-            if (File::exists(public_path() . $folderName . $user->pic))
166
-                File::delete(public_path() . $folderName . $user->pic);
165
+            if (File::exists(public_path().$folderName.$user->pic))
166
+                File::delete(public_path().$folderName.$user->pic);
167 167
 
168 168
             //save new file path into db
169 169
             $user->pic = $safeName;
170 170
 
171
-            Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its profile photo. ');
171
+            Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its profile photo. ');
172 172
         }
173 173
 
174 174
         // Was the user updated?
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 
179 179
             if ($passwordChanged)
180 180
             {
181
-                Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its password. ');
182
-                Mail::queue('emails.account.password-changed', [ 'user' => $user ], function ($m) use ($user) {
183
-                    $m->to($user->email, $user->first_name . ' ' . $user->last_name);
181
+                Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its password. ');
182
+                Mail::queue('emails.account.password-changed', ['user' => $user], function($m) use ($user) {
183
+                    $m->to($user->email, $user->first_name.' '.$user->last_name);
184 184
                     $m->subject(Lang::get('base.mails.password_changed'));
185 185
                 });
186 186
             }
187 187
 
188
-            Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') updated the profile. ');
188
+            Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') updated the profile. ');
189 189
 
190 190
             // Redirect to the user page
191 191
             return Redirect::route('profile')->with('success', $success);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             // Do we want to update the user password?
235 235
             $password = Input::get('password');
236 236
 
237
-            if (Sentinel::validateCredentials($user, [ 'email' => $user->email, 'password' => Input::get('old-password')]))
237
+            if (Sentinel::validateCredentials($user, ['email' => $user->email, 'password' => Input::get('old-password')]))
238 238
             {
239 239
                 $user->password = Hash::make($password);
240 240
                 $redirect = 'change-password';
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
                     // Prepare the success message
252 252
                     $success = Lang::get('base.auth.account.changed');
253 253
 
254
-                    Mail::queue('emails.account.password-changed', [ 'user' => $user ], function ($m) use ($user) {
255
-                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
254
+                    Mail::queue('emails.account.password-changed', ['user' => $user], function($m) use ($user) {
255
+                        $m->to($user->email, $user->first_name.' '.$user->last_name);
256 256
                         $m->subject(Lang::get('base.mails.password_changed'));
257 257
                     });
258 258
 
259
-                    Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its password account. ');
259
+                    Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its password account. ');
260 260
 
261 261
                     // Redirect to the user page
262 262
                     return Redirect::route($redirect)->with('success', $success);
@@ -353,13 +353,13 @@  discard block
 block discarded – undo
353 353
                 $activation = Activation::exists($user);
354 354
             }
355 355
 
356
-            if($activation)
356
+            if ($activation)
357 357
                 Activation::complete($user, $activation->code);
358 358
 
359
-            Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was accepted. ', $user->id);
359
+            Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was accepted. ', $user->id);
360 360
 
361
-            Mail::queue('emails.account.accepted-by-admin', [ 'user' => $user ], function ($m) use ($user) {
362
-                $m->to($user->email, $user->first_name . ' ' . $user->last_name);
361
+            Mail::queue('emails.account.accepted-by-admin', ['user' => $user], function($m) use ($user) {
362
+                $m->to($user->email, $user->first_name.' '.$user->last_name);
363 363
                 $m->subject(Lang::get('base.mails.account_accepted'));
364 364
             });
365 365
 
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 
400 400
         if ($user->save())
401 401
         {
402
-            Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was refused. ', $user->id);
402
+            Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was refused. ', $user->id);
403 403
 
404 404
             if (Base::getSetting('SEND_EMAIL_ON_REFUSE'))
405
-                Mail::queue('emails.account.refused-by-admin', [ 'user' => $user ], function ($m) use ($user) {
406
-                    $m->to($user->email, $user->first_name . ' ' . $user->last_name);
405
+                Mail::queue('emails.account.refused-by-admin', ['user' => $user], function($m) use ($user) {
406
+                    $m->to($user->email, $user->first_name.' '.$user->last_name);
407 407
                     $m->subject(Lang::get('base.mails.account_accepted'));
408 408
                 });
409 409
 
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
         }
487 487
 
488 488
         // Check if we are not trying to delete ourselves
489
-        if ($user->id === Sentinel::getUser()->id)  {
489
+        if ($user->id === Sentinel::getUser()->id) {
490 490
             // Prepare the error message
491 491
             $error = Lang::get('base.base.error');
492 492
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     public function getAdminEdit($id = null)
578 578
     {
579 579
         // Get the user information
580
-        if($user = Sentinel::findById($id))
580
+        if ($user = Sentinel::findById($id))
581 581
         {
582 582
             // Get this user groups
583 583
             $userRoles = $user->getRoles()->lists('name', 'id')->all();
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 
657 657
         try {
658 658
             // Update the user
659
-            $user->gender   = Input::get('gender');
659
+            $user->gender = Input::get('gender');
660 660
             $user->first_name  = Input::get('first_name');
661 661
             $user->last_name   = Input::get('last_name');
662 662
             $user->username    = Input::get('username');
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
                 if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
690 690
                 {
691 691
                     $folderName      = '/uploads/users/';
692
-                    $destinationPath = public_path() . $folderName;
692
+                    $destinationPath = public_path().$folderName;
693 693
                     $safeName        = str_random(10).'.'.$extension;
694 694
                     $file->move($destinationPath, $safeName);
695 695
 
696 696
                     //delete old pic if exists
697
-                    if(File::exists(public_path() . $folderName . $user->pic))
698
-                        File::delete(public_path() . $folderName . $user->pic);
697
+                    if (File::exists(public_path().$folderName.$user->pic))
698
+                        File::delete(public_path().$folderName.$user->pic);
699 699
 
700 700
                     //save new file path into db
701
-                    $user->pic   = $safeName;
701
+                    $user->pic = $safeName;
702 702
                 }
703 703
             }
704 704
 
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
             $status = $activation = Activation::completed($user);
734 734
             $currentStatus = Input::get('status');
735 735
 
736
-            if($currentStatus != $status)
736
+            if ($currentStatus != $status)
737 737
             {
738 738
                 if ($currentStatus == 0)
739 739
                     // Remove existing activation record
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
                         $activation = Activation::exists($user);
750 750
                     }
751 751
 
752
-                    if($activation)
752
+                    if ($activation)
753 753
                         Activation::complete($user, $activation->code);
754 754
                 }
755 755
 
@@ -763,16 +763,16 @@  discard block
 block discarded – undo
763 763
             {
764 764
                 if ($password_changed && Input::get('send_new_password_email'))
765 765
                 {
766
-                    Mail::queue('emails.account.password-changed-by-admin', [ 'user' => $user, 'new_password' => $password ], function ($m) use ($user) {
767
-                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
766
+                    Mail::queue('emails.account.password-changed-by-admin', ['user' => $user, 'new_password' => $password], function($m) use ($user) {
767
+                        $m->to($user->email, $user->first_name.' '.$user->last_name);
768 768
                         $m->subject(Lang::get('base.mails.password_changed'));
769 769
                     });
770 770
                 }
771 771
 
772 772
                 if ($password_changed)
773
-                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
773
+                    Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') password was changed by an admin. ', $user->id);
774 774
 
775
-                Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
775
+                Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') profile was changed by an admin. ', $user->id);
776 776
 
777 777
                 // Prepare the success message
778 778
                 $success = Lang::get('base.auth.user_changed');
@@ -864,36 +864,36 @@  discard block
 block discarded – undo
864 864
                 if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
865 865
                 {
866 866
                     $folderName      = '/uploads/users/';
867
-                    $destinationPath = public_path() . $folderName;
867
+                    $destinationPath = public_path().$folderName;
868 868
                     $safeName        = str_random(10).'.'.$extension;
869 869
                     $file->move($destinationPath, $safeName);
870 870
 
871 871
                     //delete old pic if exists
872
-                    if(File::exists(public_path() . $folderName . $user->pic))
873
-                        File::delete(public_path() . $folderName . $user->pic);
872
+                    if (File::exists(public_path().$folderName.$user->pic))
873
+                        File::delete(public_path().$folderName.$user->pic);
874 874
 
875 875
                     //save new file path into db
876
-                    $user->pic   = $safeName;
876
+                    $user->pic = $safeName;
877 877
                 }
878 878
             }
879 879
 
880 880
             $user->save();
881 881
 
882
-            Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was created by an admin. ', $user->id);
882
+            Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was created by an admin. ', $user->id);
883 883
 
884 884
             if (Input::get('send_new_password_email'))
885 885
             {
886 886
                 if ($activate)
887 887
                 {
888
-                    Mail::queue('emails.account.account-created-by-admin', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m) use ($user) {
889
-                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
888
+                    Mail::queue('emails.account.account-created-by-admin', ['user' => $user, 'new_password' => Input::get('password')], function($m) use ($user) {
889
+                        $m->to($user->email, $user->first_name.' '.$user->last_name);
890 890
                         $m->subject(Lang::get('base.mails.account_created'));
891 891
                     });
892 892
                 }
893 893
                 else
894 894
                 {
895
-                    Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
896
-                        $m2->to($user->email, $user->first_name . ' ' . $user->last_name);
895
+                    Mail::queue('emails.account.account-created-by-admin-inactive', ['user' => $user, 'new_password' => Input::get('password')], function($m2) use ($user) {
896
+                        $m2->to($user->email, $user->first_name.' '.$user->last_name);
897 897
                         $m2->subject(Lang::get('base.mails.account_created'));
898 898
                     });
899 899
 
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
                     );
907 907
 
908 908
                     // Send the activation code through email
909
-                    Mail::queue('emails.auth.register-activate', $data, function ($m) use ($user) {
910
-                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
911
-                        $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
909
+                    Mail::queue('emails.auth.register-activate', $data, function($m) use ($user) {
910
+                        $m->to($user->email, $user->first_name.' '.$user->last_name);
911
+                        $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
912 912
                     });
913 913
 
914 914
                 }
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         }
970 970
 
971 971
         // Check if we are not trying to delete ourselves
972
-        if ($user->id === Sentinel::getUser()->id + 1)  {
972
+        if ($user->id === Sentinel::getUser()->id + 1) {
973 973
             // Prepare the error message
974 974
             $error = Lang::get('base.base.yourself');
975 975
 
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
         }
1011 1011
 
1012 1012
         // Check if we are not trying to delete ourselves
1013
-        if ($user->id === Sentinel::getUser()->id + 1)  {
1013
+        if ($user->id === Sentinel::getUser()->id + 1) {
1014 1014
             // Prepare the error message
1015 1015
             $error = Lang::get('base.base.yourself');
1016 1016
 
Please login to merge, or discard this patch.
Braces   +57 added lines, -48 removed lines patch added patch discarded remove patch
@@ -130,8 +130,9 @@  discard block
 block discarded – undo
130 130
         $user->gender = Input::get('gender');
131 131
         $user->description = Input::get('description');
132 132
 
133
-        if (Input::get('birthday') != null)
134
-            $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
133
+        if (Input::get('birthday') != null) {
134
+                    $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
135
+        }
135 136
 
136 137
         $passwordChanged = false;
137 138
 
@@ -142,8 +143,7 @@  discard block
 block discarded – undo
142 143
             {
143 144
                 $passwordChanged = true;
144 145
                 $user->password = Hash::make($password);
145
-            }
146
-            else
146
+            } else
147 147
             {
148 148
                 $error = Lang::get('base.auth.wrong_password');
149 149
                 $validator->messages()->add('old-password', Lang::get('base.auth.wrong_password'));
@@ -162,8 +162,9 @@  discard block
 block discarded – undo
162 162
             $file->move($destinationPath, $safeName);
163 163
 
164 164
             //delete old pic if exists
165
-            if (File::exists(public_path() . $folderName . $user->pic))
166
-                File::delete(public_path() . $folderName . $user->pic);
165
+            if (File::exists(public_path() . $folderName . $user->pic)) {
166
+                            File::delete(public_path() . $folderName . $user->pic);
167
+            }
167 168
 
168 169
             //save new file path into db
169 170
             $user->pic = $safeName;
@@ -261,8 +262,7 @@  discard block
 block discarded – undo
261 262
                     // Redirect to the user page
262 263
                     return Redirect::route($redirect)->with('success', $success);
263 264
                 }
264
-            }
265
-            else
265
+            } else
266 266
             {
267 267
                 $error = Lang::get('base.auth.wrong_password');
268 268
                 $validator->messages()->add('old-password', Lang::get('base.auth.wrong_password'));
@@ -353,8 +353,9 @@  discard block
 block discarded – undo
353 353
                 $activation = Activation::exists($user);
354 354
             }
355 355
 
356
-            if($activation)
357
-                Activation::complete($user, $activation->code);
356
+            if($activation) {
357
+                            Activation::complete($user, $activation->code);
358
+            }
358 359
 
359 360
             Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was accepted. ', $user->id);
360 361
 
@@ -401,9 +402,10 @@  discard block
 block discarded – undo
401 402
         {
402 403
             Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was refused. ', $user->id);
403 404
 
404
-            if (Base::getSetting('SEND_EMAIL_ON_REFUSE'))
405
-                Mail::queue('emails.account.refused-by-admin', [ 'user' => $user ], function ($m) use ($user) {
406
-                    $m->to($user->email, $user->first_name . ' ' . $user->last_name);
405
+            if (Base::getSetting('SEND_EMAIL_ON_REFUSE')) {
406
+                            Mail::queue('emails.account.refused-by-admin', [ 'user' => $user ], function ($m) use ($user) {
407
+                    $m->to($user->email, $user->first_name . ' ' . $user->last_name);
408
+            }
407 409
                     $m->subject(Lang::get('base.mails.account_accepted'));
408 410
                 });
409 411
 
@@ -584,8 +586,7 @@  discard block
 block discarded – undo
584 586
 
585 587
             // Get a list of all the available groups
586 588
             $roles = Sentinel::getRoleRepository()->all();
587
-        }
588
-        else
589
+        } else
589 590
         {
590 591
             // Prepare the error message
591 592
             $error = Lang::get('base.auth.not_found');
@@ -604,12 +605,14 @@  discard block
 block discarded – undo
604 605
         foreach ($groups2 as $g)
605 606
         {
606 607
             $has = false;
607
-            foreach ($user->roles as $g2)
608
-                if ($g2->id == $g->id)
609
-                    $has = true;
610
-
611
-            if (!$has)
612
-                $groups[$g->id] = $g->name;
608
+            foreach ($user->roles as $g2) {
609
+                            if ($g2->id == $g->id)
610
+                    $has = true;
611
+            }
612
+
613
+            if (!$has) {
614
+                            $groups[$g->id] = $g->name;
615
+            }
613 616
         }
614 617
 
615 618
         // Show the page
@@ -663,13 +666,15 @@  discard block
 block discarded – undo
663 666
             $user->email       = Input::get('email');
664 667
             $user->description = Input::get('description');
665 668
 
666
-            if (Input::get('force_new_password'))
667
-                $user->force_new_password = 1;
668
-            else
669
-                $user->force_new_password = 0;
669
+            if (Input::get('force_new_password')) {
670
+                            $user->force_new_password = 1;
671
+            } else {
672
+                            $user->force_new_password = 0;
673
+            }
670 674
 
671
-            if (Input::get('birthday') != null)
672
-                $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
675
+            if (Input::get('birthday') != null) {
676
+                            $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
677
+            }
673 678
 
674 679
             $password_changed = false;
675 680
 
@@ -694,8 +699,9 @@  discard block
 block discarded – undo
694 699
                     $file->move($destinationPath, $safeName);
695 700
 
696 701
                     //delete old pic if exists
697
-                    if(File::exists(public_path() . $folderName . $user->pic))
698
-                        File::delete(public_path() . $folderName . $user->pic);
702
+                    if(File::exists(public_path() . $folderName . $user->pic)) {
703
+                                            File::delete(public_path() . $folderName . $user->pic);
704
+                    }
699 705
 
700 706
                     //save new file path into db
701 707
                     $user->pic   = $safeName;
@@ -735,10 +741,10 @@  discard block
 block discarded – undo
735 741
 
736 742
             if($currentStatus != $status)
737 743
             {
738
-                if ($currentStatus == 0)
739
-                    // Remove existing activation record
740
-                    Activation::remove($user);
741
-                else
744
+                if ($currentStatus == 0) {
745
+                                    // Remove existing activation record
746
+                    Activation::remove($user);
747
+                } else
742 748
                 {
743 749
                     $activation = Activation::exists($user);
744 750
 
@@ -749,14 +755,15 @@  discard block
 block discarded – undo
749 755
                         $activation = Activation::exists($user);
750 756
                     }
751 757
 
752
-                    if($activation)
753
-                        Activation::complete($user, $activation->code);
758
+                    if($activation) {
759
+                                            Activation::complete($user, $activation->code);
760
+                    }
754 761
                 }
755 762
 
756 763
                 $user->status = $currentStatus;
757
-            }
758
-            else
759
-                $user->status = $currentStatus;
764
+            } else {
765
+                            $user->status = $currentStatus;
766
+            }
760 767
 
761 768
             // Was the user updated?
762 769
             if ($user->save())
@@ -769,8 +776,9 @@  discard block
 block discarded – undo
769 776
                     });
770 777
                 }
771 778
 
772
-                if ($password_changed)
773
-                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
779
+                if ($password_changed) {
780
+                                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
781
+                }
774 782
 
775 783
                 Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
776 784
 
@@ -850,10 +858,11 @@  discard block
 block discarded – undo
850 858
             $user->password = Hash::make(Input::get('password'));
851 859
             $user->description = Input::get('description');
852 860
 
853
-            if (Input::get('force_new_password'))
854
-                $user->force_new_password = 1;
855
-            else
856
-                $user->force_new_password = 0;
861
+            if (Input::get('force_new_password')) {
862
+                            $user->force_new_password = 1;
863
+            } else {
864
+                            $user->force_new_password = 0;
865
+            }
857 866
 
858 867
             // is new image uploaded?
859 868
             if ($file = Input::file('pic'))
@@ -869,8 +878,9 @@  discard block
 block discarded – undo
869 878
                     $file->move($destinationPath, $safeName);
870 879
 
871 880
                     //delete old pic if exists
872
-                    if(File::exists(public_path() . $folderName . $user->pic))
873
-                        File::delete(public_path() . $folderName . $user->pic);
881
+                    if(File::exists(public_path() . $folderName . $user->pic)) {
882
+                                            File::delete(public_path() . $folderName . $user->pic);
883
+                    }
874 884
 
875 885
                     //save new file path into db
876 886
                     $user->pic   = $safeName;
@@ -889,8 +899,7 @@  discard block
 block discarded – undo
889 899
                         $m->to($user->email, $user->first_name . ' ' . $user->last_name);
890 900
                         $m->subject(Lang::get('base.mails.account_created'));
891 901
                     });
892
-                }
893
-                else
902
+                } else
894 903
                 {
895 904
                     Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
896 905
                         $m2->to($user->email, $user->first_name . ' ' . $user->last_name);
Please login to merge, or discard this patch.
src/Controllers/AuthController.php 1 patch
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -49,10 +49,11 @@  discard block
 block discarded – undo
49 49
         // Is the user logged in?
50 50
         if (Sentinel::check())
51 51
         {
52
-            if (Sentinel::inRole('admin'))
53
-                return Redirect::route('home');
54
-            else
55
-                return Redirect::route('user.home');
52
+            if (Sentinel::inRole('admin')) {
53
+                            return Redirect::route('home');
54
+            } else {
55
+                            return Redirect::route('user.home');
56
+            }
56 57
         }
57 58
 
58 59
         // Show the page
@@ -69,10 +70,11 @@  discard block
 block discarded – undo
69 70
         // Is the user logged in?
70 71
         if (Sentinel::check())
71 72
         {
72
-            if (Sentinel::inRole('admin'))
73
-                return Redirect::route('home');
74
-            else
75
-                return Redirect::route('user.home');
73
+            if (Sentinel::inRole('admin')) {
74
+                            return Redirect::route('home');
75
+            } else {
76
+                            return Redirect::route('user.home');
77
+            }
76 78
         }
77 79
 
78 80
         // Show the page
@@ -89,10 +91,11 @@  discard block
 block discarded – undo
89 91
         // Is the user logged in?
90 92
         if (Sentinel::check())
91 93
         {
92
-            if (Sentinel::inRole('admin'))
93
-                return Redirect::route('home');
94
-            else
95
-                return Redirect::route('user.home');
94
+            if (Sentinel::inRole('admin')) {
95
+                            return Redirect::route('home');
96
+            } else {
97
+                            return Redirect::route('user.home');
98
+            }
96 99
         }
97 100
 
98 101
         // Show the page
@@ -145,10 +148,11 @@  discard block
 block discarded – undo
145 148
         // Is user logged in?
146 149
         if (Sentinel::check())
147 150
         {
148
-            if (Sentinel::inRole('admin'))
149
-                return Redirect::route('home');
150
-            else
151
-                return Redirect::route('user.home');
151
+            if (Sentinel::inRole('admin')) {
152
+                            return Redirect::route('home');
153
+            } else {
154
+                            return Redirect::route('user.home');
155
+            }
152 156
         }
153 157
 
154 158
         // Find the user using the password reset code
@@ -167,8 +171,7 @@  discard block
 block discarded – undo
167 171
             // Activation was successful
168 172
             // Redirect to the login page
169 173
             return Redirect::route('login')->with('success', Lang::get('base.auth.activate.success'));
170
-        }
171
-        else
174
+        } else
172 175
         {
173 176
             // Activation not found or not completed.
174 177
             $error = Lang::get('base.auth.activate.error');
@@ -192,8 +195,9 @@  discard block
 block discarded – undo
192 195
             'password' => 'required|between:3,32',
193 196
         );
194 197
 
195
-        if (!$isEmail)
196
-            $rules['email'] = 'required';
198
+        if (!$isEmail) {
199
+                    $rules['email'] = 'required';
200
+        }
197 201
 
198 202
         // Create a new validator instance from our validation rules
199 203
         $validator = Validator::make(Input::all(), $rules);
@@ -258,14 +262,16 @@  discard block
 block discarded – undo
258 262
         $userActivation = $signupStatus == 2;
259 263
         $adminActivation = $signupStatus == 3;
260 264
 
261
-        if (!$signupEnabled)
262
-            return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled'));
265
+        if (!$signupEnabled) {
266
+                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled'));
267
+        }
263 268
 
264 269
         $rules = array();
265 270
 
266 271
         // Declare the rules for the form validation
267
-        foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field)
268
-            $rules[$fieldid] = $field['validator'];
272
+        foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) {
273
+                    $rules[$fieldid] = $field['validator'];
274
+        }
269 275
 
270 276
         $rules['g-recaptcha-response'] = 'required';
271 277
 
@@ -276,8 +282,9 @@  discard block
 block discarded – undo
276 282
 
277 283
         // If validation fails, we'll exit the operation now.
278 284
         if ($validator->fails() || ($err = $this->captchaCheck()) == false) {
279
-            if ($err)
280
-                return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]);
285
+            if ($err) {
286
+                            return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]);
287
+            }
281 288
 
282 289
             // Ooops.. something went wrong
283 290
             return Redirect::to(URL::previous())->withInput()->withErrors($validator);
@@ -287,15 +294,17 @@  discard block
 block discarded – undo
287 294
             $data = array();
288 295
 
289 296
             // Set the data to the user from the User class
290
-            foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field)
291
-                $data[$fieldid] = Input::get($fieldid);
297
+            foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) {
298
+                            $data[$fieldid] = Input::get($fieldid);
299
+            }
292 300
 
293 301
             // Set the standard data to the user
294 302
             $data['ip'] = Request::getClientIP();
295 303
             $data['status'] = 0;
296 304
             $data['staff'] = 0;
297
-            if ($data['birthday'] != null)
298
-                $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']);
305
+            if ($data['birthday'] != null) {
306
+                            $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']);
307
+            }
299 308
 
300 309
             // Find the user if it exists and needs to be created
301 310
             $user = Sentinel::getUserRepository()->findByCredentials(['email' => Input::get('email')]);
@@ -307,19 +316,21 @@  discard block
 block discarded – undo
307 316
                     $testing = Sentinel::createModel()->getRegisterFields();
308 317
                     $user = Sentinel::findById($user->id);
309 318
 
310
-                    foreach($data as $fieldid => $field)
311
-                        if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true)
312
-                            $user[$fieldid] = $field;
319
+                    foreach($data as $fieldid => $field) {
320
+                                            if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true)
321
+                            $user[$fieldid] = $field;
322
+                    }
313 323
 
314 324
                     $user['password'] = bcrypt($user['password']);
315 325
                     Sentinel::update($user, ['email' => Input::get('email')]);
316
-                }
317
-                else
318
-                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed'));
326
+                } else {
327
+                                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed'));
328
+                }
319 329
             }
320 330
             // Register the user
321
-            else
322
-                $user = Sentinel::register($data, false);
331
+            else {
332
+                            $user = Sentinel::register($data, false);
333
+            }
323 334
 
324 335
             // If the user needs to activate the account send him an email
325 336
             if ($userActivation)
Please login to merge, or discard this patch.
src/baseServiceProvider.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -49,41 +49,41 @@  discard block
 block discarded – undo
49 49
     {
50 50
         // Publish our views
51 51
         $this->publishes([
52
-            __DIR__ .  '/views' => base_path("resources/views")
52
+            __DIR__.'/views' => base_path("resources/views")
53 53
         ]);
54 54
 
55 55
         // Publish our lang
56 56
         $this->publishes([
57
-            __DIR__ .  '/lang' => base_path("resources/lang")
57
+            __DIR__.'/lang' => base_path("resources/lang")
58 58
         ]);
59 59
 
60 60
         // Publish our public
61 61
         $this->publishes([
62
-            __DIR__ .  '/public' => base_path("public")
62
+            __DIR__.'/public' => base_path("public")
63 63
         ]);
64 64
 
65 65
         // Publish our migrations
66 66
         $this->publishes([
67
-            __DIR__ .  '/migrations' => base_path("database/migrations")
67
+            __DIR__.'/migrations' => base_path("database/migrations")
68 68
         ], 'migrations');
69 69
 
70 70
         // Publish our migrations
71 71
         $this->publishes([
72
-            __DIR__ .  '/seeds' => base_path("database/seeds")
72
+            __DIR__.'/seeds' => base_path("database/seeds")
73 73
         ], 'seeds');
74 74
 
75 75
         // Publish a config file
76 76
         $this->publishes([
77
-            __DIR__ . '/config' => base_path('/config')
77
+            __DIR__.'/config' => base_path('/config')
78 78
         ], 'config');
79 79
 
80 80
         // Publish our routes
81 81
         $this->publishes([
82
-            __DIR__ .  '/routes.php' => base_path("app/Http/base_routes.php")
82
+            __DIR__.'/routes.php' => base_path("app/Http/base_routes.php")
83 83
         ], 'routes');
84 84
 
85 85
         // Include the routes file
86
-        if(file_exists(base_path("app/Http/base_routes.php")))
86
+        if (file_exists(base_path("app/Http/base_routes.php")))
87 87
             include base_path("app/Http/base_routes.php");
88 88
     }
89 89
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function registerUsers()
96 96
     {
97
-        $this->app->singleton('jlourenco.user', function ($app) {
97
+        $this->app->singleton('jlourenco.user', function($app) {
98 98
             $config = $app['config']->get('jlourenco.base');
99 99
 
100 100
             $users = array_get($config, 'models.User');
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function registerGroups()
116 116
     {
117
-        $this->app->singleton('jlourenco.group', function ($app) {
117
+        $this->app->singleton('jlourenco.group', function($app) {
118 118
             $config = $app['config']->get('jlourenco.base');
119 119
 
120 120
             $model = array_get($config, 'base.models.Group');
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     protected function registerSettings()
132 132
     {
133
-        $this->app->singleton('jlourenco.settings', function ($app) {
133
+        $this->app->singleton('jlourenco.settings', function($app) {
134 134
             $config = $app['config']->get('jlourenco.base');
135 135
 
136 136
             $model = array_get($config, 'models.Settings');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     protected function registerLog()
148 148
     {
149
-        $this->app->singleton('jlourenco.log', function ($app) {
149
+        $this->app->singleton('jlourenco.log', function($app) {
150 150
             $config = $app['config']->get('jlourenco.base');
151 151
 
152 152
             $model = array_get($config, 'models.Logs');
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     protected function registerVisits()
164 164
     {
165
-        $this->app->singleton('jlourenco.visits', function ($app) {
165
+        $this->app->singleton('jlourenco.visits', function($app) {
166 166
             $config = $app['config']->get('jlourenco.base');
167 167
 
168 168
             $model = array_get($config, 'models.Visits');
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     protected function registerJobs()
180 180
     {
181
-        $this->app->singleton('jlourenco.jobs', function ($app) {
181
+        $this->app->singleton('jlourenco.jobs', function($app) {
182 182
             $config = $app['config']->get('jlourenco.base');
183 183
 
184 184
             $model = array_get($config, 'models.Jobs');
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function registerBase()
196 196
     {
197
-        $this->app->singleton('base', function ($app) {
197
+        $this->app->singleton('base', function($app) {
198 198
             $base = new Base($app['jlourenco.settings'], $app['jlourenco.user'], $app['jlourenco.log'], $app['jlourenco.visits'], $app['jlourenco.jobs']);
199 199
 
200 200
             return $base;
Please login to merge, or discard this patch.