function launch($msg = null) { global $interface; global $configArray; global $user; if (!($user = UserAccount::isLoggedIn())) { require_once 'Login.php'; Login::launch(); exit; } // Save Data if (isset($_REQUEST['tagId'])) { //Remove the tag for the user. $resource = new Resource(); if (isset($_REQUEST['resourceId'])) { $resource = $resource->staticGet('record_id', $_REQUEST['resourceId']); $resource->removeTag($_REQUEST['tagId'], $user, false); header('Location: ' . $configArray['Site']['path'] . '/Record/' . $_REQUEST['resourceId']); exit; } else { $resource->removeTag($_REQUEST['tagId'], $user, true); header('Location: ' . $configArray['Site']['path'] . '/MyResearch/Favorites'); exit; } } else { //No id provided to delete raise an error? PEAR_Singleton::raiseError(new PEAR_Error('Tag Id Missing')); } }
function launch($msg = null) { global $interface; global $configArray; if (!($user = UserAccount::isLoggedIn())) { require_once 'Login.php'; Login::launch(); exit; } // Save Data if (isset($_POST['submit'])) { $this->saveChanges($user); // After changes are saved, send the user back to an appropriate page; // either the list they were viewing when they started editing, or the // overall favorites list. if (isset($_REQUEST['list_id'])) { $nextAction = 'MyList/' . $_REQUEST['list_id']; } elseif (isset($_REQUEST['lists'])) { if (is_array($_REQUEST['lists'])) { $nextAction = 'MyList/' . $_REQUEST['lists'][0]; } else { $nextAction = 'MyList/' . $_REQUEST['lists']; } } else { $nextAction = 'Home'; } header('Location: ' . $configArray['Site']['path'] . '/MyResearch/' . $nextAction); exit; } // Setup Search Engine Connection $class = $configArray['Index']['engine']; $db = new $class($configArray['Index']['url']); if ($configArray['System']['debugSolr']) { $db->debug = true; } // Get Record Information $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = $_GET['source']; if ($resource->find(true)) { $interface->assign('resource', $resource); } // Record ID $interface->assign('recordId', $_GET['id']); // Retrieve saved information about record $saved = $user->getSavedData($_GET['id'], $_GET['source']); // Add tag information $savedData = array(); foreach ($saved as $current) { // If we're filtering to a specific list, skip any other lists: if (isset($_GET['list_id']) && $current->list_id != $_GET['list_id']) { continue; } $savedData[] = array('listId' => $current->list_id, 'listTitle' => $current->list_title, 'notes' => $current->notes, 'tags' => $this->getTags($user, $current->list_id)); } $interface->assign('savedData', $savedData); $interface->assign('listFilter', $_GET['list_id']); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; // Depending on context, we may get the record ID that initiated the "add // list" action in a couple of different places -- make sure we check all // necessary options before giving up! if (!isset($_GET['id']) && isset($_REQUEST['recordId'])) { $_GET['id'] = $_REQUEST['recordId']; } $interface->assign('recordId', isset($_GET['id']) ? $_GET['id'] : false); $interface->assign('bulkIDs', isset($_REQUEST['ids']) ? $_REQUEST['ids'] : false); // Check if user is logged in if (!$this->_user) { if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); $interface->assign('message', 'You must be logged in first'); Login::setupLoginFormVars(); return $interface->fetch('AJAX/login.tpl'); } else { include_once 'Login.php'; Login::launch(); } exit; } // Display Page if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); return $interface->fetch('MyResearch/list-form.tpl'); } else { if (isset($_REQUEST['submit'])) { $result = $this->addList(); if (PEAR::isError($result)) { $interface->assign('listError', $result->getMessage()); } else { if (!empty($_REQUEST['recordId'])) { $url = '../Record/' . urlencode($_REQUEST['recordId']) . '/Save'; } if (isset($_REQUEST['ids']) && !empty($_REQUEST['ids'])) { $parts = array(); foreach ($_REQUEST['ids'] as $id) { $parts[] = urlencode('ids[]') . '=' . urlencode($id); } $url = '../Cart/Home?saveCart=&' . implode('&', $parts); } else { $url = 'Favorites'; } header('Location: ' . $url); die; } } $interface->setPageTitle('Create a List'); $interface->assign('subTemplate', 'list-form.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl'); } }
/** * Constructor * * @param bool $skipLogin Set to true to bypass the default login requirement. * * @access public */ public function __construct($skipLogin = false) { global $interface; global $configArray; global $user; if (!$skipLogin && !UserAccount::isLoggedIn()) { include_once 'Login.php'; Login::launch(); exit; } // Setup Search Engine Connection $this->db = ConnectionManager::connectToIndex(); // Connect to Database $this->catalog = ConnectionManager::connectToCatalog(); // Is Placing Holds allowed? $this->checkHolds = $this->catalog->checkFunction("Holds", null); // Is Cancelling Holds allowed? $this->cancelHolds = $this->catalog->checkFunction("cancelHolds", null); // Is Renewing Items allowed? $this->checkRenew = $this->catalog->checkFunction("Renewals", null); // Register Library Catalog Account if (isset($_POST['submit']) && !empty($_POST['submit']) && $this->catalog && isset($_POST['cat_username']) && isset($_POST['cat_password'])) { $username = $_POST['cat_username']; $password = $_POST['cat_password']; $loginTarget = isset($_POST['login_target']) ? $_POST['login_target'] : false; if ($loginTarget) { $username = "******"; } if (UserAccount::processCatalogLogin($username, $password)) { $interface->assign('user', $user); } else { $interface->assign('loginError', 'Invalid Patron Login'); } } // Assign Exporter Options $exportOptions = array(); if ($configArray['BulkExport']['enabled']) { $options = explode(':', $configArray['BulkExport']['options']); foreach ($options as $option) { if ($configArray['Export'][$option] == true) { $exportOptions[] = $option; } } $interface->assign('exportOptions', $exportOptions); } // Get Messages $this->infoMsg = isset($_GET['infoMsg']) ? $_GET['infoMsg'] : false; $this->errorMsg = isset($_GET['errorMsg']) ? $_GET['errorMsg'] : false; $this->showExport = isset($_GET['showExport']) ? $_GET['showExport'] : false; $this->followupUrl = false; }
function launch() { global $interface; global $configArray; // Depending on context, we may get the record ID that initiated the "add // list" action in a couple of different places -- make sure we check all // necessary options before giving up! if (!isset($_GET['id']) && isset($_REQUEST['recordId'])) { $_GET['id'] = $_REQUEST['recordId']; } $interface->assign('recordId', isset($_GET['id']) ? $_GET['id'] : false); $interface->assign('source', isset($_GET['source']) ? $_GET['source'] : false); // Check if user is logged in if (!$this->user) { if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); $interface->assign('message', 'You must be logged in first'); return $interface->fetch('AJAX/login.tpl'); } else { require_once 'Login.php'; Login::launch(); } exit; } // Display Page if (isset($_GET['lightbox'])) { $interface->assign('title', translate('Create new list')); echo $interface->fetch('MyResearch/list-form.tpl'); } else { if (isset($_REQUEST['submit'])) { $result = $this->addList(); if (PEAR_Singleton::isError($result)) { $interface->assign('listError', $result->getMessage()); } else { if (!empty($_REQUEST['recordId'])) { $url = '../Record/' . urlencode($_REQUEST['recordId']) . '/Save'; } else { $url = 'Home'; } header('Location: ' . $url); die; } } $interface->setPageTitle('Create a List'); $interface->assign('subTemplate', 'list-form.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl'); } }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (!($user = UserAccount::isLoggedIn())) { include_once 'Login.php'; Login::launch(); exit; } // Fetch List object $list = User_list::staticGet($_GET['id']); // Ensure user have privs to view the list if ($list->user_id != $user->id) { PEAR::raiseError(new PEAR_Error(translate('list_access_denied'))); } // Save Data if (isset($_POST['submit'])) { if (empty($_POST['title'])) { $interface->assign('errorMsg', 'list_edit_name_required'); } else { if ($this->_saveChanges($user, $list)) { // After changes are saved, send the user back to an appropriate page $nextAction = 'MyList/' . $list->id; header('Location: ' . $configArray['Site']['url'] . '/MyResearch/' . $nextAction); exit; } else { // List was not edited $interface->assign('errorMsg', 'edit_list_fail'); } } } // Send list to template so title/description can be displayed: $interface->assign('list', $list); $interface->setTemplate('editList.tpl'); $interface->display('layout.tpl'); }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (!($user = UserAccount::isLoggedIn())) { include_once 'Login.php'; Login::launch(); exit; } // Save Data if (isset($_POST['submit'])) { $this->_saveChanges($user); // After changes are saved, send the user back to an appropriate page; // either the list they were viewing when they started editing, or the // overall favorites list. if (isset($_GET['list_id'])) { $nextAction = 'MyList/' . $_GET['list_id']; } else { $nextAction = 'Favorites'; } header('Location: ' . $configArray['Site']['url'] . '/MyResearch/' . $nextAction); exit; } // Setup Search Engine Connection $db = ConnectionManager::connectToIndex(); // Get Record Information $details = $db->getRecord($_GET['id']); $interface->assign('record', $details); // Record ID $interface->assign('recordId', $_GET['id']); // Retrieve saved information about record $saved = $user->getSavedData($_GET['id']); // Add tag information $savedData = array(); foreach ($saved as $current) { // If we're filtering to a specific list, skip any other lists: if (isset($_GET['list_id']) && $current->list_id != $_GET['list_id']) { continue; } $savedData[] = array('listId' => $current->list_id, 'listTitle' => $current->list_title, 'notes' => $current->notes, 'tags' => $this->_getTags($user, $current->list_id)); } $interface->assign('savedData', $savedData); $interface->assign('listFilter', isset($_GET['list_id']) ? $_GET['list_id'] : null); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $configArray; global $interface; global $user; // Delete List and All Resources (but only if list owner is logged in!) if (isset($_POST['deleteList'])) { $listID = $_POST['listID']; $list = User_list::staticGet($listID); if ($user->id == $list->user_id) { // Remove the List $result = $list->emptyList(); if ($result) { $followupUrl = $configArray['Site']['url'] . "/MyResearch/Favorites"; header("Location: " . $followupUrl . "?infoMsg=fav_list_delete"); exit; } } // If we get this far, there's an error $this->errorMsg = "fav_list_delete_fail"; } // Fetch List object $list = User_list::staticGet($_GET['id']); // Ensure user have privs to view the list if (!$list->public && !UserAccount::isLoggedIn()) { include_once 'Login.php'; Login::launch(); exit; } if (!$list->public && $list->user_id != $user->id) { PEAR::raiseError(new PEAR_Error(translate('list_access_denied'))); } // Redirect anonymous users to public list URL if ($list->public && (!UserAccount::isLoggedIn() || $list->user_id != $user->id)) { header("Location: " . $configArray['Site']['url'] . "/List/" . $list->id); } $this->infoMsg = isset($_GET['infoMsg']) ? $_GET['infoMsg'] : false; $this->errorMsg = isset($_GET['errorMsg']) ? $_GET['errorMsg'] : false; $this->showExport = isset($_GET['showExport']) ? $_GET['showExport'] : false; // Delete Resource (but only if list owner is logged in!) if (isset($_GET['delete']) && $user->id == $list->user_id) { $resource = new Resource(); $resource->record_id = $_GET['delete']; unset($resource->source); if ($resource->find(true)) { $list->removeResource($resource); } } // Send list to template so title/description can be displayed: $interface->assign('list', $list); // Build Favorites List $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null); // Load the User object for the owner of the list (if necessary): if ($user && $user->id == $list->user_id) { $listUser = $user; } else { $listUser = User::staticGet($list->user_id); } // Create a handler for displaying favorites and use it to assign // appropriate template variables: $allowEdit = $user && $user->id == $list->user_id; $favList = new FavoriteHandler($favorites, $listUser, $list->id, $allowEdit); $favList->assign(); if (!$this->infoMsg) { $this->infoMsg = $favList->getInfoMsg(); } // Narrow by Tag if (isset($_GET['tag'])) { $interface->assign('tags', $_GET['tag']); } // Get My Lists $listList = $user ? $user->getLists() : array(); $interface->assign('listList', $listList); // Get My Tags $tagList = $list->getTags(); $interface->assign('tagList', $tagList); // Assign Error & Info Messages $interface->assign('infoMsg', $this->infoMsg); $interface->assign('errorMsg', $this->errorMsg); $interface->assign('showExport', $this->showExport); // Assign Exporter Options $exportOptions = array(); if ($configArray['BulkExport']['enabled']) { $options = explode(':', $configArray['BulkExport']['options']); foreach ($options as $option) { if ($configArray['Export'][$option] == true) { $exportOptions[] = $option; } } $interface->assign('exportOptions', $exportOptions); } $interface->setTemplate('list.tpl'); $interface->setPageTitle($list->title); $interface->display('layout.tpl'); }
function launch() { global $configArray; global $interface; global $user; //Get all lists for the user if ($user) { $tmpList = new User_list(); $tmpList->user_id = $user->id; $tmpList->orderBy("title ASC"); $tmpList->find(); $allLists = array(); if ($tmpList->N > 0) { while ($tmpList->fetch()) { $allLists[$tmpList->id] = $tmpList->title; } } else { $allList["-1"] = "My Favorites"; } $interface->assign('allLists', $allLists); } //Figure out if we should show a link to classic opac to pay holds. $ecommerceLink = $configArray['Site']['ecommerceLink']; if ($user) { $homeLibrary = Library::getLibraryForLocation($user->homeLocationId); } if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) { $interface->assign('showEcommerceLink', true); $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount); if ($homeLibrary->payFinesLink == 'default' || strlen($homeLibrary->payFinesLink) == 0) { $interface->assign('ecommerceLink', $ecommerceLink); } else { $interface->assign('ecommerceLink', $homeLibrary->payFinesLink); } $interface->assign('payFinesLinkText', $homeLibrary->payFinesLinkText); } else { $interface->assign('showEcommerceLink', false); $interface->assign('minimumFineAmount', 0); } // Fetch List object if (isset($_GET['id'])) { $list = User_list::staticGet($_GET['id']); } else { //Use the first list. if (isset($allLists)) { $firstListId = reset(array_keys($allLists)); if ($firstListId == false || $firstListId == -1) { $list = new User_list(); $list->user_id = $user->id; $list->public = false; $list->title = "My Favorites"; } else { $list = User_list::staticGet($firstListId); } } } // Ensure user have privs to view the list if (!isset($list) || !$list->public && !UserAccount::isLoggedIn()) { require_once 'Login.php'; Login::launch(); exit; } if (!$list->public && $list->user_id != $user->id) { PEAR_Singleton::raiseError(new PEAR_Error(translate('list_access_denied'))); } //Reindex can happen by anyone since it needs to be called by cron if (isset($_REQUEST['myListActionHead']) && strlen($_REQUEST['myListActionHead']) > 0) { $actionToPerform = $_REQUEST['myListActionHead']; if ($actionToPerform == 'reindex') { $list->updateDetailed(true); } } if (isset($_SESSION['listNotes'])) { $interface->assign('notes', $_SESSION['listNotes']); unset($_SESSION['listNotes']); } //Perform an action on the list, but verify that the user has permission to do so. $userCanEdit = false; if ($user != false) { if ($user->id == $list->user_id) { $userCanEdit = true; } elseif ($user->hasRole('opacAdmin')) { $userCanEdit = true; } elseif ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) { $listUser = new User(); $listUser->id = $list->user_id; $listUser->find(true); $listLibrary = Library::getLibraryForLocation($listUser->homeLocationId); $userLibrary = Library::getLibraryForLocation($user->homeLocationId); if ($userLibrary->libraryId == $listLibrary->libraryId) { $userCanEdit = true; } } } if ($userCanEdit && (isset($_REQUEST['myListActionHead']) || isset($_REQUEST['myListActionItem']) || isset($_GET['delete']))) { if (isset($_REQUEST['myListActionHead']) && strlen($_REQUEST['myListActionHead']) > 0) { $actionToPerform = $_REQUEST['myListActionHead']; if ($actionToPerform == 'makePublic') { $list->public = 1; $list->update(); } elseif ($actionToPerform == 'makePrivate') { $list->public = 0; $list->updateDetailed(false); $list->removeFromSolr(); } elseif ($actionToPerform == 'saveList') { $list->title = $_REQUEST['newTitle']; $list->description = $_REQUEST['newDescription']; $list->update(); } elseif ($actionToPerform == 'deleteList') { $list->delete(); header("Location: {$configArray['Site']['path']}/MyResearch/Home"); die; } elseif ($actionToPerform == 'bulkAddTitles') { $notes = $this->bulkAddTitles($list); $_SESSION['listNotes'] = $notes; } } elseif (isset($_REQUEST['myListActionItem']) && strlen($_REQUEST['myListActionItem']) > 0) { $actionToPerform = $_REQUEST['myListActionItem']; if ($actionToPerform == 'deleteMarked') { //get a list of all titles that were selected $itemsToRemove = $_REQUEST['selected']; foreach ($itemsToRemove as $id => $selected) { //add back the leading . to get the full bib record $resource = Resource::staticGet('record_id', "{$id}"); $list->removeResource($resource); } } elseif ($actionToPerform == 'deleteAll') { $list->removeAllResources(isset($_GET['tag']) ? $_GET['tag'] : null); } $list->update(); } elseif (isset($_GET['delete'])) { $resource = Resource::staticGet('record_id', $_GET['delete']); $list->removeResource($resource); $list->update(); } //Redirect back to avoid having the parameters stay in the URL. header("Location: {$configArray['Site']['path']}/MyResearch/MyList/{$list->id}"); die; } // Send list to template so title/description can be displayed: $interface->assign('favList', $list); $interface->assign('listSelected', $list->id); // Build Favorites List $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null); // Load the User object for the owner of the list (if necessary): if ($user && $user->id == $list->user_id) { $listUser = $user; } else { if ($list->user_id != 0) { $listUser = new User(); $listUser->id = $list->user_id; if (!$listUser->fetch(true)) { $listUser = false; } } else { $listUser = false; } } // Create a handler for displaying favorites and use it to assign // appropriate template variables: $interface->assign('allowEdit', $userCanEdit); $favList = new FavoriteHandler($favorites, $listUser, $list->id, $userCanEdit); $favList->assign(); //Need to add profile information from MyResearch to show profile data. if ($user !== false) { global $configArray; $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); // 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. $homeLibrary = Library::getLibraryForLocation($user->homeLocationId); if (isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) { $interface->assign('showEcommerceLink', true); $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount); } else { $interface->assign('showEcommerceLink', false); $interface->assign('minimumFineAmount', 0); } } $interface->setTemplate('list.tpl'); $interface->display('layout.tpl'); }
// If we authenticated, store the user in the session: if (PEAR::isError($user)) { if ($user->getMessage() == 'authentication_error_admin') { // Suppressed: error_log('User id not set, Shibboleth login not possible'); } else { error_log("Shibboleth login failed: " . $user->getMessage()); } $user = false; } } if (!$user && $standardLoginNeeded) { $user = UserAccount::login(); if (PEAR::isError($user)) { $interface->initGlobals(); include_once 'services/MyResearch/Login.php'; Login::launch($user->getMessage()); exit; } } } } // Update user's language if ($user && (isset($_POST['mylang']) || isset($_GET['lng']))) { $user->changeLanguage($language); } // Activate catalog account if (isset($_REQUEST['catalogAccount'])) { if ($_REQUEST['catalogAccount'] == 'new') { header("Location: {$configArray['Site']['url']}/MyResearch/Accounts?add=1"); return; }
/** * 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'); }
function __construct() { global $interface; global $configArray; global $user; $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('ils', $configArray['Catalog']['ils']); if ($this->requireLogin && !UserAccount::isLoggedIn()) { require_once 'Login.php'; Login::launch(); exit; } //$interface->assign('userNoticeFile', 'MyResearch/listNotice.tpl'); // Setup Search Engine Connection $class = $configArray['Index']['engine']; $this->db = new $class($configArray['Index']['url']); if ($configArray['System']['debugSolr']) { $this->db->debug = true; } // Connect to Database $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); // Register Library Catalog Account if (isset($_POST['submit']) && !empty($_POST['submit'])) { if ($this->catalog && isset($_POST['cat_username']) && isset($_POST['cat_password'])) { $result = $this->catalog->patronLogin($_POST['cat_username'], $_POST['cat_password']); if ($result && !PEAR_Singleton::isError($result)) { $user->cat_username = $_POST['cat_username']; $user->cat_password = $_POST['cat_password']; $user->update(); UserAccount::updateSession($user); $interface->assign('user', $user); } else { $interface->assign('loginError', 'Invalid Patron Login'); } } } //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Check to see if we have any acs or single use eContent in the catalog //to enable the holds and wishlist appropriately if (isset($configArray['EContent']['hasProtectedEContent'])) { $interface->assign('hasProtectedEContent', $configArray['EContent']['hasProtectedEContent']); } else { $interface->assign('hasProtectedEContent', false); } global $library; if (isset($library)) { $interface->assign('showFavorites', $library->showFavorites); $interface->assign('showRatings', $library->showRatings); $interface->assign('showComments', $library->showComments); } else { $interface->assign('showFavorites', 1); $interface->assign('showRatings', 1); $interface->assign('showComments', 1); } //This code is also in Search/History since that page displays in the My Account menu as well. //It is also in MyList.php and Admin.php if ($user !== false) { $interface->assign('user', $user); // 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); } $profile = $this->catalog->getMyProfile($patron); //global $logger; //$logger->log("Patron profile phone number in MyResearch = " . $profile['phone'], PEAR_LOG_INFO); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } } //Figure out if we should show a link to classic opac to pay holds. $ecommerceLink = $configArray['Site']['ecommerceLink']; $homeLibrary = Library::getLibraryForLocation($user->homeLocationId); if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) { $interface->assign('showEcommerceLink', true); $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount); if ($homeLibrary->payFinesLink == 'default') { $interface->assign('ecommerceLink', $ecommerceLink); } else { $interface->assign('ecommerceLink', $homeLibrary->payFinesLink); } $interface->assign('payFinesLinkText', $homeLibrary->payFinesLinkText); } else { $interface->assign('showEcommerceLink', false); $interface->assign('minimumFineAmount', 0); } //Load a list of lists $lists = array(); if ($user->disableRecommendations == 0) { $lists[] = array('name' => 'Recommended For You', 'url' => '/MyResearch/SuggestedTitles', 'id' => 'suggestions'); } $tmpList = new User_list(); $tmpList->user_id = $user->id; $tmpList->orderBy("title ASC"); $tmpList->find(); if ($tmpList->N > 0) { while ($tmpList->fetch()) { $lists[$tmpList->id] = array('name' => $tmpList->title, 'url' => '/MyResearch/MyList/' . $tmpList->id, 'id' => $tmpList->id); } } else { $lists[-1] = array('name' => "My Favorites", 'url' => '/MyResearch/MyList/-1', 'id' => -1); } $interface->assign('lists', $lists); // Get My Tags $tagList = $user->getTags(); $interface->assign('tagList', $tagList); } }
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/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('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 inforamtion for display in My Account menu //This code is also in MyResearch.php if ($user !== false) { global $configArray; $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); // 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 $librarySingleton; $homeLibrary = $librarySingleton->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->setTemplate('history.tpl'); $interface->display('layout.tpl'); }