Merge pull request #3927 from eileenmcnaughton/CRM-15168
[civicrm-core.git] / CRM / Core / BAO / CustomGroup.php
index abe4be26be48140e16369ce6b074d0e2d83841ae..8cc623a92f1acb7d099852b4121083821e80625f 100644 (file)
@@ -160,6 +160,12 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
       }
     }
 
+    if (array_key_exists('is_reserved', $params)) {
+      $group->is_reserved = $params['is_reserved'] ? 1 : 0;
+    }
+    $op = isset($params['id']) ? 'edit' : 'create';
+    CRM_Utils_Hook::pre($op, 'CustomGroup', CRM_Utils_Array::value('id', $params), $params);
+
     // enclose the below in a transaction
     $transaction = new CRM_Core_Transaction();
 
@@ -1031,6 +1037,7 @@ ORDER BY civicrm_custom_group.weight,
       $group['query']      = "reset=1&gid={$customGroupDAO->id}&cid={$cidToken}";
       $group['extra']      = array('gid' => $customGroupDAO->id);
       $group['table_name'] = $customGroupDAO->table_name;
+      $group['is_multiple'] = $customGroupDAO->is_multiple;
       $groups[]            = $group;
     }
 
@@ -1046,11 +1053,12 @@ ORDER BY civicrm_custom_group.weight,
    *
    * @return string $tableName
    *
-   * @access private
+   * @access public
    * @static
    *
+   * @see _apachesolr_civiAttachments_dereference_file_parent
    */
-  private static function _getTableName($entityType) {
+  public static function getTableNameByEntityName($entityType) {
     $tableName = '';
     switch ($entityType) {
       case 'Contact':
@@ -1231,7 +1239,6 @@ ORDER BY civicrm_custom_group.weight,
       if (!isset($group['fields'])) {
         continue;
       }
-      $groupId = CRM_Utils_Array::value('id', $group);
       foreach ($group['fields'] as $field) {
         if (CRM_Utils_Array::value('element_value', $field) !== NULL) {
           $value = $field['element_value'];
@@ -1248,8 +1255,9 @@ ORDER BY civicrm_custom_group.weight,
           continue;
         }
 
-        $fieldId = $field['id'];
-        $elementName = $field['element_name'];
+        if (!empty($field['element_name'])) {
+          $elementName = $field['element_name'];
+        }
         switch ($field['html_type']) {
           case 'Multi-Select':
           case 'AdvMulti-Select':