From 8f9632b22c7fb4cbe4150b62458df7952f62d35b Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 4 May 2020 12:47:39 +0100 Subject: [PATCH] Fix updating optiongroups in multilingual mode --- CRM/Core/OptionGroup.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 2540c15471..89018c1a21 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -439,8 +439,6 @@ WHERE v.option_group_id = g.id /** * Creates a new option group with the passed in values. - * @TODO: Should update the group if it already exists intelligently, so multi-lingual is - * not messed up. Currently deletes the old group * * @param string $groupName * The name of the option group - make sure there is no conflict. @@ -464,10 +462,10 @@ WHERE v.option_group_id = g.id * the option group ID */ public static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) { - self::deleteAssoc($groupName); if (!empty($values)) { $group = new CRM_Core_DAO_OptionGroup(); $group->name = $groupName; + $group->find(TRUE); $group->title = empty($groupTitle) ? $groupName : $groupTitle; $group->is_reserved = 1; $group->is_active = 1; @@ -476,8 +474,9 @@ WHERE v.option_group_id = g.id foreach ($values as $v) { $value = new CRM_Core_DAO_OptionValue(); $value->option_group_id = $group->id; - $value->label = $v['label']; $value->value = $v['value']; + $value->find(TRUE); + $value->label = $v['label']; $value->name = $v['name'] ?? NULL; $value->description = $v['description'] ?? NULL; $value->weight = $v['weight'] ?? NULL; @@ -502,8 +501,11 @@ WHERE v.option_group_id = g.id * @param $values * @param bool $flip * @param string $field + * + * @deprecated */ public static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'name') { + CRM_Core_Error::deprecatedFunctionWarning('unused function'); $query = " SELECT v.id as amount_id, v.value, v.label, v.name, v.description, v.weight FROM civicrm_option_group g, @@ -546,8 +548,11 @@ ORDER BY v.weight /** * @param string $groupName * @param string $operator + * + * @deprecated */ public static function deleteAssoc($groupName, $operator = "=") { + CRM_Core_Error::deprecatedFunctionWarning('unused function'); $query = " DELETE g, v FROM civicrm_option_group g, -- 2.25.1