Fix UFGroup add to call writeRecord
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 6 Dec 2023 23:18:19 +0000 (12:18 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 6 Dec 2023 23:18:19 +0000 (12:18 +1300)
CRM/Core/BAO/UFGroup.php

index fae355c2e705941ca0a333bff4fcbf1855a763b9..6451188dccc5584d78f65e9c502c95794f3ce3eb 100644 (file)
@@ -1458,28 +1458,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup implements \Civi\Core\Ho
       $params['group_type'] = implode(',', $params['group_type']);
     }
 
-    $hook = empty($params['id']) ? 'create' : 'edit';
-    CRM_Utils_Hook::pre($hook, 'UFGroup', ($params['id'] ?? NULL), $params);
-
-    $ufGroup = new CRM_Core_DAO_UFGroup();
-    $ufGroup->copyValues($params);
-
-    $ufGroupID = CRM_Utils_Array::value('ufgroup', $ids, CRM_Utils_Array::value('id', $params));
-    if (!$ufGroupID && empty($params['name'])) {
-      $ufGroup->name = CRM_Utils_String::munge($ufGroup->title, '_', 56);
-    }
-    $ufGroup->id = $ufGroupID;
-
-    $ufGroup->save();
-
-    if (!$ufGroupID && empty($params['name'])) {
-      $ufGroup->name = $ufGroup->name . "_{$ufGroup->id}";
-      $ufGroup->save();
-    }
-
-    CRM_Utils_Hook::post($hook, 'UFGroup', $ufGroup->id, $ufGroup);
-
-    return $ufGroup;
+    return self::writeRecord($params);
   }
 
   /**