Skip to content

Commit d0bc6d6

Browse files
committed
fixed array operator parsing, updated migration and composer json
1 parent e29e8b9 commit d0bc6d6

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
],
1212
"require": {
1313
"php": ">=5.4.0",
14-
"illuminate/support": "4.2.x|~5.0"
14+
"illuminate/support": "4.2.x|~5.0",
15+
"illuminate/database": "4.2.x|~5.0"
1516
},
1617
"autoload": {
1718
"classmap": [

src/Kodeine/Acl/Helper/Helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ protected function toDotPermissions(array $permissions)
3737

3838
protected function parseOperator($str)
3939
{
40+
// if its an array lets use
41+
// and operator by default
42+
if (is_array($str)) {
43+
$str = implode(',', $str);
44+
}
45+
4046
if (preg_match('/([,|])(?:\s+)?/', $str, $m)) {
4147
return $m[1] == '|' ? 'or' : 'and';
4248
}

src/Kodeine/Acl/Models/Eloquent/Role.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function can($permission, $operator = null, $mergePermissions = [])
8484
protected function canWithAnd($permission, $permissions)
8585
{
8686
foreach ($permission as $check) {
87-
if ( ! in_array($check, $permissions) || $permissions[$check] != true ) {
87+
if ( ! in_array($check, $permissions) || ! isset($permissions[$check]) || $permissions[$check] != true ) {
8888
return false;
8989
}
9090
}
@@ -100,7 +100,7 @@ protected function canWithAnd($permission, $permissions)
100100
protected function canWithOr($permission, $permissions)
101101
{
102102
foreach ($permission as $check) {
103-
if ( in_array($check, $permissions) && $permissions[$check] == true ) {
103+
if ( in_array($check, $permissions) && isset($permissions[$check]) && $permissions[$check] == true ) {
104104
return true;
105105
}
106106
}

src/migrations/2015_02_07_172649_create_permissions_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function up()
1515
{
1616
Schema::create('permissions', function (Blueprint $table) {
1717
$table->increments('id');
18+
$table->integer('inherit_id')->index();
1819
$table->string('name')->index();
1920
$table->string('slug')->index();
2021
$table->text('description')->nullable();

0 commit comments

Comments
 (0)