@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public function addUserToGroup($user_id, $group_id) |
87 | 87 | { |
88 | 88 | $data = [ |
89 | - 'user_id' => (int)$user_id, |
|
90 | - 'group_id' => (int)$group_id |
|
89 | + 'user_id' => (int) $user_id, |
|
90 | + 'group_id' => (int) $group_id |
|
91 | 91 | ]; |
92 | 92 | |
93 | 93 | return $this->db->insert('auth_groups_users', $data); |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | public function removeUserFromGroup($user_id, $group_id) |
107 | 107 | { |
108 | 108 | return $this->where([ |
109 | - 'user_id' => (int)$user_id, |
|
110 | - 'group_id' => (int)$group_id |
|
109 | + 'user_id' => (int) $user_id, |
|
110 | + 'group_id' => (int) $group_id |
|
111 | 111 | ])->delete('auth_groups_users'); |
112 | 112 | } |
113 | 113 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function removeUserFromAllGroups($user_id) |
124 | 124 | { |
125 | - return $this->db->where('user_id', (int)$user_id) |
|
125 | + return $this->db->where('user_id', (int) $user_id) |
|
126 | 126 | ->delete('auth_groups_users'); |
127 | 127 | } |
128 | 128 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | public function addPermissionToGroup($permission_id, $group_id) |
157 | 157 | { |
158 | 158 | $data = [ |
159 | - 'permission_id' => (int)$permission_id, |
|
160 | - 'group_id' => (int)$group_id |
|
159 | + 'permission_id' => (int) $permission_id, |
|
160 | + 'group_id' => (int) $group_id |
|
161 | 161 | ]; |
162 | 162 | |
163 | 163 | return $this->db->insert('auth_groups_permissions', $data); |
@@ -84,11 +84,11 @@ |
||
84 | 84 | { |
85 | 85 | $permissions = $this->join('auth_groups_permissions', 'auth_groups_permissions.permission_id = auth_permissions.id', 'inner') |
86 | 86 | ->join('auth_groups_users', 'auth_groups_users.group_id = auth_groups_permissions.group_id', 'inner') |
87 | - ->where('auth_groups_users.user_id', (int)$user_id) |
|
87 | + ->where('auth_groups_users.user_id', (int) $user_id) |
|
88 | 88 | ->as_array() |
89 | 89 | ->find_all(); |
90 | 90 | |
91 | - if (! $permissions) |
|
91 | + if ( ! $permissions) |
|
92 | 92 | { |
93 | 93 | return false; |
94 | 94 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function __construct($groupModel = null, $permModel = null) |
50 | 50 | { |
51 | 51 | $this->groupModel = ! empty($groupModel) ? $groupModel : new FlatGroupsModel(); |
52 | - $this->permissionModel = ! empty($permModel) ? $permModel : new FlatPermissionsModel(); |
|
52 | + $this->permissionModel = ! empty($permModel) ? $permModel : new FlatPermissionsModel(); |
|
53 | 53 | |
54 | 54 | get_instance()->load->language('auth/auth'); |
55 | 55 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function useModel($model) |
74 | 74 | { |
75 | - $this->user_model =& $model; |
|
75 | + $this->user_model = & $model; |
|
76 | 76 | |
77 | 77 | return $this; |
78 | 78 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - public function inGroup( $groups, $user_id ) |
|
97 | + public function inGroup($groups, $user_id) |
|
98 | 98 | { |
99 | - if ( ! is_array( $groups ) ) |
|
99 | + if ( ! is_array($groups)) |
|
100 | 100 | { |
101 | - $groups = [ $groups ]; |
|
101 | + $groups = [$groups]; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if (empty($user_id)) |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | return null; |
107 | 107 | } |
108 | 108 | |
109 | - $user_groups = $this->groupModel->getGroupsForUser( (int) $user_id ); |
|
109 | + $user_groups = $this->groupModel->getGroupsForUser((int) $user_id); |
|
110 | 110 | |
111 | - if ( ! $user_groups ) |
|
111 | + if ( ! $user_groups) |
|
112 | 112 | { |
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | - foreach ( $groups as $group ) |
|
116 | + foreach ($groups as $group) |
|
117 | 117 | { |
118 | 118 | if (is_numeric($group)) |
119 | 119 | { |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return mixed |
149 | 149 | */ |
150 | - public function hasPermission( $permission, $user_id ) |
|
150 | + public function hasPermission($permission, $user_id) |
|
151 | 151 | { |
152 | - if (empty($permission) || (! is_string($permission) && ! is_numeric($permission)) ) |
|
152 | + if (empty($permission) || ( ! is_string($permission) && ! is_numeric($permission))) |
|
153 | 153 | { |
154 | 154 | return null; |
155 | 155 | } |
@@ -162,19 +162,19 @@ discard block |
||
162 | 162 | // Get the Permission ID |
163 | 163 | $permission_id = $this->getPermissionID($permission); |
164 | 164 | |
165 | - if ( ! is_numeric( $permission_id ) ) |
|
165 | + if ( ! is_numeric($permission_id)) |
|
166 | 166 | { |
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | 170 | // First check the permission model. If that exists, then we're golden. |
171 | - if ($this->permissionModel->doesUserHavePermission( (int)$user_id, (int)$permission_id ) ) |
|
171 | + if ($this->permissionModel->doesUserHavePermission((int) $user_id, (int) $permission_id)) |
|
172 | 172 | { |
173 | 173 | return true; |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Still here? Then we have one last check to make - any user private permissions. |
177 | - return $this->doesUserHavePermission( (int)$user_id, (int)$permission_id); |
|
177 | + return $this->doesUserHavePermission((int) $user_id, (int) $permission_id); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | //-------------------------------------------------------------------- |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return bool |
189 | 189 | */ |
190 | - public function addUserToGroup( $user_id, $group ) |
|
190 | + public function addUserToGroup($user_id, $group) |
|
191 | 191 | { |
192 | 192 | if (empty($user_id) || ! is_numeric($user_id)) |
193 | 193 | { |
194 | 194 | return null; |
195 | 195 | } |
196 | 196 | |
197 | - if (empty($group) || (! is_numeric($group) && ! is_string($group) ) ) |
|
197 | + if (empty($group) || ( ! is_numeric($group) && ! is_string($group))) |
|
198 | 198 | { |
199 | 199 | return null; |
200 | 200 | } |
201 | 201 | |
202 | - if (! Events::trigger('beforeAddUserToGroup', [$user_id, $group])) |
|
202 | + if ( ! Events::trigger('beforeAddUserToGroup', [$user_id, $group])) |
|
203 | 203 | { |
204 | 204 | return false; |
205 | 205 | } |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | $group_id = $this->getGroupID($group); |
208 | 208 | |
209 | 209 | // Group ID |
210 | - if ( ! is_numeric( $group_id ) ) |
|
210 | + if ( ! is_numeric($group_id)) |
|
211 | 211 | { |
212 | 212 | return null; |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! $this->groupModel->addUserToGroup( (int)$user_id, (int)$group_id ) ) |
|
215 | + if ( ! $this->groupModel->addUserToGroup((int) $user_id, (int) $group_id)) |
|
216 | 216 | { |
217 | 217 | $this->error = $this->groupModel->error(); |
218 | 218 | |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return mixed |
236 | 236 | */ |
237 | - public function removeUserFromGroup( $user_id, $group ) |
|
237 | + public function removeUserFromGroup($user_id, $group) |
|
238 | 238 | { |
239 | 239 | if (empty($user_id) || ! is_numeric($user_id)) |
240 | 240 | { |
241 | 241 | return null; |
242 | 242 | } |
243 | 243 | |
244 | - if (empty($group) || (! is_numeric($group) && ! is_string($group) ) ) |
|
244 | + if (empty($group) || ( ! is_numeric($group) && ! is_string($group))) |
|
245 | 245 | { |
246 | 246 | return null; |
247 | 247 | } |
248 | 248 | |
249 | - if (! Events::trigger('beforeRemoveUserFromGroup', [$user_id, $group])) |
|
249 | + if ( ! Events::trigger('beforeRemoveUserFromGroup', [$user_id, $group])) |
|
250 | 250 | { |
251 | 251 | return false; |
252 | 252 | } |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | $group_id = $this->getGroupID($group); |
255 | 255 | |
256 | 256 | // Group ID |
257 | - if ( ! is_numeric( $group_id ) ) |
|
257 | + if ( ! is_numeric($group_id)) |
|
258 | 258 | { |
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | |
262 | - if ( ! $this->groupModel->removeUserFromGroup( $user_id, $group_id ) ) |
|
262 | + if ( ! $this->groupModel->removeUserFromGroup($user_id, $group_id)) |
|
263 | 263 | { |
264 | 264 | $this->error = $this->groupModel->error(); |
265 | 265 | |
@@ -281,25 +281,25 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return mixed |
283 | 283 | */ |
284 | - public function addPermissionToGroup( $permission, $group ) |
|
284 | + public function addPermissionToGroup($permission, $group) |
|
285 | 285 | { |
286 | 286 | $permission_id = $this->getPermissionID($permission); |
287 | 287 | $group_id = $this->getGroupID($group); |
288 | 288 | |
289 | 289 | // Permission ID |
290 | - if ( ! is_numeric( $permission_id ) ) |
|
290 | + if ( ! is_numeric($permission_id)) |
|
291 | 291 | { |
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Group ID |
296 | - if ( ! is_numeric( $group_id ) ) |
|
296 | + if ( ! is_numeric($group_id)) |
|
297 | 297 | { |
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Remove it! |
302 | - if ( ! $this->groupModel->addPermissionToGroup( $permission_id, $group_id ) ) |
|
302 | + if ( ! $this->groupModel->addPermissionToGroup($permission_id, $group_id)) |
|
303 | 303 | { |
304 | 304 | $this->error = $this->groupModel->error(); |
305 | 305 | |
@@ -319,25 +319,25 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return mixed |
321 | 321 | */ |
322 | - public function removePermissionFromGroup( $permission, $group ) |
|
322 | + public function removePermissionFromGroup($permission, $group) |
|
323 | 323 | { |
324 | 324 | $permission_id = $this->getPermissionID($permission); |
325 | 325 | $group_id = $this->getGroupID($group); |
326 | 326 | |
327 | 327 | // Permission ID |
328 | - if ( ! is_numeric( $permission_id ) ) |
|
328 | + if ( ! is_numeric($permission_id)) |
|
329 | 329 | { |
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Group ID |
334 | - if ( ! is_numeric( $group_id ) ) |
|
334 | + if ( ! is_numeric($group_id)) |
|
335 | 335 | { |
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Remove it! |
340 | - if ( ! $this->groupModel->removePermissionFromGroup( $permission_id, $group_id ) ) |
|
340 | + if ( ! $this->groupModel->removePermissionFromGroup($permission_id, $group_id)) |
|
341 | 341 | { |
342 | 342 | $this->error = $this->groupModel->error(); |
343 | 343 | |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return int|bool |
360 | 360 | */ |
361 | - public function addPermissionToUser( $permission, $user_id ) |
|
361 | + public function addPermissionToUser($permission, $user_id) |
|
362 | 362 | { |
363 | 363 | $permission_id = $this->getPermissionID($permission); |
364 | 364 | |
365 | - if (! is_numeric($permission_id) ) |
|
365 | + if ( ! is_numeric($permission_id)) |
|
366 | 366 | { |
367 | 367 | return null; |
368 | 368 | } |
@@ -372,21 +372,21 @@ discard block |
||
372 | 372 | return null; |
373 | 373 | } |
374 | 374 | |
375 | - $user_id = (int)$user_id; |
|
375 | + $user_id = (int) $user_id; |
|
376 | 376 | |
377 | - if (! Events::trigger('beforeAddPermissionToUser', [$user_id, $permission])) |
|
377 | + if ( ! Events::trigger('beforeAddPermissionToUser', [$user_id, $permission])) |
|
378 | 378 | { |
379 | 379 | return false; |
380 | 380 | } |
381 | 381 | |
382 | - $ci =& get_instance(); |
|
382 | + $ci = & get_instance(); |
|
383 | 383 | $ci->load->model('User_model'); |
384 | 384 | |
385 | 385 | $permissions = $ci->user_model->getMetaItem($user_id, 'RBAC_permissions'); |
386 | 386 | |
387 | 387 | // If we already have permissions, unserialize them and add |
388 | 388 | // the new permission to it. |
389 | - if (! empty($permissions)) |
|
389 | + if ( ! empty($permissions)) |
|
390 | 390 | { |
391 | 391 | $permissions = unserialize($permissions); |
392 | 392 | } |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | * @param int/string $permission |
412 | 412 | * @param int $user_id |
413 | 413 | */ |
414 | - public function removePermissionFromUser( $permission, $user_id ) |
|
414 | + public function removePermissionFromUser($permission, $user_id) |
|
415 | 415 | { |
416 | 416 | $permission_id = $this->getPermissionID($permission); |
417 | 417 | |
418 | - if (! is_numeric($permission_id) ) |
|
418 | + if ( ! is_numeric($permission_id)) |
|
419 | 419 | { |
420 | 420 | return false; |
421 | 421 | } |
@@ -425,26 +425,26 @@ discard block |
||
425 | 425 | return null; |
426 | 426 | } |
427 | 427 | |
428 | - $user_id = (int)$user_id; |
|
428 | + $user_id = (int) $user_id; |
|
429 | 429 | |
430 | - if (! Events::trigger('beforeRemovePermissionFromUser', [$user_id, $permission])) |
|
430 | + if ( ! Events::trigger('beforeRemovePermissionFromUser', [$user_id, $permission])) |
|
431 | 431 | { |
432 | 432 | return false; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Grab the existing permissions for this user, and remove |
436 | 436 | // the permission id from the list. |
437 | - $ci =& get_instance(); |
|
437 | + $ci = & get_instance(); |
|
438 | 438 | $ci->load->model('User_model'); |
439 | 439 | |
440 | 440 | $permissions = $ci->user_model->getMetaItem($user_id, 'RBAC_permissions'); |
441 | 441 | |
442 | - if (! is_array($permissions)) |
|
442 | + if ( ! is_array($permissions)) |
|
443 | 443 | { |
444 | 444 | $permissions = []; |
445 | 445 | } |
446 | 446 | |
447 | - unset($permissions[ array_search($permission_id, $permissions) ]); |
|
447 | + unset($permissions[array_search($permission_id, $permissions)]); |
|
448 | 448 | |
449 | 449 | // Save the updated permissions |
450 | 450 | return $ci->user_model->saveMetaToUser($user_id, 'RBAC_permissions', serialize($permissions)); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | { |
465 | 465 | $permission_id = $this->getPermissionID($permission); |
466 | 466 | |
467 | - if (! is_numeric($permission_id) ) |
|
467 | + if ( ! is_numeric($permission_id)) |
|
468 | 468 | { |
469 | 469 | return false; |
470 | 470 | } |
@@ -474,14 +474,14 @@ discard block |
||
474 | 474 | return null; |
475 | 475 | } |
476 | 476 | |
477 | - $user_id = (int)$user_id; |
|
477 | + $user_id = (int) $user_id; |
|
478 | 478 | |
479 | 479 | $model = $this->user_model; |
480 | 480 | |
481 | 481 | if (empty($model)) |
482 | 482 | { |
483 | - $ci =& get_instance(); |
|
484 | - $ci->load->model( 'User_model' ); |
|
483 | + $ci = & get_instance(); |
|
484 | + $ci->load->model('User_model'); |
|
485 | 485 | |
486 | 486 | $model = $ci->user_model; |
487 | 487 | } |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return object|null |
508 | 508 | */ |
509 | - public function group( $group ) |
|
509 | + public function group($group) |
|
510 | 510 | { |
511 | - if ( is_numeric( $group ) ) |
|
511 | + if (is_numeric($group)) |
|
512 | 512 | { |
513 | - return $this->groupModel->find( (int) $group ); |
|
513 | + return $this->groupModel->find((int) $group); |
|
514 | 514 | } |
515 | 515 | |
516 | - return $this->groupModel->find_by( 'name', $group ); |
|
516 | + return $this->groupModel->find_by('name', $group); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | //-------------------------------------------------------------------- |
@@ -536,16 +536,16 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return mixed |
538 | 538 | */ |
539 | - public function createGroup( $name, $description = '' ) |
|
539 | + public function createGroup($name, $description = '') |
|
540 | 540 | { |
541 | 541 | $data = [ |
542 | 542 | 'name' => $name, |
543 | 543 | 'description' => $description |
544 | 544 | ]; |
545 | 545 | |
546 | - $id = $this->groupModel->insert( $data ); |
|
546 | + $id = $this->groupModel->insert($data); |
|
547 | 547 | |
548 | - if ( is_numeric( $id ) ) |
|
548 | + if (is_numeric($id)) |
|
549 | 549 | { |
550 | 550 | return (int) $id; |
551 | 551 | } |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return bool |
566 | 566 | */ |
567 | - public function deleteGroup( $group_id ) |
|
567 | + public function deleteGroup($group_id) |
|
568 | 568 | { |
569 | - if ( ! $this->groupModel->delete( $group_id ) ) |
|
569 | + if ( ! $this->groupModel->delete($group_id)) |
|
570 | 570 | { |
571 | 571 | $this->error = $this->groupModel->error(); |
572 | 572 | |
@@ -587,18 +587,18 @@ discard block |
||
587 | 587 | * |
588 | 588 | * @return mixed |
589 | 589 | */ |
590 | - public function updateGroup( $id, $name, $description = '' ) |
|
590 | + public function updateGroup($id, $name, $description = '') |
|
591 | 591 | { |
592 | 592 | $data = [ |
593 | 593 | 'name' => $name |
594 | 594 | ]; |
595 | 595 | |
596 | - if ( ! empty( $description ) ) |
|
596 | + if ( ! empty($description)) |
|
597 | 597 | { |
598 | 598 | $data['description'] = $description; |
599 | 599 | } |
600 | 600 | |
601 | - if ( ! $this->groupModel->update( (int) $id, $data ) ) |
|
601 | + if ( ! $this->groupModel->update((int) $id, $data)) |
|
602 | 602 | { |
603 | 603 | $this->error = $this->groupModel->error(); |
604 | 604 | |
@@ -618,23 +618,23 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return int|false |
620 | 620 | */ |
621 | - protected function getGroupID( $group ) |
|
621 | + protected function getGroupID($group) |
|
622 | 622 | { |
623 | 623 | if (is_numeric($group)) |
624 | 624 | { |
625 | - return (int)$group; |
|
625 | + return (int) $group; |
|
626 | 626 | } |
627 | 627 | |
628 | - $g = $this->groupModel->find_by( 'name', $group ); |
|
628 | + $g = $this->groupModel->find_by('name', $group); |
|
629 | 629 | |
630 | - if ( ! $g ) |
|
630 | + if ( ! $g) |
|
631 | 631 | { |
632 | 632 | $this->error = lang('auth.group_not_found'); |
633 | 633 | |
634 | 634 | return FALSE; |
635 | 635 | } |
636 | 636 | |
637 | - return (int)$g->id; |
|
637 | + return (int) $g->id; |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | //-------------------------------------------------------------------- |
@@ -650,14 +650,14 @@ discard block |
||
650 | 650 | * |
651 | 651 | * @return object|null |
652 | 652 | */ |
653 | - public function permission( $permission ) |
|
653 | + public function permission($permission) |
|
654 | 654 | { |
655 | - if ( is_numeric( $permission ) ) |
|
655 | + if (is_numeric($permission)) |
|
656 | 656 | { |
657 | - return $this->permissionModel->find( (int) $permission ); |
|
657 | + return $this->permissionModel->find((int) $permission); |
|
658 | 658 | } |
659 | 659 | |
660 | - return $this->permissionModel->find_by( 'LOWER(name)', strtolower( $permission ) ); |
|
660 | + return $this->permissionModel->find_by('LOWER(name)', strtolower($permission)); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | //-------------------------------------------------------------------- |
@@ -682,16 +682,16 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @return mixed |
684 | 684 | */ |
685 | - public function createPermission( $name, $description = '' ) |
|
685 | + public function createPermission($name, $description = '') |
|
686 | 686 | { |
687 | 687 | $data = [ |
688 | 688 | 'name' => $name, |
689 | 689 | 'description' => $description |
690 | 690 | ]; |
691 | 691 | |
692 | - $id = $this->permissionModel->insert( $data ); |
|
692 | + $id = $this->permissionModel->insert($data); |
|
693 | 693 | |
694 | - if ( is_numeric( $id ) ) |
|
694 | + if (is_numeric($id)) |
|
695 | 695 | { |
696 | 696 | return (int) $id; |
697 | 697 | } |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @return mixed |
712 | 712 | */ |
713 | - public function deletePermission( $permission_id ) |
|
713 | + public function deletePermission($permission_id) |
|
714 | 714 | { |
715 | - if ( ! $this->permissionModel->delete( $permission_id ) ) |
|
715 | + if ( ! $this->permissionModel->delete($permission_id)) |
|
716 | 716 | { |
717 | 717 | $this->error = $this->permissionModel->error(); |
718 | 718 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | } |
721 | 721 | |
722 | 722 | // Remove the permission from all groups |
723 | - $this->groupModel->removePermissionFromAllGroups( $permission_id ); |
|
723 | + $this->groupModel->removePermissionFromAllGroups($permission_id); |
|
724 | 724 | |
725 | 725 | return TRUE; |
726 | 726 | } |
@@ -736,18 +736,18 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function updatePermission( $id, $name, $description = '' ) |
|
739 | + public function updatePermission($id, $name, $description = '') |
|
740 | 740 | { |
741 | 741 | $data = [ |
742 | 742 | 'name' => $name |
743 | 743 | ]; |
744 | 744 | |
745 | - if ( ! empty( $description ) ) |
|
745 | + if ( ! empty($description)) |
|
746 | 746 | { |
747 | 747 | $data['description'] = $description; |
748 | 748 | } |
749 | 749 | |
750 | - if ( ! $this->permissionModel->update( (int) $id, $data ) ) |
|
750 | + if ( ! $this->permissionModel->update((int) $id, $data)) |
|
751 | 751 | { |
752 | 752 | $this->error = $this->permissionModel->error(); |
753 | 753 | |
@@ -767,25 +767,25 @@ discard block |
||
767 | 767 | * |
768 | 768 | * @return int|null |
769 | 769 | */ |
770 | - protected function getPermissionID( $permission ) |
|
770 | + protected function getPermissionID($permission) |
|
771 | 771 | { |
772 | 772 | // If it's a number, we're done here. |
773 | 773 | if (is_numeric($permission)) |
774 | 774 | { |
775 | - return (int)$permission; |
|
775 | + return (int) $permission; |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | // Otherwise, pull it from the database. |
779 | - $p = $this->permissionModel->find_by( 'name', $permission ); |
|
779 | + $p = $this->permissionModel->find_by('name', $permission); |
|
780 | 780 | |
781 | - if ( ! $p ) |
|
781 | + if ( ! $p) |
|
782 | 782 | { |
783 | 783 | $this->error = lang('auth.permission_not_found'); |
784 | 784 | |
785 | 785 | return FALSE; |
786 | 786 | } |
787 | 787 | |
788 | - return (int)$p->id; |
|
788 | + return (int) $p->id; |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | //-------------------------------------------------------------------- |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | |
63 | 63 | //-------------------------------------------------------------------- |
64 | 64 | |
65 | - public function __construct( $ci=null ) |
|
65 | + public function __construct($ci = null) |
|
66 | 66 | { |
67 | 67 | if ($ci) |
68 | 68 | { |
69 | - $this->ci= $ci; |
|
69 | + $this->ci = $ci; |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - $this->ci =& get_instance(); |
|
73 | + $this->ci = & get_instance(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Get our compatibility password file loaded up. |
77 | - if (! function_exists('password_hash')) |
|
77 | + if ( ! function_exists('password_hash')) |
|
78 | 78 | { |
79 | - require_once dirname(__FILE__) .'password.php'; |
|
79 | + require_once dirname(__FILE__).'password.php'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if (empty($this->ci->session)) |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | * @param bool $remember |
102 | 102 | * @return bool|mixed |
103 | 103 | */ |
104 | - public function login($credentials, $remember=false) |
|
104 | + public function login($credentials, $remember = false) |
|
105 | 105 | { |
106 | 106 | $user = $this->validate($credentials, true); |
107 | 107 | |
108 | - if (! $user) |
|
108 | + if ( ! $user) |
|
109 | 109 | { |
110 | 110 | // We need to send an error even if no |
111 | 111 | // user was found! |
112 | 112 | $this->error = lang('auth.invalid_user'); |
113 | 113 | |
114 | 114 | // If an email is present, log the attempt |
115 | - if (! empty($credentials['email']) ) |
|
115 | + if ( ! empty($credentials['email'])) |
|
116 | 116 | { |
117 | 117 | $this->ci->login_model->recordLoginAttempt($credentials['email']); |
118 | 118 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | // If throttling time is above zero, we can't allow |
130 | 130 | // logins now. |
131 | - $time = (int)$this->isThrottled($user['email']); |
|
131 | + $time = (int) $this->isThrottled($user['email']); |
|
132 | 132 | if ($time > 0) |
133 | 133 | { |
134 | 134 | $this->error = sprintf(lang('auth.throttled'), $time); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param bool $return_user |
160 | 160 | * @return mixed |
161 | 161 | */ |
162 | - public function validate($credentials, $return_user=false) |
|
162 | + public function validate($credentials, $return_user = false) |
|
163 | 163 | { |
164 | 164 | // Can't validate without a password. |
165 | 165 | if (empty($credentials['password']) || count($credentials) < 2) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | // Ensure that the fields are allowed validation fields |
182 | - if (! in_array(key($credentials), config_item('auth.valid_fields')) ) |
|
182 | + if ( ! in_array(key($credentials), config_item('auth.valid_fields'))) |
|
183 | 183 | { |
184 | 184 | $this->error = lang('auth.invalid_credentials'); |
185 | 185 | return false; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | // We do not want to force case-sensitivity on things |
189 | 189 | // like username and email for usability sake. |
190 | - if (! empty($credentials['email'])) |
|
190 | + if ( ! empty($credentials['email'])) |
|
191 | 191 | { |
192 | 192 | $credentials['email'] = strtolower($credentials['email']); |
193 | 193 | } |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | ->where($credentials) |
198 | 198 | ->first(); |
199 | 199 | |
200 | - if (! $user) |
|
200 | + if ( ! $user) |
|
201 | 201 | { |
202 | 202 | $this->error = lang('auth.invalid_user'); |
203 | 203 | return false; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Now, try matching the passwords. |
207 | - $result = password_verify($password, $user['password_hash']); |
|
207 | + $result = password_verify($password, $user['password_hash']); |
|
208 | 208 | |
209 | - if (! $result) |
|
209 | + if ( ! $result) |
|
210 | 210 | { |
211 | 211 | $this->error = lang('auth.invalid_password'); |
212 | 212 | $this->ci->login_model->recordLoginAttempt($user['email']); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // This would be due to the hash algorithm or hash |
218 | 218 | // cost changing since the last time that a user |
219 | 219 | // logged in. |
220 | - if (password_needs_rehash($user['password_hash'], PASSWORD_DEFAULT, ['cost' => config_item('auth.hash_cost')] )) |
|
220 | + if (password_needs_rehash($user['password_hash'], PASSWORD_DEFAULT, ['cost' => config_item('auth.hash_cost')])) |
|
221 | 221 | { |
222 | 222 | $new_hash = Password::hashPassword($password); |
223 | 223 | $this->user_model->skip_validation() |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | // Is the user active? |
229 | - if (! $user['active']) |
|
229 | + if ( ! $user['active']) |
|
230 | 230 | { |
231 | 231 | $this->error = lang('auth.inactive_account'); |
232 | 232 | return false; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | $this->ci->load->helper('cookie'); |
248 | 248 | |
249 | - if (! Events::trigger('beforeLogout', [$this->user])) |
|
249 | + if ( ! Events::trigger('beforeLogout', [$this->user])) |
|
250 | 250 | { |
251 | 251 | return false; |
252 | 252 | } |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | // available for flash messages, etc. |
256 | 256 | if (isset($_SESSION)) |
257 | 257 | { |
258 | - foreach ( $_SESSION as $key => $value ) |
|
258 | + foreach ($_SESSION as $key => $value) |
|
259 | 259 | { |
260 | - $_SESSION[ $key ] = NULL; |
|
261 | - unset( $_SESSION[ $key ] ); |
|
260 | + $_SESSION[$key] = NULL; |
|
261 | + unset($_SESSION[$key]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | // Also, regenerate the session ID for a touch of added safety. |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | { |
285 | 285 | $id = $this->ci->session->userdata('logged_in'); |
286 | 286 | |
287 | - if (! $id) |
|
287 | + if ( ! $id) |
|
288 | 288 | { |
289 | 289 | return false; |
290 | 290 | } |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | // If the user var hasn't been filled in, we need to fill it in, |
293 | 293 | // since this method will typically be used as the only method |
294 | 294 | // to determine whether a user is logged in or not. |
295 | - if (! $this->user) |
|
295 | + if ( ! $this->user) |
|
296 | 296 | { |
297 | 297 | $this->user = $this->user_model->as_array() |
298 | - ->find_by('id', (int)$id); |
|
298 | + ->find_by('id', (int) $id); |
|
299 | 299 | |
300 | 300 | if (empty($this->user)) |
301 | 301 | { |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function viaRemember() |
321 | 321 | { |
322 | - if (! config_item('auth.allow_remembering')) |
|
322 | + if ( ! config_item('auth.allow_remembering')) |
|
323 | 323 | { |
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | |
327 | 327 | $this->ci->load->helper('cookie'); |
328 | 328 | |
329 | - if (! $token = get_cookie('remember')) |
|
329 | + if ( ! $token = get_cookie('remember')) |
|
330 | 330 | { |
331 | 331 | return false; |
332 | 332 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $query = $this->ci->db->where('hash', $this->ci->login_model->hashRememberToken($token)) |
336 | 336 | ->get('auth_tokens'); |
337 | 337 | |
338 | - if (! $query->num_rows()) |
|
338 | + if ( ! $query->num_rows()) |
|
339 | 339 | { |
340 | 340 | return false; |
341 | 341 | } |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | // If via email, we need to generate a hash |
374 | 374 | $this->ci->load->helper('string'); |
375 | 375 | $token = random_string('alnum', 24); |
376 | - $user_data['activate_hash'] = hash('sha1', config_item('auth.salt') . $token); |
|
376 | + $user_data['activate_hash'] = hash('sha1', config_item('auth.salt').$token); |
|
377 | 377 | |
378 | 378 | // Email should NOT be case sensitive. |
379 | - if (! empty($user_data['email'])) |
|
379 | + if ( ! empty($user_data['email'])) |
|
380 | 380 | { |
381 | 381 | $user_data['email'] = strtolower($user_data['email']); |
382 | 382 | } |
383 | 383 | |
384 | 384 | // Save the user |
385 | - if (! $id = $this->user_model->insert($user_data)) |
|
385 | + if ( ! $id = $this->user_model->insert($user_data)) |
|
386 | 386 | { |
387 | 387 | $this->error = $this->user_model->error(); |
388 | 388 | return false; |
@@ -413,25 +413,25 @@ discard block |
||
413 | 413 | { |
414 | 414 | $post = [ |
415 | 415 | 'email' => $data['email'], |
416 | - 'activate_hash' => hash('sha1', config_item('auth.salt') . $data['code']) |
|
416 | + 'activate_hash' => hash('sha1', config_item('auth.salt').$data['code']) |
|
417 | 417 | ]; |
418 | 418 | |
419 | 419 | $user = $this->user_model->where($post) |
420 | 420 | ->first(); |
421 | 421 | |
422 | - if (! $user) { |
|
422 | + if ( ! $user) { |
|
423 | 423 | $this->error = $this->user_model->error() ? $this->user_model->error() : lang('auth.activate_no_user'); |
424 | 424 | |
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
428 | - if (! $this->user_model->update($user->id, ['active' => 1, 'activate_hash' => null])) |
|
428 | + if ( ! $this->user_model->update($user->id, ['active' => 1, 'activate_hash' => null])) |
|
429 | 429 | { |
430 | 430 | $this->error = $this->user_model->error(); |
431 | 431 | return false; |
432 | 432 | } |
433 | 433 | |
434 | - Events::trigger('didActivate', [(array)$user]); |
|
434 | + Events::trigger('didActivate', [(array) $user]); |
|
435 | 435 | |
436 | 436 | return true; |
437 | 437 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function activateUserById($id) |
448 | 448 | { |
449 | - if (! $this->user_model->update($id, ['active' => 1, 'activate_hash' => null])) |
|
449 | + if ( ! $this->user_model->update($id, ['active' => 1, 'activate_hash' => null])) |
|
450 | 450 | { |
451 | 451 | $this->error = $this->user_model->error(); |
452 | 452 | return false; |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | */ |
479 | 479 | public function id() |
480 | 480 | { |
481 | - if (! is_array($this->user) || empty($this->user['id'])) |
|
481 | + if ( ! is_array($this->user) || empty($this->user['id'])) |
|
482 | 482 | { |
483 | 483 | return null; |
484 | 484 | } |
485 | 485 | |
486 | - return (int)$this->user['id']; |
|
486 | + return (int) $this->user['id']; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | //-------------------------------------------------------------------- |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | public function isThrottled($email) |
501 | 501 | { |
502 | 502 | // Not throttling? Get outta here! |
503 | - if (! config_item('auth.allow_throttling')) |
|
503 | + if ( ! config_item('auth.allow_throttling')) |
|
504 | 504 | { |
505 | 505 | return false; |
506 | 506 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | { |
565 | 565 | $this->error = lang('auth.bruteBan_notice'); |
566 | 566 | |
567 | - $ban_time = 60 * 15; // 15 minutes |
|
567 | + $ban_time = 60 * 15; // 15 minutes |
|
568 | 568 | $_SESSION['bruteBan'] = time() + $ban_time; |
569 | 569 | return $ban_time; |
570 | 570 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | // Is it a valid user? |
613 | 613 | $user = $this->user_model->find_by('email', $email); |
614 | 614 | |
615 | - if (! $user) |
|
615 | + if ( ! $user) |
|
616 | 616 | { |
617 | 617 | $this->error = lang('auth.invalid_email'); |
618 | 618 | return false; |
@@ -621,17 +621,17 @@ discard block |
||
621 | 621 | // Generate/store our codes |
622 | 622 | $this->ci->load->helper('string'); |
623 | 623 | $token = random_string('alnum', 24); |
624 | - $hash = hash('sha1', config_item('auth.salt') .$token); |
|
624 | + $hash = hash('sha1', config_item('auth.salt').$token); |
|
625 | 625 | |
626 | 626 | $result = $this->user_model->update($user->id, ['reset_hash' => $hash]); |
627 | 627 | |
628 | - if (! $result) |
|
628 | + if ( ! $result) |
|
629 | 629 | { |
630 | 630 | $this->error = $this->user_model->error(); |
631 | 631 | return false; |
632 | 632 | } |
633 | 633 | |
634 | - Events::trigger('didRemindUser', [(array)$user, $token]); |
|
634 | + Events::trigger('didRemindUser', [(array) $user, $token]); |
|
635 | 635 | |
636 | 636 | return true; |
637 | 637 | } |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | } |
659 | 659 | |
660 | 660 | // Generate a hash to match against the table. |
661 | - $credentials['reset_hash'] = hash('sha1', config_item('auth.salt') .$credentials['code']); |
|
661 | + $credentials['reset_hash'] = hash('sha1', config_item('auth.salt').$credentials['code']); |
|
662 | 662 | unset($credentials['code']); |
663 | 663 | |
664 | - if (! empty($credentials['email'])) |
|
664 | + if ( ! empty($credentials['email'])) |
|
665 | 665 | { |
666 | 666 | $credentials['email'] = strtolower($credentials['email']); |
667 | 667 | } |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | // Is there a matching user? |
670 | 670 | $user = $this->user_model->find_by($credentials); |
671 | 671 | |
672 | - if (! $user) |
|
672 | + if ( ! $user) |
|
673 | 673 | { |
674 | 674 | $this->error = lang('auth.reset_no_user'); |
675 | 675 | return false; |
@@ -682,13 +682,13 @@ discard block |
||
682 | 682 | 'reset_hash' => null |
683 | 683 | ]; |
684 | 684 | |
685 | - if (! $this->user_model->update($user->id, $data)) |
|
685 | + if ( ! $this->user_model->update($user->id, $data)) |
|
686 | 686 | { |
687 | 687 | $this->error = $this->user_model->error(); |
688 | 688 | return false; |
689 | 689 | } |
690 | 690 | |
691 | - Events::trigger('didResetPassword', [(array)$user]); |
|
691 | + Events::trigger('didResetPassword', [(array) $user]); |
|
692 | 692 | |
693 | 693 | return true; |
694 | 694 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param null $message |
705 | 705 | * @return mixed |
706 | 706 | */ |
707 | - public function changeStatus($newStatus, $message=null) |
|
707 | + public function changeStatus($newStatus, $message = null) |
|
708 | 708 | { |
709 | 709 | // todo actually record new users status! |
710 | 710 | } |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | * @param bool $allow_any_parent |
722 | 722 | * @return mixed |
723 | 723 | */ |
724 | - public function useModel($model, $allow_any_parent=false) |
|
724 | + public function useModel($model, $allow_any_parent = false) |
|
725 | 725 | { |
726 | - if (! $allow_any_parent && get_parent_class($model) != 'Myth\Models\CIDbModel') |
|
726 | + if ( ! $allow_any_parent && get_parent_class($model) != 'Myth\Models\CIDbModel') |
|
727 | 727 | { |
728 | 728 | throw new \RuntimeException('Models passed into LocalAuthenticate MUST extend Myth\Models\CIDbModel'); |
729 | 729 | } |
730 | 730 | |
731 | - $this->user_model =& $model; |
|
731 | + $this->user_model = & $model; |
|
732 | 732 | |
733 | 733 | return $this; |
734 | 734 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | */ |
801 | 801 | protected function rememberUser($user) |
802 | 802 | { |
803 | - if (! config_item('auth.allow_remembering')) |
|
803 | + if ( ! config_item('auth.allow_remembering')) |
|
804 | 804 | { |
805 | 805 | log_message('debug', 'Auth library set to refuse "Remember Me" functionality.'); |
806 | 806 | return false; |
@@ -819,13 +819,13 @@ discard block |
||
819 | 819 | * @param null $token |
820 | 820 | * @return mixed |
821 | 821 | */ |
822 | - protected function refreshRememberCookie($user, $token=null) |
|
822 | + protected function refreshRememberCookie($user, $token = null) |
|
823 | 823 | { |
824 | 824 | $this->ci->load->helper('cookie'); |
825 | 825 | |
826 | 826 | // If a token is passed in, we know we're removing the |
827 | 827 | // old one. |
828 | - if (! empty($token)) |
|
828 | + if ( ! empty($token)) |
|
829 | 829 | { |
830 | 830 | $this->invalidateRememberCookie($user['email'], $token); |
831 | 831 | } |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | // Save the token to the database. |
836 | 836 | $data = [ |
837 | 837 | 'email' => $user['email'], |
838 | - 'hash' => sha1(config_item('auth.salt') . $new_token), |
|
838 | + 'hash' => sha1(config_item('auth.salt').$new_token), |
|
839 | 839 | 'created' => date('Y-m-d H:i:s') |
840 | 840 | ]; |
841 | 841 | |
@@ -843,13 +843,13 @@ discard block |
||
843 | 843 | |
844 | 844 | // Create the cookie |
845 | 845 | set_cookie( |
846 | - 'remember', // Cookie Name |
|
847 | - $new_token, // Value |
|
848 | - config_item('auth.remember_length'), // # Seconds until it expires |
|
846 | + 'remember', // Cookie Name |
|
847 | + $new_token, // Value |
|
848 | + config_item('auth.remember_length'), // # Seconds until it expires |
|
849 | 849 | config_item('cookie_domain'), |
850 | 850 | config_item('cookie_path'), |
851 | 851 | config_item('cookie_prefix'), |
852 | - false, // Only send over HTTPS? |
|
852 | + false, // Only send over HTTPS? |
|
853 | 853 | true // Hide from Javascript? |
854 | 854 | ); |
855 | 855 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @since Version 1.0 |
31 | 31 | */ |
32 | 32 | |
33 | -define('DICTIONARY_PATH', dirname(__FILE__) .'/dictionary.txt'); |
|
33 | +define('DICTIONARY_PATH', dirname(__FILE__).'/dictionary.txt'); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Class Password |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function hashPassword($password) |
62 | 62 | { |
63 | - if (! config_item('auth.hash_cost')) |
|
63 | + if ( ! config_item('auth.hash_cost')) |
|
64 | 64 | { |
65 | 65 | get_instance()->load->config('auth'); |
66 | 66 | } |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | else if ($tempchr == ord(" ")) $space = true; |
158 | 158 | else $other = true; |
159 | 159 | } |
160 | - $extrabits = ($upper && $lower && $other ? ($numeric ? 6 : 5) : ($numeric && !$upper && !$lower ? ($other ? -2 : -6) : 0)); |
|
161 | - if (!$space) $extrabits -= 2; |
|
160 | + $extrabits = ($upper && $lower && $other ? ($numeric ? 6 : 5) : ($numeric && ! $upper && ! $lower ? ($other ? -2 : -6) : 0)); |
|
161 | + if ( ! $space) $extrabits -= 2; |
|
162 | 162 | else if (count(explode(" ", preg_replace('/\s+/', " ", $password))) > 3) $extrabits++; |
163 | 163 | $result = self::getNISTNumBits($password, true) + $extrabits; |
164 | 164 | |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | $found = false; |
335 | - while (!$found && $x2 - $x >= $minwordlen) |
|
335 | + while ( ! $found && $x2 - $x >= $minwordlen) |
|
336 | 336 | { |
337 | - $word = "/\\n" . substr($password, $x, $minwordlen); |
|
338 | - for ($x3 = $x + $minwordlen; $x3 < $x2; $x3++) $word .= "(" . $password{$x3}; |
|
337 | + $word = "/\\n".substr($password, $x, $minwordlen); |
|
338 | + for ($x3 = $x + $minwordlen; $x3 < $x2; $x3++) $word .= "(".$password{$x3}; |
|
339 | 339 | for ($x3 = $x + $minwordlen; $x3 < $x2; $x3++) $word .= ")?"; |
340 | 340 | $word .= "\\n/"; |
341 | 341 | |
342 | 342 | preg_match_all($word, $data, $matches); |
343 | - if (!count($matches[0])) |
|
343 | + if ( ! count($matches[0])) |
|
344 | 344 | { |
345 | 345 | $password{$x} = "*"; |
346 | 346 | $x++; |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | 'password' => $this->input->post('password') |
72 | 72 | ]; |
73 | 73 | |
74 | - $remember = (bool)$this->input->post('remember'); |
|
74 | + $remember = (bool) $this->input->post('remember'); |
|
75 | 75 | |
76 | 76 | if ($auth->login($post_data, $remember)) |
77 | 77 | { |
78 | 78 | // Is the user being forced to reset their password? |
79 | 79 | if ($auth->user()['force_pass_reset'] == 1) |
80 | 80 | { |
81 | - redirect( Route::named('change_pass') ); |
|
81 | + redirect(Route::named('change_pass')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | unset($_SESSION['redirect_url']); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | if ($auth->registerUser($post_data)) |
136 | 136 | { |
137 | 137 | $this->setMessage(lang('auth.did_register'), 'success'); |
138 | - redirect( Route::named('login') ); |
|
138 | + redirect(Route::named('login')); |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | if ($auth->activateUser($post_data)) |
169 | 169 | { |
170 | 170 | $this->setMessage(lang('auth.did_activate'), 'success'); |
171 | - redirect( Route::named('login') ); |
|
171 | + redirect(Route::named('login')); |
|
172 | 172 | } |
173 | 173 | else |
174 | 174 | { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if ($auth->remindUser($this->input->post('email'))) |
202 | 202 | { |
203 | 203 | $this->setMessage(lang('auth.send_success'), 'success'); |
204 | - redirect( Route::named('reset_pass') ); |
|
204 | + redirect(Route::named('reset_pass')); |
|
205 | 205 | } |
206 | 206 | else |
207 | 207 | { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | if ($auth->resetPassword($credentials, $password, $pass_confirm)) |
237 | 237 | { |
238 | 238 | $this->setMessage(lang('auth.new_password_success'), 'success'); |
239 | - redirect( Route::named('login') ); |
|
239 | + redirect(Route::named('login')); |
|
240 | 240 | } |
241 | 241 | else |
242 | 242 | { |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | $this->load->model('user_model'); |
268 | 268 | $auth->useModel($this->user_model); |
269 | 269 | |
270 | - if (! $auth->isLoggedIn()) |
|
270 | + if ( ! $auth->isLoggedIn()) |
|
271 | 271 | { |
272 | - redirect( Route::named('login') ); |
|
272 | + redirect(Route::named('login')); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | $this->load->helper('form'); |
@@ -281,35 +281,35 @@ discard block |
||
281 | 281 | $pass_confirm = $this->input->post('pass_confirm'); |
282 | 282 | |
283 | 283 | // Does the current password match? |
284 | - if (! password_verify($current_pass, $auth->user()['password_hash'])) |
|
284 | + if ( ! password_verify($current_pass, $auth->user()['password_hash'])) |
|
285 | 285 | { |
286 | - $this->setMessage( lang('auth.bad_current_pass'), 'warning'); |
|
287 | - redirect( current_url() ); |
|
286 | + $this->setMessage(lang('auth.bad_current_pass'), 'warning'); |
|
287 | + redirect(current_url()); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Do the passwords match? |
291 | 291 | if ($password != $pass_confirm) |
292 | 292 | { |
293 | - $this->setMessage( lang('auth.pass_must_match'), 'warning'); |
|
294 | - redirect( current_url() ); |
|
293 | + $this->setMessage(lang('auth.pass_must_match'), 'warning'); |
|
294 | + redirect(current_url()); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | $hash = \Myth\Auth\Password::hashPassword($password); |
298 | 298 | |
299 | - if (! $this->user_model->update( $auth->id(), ['password_hash' => $hash, 'force_pass_reset' => 0]) ) |
|
299 | + if ( ! $this->user_model->update($auth->id(), ['password_hash' => $hash, 'force_pass_reset' => 0])) |
|
300 | 300 | { |
301 | - $this->setMessage( 'Error: '. $this->user_model->error(), 'danger'); |
|
302 | - redirect( current_url() ); |
|
301 | + $this->setMessage('Error: '.$this->user_model->error(), 'danger'); |
|
302 | + redirect(current_url()); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | $redirect_url = $this->session->userdata('redirect_url'); |
306 | 306 | unset($_SESSION['redirect_url']); |
307 | 307 | |
308 | - $this->setMessage( lang('auth.new_password_success'), 'success' ); |
|
308 | + $this->setMessage(lang('auth.new_password_success'), 'success'); |
|
309 | 309 | |
310 | 310 | $auth->logout(); |
311 | 311 | |
312 | - redirect( Route::named('login') ); |
|
312 | + redirect(Route::named('login')); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $this->addScript('register.js'); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // Convert the milliseconds to seconds. |
49 | 49 | $target_time = $target_time / 1000; |
50 | 50 | |
51 | - CLI::write('Testing for password hash value with a target time of '. $target_time .' seconds...'); |
|
51 | + CLI::write('Testing for password hash value with a target time of '.$target_time.' seconds...'); |
|
52 | 52 | |
53 | 53 | // Taken from the PHP manual |
54 | 54 | $cost = 8; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $end = microtime(true); |
60 | 60 | } while (($end - $start) < $target_time); |
61 | 61 | |
62 | - CLI::write("Hash value should be set to: ". CLI::color($cost, 'green')); |
|
62 | + CLI::write("Hash value should be set to: ".CLI::color($cost, 'green')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //-------------------------------------------------------------------- |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @since Version 1.0 |
31 | 31 | */ |
32 | 32 | |
33 | -if (! function_exists('isStrongPassword')) |
|
33 | +if ( ! function_exists('isStrongPassword')) |
|
34 | 34 | { |
35 | 35 | /** |
36 | 36 | * Works with Myth\Auth\Password to enforce a strong password. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $strong = \Myth\Auth\Password::isStrongPassword($password, $min_strength, $use_dict); |
47 | 47 | |
48 | - if (! $strong) |
|
48 | + if ( ! $strong) |
|
49 | 49 | { |
50 | 50 | if (isset(get_instance()->form_validation)) |
51 | 51 | { |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | $lang['auth.password_strength'] = 'Password Strength'; |
28 | 28 | $lang['auth.pass_not_strong'] = 'The Password must be stronger.'; |
29 | 29 | |
30 | -$lang['auth.have_account'] = 'Already a member? <a href="'. site_url( \Myth\Route::named('login') ) .'">Sign In</a>'; |
|
31 | -$lang['auth.need_account'] = 'Need an Account? <a href="'. site_url( \Myth\Route::named('register') ) .'">Sign Up</a>'; |
|
32 | -$lang['auth.forgot_pass'] = '<a href="'. site_url( \Myth\Route::named('forgot_pass') ) .'">Forgot your Password?</a>'; |
|
30 | +$lang['auth.have_account'] = 'Already a member? <a href="'.site_url(\Myth\Route::named('login')).'">Sign In</a>'; |
|
31 | +$lang['auth.need_account'] = 'Need an Account? <a href="'.site_url(\Myth\Route::named('register')).'">Sign Up</a>'; |
|
32 | +$lang['auth.forgot_pass'] = '<a href="'.site_url(\Myth\Route::named('forgot_pass')).'">Forgot your Password?</a>'; |
|
33 | 33 | |
34 | 34 | $lang['auth.first_name'] = 'First Name'; |
35 | 35 | $lang['auth.last_name'] = 'Last Name'; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $lang['auth.activate'] = 'Activate'; |
57 | 57 | $lang['auth.inactive_account'] = 'Your account is not active.'; |
58 | 58 | |
59 | -$lang['auth.register_subject'] = "Open to activate your account at ". config_item('site.name'); |
|
59 | +$lang['auth.register_subject'] = "Open to activate your account at ".config_item('site.name'); |
|
60 | 60 | $lang['auth.activate_no_user'] = 'Unable to find a user with those credentials.'; |
61 | 61 | $lang['auth.remind_subject'] = "Here's how to reset your password..."; |
62 | 62 | $lang['auth.need_reset_code'] = 'You must provide the Reset Code.'; |