Commit d249edf5 authored by ErikHommel's avatar ErikHommel
Browse files

nbr issue 9431 - use postCommit hook if available so phone and email are copied upon delete

parent f2fed12d
......@@ -313,7 +313,7 @@ class CRM_Formercommunicationdata_CommunicationData {
* @param array $preData
* @return bool
*/
private function saveFormerCommunicationData($preData) {
public function saveFormerCommunicationData($preData) {
// only if contact_id can be found (it should!)
if (isset($preData['contact_id']) && !empty($preData['contact_id'])) {
$contactId = $preData['contact_id'];
......
......@@ -20,11 +20,11 @@ function formercommunicationdata_civicrm_pre($op, $objectName, $objectId, &$para
}
/**
* Implements hook_civicrm_post().
* Implements hook_civicrm_postCommit().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postCommit/
*/
function formercommunicationdata_civicrm_post($op, $objectName, $objectId, &$objectRef) {
function formercommunicationdata_civicrm_postCommit($op, $objectName, $objectId, &$objectRef) {
if (strtolower($op) == 'delete' || strtolower($op) == 'edit') {
$validObjectNames = ["address", "email", "phone"];
$objectName = strtolower($objectName);
......@@ -34,6 +34,19 @@ function formercommunicationdata_civicrm_post($op, $objectName, $objectId, &$obj
}
}
}
function formercommunicationdata_civicrm_post($op, $objectName, $objectId, &$objectRef) {
// only if postCommit does not work in installation
if (!method_exists('CRM_Utils_Hook', 'postCommit')) {
if (strtolower($op) == 'delete' || strtolower($op) == 'edit') {
$validObjectNames = ["address", "email", "phone"];
$objectName = strtolower($objectName);
if (in_array($objectName, $validObjectNames)) {
$fcd = new CRM_Formercommunicationdata_CommunicationData($objectName, $objectId);
$fcd->processPostHook($op);
}
}
}
}
/**
* Implements hook_civicrm_postProcess().
......
......@@ -14,8 +14,8 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-23</releaseDate>
<version>1.1</version>
<releaseDate>2022-06-07</releaseDate>
<version>1.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.9</ver>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment