Ejemplo n.º 1
0
 /**
  * Given an id for an agent, return the list of agent names associated with that agent.
  * 
  * @param agentid the agentid for the agent to find names for.
  * @return an array of agentnames containing the names for the specified agent.
  */
 public function findAgentNamesByAgentId($agentid)
 {
     $result = array();
     $sql = "select agentnamesid from agentnames where agentid = ? ";
     if ($statement = $this->conn->prepare($sql)) {
         $statement->bind_param("i", $agentid);
         $statement->execute();
         $statement->bind_result($agentnameid);
         while ($statement->fetch()) {
             $an = new agentnames();
             $an->load($agentnameid);
             $result[] = $an;
         }
         $statement->close();
     } else {
         throw new Exception("Query preparation failed for '{$sql}'");
     }
     return $result;
 }
Ejemplo n.º 2
0
     $others = trim(str_replace('"', '', $bits[8]));
 }
 echo "{$name} ({$startyear}-{$endyear}) ";
 $prefix = null;
 $guid = null;
 $notes = null;
 $result = $am->addAgentsFromPartsIfNotExistExt($name, $prefix, $firstname, $middlename, $familyname, $suffix, $startyear, $endyear, $living, $notes, $guid);
 if ($debug) {
     print_r($result);
 }
 $agentid = $result['agentid'];
 if (strlen($others) > 0 && strlen($agentid) > 0) {
     $otherbits = explode("|", $others);
     foreach ($otherbits as $otherbit) {
         $othername = explode(":", $otherbit);
         $an = new agentnames();
         $an->setagentid($agentid);
         $type = $othername[0];
         // TODO: Add full range of types.
         if ($type == "standard" || $type == "Standard Abbreviation") {
             $an->setType('Standard Abbreviation');
         } elseif ($type == "First Initials Last") {
             $an->setType('First Initials Last');
         } else {
             $an->setType('Also Known As');
         }
         $an->setname($othername[1]);
         if (!$an->save()) {
             if (strpos($an->errorMessage(), "Duplicate entry") === FALSE) {
                 // report problems other than duplicate entries
                 echo "Error in saving agent name record: " . $an->errorMessage();
Ejemplo n.º 3
0
function deleteAgentName($agentnameid = NULL)
{
    global $clientRoot;
    $result = "";
    $am = new AgentManager();
    if ($am->isAgentEditor()) {
        if (strlen($agentnameid) > 0) {
            $toDelete = new agentnames();
            $toDelete->setagentnamesid($agentnameid);
            if ($toDelete->delete()) {
                $result = "Deleted.";
            } else {
                $result = "Error in deleting agent name record. " . $toDelete->errorMessage();
            }
        } else {
            $result = "No agent name specified to delete.";
        }
    } else {
        $result = "You aren't authorized to edit agent records.";
    }
    return $result;
}