Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository 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
WCMS
uw_cfg_common
Commits
c4640a09
Commit
c4640a09
authored
4 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-3921: updating function in UW permissions class to revoke or grant permissions
parent
3bce6be3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/UwPermissions/UwPermissions.php
+24
-13
24 additions, 13 deletions
src/UwPermissions/UwPermissions.php
with
24 additions
and
13 deletions
src/UwPermissions/UwPermissions.php
+
24
−
13
View file @
c4640a09
...
...
@@ -205,12 +205,14 @@ class UwPermissions {
}
/**
*
Add
UW permission to roles and save.
*
Grant/revoke
UW permission to roles and save.
*
* @parm array $permissions_to_add
* The array of permissions to be added.
* @parm array $permissions_to_process
* The array of permissions to be granted or revoked.
* @param string $type
* The type of permissions to be processed (grant/revoke).
*/
public
static
function
uw_
add
_permissions
(
array
$permissions_to_
add
)
{
public
static
function
uw_
grant_revoke
_permissions
(
array
$permissions_to_
process
,
string
$type
):
void
{
// Get the UW roles.
$uw_roles
=
UwPermissions
::
uw_get_roles
();
...
...
@@ -218,22 +220,31 @@ class UwPermissions {
// The array of uw permissions.
$uw_permissions
=
UwPermissions
::
uw_get_permissions_array
();
// Step through each of the permissions to
add and get teh featur
e.
foreach
(
$permissions_to_
add
as
$feature
=>
$permission_to_
add
)
{
// Step through each of the permissions to
grant/revok
e.
foreach
(
$permissions_to_
process
as
$feature
=>
$permission_to_
process
)
{
// Step through the feature and get the roles.
foreach
(
$permission_to_
add
as
$permission
=>
$roles
)
{
foreach
(
$permission_to_
process
as
$permission
=>
$roles
)
{
// Step through each of the roles and grant the permission.
// Step through each of the roles and grant
/revoke
the permission.
foreach
(
$roles
as
$role
)
{
// Step through each of the permissions that need to be granted
// for that actually permission and grant them for the specified
// uw role.
// Step through each of the permissions that need to be granted/revoke
// and grant/revoke for the specified uw role.
foreach
(
$uw_permissions
[
$feature
][
$permission
][
$role
]
as
$uw_perm
)
{
// Grant the permission for the specified role.
$uw_roles
[
$role
][
'object'
]
->
grantPermission
(
$uw_perm
);
// If type is grant, grant the permission for the role.
if
(
$type
==
'grant'
)
{
// Grant the permission for the specified role.
$uw_roles
[
$role
][
'object'
]
->
grantPermission
(
$uw_perm
);
}
// If the type is revoke, revoke the permission for the role.
elseif
(
$type
==
'revoke'
)
{
// Revoke the permission for the specified role.
$uw_roles
[
$role
][
'object'
]
->
revokePermission
(
$uw_perm
);
}
}
}
}
...
...
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