//csv file delimiter $lang = "en"; //language to render $taxonomyFile = "../../factual_taxonomy.json"; //filename and path $outPutFile = "/tmp/factual_taxonomy.csv"; //output file //Should not need to edit anything below this line $taxonomy = json_decode(file_get_contents($taxonomyFile), true); $iteration = array(); //get information for each node foreach ($taxonomy as $nodeID => $node) { $iteration[$nodeID]['label'] = $taxonomy[$nodeID]['labels'][$lang]; $iteration[$nodeID]['parents'] = $taxonomy[$nodeID]['parents']; $iteration[$nodeID]['ancestors'] = getAncestors($nodeID); $iteration[$nodeID]['breadcrumb'] = getBreadCrumb($nodeID); } //order by node ID ksort($iteration); //render to file $fp = fopen($outPutFile, 'a'); foreach ($iteration as $nodeID => $node) { $line = $nodeID . $delim . $node['label'] . $delim . $node['parents'][0] . $delim . json_encode($node['breadcrumb']) . "\n"; fwrite($fp, $line); } fclose($fp); //get ancestors function getAncestors($nodeID) { global $globalParents; global $taxonomy;
function getBreadCrumb($username) { global $breadCrumb, $config, $return_fields, $home_user; include "../../oit/config/config.php"; if ($_GET["username"] != "{$home_user}" && $_GET["username"] != "") { $ldap_search = ''; $attrs = array(); foreach ($return_fields as $item => $value) { //build attr array $attrs[] = $value; } $ad = ldap_connect($config['host']) or die("Could not connect!"); // Set version number ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3) or die("Could not set ldap protocol"); ldap_set_option($ad, LDAP_OPT_REFERRALS, 0) or die("Could not set the ldap referrals"); // Binding to ldap server $bd = ldap_bind($ad, $config['username'], $config['password']) or die("Could not bind"); if (is_numeric($username)) { $query = odbc_exec($dbconn, "SELECT DISTINCT DESCR, POSITION_REPORT_TO FROM org_chart_open_position WHERE POSITION = '{$username}'"); if (odbc_num_rows($query) != 0) { $descr = odbc_result($query, "DESCR"); $POSITION_REPORT_TO = odbc_result($query, "POSITION_REPORT_TO"); $breadCrumb = " › <a href=\"index.php?username="******"\">" . $descr . " - Open Position</a>{$breadCrumb}"; $ldap_search = "(&(samaccountname=" . $POSITION_REPORT_TO . "))"; $search = ldap_search($ad, $config['dn'], $ldap_search, $attrs) or die("ldap search failed"); $entries = ldap_get_entries($ad, $search); $entries[0]["manager"][0] = $entries[0]["dn"]; } } else { $ldap_search = "(&(distinguishedName=" . $username . "))"; // Create the DN // Specify only those parameters we're interested in displaying // Create the filter from the search parameters $search = ldap_search($ad, $config['dn'], $ldap_search, $attrs) or die("ldap search failed"); $entries = ldap_get_entries($ad, $search); $breadCrumb = " › <a href=\"index.php?username="******"samaccountname"][0] . "\">" . $entries[0]["givenname"][0] . " " . $entries[0]["sn"][0] . "</a>{$breadCrumb}"; if ($entries[0]["manager"][0] == "") { $query = odbc_exec($dbconn, "SELECT DISTINCT POSITION FROM org_chart_open_position WHERE OPRID3 = '" . $entries[0]["samaccountname"][0] . "'"); if (odbc_num_rows($query) != 0) { $entries[0]["manager"][0] = odbc_result($query, "POSITION"); } } } if ($entries[0]["manager"][0] != "") { getBreadCrumb($entries[0]["manager"][0]) . "{$breadCrumb}"; } } }
for ($i = 1; $i <= odbc_num_rows($query); $i++) { odbc_fetch_row($query, $i); $user = odbc_result($query, "OPRID3"); $sub_search = ldap_search($ad, $config['dn'], "(&(samaccountname={$user}))", $attrs) or die("ldap search failed"); $sub_entries = ldap_get_entries($ad, $sub_search); $entries[0]["directreports"][$i - 1] = $sub_entries[0]["dn"]; } getBreadCrumb($username); } else { $ldap_search = "(&(samaccountname=" . $username . ")(company=*)(!(company=Student)))"; // Create the DN // Specify only those parameters we're interested in displaying // Create the filter from the search parameters $search = ldap_search($ad, $config['dn'], $ldap_search, $attrs) or die("ldap search failed"); $entries = ldap_get_entries($ad, $search); getBreadCrumb($entries[0]["distinguishedname"][0]); $title_query = odbc_exec($form_dbconn, "SELECT title FROM directory_info WHERE username = '******'"); $entries[0]["title"][0] = odbc_result($title_query, "title"); } if ($breadCrumb != "") { echo "<br /><div id=\"bread_crumbs\"><a href=\"index.php\">Home</a> {$breadCrumb}</div>"; } echo "\n <div class=\"person_container\">\n <div class=\"person_image\">"; $photo = "<img border=\"0\" src=\"{$image_path}" . $entries[0]["samaccountname"][0] . "{$image_extention}\" width=\"100px\" alt=\"" . $entries[0]["givenname"][0] . " " . $entries[0]["sn"][0] . "\" title=\"" . $entries[0]["givenname"][0] . " " . $entries[0]["sn"][0] . "\" />"; if ($read_only) { echo "{$photo}"; } else { echo "<a href=\"index.php?username="******"samaccountname"][0] . "\">{$photo}</a>"; } echo "</div>\n <div class=\"person\">\n\t<h3>" . $entries[0]["givenname"][0] . " " . $entries[0]["sn"][0] . "</h3>"; if ($entries[0]["title"][0] != "") {
</div> </div> </div> </div> <div id="divider-bar" class="col-m-1 hidden-sm hidden-xs"><i class="fa fa-toggle-left clickable"></i></div> <div id="erp_form_area" class="col-md-10 col-md-offset-2 mainbar"> <div class='visible-xs visible-sm'> <div class="error"></div><div id="loading"></div> </div> <div id="content"> <div id="structure"><span class="heading"> <?php echo getBreadCrumb($class_first); if (!empty($_GET['function_name'])) { echo '<div class="alert alert-info" role="alert" >' . ucwords(str_replace('_', ' ', $_GET['function_name'])) . ' Report</div>'; } else { echo '<div class="alert alert-info" role="alert" >Search ' . ucwords(str_replace('_', ' ', $class)) . '</div>'; } ?> </span> <div id="search_page"> <div id ="form_header"> <?php echo !empty($show_message) ? $show_message : ""; ?> </div> <div id="list_contents">