コード例 #1
0
 public static function destroy($sess_id)
 {
     // Delete the searches stored for this session
     $search = new SearchEntry();
     $searchList = $search->getSearches($sess_id);
     // Make sure there are some
     if (count($searchList) > 0) {
         foreach ($searchList as $oldSearch) {
             // And make sure they aren't saved
             if ($oldSearch->saved == 0) {
                 $oldSearch->delete();
             }
         }
     }
 }
コード例 #2
0
ファイル: Base.php プロジェクト: victorfcm/VuFind-Plus
 /**
  * Add into the search table (history)
  *
  * @access  protected
  */
 protected function addToHistory()
 {
     global $user;
     // Get the list of all old searches for this session and/or user
     $s = new SearchEntry();
     /** @var SearchEntry[] $searchHistory */
     $searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
     // Duplicate elimination
     $dupSaved = false;
     foreach ($searchHistory as $oldSearch) {
         // Deminify the old search
         $minSO = unserialize($oldSearch->search_object);
         $dupSearch = SearchObjectFactory::deminify($minSO);
         // See if the classes and urls match
         if (get_class($dupSearch) && get_class($this) && $dupSearch->renderSearchUrl() == $this->renderSearchUrl()) {
             // Is the older search saved?
             if ($oldSearch->saved) {
                 // Flag for later
                 $dupSaved = true;
                 // Record the details
                 $this->searchId = $oldSearch->id;
                 $this->savedSearch = true;
             } else {
                 // Delete this search
                 $oldSearch->delete();
             }
         }
     }
     // Save this search unless we found a 'saved' duplicate
     if (!$dupSaved) {
         $search = new SearchEntry();
         $search->session_id = session_id();
         $search->created = date('Y-m-d');
         $search->search_object = serialize($this->minify());
         $search->insert();
         // Record the details
         $this->searchId = $search->id;
         $this->savedSearch = false;
         // Chicken and egg... We didn't know the id before insert
         $search->search_object = serialize($this->minify());
         $search->update();
     }
 }
コード例 #3
0
ファイル: History.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $user;
     // Assign the ID of the last search so the user can return to it.
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : 'perkele');
     $dateFormat = new VuFindDate();
     // In some contexts, we want to require a login before showing search
     // history:
     if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
         include_once 'services/MyResearch/Login.php';
         Login::launch();
         exit;
     }
     $interface->setPageTitle('Search History');
     // Retrieve search history
     $s = new SearchEntry();
     $searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
     if (count($searchHistory) > 0) {
         // Build an array of history entries
         $links = array();
         $saved = array();
         // Loop through the history
         foreach ($searchHistory as $search) {
             $size = strlen($search->search_object);
             $minSO = unserialize($search->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             // Make sure all facets are active so we get appropriate
             // descriptions in the filter box.
             $searchObject->activateAllFacets();
             $newItem = array('time' => $dateFormat->convertToDisplayDate("U", floor($searchObject->getStartTime())), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal(), 0, ',', ' '), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb", 'schedule' => $search->schedule, 'last_executed' => $search->last_executed);
             // Saved searches
             if ($search->saved == 1) {
                 $saved[] = $newItem;
             } else {
                 // All the others...
                 // If this was a purge request we don't need this
                 if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
                     $search->delete();
                     // We don't want to remember the last search after a purge:
                     unset($_SESSION['lastSearchURL']);
                     unset($_SESSION['lastSearchDisplayQuery']);
                 } else {
                     // Otherwise add to the list
                     $links[] = $newItem;
                 }
             }
         }
         // One final check, after a purge make sure we still have a history
         if (count($links) > 0 || count($saved) > 0) {
             $interface->assign('links', array_reverse($links));
             $interface->assign('saved', array_reverse($saved));
             $interface->assign('noHistory', false);
         } else {
             // Nothing left in history
             $interface->assign('noHistory', true);
         }
     } else {
         // No history
         $interface->assign('noHistory', true);
     }
     $interface->setTemplate('history.tpl');
     $interface->display('layout.tpl');
 }
コード例 #4
0
ファイル: History.php プロジェクト: victorfcm/VuFind-Plus
 function launch()
 {
     global $interface;
     global $user;
     // In some contexts, we want to require a login before showing search
     // history:
     if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
         require_once ROOT_DIR . '/services/MyAccount/Login.php';
         MyAccount_Login::launch();
         exit;
     }
     $interface->setPageTitle('Search History');
     // Retrieve search history
     $s = new SearchEntry();
     $searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
     if (count($searchHistory) > 0) {
         // Build an array of history entries
         $links = array();
         $saved = array();
         // Loop through the history
         foreach ($searchHistory as $search) {
             $size = strlen($search->search_object);
             $minSO = unserialize($search->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             // Make sure all facets are active so we get appropriate
             // descriptions in the filter box.
             $searchObject->activateAllFacets();
             $newItem = array('id' => $search->id, 'time' => date("g:ia, jS M y", $searchObject->getStartTime()), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal()), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb");
             // Saved searches
             if ($search->saved == 1) {
                 $saved[] = $newItem;
                 // All the others
             } else {
                 // If this was a purge request we don't need this
                 if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
                     $search->delete();
                     // We don't want to remember the last search after a purge:
                     unset($_SESSION['lastSearchURL']);
                     // Otherwise add to the list
                 } else {
                     $links[] = $newItem;
                 }
             }
         }
         // One final check, after a purge make sure we still have a history
         if (count($links) > 0 || count($saved) > 0) {
             $interface->assign('links', array_reverse($links));
             $interface->assign('saved', array_reverse($saved));
             $interface->assign('noHistory', false);
             // Nothing left in history
         } else {
             $interface->assign('noHistory', true);
         }
         // No history
     } else {
         $interface->assign('noHistory', true);
     }
     //Load profile information for display in My Account menu
     //This code is also in MyResearch.php
     if ($user !== false) {
         global $configArray;
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         // Get My Profile
         if ($this->catalog->status) {
             if ($user->cat_username) {
                 $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
                 if (PEAR_Singleton::isError($patron)) {
                     PEAR_Singleton::raiseError($patron);
                 }
                 $result = $this->catalog->getMyProfile($patron);
                 if (!PEAR_Singleton::isError($result)) {
                     $interface->assign('profile', $result);
                 }
             }
         }
         //Figure out if we should show a link to classic opac to pay holds.
         global $library;
         $homeLibrary = $library->getLibraryForLocation($user->homeLocationId);
         if ($homeLibrary->showEcommerceLink == 1) {
             $interface->assign('showEcommerceLink', true);
             $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
         } else {
             $interface->assign('showEcommerceLink', false);
             $interface->assign('minimumFineAmount', 0);
         }
     }
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('history.tpl');
     $interface->display('layout.tpl');
 }