Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
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
Development
CiviCRM Core
Commits
d6009096
Unverified
Commit
d6009096
authored
4 years ago
by
colemanw
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19796 from eileenmcnaughton/desc
[REF] Cleanup on permission code
parents
da28128b
b4d6a411
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Permission.php
+37
-32
37 additions, 32 deletions
CRM/Core/Permission.php
CRM/Core/Permission/Base.php
+1
-0
1 addition, 0 deletions
CRM/Core/Permission/Base.php
with
38 additions
and
32 deletions
CRM/Core/Permission.php
+
37
−
32
View file @
d6009096
...
...
@@ -589,44 +589,16 @@ class CRM_Core_Permission {
public
static
function
assembleBasicPermissions
(
$all
=
FALSE
,
$descriptions
=
FALSE
)
{
$config
=
CRM_Core_Config
::
singleton
();
$permissions
=
self
::
getCorePermissions
();
$permissions
=
array_merge
(
$permissions
,
self
::
getComponentPermissions
(
$all
));
// Add any permissions defined in hook_civicrm_permission implementations.
$module_permissions
=
$config
->
userPermissionClass
->
getAllModulePermissions
(
TRUE
);
$permissions
=
array_merge
(
$permissions
,
$module_permissions
);
if
(
!
$descriptions
)
{
foreach
(
$permissions
as
$name
=>
$attr
)
{
$permissions
[
$name
]
=
array_shift
(
$attr
);
}
}
if
(
!
$all
)
{
$components
=
CRM_Core_Component
::
getEnabledComponents
();
}
else
{
$components
=
CRM_Core_Component
::
getComponents
();
}
foreach
(
$components
as
$comp
)
{
$perm
=
$comp
->
getPermissions
(
$all
,
$descriptions
);
if
(
$perm
)
{
$info
=
$comp
->
getInfo
();
foreach
(
$perm
as
$p
=>
$attr
)
{
if
(
!
is_array
(
$attr
))
{
$attr
=
[
$attr
];
}
$attr
[
0
]
=
$info
[
'translatedName'
]
.
': '
.
$attr
[
0
];
if
(
$descriptions
)
{
$permissions
[
$p
]
=
$attr
;
}
else
{
$permissions
[
$p
]
=
$attr
[
0
];
}
}
}
}
// Add any permissions defined in hook_civicrm_permission implementations.
$module_permissions
=
$config
->
userPermissionClass
->
getAllModulePermissions
(
$descriptions
);
$permissions
=
array_merge
(
$permissions
,
$module_permissions
);
return
$permissions
;
}
...
...
@@ -1711,4 +1683,37 @@ class CRM_Core_Permission {
return
FALSE
;
}
/**
* @param bool $includeDisabled
*
* @return array
* @throws \CRM_Core_Exception
*/
protected
static
function
getComponentPermissions
(
bool
$includeDisabled
):
array
{
if
(
!
$includeDisabled
)
{
$components
=
CRM_Core_Component
::
getEnabledComponents
();
}
else
{
$components
=
CRM_Core_Component
::
getComponents
();
}
$permissions
=
[];
foreach
(
$components
as
$comp
)
{
$perm
=
$comp
->
getPermissions
(
$includeDisabled
,
TRUE
);
if
(
$perm
)
{
$info
=
$comp
->
getInfo
();
foreach
(
$perm
as
$p
=>
$attr
)
{
if
(
!
is_array
(
$attr
))
{
$attr
=
[
$attr
];
}
$attr
[
0
]
=
$info
[
'translatedName'
]
.
': '
.
$attr
[
0
];
$permissions
[
$p
]
=
$attr
;
}
}
}
return
$permissions
;
}
}
This diff is collapsed.
Click to expand it.
CRM/Core/Permission/Base.php
+
1
−
0
View file @
d6009096
...
...
@@ -395,6 +395,7 @@ class CRM_Core_Permission_Base {
* Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions().
*/
public
function
getAllModulePermissions
(
$descriptions
=
FALSE
)
{
// Passing in false here is to be deprecated.
$permissions
=
[];
CRM_Utils_Hook
::
permission
(
$permissions
);
...
...
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