Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
86b5a400
Commit
86b5a400
authored
5 years ago
by
Simon Leipold
Browse files
Options
Downloads
Patches
Plain Diff
Permissions - onDelete deletes now also all subordinated permissions
parent
cbcd8dcd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
entity/PermissionDetail_entity/recordcontainers/jdito/onDelete.js
+25
-5
25 additions, 5 deletions
...ermissionDetail_entity/recordcontainers/jdito/onDelete.js
process/Permission_lib/process.js
+13
-0
13 additions, 0 deletions
process/Permission_lib/process.js
with
38 additions
and
5 deletions
entity/PermissionDetail_entity/recordcontainers/jdito/onDelete.js
+
25
−
5
View file @
86b5a400
import
(
"
system.logging
"
);
import
(
"
system.tools
"
);
import
(
"
Sql_lib
"
);
import
(
"
system.neon
"
);
...
...
@@ -10,6 +11,7 @@ var permId = vars.get("$field.UID");
var
accessType
=
vars
.
get
(
"
$field.ACCESSTYPE
"
);
var
parentPermSetId
=
PermissionUtil
.
getParentSet
(
permId
);
var
linkedActions
=
PermissionUtil
.
getActions
([
permId
]);
var
noCond
=
"
{
\"
entity
\"
:
\"
"
+
vars
.
get
(
"
$field.ENTITY
"
)
+
"
\"
,
\"
filter
\"
:{
\"
type
\"
:
\"
group
\"
,
\"
operator
\"
:
\"
AND
\"
,
\"
childs
\"
:[]}}
"
;
var
sqlCondDelAction
=
SqlCondition
.
begin
()
.
and
(
"
ASYS_PERMISSIONACTION.ASYS_PERMISSIONACTIONID in ('
"
+
linkedActions
.
join
(
"
','
"
)
+
"
')
"
)
...
...
@@ -23,10 +25,10 @@ var sqlCondDelPermSet = SqlCondition.begin()
switch
(
accessType
)
{
case
"
E
"
:
var
allPermSets
=
PermissionUtil
.
getChildSetsOfSet
(
parentPermSetId
);
let
allPermSets
=
PermissionUtil
.
getChildSetsOfSet
(
parentPermSetId
);
allPermSets
.
push
(
parentPermSetId
);
var
allPerms
=
PermissionUtil
.
getPermissions
(
allPermSets
);
var
allPermActions
=
PermissionUtil
.
getActions
(
allPerms
);
let
allPerms
=
PermissionUtil
.
getPermissions
(
allPermSets
);
let
allPermActions
=
PermissionUtil
.
getActions
(
allPerms
);
sqlCondDelAction
=
SqlCondition
.
begin
()
.
and
(
"
ASYS_PERMISSIONACTION.ASYS_PERMISSIONACTIONID in ('
"
+
allPermActions
.
join
(
"
','
"
)
+
"
')
"
)
...
...
@@ -43,8 +45,26 @@ switch (accessType) {
db
.
deleteData
(
"
ASYS_PERMISSIONSET
"
,
sqlCondDelPermSet
,
alias
);
// delete all permission sets
break
;
default
:
db
.
deleteData
(
"
ASYS_PERMISSIONACTION
"
,
sqlCondDelAction
,
alias
);
// delete all actions of the selected permission
db
.
deleteData
(
"
ASYS_PERMISSION
"
,
sqlCondDelPerm
,
alias
);
// delete the selected permission
if
(
PermissionUtil
.
getCond
(
permId
)
==
""
||
PermissionUtil
.
getCond
(
permId
)
==
noCond
)
{
// check if permission is default or conditional permission
// default permission -> also have to delete sub permissions
let
allPerms
=
PermissionUtil
.
getPermissionWithCond
(
PermissionUtil
.
getParentSet
(
permId
));
allPerms
.
push
(
permId
);
let
allActions
=
PermissionUtil
.
getActions
(
allPerms
);
sqlCondDelAction
=
SqlCondition
.
begin
()
.
and
(
"
ASYS_PERMISSIONACTION.ASYS_PERMISSIONACTIONID in ('
"
+
allActions
.
join
(
"
','
"
)
+
"
')
"
)
.
build
();
sqlCondDelPerm
=
SqlCondition
.
begin
()
.
and
(
"
ASYS_PERMISSION.ASYS_PERMISSIONID in ('
"
+
allPerms
.
join
(
"
','
"
)
+
"
')
"
)
.
build
();
db
.
deleteData
(
"
ASYS_PERMISSIONACTION
"
,
sqlCondDelAction
,
alias
);
// delete all actions of the selected permission
db
.
deleteData
(
"
ASYS_PERMISSION
"
,
sqlCondDelPerm
,
alias
);
// delete the selected permission
}
else
{
// conditional permission -> only delete this permission
db
.
deleteData
(
"
ASYS_PERMISSIONACTION
"
,
sqlCondDelAction
,
alias
);
// delete all actions of the selected permission
db
.
deleteData
(
"
ASYS_PERMISSION
"
,
sqlCondDelPerm
,
alias
);
// delete the selected permission
}
break
;
}
...
...
This diff is collapsed.
Click to expand it.
process/Permission_lib/process.js
+
13
−
0
View file @
86b5a400
...
...
@@ -431,6 +431,19 @@ function PermissionUtil () {}
var
sqlStr
=
"
select CONDTYPE from
"
+
table
+
"
where ASYS_PERMISSIONID = '
"
+
pPermId
+
"
'
"
;
return
db
.
cell
(
sqlStr
,
alias
);
}
/**
* Returns the condition of a permission.
*
* @param {String} pPermId id of the permission which condition should be returned, mandatory
*
* @result {String} returns the condition of a permission
*/
PermissionUtil
.
getCond
=
function
(
pPermId
)
{
var
table
=
"
ASYS_PERMISSION
"
;
var
sqlStr
=
"
select COND from
"
+
table
+
"
where ASYS_PERMISSIONID = '
"
+
pPermId
+
"
'
"
;
return
db
.
cell
(
sqlStr
,
alias
);
}
/**
* Returns true if the permission exists, otherwise false.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment