From: Tim Otten Date: Thu, 27 Jul 2017 03:40:26 +0000 (-0700) Subject: CRM-20958 - Create case-activity triggers (to update case when activity changes) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b21ffed7895ea4ba55c09dfdfadd599a78a08eb7;p=civicrm-core.git CRM-20958 - Create case-activity triggers (to update case when activity changes) --- 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()