Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
458615f8
Commit
458615f8
authored
May 27, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2
parents
5f269399
212649c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
DbManager.php
framework/yii/rbac/DbManager.php
+29
-16
No files found.
framework/yii/rbac/DbManager.php
View file @
458615f8
...
...
@@ -160,7 +160,8 @@ class DbManager extends Manager
throw
new
InvalidCallException
(
"Cannot add '
$childName
' as a child of '
$itemName
'. A loop has been detected."
);
}
$this
->
db
->
createCommand
()
->
insert
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$itemName
,
'child'
=>
$childName
));
->
insert
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$itemName
,
'child'
=>
$childName
))
->
execute
();
return
true
;
}
else
{
throw
new
Exception
(
"Either '
$itemName
' or '
$childName
' does not exist."
);
...
...
@@ -177,7 +178,8 @@ class DbManager extends Manager
public
function
removeItemChild
(
$itemName
,
$childName
)
{
return
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$itemName
,
'child'
=>
$childName
))
>
0
;
->
delete
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$itemName
,
'child'
=>
$childName
))
->
execute
()
>
0
;
}
/**
...
...
@@ -248,7 +250,8 @@ class DbManager extends Manager
'item_name'
=>
$itemName
,
'biz_rule'
=>
$bizRule
,
'data'
=>
serialize
(
$data
),
));
))
->
execute
();
return
new
Assignment
(
array
(
'manager'
=>
$this
,
'userId'
=>
$userId
,
...
...
@@ -267,7 +270,8 @@ class DbManager extends Manager
public
function
revoke
(
$userId
,
$itemName
)
{
return
$this
->
db
->
createCommand
()
->
delete
(
$this
->
assignmentTable
,
array
(
'user_id'
=>
$userId
,
'item_name'
=>
$itemName
))
>
0
;
->
delete
(
$this
->
assignmentTable
,
array
(
'user_id'
=>
$userId
,
'item_name'
=>
$itemName
))
->
execute
()
>
0
;
}
/**
...
...
@@ -358,7 +362,8 @@ class DbManager extends Manager
),
array
(
'user_id'
=>
$assignment
->
userId
,
'item_name'
=>
$assignment
->
itemName
,
));
))
->
execute
();
}
/**
...
...
@@ -431,7 +436,8 @@ class DbManager extends Manager
'description'
=>
$description
,
'biz_rule'
=>
$bizRule
,
'data'
=>
serialize
(
$data
),
));
))
->
execute
();
return
new
Item
(
array
(
'manager'
=>
$this
,
'name'
=>
$name
,
...
...
@@ -451,12 +457,15 @@ class DbManager extends Manager
{
if
(
$this
->
usingSqlite
())
{
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemChildTable
,
array
(
'or'
,
'parent=:name'
,
'child=:name'
),
array
(
':name'
=>
$name
));
->
delete
(
$this
->
itemChildTable
,
array
(
'or'
,
'parent=:name'
,
'child=:name'
),
array
(
':name'
=>
$name
))
->
execute
();
$this
->
db
->
createCommand
()
->
delete
(
$this
->
assignmentTable
,
array
(
'item_name'
=>
$name
));
->
delete
(
$this
->
assignmentTable
,
array
(
'item_name'
=>
$name
))
->
execute
();
}
return
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemTable
,
array
(
'name'
=>
$name
))
>
0
;
->
delete
(
$this
->
itemTable
,
array
(
'name'
=>
$name
))
->
execute
()
>
0
;
}
/**
...
...
@@ -497,11 +506,14 @@ class DbManager extends Manager
{
if
(
$this
->
usingSqlite
()
&&
$oldName
!==
null
&&
$item
->
getName
()
!==
$oldName
)
{
$this
->
db
->
createCommand
()
->
update
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$item
->
getName
()),
array
(
'parent'
=>
$oldName
));
->
update
(
$this
->
itemChildTable
,
array
(
'parent'
=>
$item
->
getName
()),
array
(
'parent'
=>
$oldName
))
->
execute
();
$this
->
db
->
createCommand
()
->
update
(
$this
->
itemChildTable
,
array
(
'child'
=>
$item
->
getName
()),
array
(
'child'
=>
$oldName
));
->
update
(
$this
->
itemChildTable
,
array
(
'child'
=>
$item
->
getName
()),
array
(
'child'
=>
$oldName
))
->
execute
();
$this
->
db
->
createCommand
()
->
update
(
$this
->
assignmentTable
,
array
(
'item_name'
=>
$item
->
getName
()),
array
(
'item_name'
=>
$oldName
));
->
update
(
$this
->
assignmentTable
,
array
(
'item_name'
=>
$item
->
getName
()),
array
(
'item_name'
=>
$oldName
))
->
execute
();
}
$this
->
db
->
createCommand
()
...
...
@@ -513,7 +525,8 @@ class DbManager extends Manager
'data'
=>
serialize
(
$item
->
data
),
),
array
(
'name'
=>
$oldName
===
null
?
$item
->
getName
()
:
$oldName
,
));
))
->
execute
();
}
/**
...
...
@@ -529,8 +542,8 @@ class DbManager extends Manager
public
function
clearAll
()
{
$this
->
clearAssignments
();
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemChildTable
);
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemTable
);
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemChildTable
)
->
execute
()
;
$this
->
db
->
createCommand
()
->
delete
(
$this
->
itemTable
)
->
execute
()
;
}
/**
...
...
@@ -538,7 +551,7 @@ class DbManager extends Manager
*/
public
function
clearAssignments
()
{
$this
->
db
->
createCommand
()
->
delete
(
$this
->
assignmentTable
);
$this
->
db
->
createCommand
()
->
delete
(
$this
->
assignmentTable
)
->
execute
()
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment