$rv['rectypes'] = getAllRectypeStructures(); } } break; //------------------------------------------------------------ //------------------------------------------------------------ case 'saveRTG': // Record type group if (!array_key_exists('rectypegroups', $data) || !array_key_exists('colNames', $data['rectypegroups']) || !array_key_exists('defs', $data['rectypegroups'])) { error_exit("Invalid data structure sent with saveRectypeGroup method call to saveStructure.php"); } $colNames = $data['rectypegroups']['colNames']; foreach ($data['rectypegroups']['defs'] as $rtgID => $rt) { if ($rtgID == -1) { // new rectype group array_push($rv, createRectypeGroups($colNames, $rt)); } else { array_push($rv, updateRectypeGroup($colNames, $rtgID, $rt)); } } if (!array_key_exists('error', $rv)) { $rv['rectypes'] = getAllRectypeStructures(); } break; case 'deleteRTG': $rtgID = @$_REQUEST['rtgID']; if (!$rtgID) { error_exit("Invalid or no record type group ID sent with deleteRectypeGroup method call to saveStructure.php"); } $rv = deleteRectypeGroup($rtgID); if (!array_key_exists('error', $rv)) {
error_exit("Can't find group #" . $grp_id . " for record type #'" . $recId . "'. \"{$rt_name}\" in source database"); } if (!$grp_name) { error_exit("Name of group is empty. Can't add group #" . $grp_id . " for record type #'" . $recId . "'. \"{$rt_name}\" in source database"); } //get name and try to find in target $isNotFound = true; foreach ($trg_rectypes['groups'] as $idx => $group) { if (is_numeric($idx) && trim($group['name']) == trim($grp_name)) { $group_rt_ids[$grp_id] = $group['id']; $isNotFound = false; break; } } if ($isNotFound) { $res = createRectypeGroups($columnNames, array(array("values" => array($grp_name, $src_group['order'], $src_group['description'])))); $new_grp_id = @$res['result']; if (is_numeric($new_grp_id)) { $group_rt_ids[$grp_id] = $new_grp_id; $trg_rectypes['groups'][$new_grp_id] = array('name' => $grp_name); } else { error_exit("Can't add record type group '" . $grp_name . "'. " . @$res['error']); } } } // ------------------------------------------------------------------------------------------------ // III. Add record types $columnNames = $def_rts['commonFieldNames']; $dtFieldNames = $def_rts['dtFieldNames']; $idx_name = $def_rts['commonNamesToIndex']['rty_Name']; $idx_origin_dbid = $def_rts['commonNamesToIndex']['rty_OriginatingDBID'];