The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit d203c613 authored by Demian Katz's avatar Demian Katz
Browse files

Implemented ILS-based reserve searching.

parent 5e400ab5
No related merge requests found
...@@ -394,7 +394,6 @@ class SearchController extends AbstractSearch ...@@ -394,7 +394,6 @@ class SearchController extends AbstractSearch
*/ */
public function reservesAction() public function reservesAction()
{ {
/* TODO
// Search parameters set? Process results. // Search parameters set? Process results.
if ($this->params()->fromQuery('inst') !== null if ($this->params()->fromQuery('inst') !== null
|| $this->params()->fromQuery('course') !== null || $this->params()->fromQuery('course') !== null
...@@ -405,17 +404,20 @@ class SearchController extends AbstractSearch ...@@ -405,17 +404,20 @@ class SearchController extends AbstractSearch
// No params? Show appropriate form (varies depending on whether we're // No params? Show appropriate form (varies depending on whether we're
// using driver-based or Solr-based reserves searching). // using driver-based or Solr-based reserves searching).
if ($this->_helper->reserves()->useIndex()) { if ($this->reserves()->useIndex()) {
return $this->forwardTo('Search', 'ReservesSearch'); return $this->forwardTo('Search', 'ReservesSearch');
} }
// If we got this far, we're using driver-based searching and need to // If we got this far, we're using driver-based searching and need to
// send options to the view: // send options to the view:
$catalog = ConnectionManager::connectToCatalog(); $catalog = ConnectionManager::connectToCatalog();
$this->view->deptList = $catalog->getDepartments(); return $this->createViewModel(
$this->view->instList = $catalog->getInstructors(); array(
$this->view->courseList = $catalog->getCourses(); 'deptList' => $catalog->getDepartments(),
*/ 'instList' => $catalog->getInstructors(),
'courseList' => $catalog->getCourses()
)
);
} }
/** /**
...@@ -439,32 +441,18 @@ class SearchController extends AbstractSearch ...@@ -439,32 +441,18 @@ class SearchController extends AbstractSearch
*/ */
public function reservesresultsAction() public function reservesresultsAction()
{ {
/* TODO
// Retrieve course reserves item list: // Retrieve course reserves item list:
$course = $this->params()->fromQuery('course'); $course = $this->params()->fromQuery('course');
$inst = $this->params()->fromQuery('inst'); $inst = $this->params()->fromQuery('inst');
$dept = $this->params()->fromQuery('dept'); $dept = $this->params()->fromQuery('dept');
$result = $this->_helper->reserves()->findReserves($course, $inst, $dept); $result = $this->reserves()->findReserves($course, $inst, $dept);
// Pass some key values to the view, if found:
if (isset($result[0]['instructor']) && !empty($result[0]['instructor'])) {
$this->view->instructor = $result[0]['instructor'];
}
if (isset($result[0]['course']) && !empty($result[0]['course'])) {
$this->view->course = $result[0]['course'];
}
// Build a list of unique IDs // Build a list of unique IDs
$bibIDs = array(); $callback = function($i) { return $i['BIB_ID']; };
foreach ($result as $record) { $bibIDs = array_unique(array_map($callback, $result));
// Avoid duplicate IDs (necessary for Voyager ILS driver):
if (!in_array($record['BIB_ID'], $bibIDs)) {
$bibIDs[] = $record['BIB_ID'];
}
}
// Truncate the list if it is too long: // Truncate the list if it is too long:
$params = new VF_Search_Solr_Params(); $params = new \VuFind\Search\Solr\Params();
$limit = $params->getQueryIDLimit(); $limit = $params->getQueryIDLimit();
if (count($bibIDs) > $limit) { if (count($bibIDs) > $limit) {
$bibIDs = array_slice($bibIDs, 0, $limit); $bibIDs = array_slice($bibIDs, 0, $limit);
...@@ -473,17 +461,25 @@ class SearchController extends AbstractSearch ...@@ -473,17 +461,25 @@ class SearchController extends AbstractSearch
} }
// Use standard search action with override parameter to show results: // Use standard search action with override parameter to show results:
$this->_request->setParam('overrideIds', $bibIDs); $this->getRequest()->getQuery()->set('overrideIds', $bibIDs);
// Call rather than forward, so we can use custom template // Call rather than forward, so we can use custom template
$this->resultsAction(); $view = $this->resultsAction();
// Pass some key values to the view, if found:
if (isset($result[0]['instructor']) && !empty($result[0]['instructor'])) {
$view->instructor = $result[0]['instructor'];
}
if (isset($result[0]['course']) && !empty($result[0]['course'])) {
$view->course = $result[0]['course'];
}
// Customize the URL helper to make sure it builds proper reserves URLs: // Customize the URL helper to make sure it builds proper reserves URLs:
$url = $this->view->results->getUrl(); $url = $view->results->getUrl();
$url->setDefaultParameter('course', $course); $url->setDefaultParameter('course', $course);
$url->setDefaultParameter('inst', $inst); $url->setDefaultParameter('inst', $inst);
$url->setDefaultParameter('dept', $dept); $url->setDefaultParameter('dept', $dept);
*/ return $view;
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment