Exemplo n.º 1
0
function saveAgent($agentid = NULL)
{
    global $clientRoot;
    $result = "";
    $am = new AgentManager();
    if ($am->isAgentEditor()) {
        if (strlen($agentid) == 0) {
            $toSave = new Agent();
            $toSave = $am->getAndChangeAgentFromRequest($agentid);
            if ($toSave != null) {
                $result = $am->saveNewAgent($toSave);
            } else {
                $result = "Error in saving new agent record.";
            }
        } else {
            $toSave = $am->getAndChangeAgentFromRequest($agentid);
            if ($toSave != null) {
                $result = $am->saveAgent($toSave);
            } else {
                $result = "Error in saving agent record.";
            }
        }
    } else {
        $result = "You aren't authorized to edit agent records.";
    }
    return $result;
}