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->data->setVariable('delete', '1'); } else { // get record $record = $this->engine->getRecord($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); $this->data->setVariable('savedRecordID', $inserted_id); } // view template $this->data->setTemplate('search/save-ajax.xsl'); return $this->data; }
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->data["delete"] = "1"; } else { // get record $sid = $_SESSION['pazpar2']['sid']; $record = $this->engine->getRawRecord($sid, $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); $this->data["savedRecordID"] = $inserted_id; } return $this->data; }
/** * 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; }