diff --git a/CRM/Householdmerge/Logic/Checker.php b/CRM/Householdmerge/Logic/Checker.php index df5b521..418ae37 100644 --- a/CRM/Householdmerge/Logic/Checker.php +++ b/CRM/Householdmerge/Logic/Checker.php @@ -106,10 +106,10 @@ function checkHousehold($household_id, $activities_checked = FALSE) { } // HEAD related checks - if ('hierarchy' == CRM_Householdmerge_Logic_Configuration::getHouseholdModeOptions()) { + if ('hierarchy' == CRM_Householdmerge_Logic_Configuration::getHouseholdMode()) { $heads = array(); foreach ($members as $member) { - if ($member['relation'] == 'head') { + if ($member['hh_relation'] == 'head') { $heads[] = $member; } } @@ -123,7 +123,7 @@ function checkHousehold($household_id, $activities_checked = FALSE) { if (count($heads) > 1) { $problems_identified[] = ts("Household has multiple heads.", array('domain' => 'de.systopia.householdmerge')); } - + // CHECK 4: does the head have a DO NOT mail/phone/sms/email $donts = CRM_Householdmerge_Logic_Configuration::getDontXXXChecks(); foreach ($heads as $head) { @@ -138,7 +138,7 @@ function checkHousehold($household_id, $activities_checked = FALSE) { // CHECK 5: does the head have certain tags $bad_tags = CRM_Householdmerge_Logic_Configuration::getBadHeadTags(); foreach ($heads as $head) { - $tags = CRM_Core_BAO_EntityTag::getContactTags($contact_id); + $tags = CRM_Core_BAO_EntityTag::getContactTags($head['id']); foreach ($tags as $tag) { if (in_array($tag, $bad_tags)) { $problems_identified[] = ts("Household head has tag '%1'.", array(1 => $tag, 'domain' => 'de.systopia.householdmerge')); @@ -320,7 +320,7 @@ protected function getMembers($household_id) { */ protected function getCheckActivityTypeID() { if ($this->_activity_type_id == NULL) { - $this->_activity_type_id = CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityType(); + $this->_activity_type_id = CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID(); } if ($this->_activity_type_id == NULL) { diff --git a/CRM/Householdmerge/Logic/Configuration.php b/CRM/Householdmerge/Logic/Configuration.php index 9dacc39..c51028c 100644 --- a/CRM/Householdmerge/Logic/Configuration.php +++ b/CRM/Householdmerge/Logic/Configuration.php @@ -114,27 +114,27 @@ public static function setConfigValue($key, $value) { /** * Get/create the activity type to be used for 'Check Household' activities */ - public static function getCheckHouseholdActivityType() { + public static function getCheckHouseholdActivityTypeID() { // now make sure that the activity types exist $option_group = civicrm_api3('OptionGroup', 'getsingle', array('name' => 'activity_type')); if ($option_group==NULL) { throw new Exception("Couldn't find activity_type group."); } - $activity = civicrm_api3('OptionValue', 'getsingle', array('name' => self::$HHMERGE_CHECK_HH_NAME, 'option_group_id' => $option_group['id'], 'option.limit' => 1)); - if (empty($activity['id'])) { - $activity = civicrm_api3('OptionValue', 'create', array( + $activities = civicrm_api3('OptionValue', 'get', array('name' => self::$HHMERGE_CHECK_HH_NAME, 'option_group_id' => $option_group['id'], 'option.limit' => 1)); + if (empty($activities['id']) || $activities['count'] != 1) { + $activities = civicrm_api3('OptionValue', 'create', array( 'label' => ts("Check Household", array('domain' => 'de.systopia.householdmerge')), 'name' => self::$HHMERGE_CHECK_HH_NAME, 'option_group_id' => $option_group['id'], 'is_default' => 0, - 'description' => ts("This activity indicates that there mmight be something wrong with this household, and that (a human) should look into it.", array('domain' => 'de.systopia.householdmerge')), + 'description' => ts("This activity indicates that there might be something wrong with this household, and that (a human) should look into it.", array('domain' => 'de.systopia.householdmerge')), 'is_active' => 1, 'is_reserved' => 1 )); - $activity = civicrm_api3('OptionValue', 'getsingle', array('id' => $activity['id'])); + $activities = civicrm_api3('OptionValue', 'get', array('id' => $activities['id'])); } - - return $activity['value']; + + return $activities['values'][$activities['id']]['value']; } }