Exemple #1
0
 function DELETE()
 {
     //Check if the array key exists
     if (!array_key_exists('id', $_GET)) {
         return FRHTTPError::err400(null, 'No ID supplied');
     }
     //Delete the record
     // TODO Add Error checking
     $this->models['User']->del($_GET['id']);
     $xml = new XMLAuthor();
     $xml->push('Status');
     $xml->element('description', 'Record Removed');
     $xml->pop();
 }
Exemple #2
0
 function POST()
 {
     /*
     		$requiredAttributes = array(
     			'id'
     			);
     */
     if (array_key_exists('id', $_POST)) {
         //Set the id to make the model update rather than insert
         $this->models['Location']->ID = $_POST['id'];
         $this->models['Location']->save($_POST);
         $xml = new XMLAuthor();
         $xml->push('location');
         foreach ($_POST as $k => $v) {
             $xml->element($k, $v);
         }
         $xml->pop();
         return $xml->getXML();
     } else {
         return FRHTTPError::err400(null, 'Invalid Arguments');
     }
 }
Exemple #3
0
 function GET()
 {
     //$this->returnXML = false;
     //$this->models['Article']->debug = true;
     $xml = new XMLAuthor();
     if (array_key_exists('id', $_GET)) {
         $id = $_GET['id'];
         $result = $this->models['Article']->findAll(array('conditions' => "location_id = {$id}"));
     } else {
         $result = $this->models['Article']->findAll();
     }
     $xml->push('articles');
     foreach ($result as $row) {
         $xml->push('article');
         $xml->element('id', $row['id']);
         $xml->element('location_id', $row['location_id']);
         $xml->element('title', $row['title']);
         $xml->element('body', $row['body']);
         $xml->pop();
     }
     $xml->pop();
     return $xml->getXML();
 }
Exemple #4
0
 function errorResponse($errCode = null, $errDescription = null)
 {
     $xml = new XMLAuthor();
     $xml->push('error');
     if (isset($errCode)) {
         $xml->element('code', $errCode);
     }
     if (isset($errDescription)) {
         $xml->element('description', $errDescription);
     }
     $xml->pop();
     return $xml->getXML();
 }