Skip to content

Commit 673b7ac

Browse files
Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
1 parent ba89e06 commit 673b7ac

File tree

10 files changed

+431
-431
lines changed

10 files changed

+431
-431
lines changed

api/application/controllers/cli.php

+31-31
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public function install()
1414

1515
// create acl table
1616
$fields = array(
17-
'key' => array(
18-
'type' => 'VARCHAR',
19-
'constraint' => '255'
17+
'key' => array(
18+
'type' => 'VARCHAR',
19+
'constraint' => '255'
2020
),
21-
'value' => array(
22-
'type' => 'TEXT'
21+
'value' => array(
22+
'type' => 'TEXT'
2323
)
2424
);
2525
$this->dbforge->drop_table('acl');
@@ -29,21 +29,21 @@ public function install()
2929

3030
// create users table
3131
$fields = array(
32-
'id' => array(
33-
'type' => 'INT',
34-
'constraint' => 11,
35-
'null' => false,
36-
'auto_increment' => true
32+
'id' => array(
33+
'type' => 'INT',
34+
'constraint' => 11,
35+
'null' => false,
36+
'auto_increment' => true
3737
),
38-
'email' => array(
39-
'type' => 'VARCHAR',
40-
'constraint' => '255',
41-
'null' => false
38+
'email' => array(
39+
'type' => 'VARCHAR',
40+
'constraint' => '255',
41+
'null' => false
4242
),
43-
'password' => array(
44-
'type' => 'VARCHAR',
45-
'constraint' => '255',
46-
'null' => false
43+
'password' => array(
44+
'type' => 'VARCHAR',
45+
'constraint' => '255',
46+
'null' => false
4747
)
4848
);
4949
$this->dbforge->drop_table('users');
@@ -52,27 +52,27 @@ public function install()
5252
$this->dbforge->create_table('users');
5353

5454
// default resources to protect
55-
$acl = new ACL();
55+
$acl = new ACL();
5656
$acl->addResource('administrator');
5757
$acl->addResource('user');
5858
$acl->addResource('role');
5959
$acl->addResource('resource');
6060

6161
// create administrator role and grant all access
6262
$acl->addRole('administrator');
63-
$acl->addPermissions('administrator', 'administrator', 'read');
64-
$acl->addPermissions('administrator', 'user', ['create', 'read', 'update', 'delete']);
65-
$acl->addPermissions('administrator', 'role', ['create', 'read', 'update', 'delete']);
66-
$acl->addPermissions('administrator', 'resource', ['create', 'read', 'update', 'delete']);
63+
$acl->addPermissions('administrator', 'administrator', 'read');
64+
$acl->addPermissions('administrator', 'user', ['create', 'read', 'update', 'delete']);
65+
$acl->addPermissions('administrator', 'role', ['create', 'read', 'update', 'delete']);
66+
$acl->addPermissions('administrator', 'resource', ['create', 'read', 'update', 'delete']);
6767

68-
// custom resources
68+
// custom resources
6969

70-
// ...
71-
// ... add your custom resources to protect here
72-
// ...
70+
// ...
71+
// ... add your custom resources to protect here
72+
// ...
7373

7474
if (!defined('PHPUNIT_TEST'))
75-
echo "installed\r\n";
75+
echo "installed\r\n";
7676
}
7777

7878
public function add($type, $email, $password)
@@ -84,16 +84,16 @@ public function add($type, $email, $password)
8484
$this->Users->register($email, $password);
8585

8686
if (!defined('PHPUNIT_TEST'))
87-
echo "user added\r\n";
87+
echo "user added\r\n";
8888
}
8989
else if ($type == 'administrator')
9090
{
9191
$id = $this->Users->register($email, $password);
92-
$acl = new ACL();
92+
$acl = new ACL();
9393
$acl->addUserRoles($id, 'administrator');
9494

9595
if (!defined('PHPUNIT_TEST'))
96-
echo "administrator added\r\n";
96+
echo "administrator added\r\n";
9797
}
9898
}
9999

api/application/controllers/resource.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public function table()
1212
$role = $this->input->post('role');
1313
$table = $this->Resources->table($params, $role);
1414
$output['status'] = true;
15-
$output['total'] = $table['total'];
16-
$output['resources'] = $table['resources'];
15+
$output['total'] = $table['total'];
16+
$output['resources'] = $table['resources'];
1717
return $output;
1818
});
1919
}

api/application/core/REST_Controller.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
class REST_Controller extends CI_Controller {
44

5-
function __construct()
6-
{
7-
parent::__construct();
8-
}
5+
function __construct()
6+
{
7+
parent::__construct();
8+
}
99

1010
private function __load()
1111
{
@@ -53,7 +53,7 @@ public function read()
5353
$id = $this->input->post('id');
5454
$resource = $this->model->read($id);
5555
$output['status'] = true;
56-
$output[$this->resource] = $resource;
56+
$output[$this->resource] = $resource;
5757
return $output;
5858
});
5959
}
@@ -67,7 +67,7 @@ public function update()
6767
$resource = json_decode(stripslashes($this->input->post($this->resource)));
6868
$resource = $this->model->update($resource);
6969
$output['status'] = true;
70-
$output[$this->resource] = $resource;
70+
$output[$this->resource] = $resource;
7171
return $output;
7272
});
7373
}

api/application/helpers/acl_helper.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
<?php
22

33
abstract class Backend {
4-
abstract function read($key);
5-
abstract function write($key, $value);
4+
abstract function read($key);
5+
abstract function write($key, $value);
66
}
77

88
class BackendRedis extends Backend {
9-
private $redis;
9+
private $redis;
1010

11-
function __construct($host, $port) {
12-
$this->redis = new Redis();
13-
$this->redis->connect($host, $port);
14-
}
11+
function __construct($host, $port) {
12+
$this->redis = new Redis();
13+
$this->redis->connect($host, $port);
14+
}
1515

16-
function read($key) {
17-
$value = $this->redis->get($key);
18-
return empty($value) ? array() : json_decode($value);
19-
}
16+
function read($key) {
17+
$value = $this->redis->get($key);
18+
return empty($value) ? array() : json_decode($value);
19+
}
2020

21-
function write($key, $value) {
22-
$this->redis->set($key, json_encode($value));
23-
}
21+
function write($key, $value) {
22+
$this->redis->set($key, json_encode($value));
23+
}
2424
}
2525

2626
class BackendCodeIgniter extends Backend {
27-
private $db;
27+
private $db;
2828

29-
function __construct() {
30-
$ci = &get_instance();
31-
$this->db = $ci->db;
32-
}
29+
function __construct() {
30+
$ci = &get_instance();
31+
$this->db = $ci->db;
32+
}
3333

34-
function read($key) {
34+
function read($key) {
3535
$this->db->select('value');
3636
$this->db->from('acl');
3737
$this->db->where('key', $key);
@@ -43,9 +43,9 @@ function read($key) {
4343
return json_decode($result[0]->value);
4444
}
4545
return array();
46-
}
46+
}
4747

48-
function write($key, $value) {
48+
function write($key, $value) {
4949
$this->db->select('value');
5050
$this->db->from('acl');
5151
$this->db->where('key', $key);

0 commit comments

Comments
 (0)