function browse() { $am = new AgentManager(); $result = "<div id='loadedWithPage'>\n"; $result .= "<h3>Collector and other agent records</h3>"; $result .= $am->getNameStats(); $result .= "<ul><li>Individuals</li>"; $result .= $am->getLastNameLinks(); $result .= "</ul><ul><li>Teams</li>"; $result .= $am->getTeamLinks(); $result .= "</ul><ul><li>Organizations</li>"; $result .= $am->getOrganizationLinks(); $result .= "</ul>"; $result .= "</div>\n"; return $result; }
reset($accept); while (!$done && (list($key, $mediarange) = each($accept))) { if ($mediarange == 'text/turtle') { deliverTurtle(); $done = TRUE; } if ($mediarange == 'application/rdf+xml') { deliverRdfXml(); $done = TRUE; } } if (!$done) { Header("Content-Type: text/html; charset=" . $charset); $spDisplay = " Agent: " . $agent->getMinimalName(); pageheader($agent); $am = new AgentManager(); if ($am->isAgentEditor()) { echo "<div id='commandDiv'><span class='link' id='editLink'>Edit</span> <span class='link' id='viewLink'>View</span> <span class='link' id='createLink'>New</span></div>"; echo "\n <script type='text/javascript'>\n \$('#editLink').click(function () {\n \$.ajax({\n type: 'GET',\n url: '{$clientRoot}/agents/rpc/handler.php',\n data: 'mode=edit&table=Agent&agentid=" . $agent->getagentid() . "',\n dataType : 'html',\n success: function(data){\n \$('#agentDetailDiv" . $agent->getagentid() . "').html(data);\n },\n error: function( xhr, status, errorThrown ) {\n \$('#statusDiv').html('Error. ' + errorThrown);\n console.log( 'Error: ' + errorThrown );\n console.log( 'Status: ' + status );\n console.dir( xhr );\n }\n });\n return false; \n });\n \$('#viewLink').click(function () {\n \$.ajax({\n type: 'GET',\n url: '{$clientRoot}/agents/rpc/handler.php',\n data: 'mode=show&table=Agent&agentid=" . $agent->getagentid() . "',\n dataType : 'html',\n success: function(data){\n \$('#agentDetailDiv" . $agent->getagentid() . "').html(data);\n },\n error: function( xhr, status, errorThrown ) {\n \$('#statusDiv').html('Error. ' + errorThrown);\n console.log( 'Error: ' + errorThrown );\n console.log( 'Status: ' + status );\n console.dir( xhr );\n }\n });\n return false; \n });\n \$('#createLink').click(function () {\n \$.ajax({\n type: 'GET',\n url: '{$clientRoot}/agents/rpc/handler.php',\n data: 'mode=create&table=Agent',\n dataType : 'html',\n success: function(data){\n \$('#agentDetailDiv" . $agent->getagentid() . "').html(data);\n },\n error: function( xhr, status, errorThrown ) {\n \$('#statusDiv').html('Error. ' + errorThrown);\n console.log( 'Error: ' + errorThrown );\n console.log( 'Status: ' + status );\n console.dir( xhr );\n }\n });\n return false; \n });\n </script>\n "; } echo "<div id='agentDetailDiv" . $agent->getagentid() . "'>"; echo $agentview->getDetailsView(); echo "</div>"; if ($findobjects == 1) { echo $am->getPrettyListOfCollectionObjectsForCollector($agent->getagentid()); } footer(); } /** * Return the requested agent as RDF in a turtle serialization. */
/** Populate omoccurrences.recordedbyid using data from omoccurrences.recordedby. */ public function indexCollectors() { //Try to populate using already linked names $sql = 'UPDATE omoccurrences o1 INNER JOIN (SELECT DISTINCT recordedbyid, recordedby FROM omoccurrences WHERE recordedbyid IS NOT NULL) o2 ON o1.recordedby = o2.recordedby ' . 'SET o1.recordedbyid = o2.recordedbyid ' . 'WHERE o1.recordedbyid IS NULL'; $this->conn->query($sql); //Query unlinked specimens and try to parse each collector $collArr = array(); $sql = 'SELECT occid, recordedby ' . 'FROM omoccurrences ' . 'WHERE recordedbyid IS NULL'; $rs = $this->conn->query($sql); while ($r = $rs->fetch_object()) { $collArr[$r->recordedby][] = $r->occid; } $rs->free(); foreach ($collArr as $collStr => $occidArr) { // check to see if collector is listed in agents table. $sql = "select distinct agentid from agentname where name = ? "; if ($stmt = $this->conn->prepare($sql)) { $stmt->bind_param('s', $collStr); $stmt->execute(); $stmt->bind_result($agentid); $stmt->store_result(); $matches = $stmt->num_rows; $stmt->fetch(); $stmt->close(); if ($matches > 0) { $recById = $agentid; } else { // no matches found to collector, add to agent table. $am = new AgentManager(); $agent = $am->constructAgentDetType($collStr); if ($agent != null) { $am->saveNewAgent($agent); $agentid = $agent->getagentid(); $recById = $agentid; } } } else { throw new Exception("Error preparing query {$sql} " . $this->conn->error); } //Add recordedbyid to omoccurrence table if ($recById) { $sql = 'UPDATE omoccurrences ' . 'SET recordedbyid = ' . $recById . ' WHERE occid IN(' . implode(',', $occidArr) . ') AND recordedbyid IS NULL '; $this->conn->query($sql); } } }
die; // TODO: Change to back bulkloads of uploaded list of agent name data. // TODO: Include ability to include GUIDs, remarks and other agent metadata beyond names and dates. include_once '../../config/symbini.php'; $filename = "agentnames.csv"; $filename = preg_replace("[^A-Za-z_\\.0-9\\-]", '', array_key_exists("file", $_REQUEST) ? $_REQUEST["file"] : $filename); include_once $serverRoot . '/classes/AgentManager.php'; include_once $serverRoot . '/classes/RdfUtility.php'; include_once $serverRoot . '/classes/UuidFactory.php'; $debug = FALSE; if ($argc == 3) { if ($argv[1] == "-f") { $filename = $argv[2]; } } $am = new AgentManager(); if (file_exists($filename) && is_readable($filename)) { // read file $file = fopen($filename, "r"); // iterate through lines //$line = '"Aall","Nicolai","Benjamin","","Nicolai Benjamin Aall","N","1805","1888"'; //$line = '"Aaron","Samuel","Francis","","Samuel Francis Aaron","N","1862","1947"'; while (($line = fgets($file)) !== false) { $others = ""; // TODO: Use a CSV parser $bits = explode('","', $line); if ($debug) { print_r($bits); } $familyname = trim(str_replace('"', '', $bits[0])); $firstname = trim(str_replace('"', '', $bits[1]));
public function getEditFormView() { global $clientRoot; $model = $this->model; if (strlen($model->getagentteamid()) == 0) { $new = TRUE; } else { $new = FALSE; } $returnvalue = "\n <script type='text/javascript'>\n var frm = \$('#saveATeamRecordForm');\n frm.submit(function () {\n \$('#statusDiv').html('Saving...');\n \$('#saveATeamResultDiv').html('');\n \$.ajax({\n type: 'POST',\n url: '{$clientRoot}/agents/rpc/handler.php',\n data: frm.serialize(),\n dataType : 'html',\n success: function(data){\n \$('#saveATeamResultDiv').html(data);\n \$('#statusDiv').html('');\n },\n error: function( xhr, status, errorThrown ) {\n \$('#statusDiv').html('Error. ' + errorThrown);\n console.log( 'Error: ' + errorThrown );\n console.log( 'Status: ' + status );\n console.dir( xhr );\n }\n });\n return false; \n });\n </script>\n"; $returnvalue .= '<div id="saveATeamResultDiv"></div>'; $returnvalue .= '<form id="saveATeamRecordForm">'; if ($new) { $returnvalue .= '<input type=hidden name=mode id=mode value=savenew>'; } else { $returnvalue .= '<input type=hidden name=mode id=mode value=save>'; } $returnvalue .= '<input type=hidden name=table id=table value="AgentTeams">'; $returnvalue .= '<input type=hidden name=agentteamid value="' . $model->getagentteamid() . '">'; $returnvalue .= '<input type=hidden name=teamagentid value="' . $model->getteamagentid() . '">'; $returnvalue .= '<ul>'; // $returnvalue .= "<li>TEAMAGENTID<input type=text name=".agentteams::TEAMAGENTID." id=".agentteams::TEAMAGENTID." value='".$model->getteamagentid()."' size='".agentteams::TEAMAGENTID_SIZE ."' maxlength='".agentteams::TEAMAGENTID_SIZE ."' ></li>\n"; $team = new Agent(); $team->load($model->getteamagentid()); $returnvalue .= "<li>Team: " . $team->getAssembledName() . "</li>\n"; $am = new AgentManager(); $returnvalue .= $am->createAgentPicker(agentteams::MEMBERAGENTID, 'Member', $model->getmemberagentid()); //$returnvalue .= "<li>Member<input type=text name=".agentteams::MEMBERAGENTID." id=".agentteams::MEMBERAGENTID." value='".$model->getmemberagentid()."' size='".agentteams::MEMBERAGENTID_SIZE ."' maxlength='".agentteams::MEMBERAGENTID_SIZE ."' ></li>\n"; $returnvalue .= "<li>Order<input type=text name=" . agentteams::ORDINAL . " id=" . agentteams::ORDINAL . " value='" . $model->getordinal() . "' size='" . agentteams::ORDINAL_SIZE . "' maxlength='" . agentteams::ORDINAL_SIZE . "' ></li>\n"; $returnvalue .= '<li><input type=submit value="Save"></li>'; $returnvalue .= '</ul>'; $returnvalue .= '</form>'; return $returnvalue; }
function deleteAgentTeams($agentteamid = NULL) { global $clientRoot; $result = ""; $am = new AgentManager(); if ($am->isAgentEditor()) { if (strlen($agentteamid) > 0) { $toDelete = new agentteams(); $toDelete->setagentteamid($agentteamid); if ($toDelete->delete()) { $result = "Deleted."; } else { $result = "Error in deleting agent team record. " . $toDelete->errorMessage(); } } else { $result = "No agent teams specified to delete."; } } else { $result = "You aren't authorized to edit agent records."; } return $result; }