public function addAgentsFromPartsIfNotExistExt($name, $prefix, $firstname, $middlename, $familyname, $suffix, $birthyear, $deathyear, $living, $notes, $guid) { $result = array(); $name = AgentManager::standardizeNameString($name); $an = new agentnames(); $matches = $an->findAgentIdByName(trim($name)); if (count($matches) == 0) { if ($birthyear == '0' || strlen(trim($birthyear) == 0)) { $birthyear = null; } if ($deathyear == '0' || strlen(trim($deathyear) == 0)) { $deathyear = null; } $toSave = $this->constructNewAgent('Individual', $firstname, $middlename, $familyname, $name, $notes); $toSave->setyearofbirth($birthyear); $toSave->setyearofdeath($deathyear); $toSave->setliving($living); if ($prefix != null && strlen($prefix) > 0) { $toSave->setprefix($prefix); } if ($suffix != null && strlen($suffix) > 0) { $toSave->setsuffix($suffix); } if ($guid != null && strlen($guid) > 0) { $toSave->setguid($guid); } $result['name'] = $this->saveNewAgent($toSave, TRUE); $result['agentid'] = $toSave->getagentid(); $result['added'] = 1; } else { $result['name'] = $name; $result['agentid'] = $matches[0]; // get first agentid from matches array $result['added'] = 0; } return $result; }