/**
  * Save or delete a record by id
  */
 public function saveAction()
 {
     $datamap = new SavedRecords();
     $username = $this->request->getSessionData("username");
     $original_id = $this->request->getParam("id");
     $inserted_id = "";
     // internal database id
     // delete command
     if ($this->isMarkedSaved($original_id) == true) {
         $datamap->deleteRecordBySource($username, $this->id, $original_id);
         $this->unmarkSaved($original_id);
         $this->response->setVariable('delete', '1');
     } else {
         // get record
         $record = $this->engine->getRecordForSave($original_id)->getRecord(0)->getXerxesRecord();
         // save it
         $inserted_id = $datamap->addRecord($username, $this->id, $original_id, $record);
         // record this in session
         $this->markSaved($original_id, $inserted_id);
         // set this for the response
         $this->response->setVariable('savedRecordID', $inserted_id);
         $this->response->setVariable('return_url', $this->request->headers->get('referer'));
     }
     // view based on request
     if ($this->request->getParam('format') == 'json') {
         $this->response->setView('search/save-ajax.xsl');
     } else {
         $this->response->setView('search/save.xsl');
     }
     return $this->response;
 }