GroupContact entity missing from Tag Conditions and Actions
My client has a particular model where we keep a group and tag in sync. We use CiviRules to watch when one or the other happens and then automate the compliment. Some recent changes caused these to stop firing correctly, and while some other fixes solved most of the problems, there's one remaining issue with GroupContact not included in the Tag Conditions and Actions. This is how I included it to correct the issue.
diff --git a//CRM/CivirulesActions/Tag/Form/TagId.php b//CRM/CivirulesActions/Tag/Form/TagId.php
--- a//CRM/CivirulesActions/Tag/Form/TagId.php
+++ b//CRM/CivirulesActions/Tag/Form/TagId.php
@@ -19,6 +19,7 @@ class CRM_CivirulesActions_Tag_Form_TagId extends CRM_CivirulesActions_Form_Form
$bao = new CRM_Core_BAO_Tag();
switch ($this->trigger->object_name) {
case 'Contact':
+ case 'GroupContact':
case 'Membership':
case 'EntityTag':
$tableName = 'civicrm_contact';
diff --git a//CRM/CivirulesActions/Tag/Tag.php b//CRM/CivirulesActions/Tag/Tag.php
--- a//CRM/CivirulesActions/Tag/Tag.php
+++ b//CRM/CivirulesActions/Tag/Tag.php
@@ -17,7 +17,7 @@ abstract class CRM_CivirulesActions_Tag_Tag extends CRM_CivirulesActions_Generic
*/
protected function alterApiParameters($params, CRM_Civirules_TriggerData_TriggerData $triggerData) {
//this function could be overridden in subclasses to alter parameters to meet certain criteria
- if ($triggerData->getEntity() == 'Membership' || $triggerData->getEntity() == 'EntityTag') {
+ if ($triggerData->getEntity() == 'GroupContact' || $triggerData->getEntity() == 'Membership' || $triggerData->getEntity() == 'EntityTag') {
$params['entity_id'] = $triggerData->getContactId();
}
else {
@@ -26,6 +26,7 @@ abstract class CRM_CivirulesActions_Tag_Tag extends CRM_CivirulesActions_Generic
switch ($triggerData->getEntity()) {
case 'Contact':
+ case 'GroupContact':
case 'Membership':
case 'EntityTag':
$tableName = 'civicrm_contact';
diff --git a//CRM/CivirulesConditions/Generic/HasTag.php b//CRM/CivirulesConditions/Generic/HasTag.php
--- a//CRM/CivirulesConditions/Generic/HasTag.php
+++ b//CRM/CivirulesConditions/Generic/HasTag.php
@@ -202,7 +202,7 @@ class CRM_CivirulesConditions_Generic_HasTag extends CRM_Civirules_Condition {
*/
public function doesWorkWithTrigger(CRM_Civirules_Trigger $trigger, CRM_Civirules_BAO_Rule $rule) {
$entities = $trigger->getProvidedEntities();
- foreach (['Contact', 'Activity', 'Case', 'File'] as $entity) {
+ foreach (['Contact', 'GroupContact', 'Activity', 'Case', 'File'] as $entity) {
if (isset($entities[$entity])) {
return TRUE;
}
I can open a pull request if these are sufficient fixes.