Skip to content
Snippets Groups Projects
Commit af95f0c2 authored by jaapjansma's avatar jaapjansma
Browse files

update other op in post event are possible

parent 3ccee4c6
No related branches found
No related tags found
No related merge requests found
...@@ -25,21 +25,30 @@ class CRM_Civirules_Event_EditEntity { ...@@ -25,21 +25,30 @@ class CRM_Civirules_Event_EditEntity {
} }
public static function post( $op, $objectName, $objectId, &$objectRef ) { public static function post( $op, $objectName, $objectId, &$objectRef ) {
if ($op != 'edit') { if ($op != 'edit' && $op != 'create' && $op != 'delete' && $op != 'trash' && $op != 'restore') {
return; return;
} }
//set data
$data = array();
CRM_Core_DAO::storeValues($objectRef, $data);
$entity = self::convertObjectNameToEntity($objectName); $entity = self::convertObjectNameToEntity($objectName);
$oldData = self::getPreData($entity, $objectId);
$rules = CRM_Civirules_BAO_Rule::findRulesByObjectnameAndAction($objectName, $op); if ($op == 'edit') {
foreach($rules as $rule) { //set data
$data = array();
CRM_Core_DAO::storeValues($objectRef, $data);
//set also original data with an edit event
$oldData = self::getPreData($entity, $objectId);
$eventData = new CRM_Civirules_EventData_Edit($entity, $objectId, $data, $oldData); $eventData = new CRM_Civirules_EventData_Edit($entity, $objectId, $data, $oldData);
CRM_Civirules_Engine::triggerRule($eventData, $rule['rule_id'], $rule['event_id']); } else {
//set data
$data = array();
CRM_Core_DAO::storeValues($objectRef, $data);
$eventData = new CRM_Civirules_EventData_EventData_Post($entity, $objectId, $data);
}
//find matching rules for this objectName and op
$rules = CRM_Civirules_BAO_Rule::findRulesByObjectNameAndOp($objectName, $op);
foreach($rules as $rule) {
CRM_Civirules_Engine::triggerRule(clone $eventData, $rule['rule_id'], $rule['event_id']);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment