From b21ffed7895ea4ba55c09dfdfadd599a78a08eb7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 26 Jul 2017 20:40:26 -0700 Subject: [PATCH] CRM-20958 - Create case-activity triggers (to update case when activity changes) --- Civi/Core/Container.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 85f6120460..75d9500017 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -218,6 +218,29 @@ class Container { array('civicrm_case', 'Case') ))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo')); + $container->setDefinition('civi.case.staticTriggers', new Definition( + 'Civi\Core\SqlTrigger\StaticTriggers', + array( + array( + array( + 'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'), + 'table' => 'civicrm_case_activity', + 'when' => 'AFTER', + 'event' => array('INSERT'), + 'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id = NEW.case_id;\n", + ), + array( + 'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'), + 'table' => 'civicrm_activity', + 'when' => 'BEFORE', + 'event' => array('UPDATE', 'DELETE'), + 'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id IN (SELECT ca.case_id FROM civicrm_case_activity ca WHERE ca.activity_id = OLD.id);\n", + ), + ), + ) + )) + ->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo')); + $container->setDefinition('civi_token_compat', new Definition( 'Civi\Token\TokenCompatSubscriber', array() -- 2.25.1