Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dataprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Extensions
dataprocessor
Commits
257dfcc0
Commit
257dfcc0
authored
10 months ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue with API permissions and performance improvement.
parent
e11a83e6
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+3
-1
3 additions, 1 deletion
CHANGELOG.md
Civi/DataProcessor/Output/Api.php
+6
-1
6 additions, 1 deletion
Civi/DataProcessor/Output/Api.php
dataprocessor.php
+6
-27
6 additions, 27 deletions
dataprocessor.php
info.xml
+1
-1
1 addition, 1 deletion
info.xml
with
16 additions
and
30 deletions
CHANGELOG.md
+
3
−
1
View file @
257dfcc0
# Version 1.107 (not yet released)
# Version 1.107
*
Fixed issue with API permissions and performance improvement.
# Version 1.106
...
...
This diff is collapsed.
Click to expand it.
Civi/DataProcessor/Output/Api.php
+
6
−
1
View file @
257dfcc0
...
...
@@ -175,13 +175,14 @@ class Api extends AbstractApi implements OutputInterface {
public
static
function
buildConfigContainer
(
ContainerBuilder
$containerBuilder
)
{
// Load the entities.
$dao
=
\CRM_Core_DAO
::
executeQuery
(
"
SELECT DISTINCT o.api_entity, api_action, api_count_action
SELECT DISTINCT o.api_entity, api_action, api_count_action
, o.permission
FROM civicrm_data_processor_output o
INNER JOIN civicrm_data_processor p ON o.data_processor_id = p.id
WHERE p.is_active = 1
"
);
$entities
=
array
();
$actions
=
array
();
$permissions
=
array
();
while
(
$dao
->
fetch
())
{
if
(
$dao
->
api_entity
)
{
...
...
@@ -195,10 +196,14 @@ class Api extends AbstractApi implements OutputInterface {
}
$actions
[
$dao
->
api_entity
][]
=
$dao
->
api_action
;
$actions
[
$dao
->
api_entity
][]
=
$dao
->
api_count_action
;
foreach
(
$actions
[
$dao
->
api_entity
]
as
$action
)
{
$permissions
[
$dao
->
api_entity
][
$action
]
=
[
$dao
->
permission
];
}
}
}
$containerBuilder
->
setParameter
(
'entity_names'
,
$entities
);
$containerBuilder
->
setParameter
(
'action_names'
,
$actions
);
$containerBuilder
->
setParameter
(
'api3_permissions'
,
$permissions
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
dataprocessor.php
+
6
−
27
View file @
257dfcc0
...
...
@@ -67,34 +67,13 @@ function dataprocessor_civicrm_permission(&$permissions) {
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterAPIPermissions/
*/
function
dataprocessor_civicrm_alterAPIPermissions
(
$entity
,
$action
,
&
$params
,
&
$permissions
)
{
// We have to check the camelcase and the non camel case names
$entityNonCamelCase
=
_civicrm_api_get_entity_name_from_camel
(
$entity
);
$entityCamelCase
=
_civicrm_api_get_camel_name
(
$entity
);
$api_action
=
$action
;
if
(
$action
==
'getfields'
&&
isset
(
$params
[
'api_action'
]))
{
$api_action
=
$params
[
'api_action'
];
}
$actionNonCamelCase
=
_civicrm_api_get_entity_name_from_camel
(
$api_action
);
$actionCamelCase
=
_civicrm_api_get_camel_name
(
$api_action
);
$dao
=
CRM_Core_DAO
::
executeQuery
(
"
SELECT *
FROM civicrm_data_processor_output o
INNER JOIN civicrm_data_processor p ON o.data_processor_id = p.id
WHERE p.is_active = 1
AND (LOWER(api_entity) = LOWER(%1) OR LOWER(api_entity) = LOWER(%2))
AND (
LOWER(api_action) = LOWER(%3) OR LOWER(api_count_action) = LOWER(%3)
OR LOWER(api_action) = LOWER(%4) OR LOWER(api_count_action) = LOWER(%4)
)"
,
array
(
1
=>
array
(
$entityCamelCase
,
'String'
),
2
=>
array
(
$entityNonCamelCase
,
'String'
),
3
=>
array
(
$actionNonCamelCase
,
'String'
),
4
=>
array
(
$actionCamelCase
,
'String'
))
);
while
(
$dao
->
fetch
())
{
$permissions
[
$entity
][
$action
]
=
array
(
$dao
->
permission
);
$config
=
\Civi\DataProcessor\Config\ConfigContainer
::
getInstance
();
foreach
(
$config
->
getParameter
(
'api3_permissions'
)
as
$e
=>
$actions
)
{
foreach
(
$actions
as
$a
=>
$p
)
{
$permissions
[
$e
][
$a
]
=
$p
;
}
}
if
(
$entity
==
'data_processor_output'
&&
$action
==
'get'
)
{
$permissions
[
'data_processor_output'
][
'get'
]
=
[
[
"access dataprocessor definitions"
,
"administer CiviCRM"
]
...
...
This diff is collapsed.
Click to expand it.
info.xml
+
1
−
1
View file @
257dfcc0
...
...
@@ -15,7 +15,7 @@
<url
desc=
"Licensing"
>
http://www.gnu.org/licenses/agpl-3.0.html
</url>
</urls>
<releaseDate>
2024-05-30
</releaseDate>
<version>
1.107
-dev
</version>
<version>
1.107
</version>
<develStage>
stable
</develStage>
<compatibility>
<ver>
5.37
</ver>
...
...
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