Example #1
0
 public function getLinksForAgent($agentid)
 {
     global $clientRoot;
     $result = "";
     $result .= "<li><h3>Links</h3></li>";
     $link = "";
     if ($this->isAgentEditor()) {
         $link .= "<a id='addAgentLinkLink'>Add</a>\n";
     }
     $result .= "<div id='addAgentLinkDiv'>{$link}</div>\n";
     $result .= "<div id='addedAgentLinkDiv'></div>\n";
     if ($this->isAgentEditor()) {
         $result .= "\n     <script type='text/javascript'>\n        function handlerAddLink () {\n            \$.ajax({\n               type: 'GET',\n               url: '{$clientRoot}/agents/rpc/handler.php',\n               data: 'mode=create&table=AgentLinks&agentid=" . $agentid . "',\n               dataType : 'html',\n               success: function(data){\n                  \$('#addedAgentLinkDiv').html(data);\n               },\n               error: function( xhr, status, errorThrown ) {\n                  \$('#statusDiv').html('Error. ' + errorThrown);\n                  console.log( 'Error: ' + errorThrown );\n                  console.log( 'Status: ' + status );\n                  console.dir( xhr );\n               }\n            });\n            return false; \n        };\n        \$('#addAgentLinkLink').bind('click',handlerAddLink);\n     </script>\n          ";
     }
     $l = new agentlinks();
     $links = $l->loadArrayByagentid($agentid);
     if (count($links) > 0) {
         $linkView = new agentlinksView();
         $result .= "<ul>";
         foreach ($links as $link) {
             $linkView->setModel($link);
             $result .= '<li>' . $linkView->getSummaryLine($this->isAgentEditor()) . '</li>';
         }
         $result .= "</ul>";
     }
     return $result;
 }
Example #2
0
function editAgentLinks($al)
{
    $result = "";
    $am = new AgentManager();
    if ($am->isAgentEditor()) {
        if ($al == null) {
            $result = "Error: No agent link object found.";
        } else {
            $alview = new agentlinksView();
            $alview->setModel($al);
            $result = $alview->getEditFormView();
        }
    } else {
        $result = "You aren't authorized to edit agent records.";
    }
    return $result;
}