Пример #1
0
 public function getAndChangeAgentRelationsFromRequest($agentrelationsid = '')
 {
     $result = new agentrelations();
     $ct = new ctrelationshiptypes();
     $agentrelationsid = preg_replace("[^0-9]", '', $agentrelationsid);
     if (strlen($agentrelationsid) > 0) {
         $result->load($agentrelationsid);
     }
     $result->setfromagentid($_REQUEST["fromagentid"]);
     $result->settoagentid($_REQUEST["toagentid"]);
     $result->setrelationship($_REQUEST["relationship"]);
     $result->setnotes($_REQUEST["notes"]);
     if ($ct->isInverse($result->getrelationship())) {
         // if name of an inverse relationship was given, flip to forward
         $result->setrelationship($ct->flipToForward($result->getrelationship()));
         $to = $result->getfromagentid();
         $from = $result->gettoagentid();
         $result->settoagentid($to);
         $result->setfromagentid($from);
     }
     return $result;
 }
Пример #2
0
function createAgentRelations()
{
    $result = "";
    $am = new AgentManager();
    if ($am->isAgentEditor()) {
        $toSave = new agentrelations();
        if ($toSave != null) {
            $fromagentid = preg_replace('[^0-9]', '', array_key_exists("fromagentid", $_REQUEST) ? $_REQUEST["fromagentid"] : "");
            $toSave->setfromagentid($fromagentid);
            $result = editAgentRelations($toSave);
        } else {
            $result = "Error in creating agent relationships record.";
        }
    } else {
        $result = "You aren't authorized to edit agent records.";
    }
    return $result;
}