public function getRecords()
 {
     if ($this->hasRecords()) {
         // get full reading list record data
         $record_data = $this->getRecordData();
         // get just the id's
         $ids = array();
         foreach ($record_data as $record_data_item) {
             $ids[] = $record_data_item->record_id;
         }
         // get the full Xerxes records
         $records_datamap = new SavedRecords();
         $records = $records_datamap->getRecordsByID($ids);
         // print_r($record_data); print_r($records); exit;
         // reorder them here -- hacky sack! @todo: find a better way!
         $final = array();
         foreach ($record_data as $record_data_item) {
             foreach ($records as $record) {
                 if ($record->id == $record_data_item->record_id) {
                     // substitute any user-supplied data
                     if ($record_data_item->title != "") {
                         $user_params = array('title' => $record_data_item->title, 'sub_title' => '', 'non_sort' => '', 'primary_author' => $record_data_item->author, 'journal' => $record_data_item->publication, 'abstract' => $record_data_item->description);
                         $record->xerxes_record->setProperties($user_params);
                     }
                     // add them in this order
                     $final[] = $record;
                     break;
                 }
             }
         }
         return $final;
     }
 }
示例#2
0
 public function getRecords()
 {
     if ($this->hasCourseRecords()) {
         $ids = $this->getCourseRecordIDs();
         $records_datamap = new SavedRecords();
         $records = $records_datamap->getRecordsByID($ids);
         // reorder them here -- hacky sack! @todo: find a better way!
         // print_r($ids); print_r($records); exit;
         $final = array();
         foreach ($ids as $id) {
             foreach ($records as $record) {
                 if ($record->id == $id) {
                     $final[] = $record;
                     break;
                 }
             }
         }
         return $final;
     }
 }
示例#3
0
 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;
 }
 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;
 }
示例#5
0
 /**
  * Register the user in session and with the user tables in the database
  * and then forwards them to the return url
  * 
  * @param User $user  [optional] user object
  */
 public function register(User $user = null)
 {
     // if passed in externally
     if ($user != null) {
         $this->user = $user;
     }
     // data map
     $datamap_users = new Users();
     $datamap_records = new SavedRecords();
     // if the user was previously active under a local username
     // then reassign any saved records to the new username
     $old_username = $this->request->getSessionData("username");
     $old_role = $this->request->getSessionData("role");
     if ($old_role == "local") {
         $datamap_records->reassignRecords($old_username, $this->user->username);
     }
     // add or update user in the database
     // get any values in the db not specified here and populates user
     $this->user = $datamap_users->touchUser($this->user);
     // @todo: reconcile this code with User code
     // should we just save user object in session?
     // set main properties in session
     $admins = explode(',', $this->registry->getConfig('ADMIN_USERS'));
     if (in_array($this->user->username, $admins)) {
         $this->request->setSessionData("user_admin", true);
     }
     $this->request->setSessionData("username", $this->user->username);
     $this->request->setSessionData("role", $this->role);
     // store user's additional properties in session, so they can be used by
     // controller, and included in xml for views.
     $this->request->setSessionData("user_properties", $this->user->properties());
     // groups too empty array not null please.
     $this->request->setSessionData("user_groups", $this->user->usergroups);
     // set this object's id in session
     $this->request->setSessionData("auth", $this->id);
     // now forward them to the return url
     return $this->redirectTo($this->return_url);
 }
 /**
  * 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;
 }
 /**
  * Delete records
  */
 public function deleteAction()
 {
     $missing = $this->checkRequiredParams();
     if ($missing != null) {
         return $missing;
     }
     $id_array = $this->request->getParam('record', null, true);
     $return = $this->request->getParam('return');
     $username = $this->request->getSessionData('username');
     // remove saved records from database
     $datamap = new SavedRecords();
     $original_ids = $datamap->deleteRecordByID($username, $id_array);
     // remove any saved record state for these
     foreach ($original_ids as $original_id) {
         $this->unmarkSaved($original_id);
     }
     $lang = $this->request->getParam("lang");
     $labels = $this->getLabels($lang);
     $this->request->setFlashMessage(Request::FLASH_MESSAGE_NOTICE, $labels->getLabel('text_folder_export_deleted'));
     return $this->redirectTo($return);
 }
示例#8
0
文件: Scheme.php 项目: navtis/xerxes
 /**
  * Registers the user in session and with the user tables in the database
  * and then forwards them to the return url
  */
 public function register()
 {
     // data map
     $datamap_users = new Users();
     $datamap_records = new SavedRecords();
     // if the user was previously active under a local username
     // then reassign any saved records to the new username
     $old_username = $this->request->getSessionData("username");
     $old_role = $this->request->getSessionData("role");
     if ($old_role == "local") {
         $datamap_records->reassignRecords($old_username, $this->user->username);
     }
     // add or update user in the database
     // get any values in the db not specified here and populates user
     $this->user = $datamap_users->touchUser($this->user);
     // @todo: should we just save user object in session?
     // set main properties in session
     $this->request->setSessionData("username", $this->user->username);
     $this->request->setSessionData("role", $this->role);
     // store user's additional properties in session, so they can be used by
     // controller, and included in xml for views.
     $this->request->setSessionData("user_properties", $this->user->properties());
     // groups too empty array not null please.
     $this->request->setSessionData("user_groups", $this->user->usergroups);
     // set this object's id in session
     $this->request->setSessionData("auth", $this->id);
     // now forward them to the return url
     $this->setRedirect($this->return_url);
     return self::SUCCESS;
 }