function createTermsOptions($config, $type) { global $sourcedbname, $db_prefix, $dbPrefix, $is_h2; $sourcedb = $db_prefix . $sourcedbname; $entnames = getTerms(); //in current database $entnames = $entnames['termsByDomainLookup'][$type]; foreach ($entnames as $id => $name) { $entnames[$id] = $name[0]; } $seloptions = createOptions("ot", $entnames); print "<h3>Term mappings ({$type}" . "s)" . "</h3>[Term code] <b>{$sourcedb}</b> ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; // Get the term mapping, by default assume that the code is unchanged so select the equivalent term if available if ($is_h2) { $query1 = "SELECT DISTINCT `rdl_id`,`rdl_id`,`rd_val` FROM `{$sourcedb}`.`rec_details`,`{$sourcedb}`.`rec_detail_lookups` " . "where (`rd_type`=`rdl_rdt_id`) AND (`rdl_value`=`rd_val`) AND (`rdl_related_rdl_id` is " . ($type != 'enum' ? "not" : "") . " null)"; } else { if ($type != 'enum') { $type = 'relationtype'; } $query1 = "SELECT DISTINCT `dtl_Value`,`trm_ID`,`trm_Label` FROM `{$sourcedb}`.`recDetails`,`{$sourcedb}`.`defTerms` " . "where (`dtl_Value`=`trm_ID`) AND (`dtl_DetailTypeID` in (select `dty_ID` from `{$sourcedb}`.`defDetailTypes` " . "where (`dty_Type`='{$type}') ))"; } $res1 = mysql_query($query1); print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $tt = $row1[0]; //0=trm_ID $selopts = $seloptions; //find the closest name $selectedId = getPresetId($config, "cbt" . $tt); if (!$selectedId) { //find the closest name $selectedId = findClosestName($row1[2], $entnames); //trm_Label } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr><td>[ {$tt} ] " . $row1[2] . " </td>" . "<td>==> <select id='cbt{$tt}' name='cbt{$tt}' class='terms'><option id='ot0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through terms print "</table>"; }
function createTagsOptions($config) { global $sourcedbname, $db_prefix, $dbPrefix, $is_h2; $sourcedb = $db_prefix . $sourcedbname; $allusers = getUsers(); //in current database $seloptions = createOptions("us", $allusers); print "<h3>User mappings for tag (keyword) import" . "</h3>" . " <b>{$sourcedb}</b> [User id] ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; // Get users with tags if ($is_h2) { $query1 = "select usr.Id, usr.Username, usr.Realname as fullname, count(kwl_rec_id)\n from `{$sourcedb}`.`Users` usr, `{$sourcedb}`.`keywords` kwd, `{$sourcedb}`.`keyword_links` kwl\n where usr.IsModelUser=0 and kwd.kwd_usr_id=usr.Id and kwl.kwl_kwd_id=kwd.kwd_id\n group by usr.Id\n order by fullname"; } else { $query1 = "select usr.ugr_ID, usr.ugr_Name,\n concat(usr.ugr_FirstName, ' ', usr.ugr_LastName) as fullname,\n count(rtl_RecID)\n from `{$sourcedb}`.`sysUGrps` usr, `{$sourcedb}`.`usrTags` kwd, `{$sourcedb}`.`usrRecTagLinks` kwl\n where usr.ugr_Enabled='y' and usr.ugr_Type='user' and\n usr.ugr_IsModelUser=0 and kwd.tag_UGrpID=usr.ugr_ID and kwl.rtl_TagID=kwd.tag_ID\n group by usr.ugr_ID\n order by fullname"; } $res1 = mysql_query($query1); print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $tt = $row1[0]; //0=usr_ID $selopts = $seloptions; $bgcolor = ""; $selectedId = null; if ($config) { $selectedId = getPresetId($config, "cbu" . $tt); } else { // if(!$selectedId){ //find the closest name $selectedId = findClosestName($row1[1], $allusers); //ugr_Name if ($selectedId < 0) { //exact match $bgcolor = "style='background-color:#ccc;'"; $selectedId = -$selectedId; } } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr {$bgcolor}><td><label id='lblu{$tt}'>" . $row1[1] . " [ {$tt} ] </label></td>" . "<td>==> <select id='cbu{$tt}' name='cbu{$tt}' class='users'><option id='ou0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through terms print "</table>"; }