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
c0c45206
Unverified
Commit
c0c45206
authored
4 years ago
by
Seamus Lee
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #17144 from lcdservices/dev-core-1716
#1716
add customPre hook
parents
1626aaa2
048b069c
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/BAO/CustomValueTable.php
+24
-18
24 additions, 18 deletions
CRM/Core/BAO/CustomValueTable.php
CRM/Utils/Hook.php
+20
-0
20 additions, 0 deletions
CRM/Utils/Hook.php
with
44 additions
and
18 deletions
CRM/Core/BAO/CustomValueTable.php
+
24
−
18
View file @
c0c45206
...
...
@@ -47,25 +47,31 @@ class CRM_Core_BAO_CustomValueTable {
$set
=
[];
$params
=
[];
$count
=
1
;
foreach
(
$fields
as
$field
)
{
if
(
!
$sqlOP
)
{
$entityID
=
$field
[
'entity_id'
];
$hookID
=
$field
[
'custom_group_id'
];
$isMultiple
=
$field
[
'is_multiple'
];
if
(
array_key_exists
(
'id'
,
$field
))
{
$sqlOP
=
"UPDATE
$tableName
"
;
$where
=
" WHERE id = %
{
$count
}
"
;
$params
[
$count
]
=
[
$field
[
'id'
],
'Integer'
];
$count
++
;
$hookOP
=
'edit'
;
}
else
{
$sqlOP
=
"INSERT INTO
$tableName
"
;
$where
=
NULL
;
$hookOP
=
'create'
;
}
}
$firstField
=
reset
(
$fields
);
$entityID
=
$firstField
[
'entity_id'
];
$hookID
=
$firstField
[
'custom_group_id'
];
$isMultiple
=
$firstField
[
'is_multiple'
];
if
(
array_key_exists
(
'id'
,
$firstField
))
{
$sqlOP
=
"UPDATE
$tableName
"
;
$where
=
" WHERE id = %
{
$count
}
"
;
$params
[
$count
]
=
[
$firstField
[
'id'
],
'Integer'
];
$count
++
;
$hookOP
=
'edit'
;
}
else
{
$sqlOP
=
"INSERT INTO
$tableName
"
;
$where
=
NULL
;
$hookOP
=
'create'
;
}
CRM_Utils_Hook
::
customPre
(
$hookOP
,
$hookID
,
$entityID
,
$fields
);
foreach
(
$fields
as
$field
)
{
// fix the value before we store it
$value
=
$field
[
'value'
];
$type
=
$field
[
'type'
];
...
...
This diff is collapsed.
Click to expand it.
CRM/Utils/Hook.php
+
20
−
0
View file @
c0c45206
...
...
@@ -531,6 +531,26 @@ abstract class CRM_Utils_Hook {
->
invoke
([
'op'
,
'groupID'
,
'entityID'
,
'params'
],
$op
,
$groupID
,
$entityID
,
$params
,
self
::
$_nullObject
,
self
::
$_nullObject
,
'civicrm_custom'
);
}
/**
* This hook is called before a db write on a custom table.
*
* @param string $op
* The type of operation being performed.
* @param string $groupID
* The custom group ID.
* @param object $entityID
* The entityID of the row in the custom table.
* @param array $params
* The parameters that were sent into the calling function.
*
* @return null
* the return value is ignored
*/
public
static
function
customPre
(
$op
,
$groupID
,
$entityID
,
&
$params
)
{
return
self
::
singleton
()
->
invoke
([
'op'
,
'groupID'
,
'entityID'
,
'params'
],
$op
,
$groupID
,
$entityID
,
$params
,
self
::
$_nullObject
,
self
::
$_nullObject
,
'civicrm_customPre'
);
}
/**
* This hook is called when composing the ACL where clause to restrict
* visibility of contacts to the logged in user
...
...
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