Skip to content
Snippets Groups Projects
Unverified Commit c0c45206 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #17144 from lcdservices/dev-core-1716

#1716 add customPre hook
parents 1626aaa2 048b069c
Branches
Tags
No related merge requests found
......@@ -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'];
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment