/** * Get/create the activity type to be used for 'Check Household' activities */ public static function getCheckHouseholdActivityTypeID() { if (self::$activity_type_id === NULL) { // 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."); } $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 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)); $activities = civicrm_api3('OptionValue', 'get', array('id' => $activities['id'])); } self::$activity_type_id = $activities['values'][$activities['id']]['value']; } return self::$activity_type_id; }