/** * Get agent fields from the request, and construct an * agent object using those values. The agent is loaded from the * database and then has values changed from the request if a * value is provided for agentid, otherwise a new agent is * created. This method does not save the changes to the * database, invoke save on the returned object to accomplish that. * * @return an agent object in state dirty, or null if an error * occurred in obtaining data. */ public function getAndChangeAgentFromRequest($agentid = '') { $result = new Agent(); $agentid = preg_replace("[^0-9]", '', $agentid); if (strlen($agentid) > 0) { $result->load($agentid); } $result->setfamilyname($_REQUEST["familyname"]); $result->setfirstname($_REQUEST["firstname"]); $result->setmiddlename($_REQUEST["middlename"]); $result->setprefix($_REQUEST["prefix"]); $result->setsuffix($_REQUEST["suffix"]); $result->setnamestring($_REQUEST["namestring"]); $result->settype($_REQUEST["type"]); $result->setyearofbirth($_REQUEST["yearofbirth"]); $result->setyearofbirthmodifier($_REQUEST["yearofbirthmodifier"]); $result->setyearofdeath($_REQUEST["yearofdeath"]); $result->setyearofdeathmodifier($_REQUEST["yearofdeathmodifier"]); $result->setstartyearactive($_REQUEST["startyearactive"]); $result->setendyearactive($_REQUEST["endyearactive"]); $result->setnotes($_REQUEST["notes"]); $result->setrating($_REQUEST["rating"]); $result->setguid($_REQUEST["guid"]); $result->setbiography($_REQUEST["biography"]); $result->settaxonomicgroups($_REQUEST["taxonomicgroups"]); $result->setcollectionsat($_REQUEST["collectionsat"]); $result->setcurated($_REQUEST["curated"]); $result->setmbox_sha1sum($_REQUEST["mbox_sha1sum"]); $result->setpreferredrecbyid($_REQUEST["preferredrecbyid"]); $result->setnototherwisespecified($_REQUEST["nototherwisespecified"]); $result->setliving($_REQUEST["living"]); return $result; }