@@ -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 | //-------------------------------------------------------------------- |
@@ -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.'; |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?= form_open( current_url(), ['id' => 'login_form']); ?> |
|
| 1 | +<?= form_open(current_url(), ['id' => 'login_form']); ?> |
|
| 2 | 2 | |
| 3 | 3 | <h2 class="form-signin-heading"><?= lang('auth.signin') ?></h2> |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?= form_open( current_url(), ['id' => 'join_form'] ) ?> |
|
| 1 | +<?= form_open(current_url(), ['id' => 'join_form']) ?> |
|
| 2 | 2 | |
| 3 | 3 | <h2 class="form-signin-heading"><?= lang('auth.register') ?></h2> |
| 4 | 4 | |