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
cdb9d297
Commit
cdb9d297
authored
6 years ago
by
Simon Leipold
Browse files
Options
Downloads
Patches
Plain Diff
1036804 Berechtigung - Entitätsübersicht - Refactoring in PermissionDetail
parent
0e6870e0
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/onInsert.js
+4
-14
4 additions, 14 deletions
...ermissionDetail_entity/recordcontainers/jdito/onInsert.js
process/Permission_lib/process.js
+63
-0
63 additions, 0 deletions
process/Permission_lib/process.js
with
67 additions
and
14 deletions
entity/PermissionDetail_entity/recordcontainers/jdito/onInsert.js
+
4
−
14
View file @
cdb9d297
...
...
@@ -29,9 +29,6 @@ if (checkInput([role, entity, accesstype, condtype, action])) {
if
(
permissionsetid
==
undefined
||
permissionsetid
==
null
||
permissionsetid
==
""
)
{
// no fitting permissionset found - insert new permissionset
table
=
"
AB_PERMISSIONSET
"
;
cols
=
db
.
getColumns
(
table
);
permissionsetid
=
util
.
getNewUUID
();
var
rootpermissionset
;
if
(
accesstype
==
"
E
"
)
rootpermissionset
=
""
;
...
...
@@ -39,30 +36,23 @@ if (checkInput([role, entity, accesstype, condtype, action])) {
sqlStr
=
"
select AB_PERMISSIONSETID from AB_PERMISSIONSET where ENTITY_ID = '
"
+
entity
+
"
' and ROLE_ID = '
"
+
role
+
"
' and ACCESSTYPE = 'E'
"
;
rootpermissionset
=
db
.
cell
(
sqlStr
);
}
vals
=
[
permissionsetid
,
rootpermissionset
,
accesstype
,
entity
,
field
,
role
];
db
.
insertData
(
table
,
cols
,
null
,
vals
);
permissionsetid
=
PermissionUtil
.
insertNewPermissionSet
(
rootpermissionset
,
entity
,
role
,
field
,
accesstype
)
}
// check if insert or update
table
=
"
AB_PERMISSION
"
;
var
existingPermId
=
permExists
(
role
,
entity
,
field
,
accesstype
,
condtype
,
condition
);
if
(
existingPermId
!=
null
&&
existingPermId
!=
undefined
&&
existingPermId
!=
""
)
{
permissionid
=
existingPermId
;
}
else
{
// permission doesnt exist, insert new permission
cols
=
db
.
getColumns
(
table
);
vals
=
[
permissionid
,
permissionsetid
,
condition
,
condtype
];
db
.
insertData
(
table
,
cols
,
null
,
vals
);
// new permissionid is needed to link actions to the permission in the next step
permissionid
=
PermissionUtil
.
insertNewPermission
(
permissionsetid
,
condition
,
condtype
)
}
// insert new permissionaction
table
=
"
AB_PERMISSIONACTION
"
;
cols
=
db
.
getColumns
(
table
);
var
actionNew
=
action
.
split
(
"
,
"
);
var
dbInserts
=
0
;
for
each
(
let
permaction
in
actionNew
)
{
vals
=
[
util
.
getNewUUID
(),
permissionid
,
permaction
];
dbInserts
+=
db
.
insertData
(
table
,
cols
,
null
,
vals
);
PermissionUtil
.
insertNewPermissionAction
(
permissionid
,
permaction
);
}
}
...
...
This diff is collapsed.
Click to expand it.
process/Permission_lib/process.js
+
63
−
0
View file @
cdb9d297
import
(
"
system.util
"
);
import
(
"
system.logging
"
);
import
(
"
system.db
"
);
import
(
"
Sql_lib
"
);
...
...
@@ -379,6 +380,68 @@ PermissionUtil.containsDuplicateActions = function(pPermId, pActionNew) {
return
res
;
}
/**
* Inserts a new instance of a permission set into AB_PERMISSIONSET.
*
* @param {String} pParentPermSet The parent permission set, empty if root node
*
* @param {String} pEntity The entity to which the PermissionSet is linked
*
* @param {String} pRole The Role to which the PermissionSet is linked
*
* @param {String} pField The Field to which the PermissionSet is linked
*
* @param {String} pAccessType Entity, Record or Field (E, R, F)
*
* @result {Integer} returns the id of the inserted permission set
*/
PermissionUtil
.
insertNewPermissionSet
=
function
(
pParentPermSet
,
pEntity
,
pRole
,
pField
,
pAccessType
)
{
var
table
=
"
AB_PERMISSIONSET
"
;
var
cols
=
db
.
getColumns
(
table
);
var
permsetid
=
util
.
getNewUUID
();
var
vals
=
[
permsetid
,
pParentPermSet
,
pAccessType
,
pEntity
,
pField
,
pRole
];
db
.
insertData
(
table
,
cols
,
null
,
vals
);
return
permsetid
;
}
/**
* Inserts a new instance of a permission into AB_PERMISSION.
*
* @param {String} pParentPermSet The parent permission set
*
* @param {String} pCond The entity to which the PermissionSet is linked
*
* @param {String} pCondType The Role to which the PermissionSet is linked
*
* @result {Integer} returns the id of the inserted permission
*/
PermissionUtil
.
insertNewPermission
=
function
(
pParentPermSet
,
pCond
,
pCondType
)
{
var
table
=
"
AB_PERMISSION
"
;
var
cols
=
db
.
getColumns
(
table
);
var
permid
=
util
.
getNewUUID
();
var
vals
=
[
permid
,
pParentPermSet
,
pCond
,
pCondType
];
db
.
insertData
(
table
,
cols
,
null
,
vals
);
return
permid
;
}
/**
* Inserts a new instance of a permission action into AB_PERMISSIONACTION.
*
* @param {String} pParentPerm The parent permission
*
* @param {String} pAction Action (view, create,...)
*
* @result {Integer} returns the id of the inserted permission action
*/
PermissionUtil
.
insertNewPermissionAction
=
function
(
pParentPerm
,
pAction
)
{
var
table
=
"
AB_PERMISSIONACTION
"
;
var
cols
=
db
.
getColumns
(
table
);
var
permactionid
=
util
.
getNewUUID
();
var
vals
=
[
permactionid
,
pParentPerm
,
pAction
];
db
.
insertData
(
table
,
cols
,
null
,
vals
);
return
permactionid
;
}
function
arrDiff
(
arr1
,
arr2
)
{
var
helperArr
=
[],
diff
=
[];
...
...
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