Skip to content
Snippets Groups Projects
Commit 7b6b8e75 authored by Erik Hommel's avatar Erik Hommel
Browse files

fix #35 check if contact member of group and only remove if so

parent 8cb0c686
Branches
Tags
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment