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'); }
/** * Change pick up location of a hold * * @return void * @access public */ public function changePickUpLocation() { if (isset($_REQUEST['reservationId'])) { // check if user is logged in $user = UserAccount::isLoggedIn(); if (!$user) { return $this->output(array('msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH); } $catalog = ConnectionManager::connectToCatalog(); if ($catalog && $catalog->status) { if ($patron = UserAccount::catalogLogin()) { if (!PEAR::isError($patron)) { $result = $catalog->changePickupLocation($patron, array('pickup' => $_REQUEST['pickup'], 'reservationId' => $_REQUEST['reservationId'], 'created' => $_REQUEST['created'], 'expires' => $_REQUEST['expires'])); if (!$result['success']) { return $this->output(array($result['sysMessage']), JSON::STATUS_ERROR); } return $this->output(array($result), JSON::STATUS_OK); } else { return $this->output($patron->getMessage(), JSON::STATUS_ERROR); } } } } return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR); }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; // Don't let bots crawl holdings $this->disallowBots(); if (!$this->hasHoldings && !(isset($configArray['Site']['ajaxRecordTabs']) && $configArray['Site']['ajaxRecordTabs'])) { $url = $configArray['Site']['url'] . "/Record/" . $_REQUEST['id'] . "/Description"; header('Location: ' . $url); } // Do not cache holdings page $interface->caching = 0; // See if patron is logged in to pass details onto get holdings for // holds / recalls $patron = UserAccount::isLoggedIn() ? UserAccount::catalogLogin() : false; if (PEAR::isError($patron)) { $patron = false; } $interface->setPageTitle($this->recordDriver->getBreadcrumb()); // Only fetch holdings if we actually need them (not needed for the basic page part of holdings when using ajax record tabs) if (!isset($configArray['Site']['ajaxRecordTabs']) || !$configArray['Site']['ajaxRecordTabs'] || isset($_REQUEST['subPage'])) { $interface->assign('holdingsMetadata', $this->recordDriver->getHoldings($patron)); } $interface->assign('subTemplate', 'view-holdings.tpl'); $interface->setTemplate('view.tpl'); // Set Messages $interface->assign('infoMsg', $this->infoMsg); $interface->assign('errorMsg', $this->errorMsg); // Display Page $interface->display('layout.tpl'); }
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')); } }
/** * Get a list of pickup locations for the given library * * @return void * @access public */ public function getPickUpLocations() { if (isset($_REQUEST['id']) && isset($_REQUEST['pickupLib'])) { // check if user is logged in $user = UserAccount::isLoggedIn(); if (!$user) { return $this->output(array('msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH); } $catalog = ConnectionManager::connectToCatalog(); if ($catalog && $catalog->status) { if ($patron = UserAccount::catalogLogin()) { if (!PEAR::isError($patron)) { $results = $catalog->getUBPickupLocations(array('id' => $_REQUEST['id'], 'patron' => $patron, 'pickupLibrary' => $_REQUEST['pickupLib'])); if (!PEAR::isError($results)) { foreach ($results as &$result) { $result['name'] = translate(array('prefix' => 'location_', 'text' => $result['name'])); } return $this->output(array('locations' => $results), JSON::STATUS_OK); } } } } } return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR); }
function __construct() { global $interface; global $configArray; global $user; if (!UserAccount::isLoggedIn()) { header("Location: " . $configArray['Site']['path'] . "/MyResearch/Home"); } }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; // Cache homepage $interface->caching = 1; $cacheId = 'auth-homepage|' . $interface->lang . '|' . (UserAccount::isLoggedIn() ? '1' : '0'); if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('Search Home'); $interface->setTemplate('home.tpl'); } $interface->display('layout.tpl', $cacheId); }
/** * Display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; // Cache homepage $interface->caching = 0; $cacheId = 'pci-homepage|' . $interface->lang . '|' . (UserAccount::isLoggedIn() ? '1' : '0') . '|' . (isset($_SESSION['lastUserLimit']) ? $_SESSION['lastUserLimit'] : '') . '|' . (isset($_SESSION['lastUserSort']) ? $_SESSION['lastUserSort'] : ''); if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('PCI Search Home'); $interface->setTemplate('home.tpl'); } $interface->display('layout.tpl', $cacheId); }
/** * 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($msg = null) { global $interface; global $configArray; if (!($user = UserAccount::isLoggedIn())) { require_once ROOT_DIR . '/services/MyAccount/Login.php'; MyAccount_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']; } else { $nextAction = 'Home'; } header('Location: ' . $configArray['Site']['path'] . '/MyAccount/' . $nextAction); exit; } require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php'; $userList = new UserList(); $userList->id = $_REQUEST['list_id']; $userList->find(true); $interface->assign('list', $userList); require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $id = $_GET['id']; $groupedWorkDriver = new GroupedWorkDriver($id); if ($groupedWorkDriver->isValid) { $interface->assign('recordDriver', $groupedWorkDriver); } // Record ID $interface->assign('recordId', $id); // Retrieve saved information about record require_once ROOT_DIR . '/sys/LocalEnrichment/UserListEntry.php'; $userListEntry = new UserListEntry(); $userListEntry->groupedWorkPermanentId = $id; $userListEntry->listId = $_REQUEST['list_id']; $userListEntry->find(true); $interface->assign('listEntry', $userListEntry); $interface->assign('listFilter', $_GET['list_id']); $interface->setTemplate('editListTitle.tpl'); $interface->display('layout.tpl'); }
function loginUser() { //Login the user. Must be called via Post parameters. global $user; global $interface; $user = UserAccount::isLoggedIn(); if (!$user || PEAR_Singleton::isError($user)) { $user = UserAccount::login(); $interface->assign('user', $user); if (!$user || PEAR_Singleton::isError($user)) { return array('success' => false, 'message' => translate("Sorry that login information was not recognized, please try again.")); } } $patronHomeBranch = Location::getUserHomeLocation(); //Check to see if materials request should be activated require_once ROOT_DIR . '/sys/MaterialsRequest.php'; return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname), 'phone' => $user->phone, 'email' => $user->email, 'homeLocation' => isset($patronHomeBranch) ? $patronHomeBranch->code : '', 'homeLocationId' => isset($patronHomeBranch) ? $patronHomeBranch->locationId : '', 'enableMaterialsRequest' => MaterialsRequest::enableMaterialsRequest(true)); }
/** * Constructor. * * @access public */ public function __construct() { global $interface; global $configArray; global $user; parent::__construct(); $this->user = UserAccount::isLoggedIn(); // Setup Search Engine Connection $this->db = ConnectionManager::connectToIndex(); // Connect to Database $this->catalog = ConnectionManager::connectToCatalog(); // 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; } } $this->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->origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : false; // Set FollowUp URL if (isset($_REQUEST['followup'])) { $this->followupUrl = $configArray['Site']['url'] . "/" . $_REQUEST['followupModule']; $this->followupUrl .= "/" . $_REQUEST['followupAction']; } else { if (isset($_REQUEST['listID']) && !empty($_REQUEST['listID'])) { $this->followupUrl = $configArray['Site']['url'] . "/MyResearch/MyList/" . urlencode($_REQUEST['listID']); } else { $this->followupUrl = $configArray['Site']['url'] . "/Cart/Home"; } } }
/** * Check Request is Valid * * @return void * @access public */ public function checkRequestIsValid() { if (isset($_REQUEST['id']) && isset($_REQUEST['data'])) { // check if user is logged in $user = UserAccount::isLoggedIn(); if (!$user) { return $this->output(array('status' => false, 'msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH); } $catalog = ConnectionManager::connectToCatalog(); if ($catalog && $catalog->status) { if ($patron = UserAccount::catalogLogin()) { if (!PEAR::isError($patron)) { $results = $catalog->checkCallSlipRequestIsValid($_REQUEST['id'], $_REQUEST['data'], $patron); if (!PEAR::isError($results)) { $msg = $results ? translate('call_slip_place_text') : translate('call_slip_error_blocked'); return $this->output(array('status' => $results, 'msg' => $msg), JSON::STATUS_OK); } } } } } return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR); }
/** * 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'; MyAccount_Login::launch(); exit; } // Fetch List object $list = UserList::staticGet($_GET['id']); // Ensure user have privs to view the list if ($list->user_id != $user->id) { PEAR_Singleton::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']['path'] . '/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'); }
/** * Display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; // Cache homepage $interface->caching = 1; $cacheId = 'summon-homepage|' . $interface->lang . '|' . (UserAccount::isLoggedIn() ? '1' : '0') . '|' . (isset($_SESSION['lastUserLimit']) ? $_SESSION['lastUserLimit'] : '') . '|' . (isset($_SESSION['lastUserSort']) ? $_SESSION['lastUserSort'] : ''); if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('Search Home'); $interface->setTemplate('home.tpl'); // Search Summon $summon = new Summon($configArray['Summon']['apiId'], $configArray['Summon']['apiKey']); $results = $summon->query('', null, null, 0, null, array('ContentType,or,1,20', 'Language,or,1,20')); // Summon may not return facet values in a predictable order -- process // them to ensure we display the right thing in the right place: $facets = array(); foreach ($results['facetFields'] as $current) { $facets[$current['displayName']] = $current; } $interface->assign('formatList', $facets['ContentType']); $interface->assign('languageList', $facets['Language']); } $interface->display('layout.tpl', $cacheId); }
function GetSavedData() { require_once ROOT_DIR . '/services/MyResearch/lib/User.php'; require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php'; // check if user is logged in if (!($user = UserAccount::isLoggedIn())) { echo "<result>Unauthorized</result>"; return; } echo "<result>\n"; $saved = $user->getSavedData($_GET['id']); if ($saved->notes) { echo "\t<Notes>{$saved->notes}</Notes>\n"; } $myTagList = $user->getTags($_GET['id']); if (count($myTagList)) { foreach ($myTagList as $tag) { echo "\t<Tag>" . $tag->tag . "</Tag>\n"; } } echo '</result>'; }
/** * Saves records to a User's favorites * * @return void * @access public */ public function bulkSave() { // Without IDs, we can't continue if (empty($_REQUEST['ids'])) { return $this->output(array('result' => translate('bulk_error_missing')), JSON::STATUS_ERROR); } include_once 'services/Cart/Save.php'; $user = UserAccount::isLoggedIn(); if ($user === false) { return $this->output(translate('You must be logged in first'), JSON::STATUS_NEED_AUTH); } $saveService = new Save(); $result = $saveService->saveRecord(); if ($result) { return $this->output(array('result' => $result, 'info' => translate("bulk_save_success")), JSON::STATUS_OK); } else { return $this->output(array('info' => translate('bulk_save_error')), JSON::STATUS_ERROR); } }
function launch() { global $configArray; global $interface; global $user; // Fetch List object $listId = $_REQUEST['id']; require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php'; $list = new UserList(); $list->id = $listId; if (!$list->find(true)) { //TODO: Use the first list? $list = new UserList(); $list->user_id = $user->id; $list->public = false; $list->title = "My Favorites"; } // Ensure user has privileges to view the list if (!isset($list) || !$list->public && !UserAccount::isLoggedIn()) { require_once ROOT_DIR . '/services/MyAccount/Login.php'; MyAccount_Login::launch(); exit; } if (!$list->public && $list->user_id != $user->id) { //Allow the user to view if they are admin if ($user && $user->hasRole('opacAdmin')) { //Allow the user to view } else { $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setTemplate('invalidList.tpl'); $interface->display('layout.tpl'); return; } } 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) { $userCanEdit = $user->canEditList($list); // 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->update(); } elseif ($actionToPerform == 'saveList') { $list->title = $_REQUEST['newTitle']; $list->description = $_REQUEST['newDescription']; $list->defaultSort = $_REQUEST['defaultSort']; $list->update(); } elseif ($actionToPerform == 'deleteList') { $list->delete(); header("Location: {$configArray['Site']['path']}/MyAccount/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 $list->removeListEntry($id); } } elseif ($actionToPerform == 'deleteAll') { $list->removeAllListEntries(isset($_GET['tag']) ? $_GET['tag'] : null); } $list->update(); } elseif (isset($_REQUEST['delete'])) { $recordToDelete = $_REQUEST['delete']; $list->removeListEntry($recordToDelete); $list->update(); } //Redirect back to avoid having the parameters stay in the URL. header("Location: {$configArray['Site']['path']}/MyAccount/MyList/{$list->id}"); die; } // Send list to template so title/description can be displayed: $interface->assign('favList', $list); $interface->assign('listSelected', $list->id); // Load the User object for the owner of the list (if necessary): if ($user && $user->id == $list->user_id) { $listUser = $user; } elseif ($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($list->getListEntries($sort), $listUser, $list->id, $userCanEdit, $list->defaultSort); // signature change to below $favList = new FavoriteHandler($list, $listUser, $userCanEdit); $favList->assign(); $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setTemplate('list.tpl'); $interface->display('layout.tpl'); }
function SaveTag() { $user = UserAccount::isLoggedIn(); if ($user === false) { return json_encode(array('result' => 'Unauthorized')); } // Create a resource entry for the current ID if necessary (or find the // existing one): $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = $_REQUEST['source']; if (!$resource->find(true)) { $resource->insert(); } // Parse apart the tags and save them in association with the resource: preg_match_all('/"[^"]*"|[^,]+/', $_REQUEST['tag'], $words); foreach ($words[0] as $tag) { $tag = trim(strtolower(str_replace('"', '', $tag))); $resource->addTag($tag, $user); } return json_encode(array('result' => 'Done')); }
function SaveComment() { require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php'; $user = UserAccount::isLoggedIn(); if ($user === false) { return json_encode(array('result' => 'Unauthorized')); } $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'eContent'; if (!$resource->find(true)) { $resource->insert(); } $resource->addComment($_REQUEST['comment'], $user, 'eContent'); return json_encode(array('result' => 'true')); }
/** * Logs in the user and sets a cookie indicating that the user is logged in. * Must be called by POSTing data to the API. * This method is only useful from VuFind itself or from files which can share cookies * with the VuFind server. * * Sample call: * <code> * http://catalog.douglascountylibraries.org/API/UserAPI * Post variables: * method=login * username=23025003575917 * password=7604 * </code> * * Sample response: * <code> * {"result":true} * </code> * * @access private * @author Mark Noble <*****@*****.**> */ function login() { //Login the user. Must be called via Post parameters. $user = UserAccount::isLoggedIn(); if (isset($_POST['username']) && isset($_POST['password'])) { if ($user && !PEAR_Singleton::isError($user)) { return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname)); } else { $user = UserAccount::login(); if ($user && !PEAR_Singleton::isError($user)) { return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname)); } else { return array('success' => false); } } } else { return array('success' => false, 'message' => 'This method must be called via POST.'); } }
/** @var Memcache $memCache */ $translator = $memCache->get("translator_{$serverName}_{$language}"); if ($translator == false || isset($_REQUEST['reloadTranslator'])) { // Make sure language code is valid, reset to default if bad: $validLanguages = array_keys($configArray['Languages']); if (!in_array($language, $validLanguages)) { $language = $configArray['Site']['language']; } $translator = new I18N_Translator('lang', $language, $configArray['System']['missingTranslations']); $memCache->set("translator_{$serverName}_{$language}", $translator, 0, $configArray['Caching']['translator']); $timer->logTime('Translator setup'); } $interface->setLanguage($language); /** @var User */ global $user; $user = UserAccount::isLoggedIn(); $timer->logTime('Check if user is logged in'); $deviceName = get_device_name(); $interface->assign('deviceName', $deviceName); //Look for spammy searches if (isset($_REQUEST['lookfor'])) { $searchTerm = $_REQUEST['lookfor']; if (preg_match('/http:|mailto:|https:/i', $searchTerm)) { PEAR_Singleton::raiseError("Sorry it looks like you are searching for a website, please rephrase your query."); $_REQUEST['lookfor'] = ''; $_GET['lookfor'] = ''; } if (strlen($searchTerm) >= 256) { PEAR_Singleton::raiseError("Sorry your query is too long, please rephrase your query."); $_REQUEST['lookfor'] = ''; $_GET['lookfor'] = '';
/** * Changes the catalog password of a user * * @param string $password The new password * * @return boolean True on success * @access public */ public function changeCatalogPassword($password) { $this->cat_password = $password; $this->update(); // Update Session if ($session_info = UserAccount::isLoggedIn()) { $session_info->cat_password = $password; UserAccount::updateSession($session_info); } // Update Account $account = new User_account(); $account->user_id = $this->id; $account->cat_username = $this->cat_username; if ($account->find(true)) { $account->cat_password = $password; $account->update(); } return true; }
/** * 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 __construct() { $this->user = UserAccount::isLoggedIn(); }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $configArray; global $interface; global $user; // Are UB Requests Allowed? $this->checkUBRequests = $this->catalog->checkFunction("UBRequests", $this->recordDriver->getUniqueID()); if ($this->checkUBRequests != false) { // Do we have valid information? // Sets $this->logonURL and $this->gatheredDetails $validate = $this->_validateUBRequestData($this->checkUBRequests['HMACKeys']); if (!$validate) { if (isset($_REQUEST['lightbox'])) { $interface->assign('lightbox', true); $interface->assign('results', array('status' => 'ub_request_error_blocked')); $interface->display('Record/ub-request-submit.tpl'); } else { header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID())); } return false; } // Assign FollowUp Details required for login and catalog login $interface->assign('followup', true); $interface->assign('recordId', $this->recordDriver->getUniqueID()); $interface->assign('followupModule', 'Record'); $interface->assign('followupAction', 'UBRequest' . $this->logonURL); // User Must be logged In to Place Holds if (UserAccount::isLoggedIn()) { if ($patron = UserAccount::catalogLogin()) { // Block invalid requests: $result = PEAR::isError($patron) ? false : $this->catalog->checkUBRequestIsValid($this->recordDriver->getUniqueID(), $this->gatheredDetails, $patron); if (!$result) { $errorMsg = PEAR::isError($patron) ? $patron->getMessage() : 'ub_request_error_blocked'; if (isset($_REQUEST['lightbox'])) { $interface->assign('lightbox', true); $interface->assign('results', array('status' => $errorMsg)); $interface->display('Record/ub-request-submit.tpl'); } else { header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()) . "?errorMsg={$errorMsg}#top"); } return false; } $interface->assign('items', $result['items']); $interface->assign('libraries', $result['libraries']); $interface->assign('locations', $result['locations']); $interface->assign('requiredBy', $result['requiredBy']); $interface->assign('formURL', $this->logonURL); $interface->assign('gatheredDetails', $this->gatheredDetails); $extraFields = isset($this->checkUBRequests['extraFields']) ? explode(":", $this->checkUBRequests['extraFields']) : array(); $interface->assign('extraFields', $extraFields); $language = $interface->getLanguage(); if (isset($this->checkUBRequests['helpText'][$language])) { $interface->assign('helpText', $this->checkUBRequests['helpText'][$language]); } elseif (isset($this->checkUBRequests['helpText'])) { $interface->assign('helpText', $this->checkUBRequests['helpText']); } if (isset($_POST['placeRequest'])) { if ($this->_placeRequest($patron)) { // If we made it this far, we're ready to place the request; // if successful, we will redirect and can stop here. return; } } } $interface->setPageTitle(translate('ub_request_place_text') . ': ' . $this->recordDriver->getBreadcrumb()); // Display Form if (isset($_REQUEST['lightbox'])) { $interface->assign('lightbox', true); $interface->display('Record/ub-request-submit.tpl'); } else { $interface->assign('subTemplate', 'ub-request-submit.tpl'); // Main Details $interface->setTemplate('view.tpl'); // Display Page $interface->display('layout.tpl'); } } else { // User is not logged in // Display Login Form Login::setupLoginFormVars(); if (isset($_REQUEST['lightbox'])) { $interface->assign('title', $_GET['message']); $interface->assign('message', 'You must be logged in first'); $interface->assign('followup', true); $interface->assign('followupModule', 'Record'); $interface->assign('followupAction', 'UBRequest'); $interface->display('AJAX/login.tpl'); } else { $interface->setTemplate('../MyResearch/login.tpl'); // Display Page $interface->display('layout.tpl'); } } } else { // Shouldn't Be Here if (isset($_REQUEST['lightbox'])) { $interface->assign('lightbox', true); $interface->assign('results', array('status' => 'ub_request_error_blocked')); $interface->display('Record/ub-request-submit.tpl'); } else { header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID())); } return false; } }
/** * 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'); }
exit; } // Setup Local Database Connection ConnectionManager::connectToDatabase(); // Initiate Session State $session_type = $configArray['Session']['type']; $session_lifetime = $configArray['Session']['lifetime']; require_once 'sys/' . $session_type . '.php'; if (class_exists($session_type)) { $session = new $session_type(); $session->init($session_lifetime); } // Determine Module and Action $loggedInModule = isset($configArray['Site']['defaultLoggedInModule']) ? $configArray['Site']['defaultLoggedInModule'] : 'MyResearch'; $loggedOutModule = isset($configArray['Site']['defaultModule']) ? $configArray['Site']['defaultModule'] : 'Search'; $module = ($user = UserAccount::isLoggedIn()) ? $loggedInModule : $loggedOutModule; $module = isset($_GET['module']) ? $_GET['module'] : $module; $module = preg_replace('/[^\\w]/', '', $module); $action = isset($_GET['action']) ? $_GET['action'] : 'Home'; $action = preg_replace('/[^\\w]/', '', $action); // Special case: Always use the Home action for Content unless an action is available. if ($module == 'Content' && !is_readable("services/{$module}/{$action}.php")) { $action = 'Home'; } // If default prefilter is in use, remember result type (split, local, PCI) // by resolving module & action in the following order: // 1. URL parameters (followupSearchModule & followupSearchAction): (search started from record page) // 2. HTTP referer $overridePrefilter = false; if (in_array($module, array('Search', 'PCI', 'MetaLib')) && (isset($_REQUEST['prefilter']) && $_REQUEST['prefilter'] == '-')) { $refAction = null;
function AddList() { require_once ROOT_DIR . '/services/MyResearch/ListEdit.php'; $return = array(); if (UserAccount::isLoggedIn()) { $listService = new ListEdit(); $result = $listService->addList(); if (!PEAR_Singleton::isError($result)) { $return['result'] = 'Done'; $return['newId'] = $result; } else { $error = $result->getMessage(); if (empty($error)) { $error = 'Error'; } $return['result'] = translate($error); } } else { $return['result'] = "Unauthorized"; } return json_encode($return); }
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'); }