diff --git a/CRM/CivirulesActions/GroupContact/Remove.php b/CRM/CivirulesActions/GroupContact/Remove.php index d0551bafa05319101bbedf2d8bcd96e4719d1124..3777c9d5ccf639ed5ba4a67d6f8bf18ad5386beb 100644 --- a/CRM/CivirulesActions/GroupContact/Remove.php +++ b/CRM/CivirulesActions/GroupContact/Remove.php @@ -21,4 +21,35 @@ class CRM_CivirulesActions_GroupContact_Remove extends CRM_CivirulesActions_Grou return 'delete'; } + /** + * Process the action + * + * @param CRM_Civirules_EventData_EventData $eventData + * @access public + */ + public function processAction(CRM_Civirules_EventData_EventData $eventData) { + $entity = $this->getApiEntity(); + $action = $this->getApiAction(); + $contactId = $eventData->getContactId(); + + $action_params = $this->getActionParameters(); + $group_ids = array(); + if (!empty($action_params['group_id'])) { + $group_ids = array($action_params['group_id']); + } elseif (!empty($action_params['group_ids']) && is_array($action_params['group_ids'])) { + $group_ids = $action_params['group_ids']; + } + foreach($group_ids as $group_id) { + if (CRM_Contact_BAO_GroupContact::isContactInGroup($contactId, $group_id)) { + $params = array(); + $params['group_id'] = $group_id; + + //alter parameters by subclass + $params = $this->alterApiParameters($params, $eventData); + + //execute the action + $this->executeApiAction($entity, $action, $params); + } + } + } } \ No newline at end of file