function launch() { global $interface; global $finesIndexEngine; global $configArray; $ils = $configArray['Catalog']['ils']; $interface->assign('showDate', $ils == 'Koha' || $ils == 'Horizon'); $interface->assign('showReason', $ils != 'Koha'); $interface->assign('showOutstanding', $ils == 'Koha'); // Get My Fines if ($patron = $this->catalogLogin()) { if (PEAR_Singleton::isError($patron)) { PEAR_Singleton::raiseError($patron); } if ($this->catalog->checkFunction('getMyFines')) { $result = $this->catalog->getMyFines($patron, true); if (!PEAR_Singleton::isError($result)) { $interface->assign('fines', $result); } else { PEAR_Singleton::raiseError($result); } } else { $interface->assign('finesData', translate('This catalog does not support listing fines.')); } } $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setTemplate('fines.tpl'); $interface->setPageTitle('My Fines'); $interface->display('layout.tpl'); }
/** * Connect to the database. * * @return void * @access public */ public static function connectToDatabase() { global $configArray; if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) { define('DB_DATAOBJECT_NO_OVERLOAD', 0); } $options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options'); // If we're using PostgreSQL, we need to set up some extra configuration // settings so that unique ID sequences are properly registered: if (substr($configArray['Database']['database'], 0, 5) == 'pgsql') { $tables = array('comments', 'oai_resumption', 'resource', 'resource_tags', 'search', 'session', 'tags', 'user', 'user_list', 'user_resource'); foreach ($tables as $table) { $configArray['Database']['sequence_' . $table] = $table . '_id_seq'; } } $options = $configArray['Database']; if (substr($configArray['Database']['database'], 0, 5) == 'mysql') { // If we're using MySQL, we need to make certain adjustments (ANSI // quotes, pipes as concatenation operator) for proper compatibility // with code built for other database systems like PostgreSQL or Oracle. $obj = new DB_DataObject(); $conn = $obj->getDatabaseConnection(); $conn->query("SET @@SESSION.sql_mode='ANSI_QUOTES,PIPES_AS_CONCAT'"); } else { if (substr($configArray['Database']['database'], 0, 4) == 'oci8') { // If we are using Oracle, set some portability values: $temp_db = new DB_DataObject(); $db =& $temp_db->getDatabaseConnection(); $db->setOption('portability', DB_PORTABILITY_NUMROWS | DB_PORTABILITY_NULL_TO_EMPTY); // Update the date format to fix issues with Oracle being evil $db->query("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); } } }
/** * Load information from the review provider and update the interface with the data. * * @param string $isbn The ISBN to load data for * @return array Returns array with review data, otherwise a * PEAR_Error. */ static function loadEnrichment($isbn) { global $interface; global $configArray; $enrichment = array(); // Fetch from provider if (isset($configArray['Content']['enrichment'])) { $providers = explode(',', $configArray['Content']['enrichment']); foreach ($providers as $provider) { $provider = explode(':', trim($provider)); $func = strtolower($provider[0]); if (method_exists(new Record_Enrichment(), $func)) { $enrichment[$func] = Record_Enrichment::$func($isbn); // If the current provider had no valid reviews, store nothing: if (empty($enrichment[$func]) || PEAR_Singleton::isError($enrichment[$func])) { unset($enrichment[$func]); } } } } if ($enrichment) { $interface->assign('enrichment', $enrichment); } return $enrichment; }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; if ($user) { $catalog = new CatalogConnection($configArray['Catalog']['driver']); $patron = $catalog->patronLogin($user->cat_username, $user->cat_password); $profile = $catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } if (!isset($_REQUEST['overDriveId']) || !isset($_REQUEST['formatId'])) { header('Location: /'); exit; } else { $interface->assign('overDriveId', $_REQUEST['overDriveId']); $interface->assign('overDriveFormatId', $_REQUEST['formatId']); $interface->setPageTitle('OverDrive Loan Period'); $interface->setTemplate('od-loan-period.tpl'); } //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', false); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'OverDrive Loan Period'); } else { $interface->setTemplate('odCOlogin.tpl'); } $interface->display('layout.tpl'); }
function launch() { global $interface; global $configArray; // Sanitize the topic name to include only alphanumeric characters // or underscores. $safe_topic = preg_replace('/[^\\w]/', '', $_GET['topic']); // Construct three possible template names -- the help screen in the current // selected language, help in the site's default language, and help in English // (most likely to exist). The code will attempt to display most appropriate // help screen that actually exists. $tpl_user = '******' . $interface->getLanguage() . "/{$safe_topic}.tpl"; $tpl_site = "Help/{$configArray['Site']['language']}/{$safe_topic}.tpl"; $tpl_en = 'Help/en/' . $safe_topic . '.tpl'; // Best case -- help is available in the user's chosen language if ($interface->template_exists($tpl_user)) { $interface->setTemplate($tpl_user); // Compromise -- help is available in the site's default language } else { if ($interface->template_exists($tpl_site)) { $interface->setTemplate($tpl_site); $interface->assign('warning', true); // Last resort -- help is available in English } else { if ($interface->template_exists($tpl_en)) { $interface->setTemplate($tpl_en); $interface->assign('warning', true); // Error -- help isn't available at all! } else { PEAR_Singleton::raiseError(new PEAR_Error('Unknown Help Page')); } } } $interface->display('Help/help.tpl'); }
function Login() { global $configArray; // Fetch Salt $salt = $this->generateSalt(); // HexDecode Password $password = pack('H*', $_GET['password']); // Decrypt Password /* require_once 'Crypt/Blowfish.php'; $cipher = new Crypt_Blowfish($salt); $password = $cipher->decrypt($_GET['password']); */ /* require_once 'Crypt/XXTEA.php'; $cipher = new Crypt_XXTEA(); $cipher->setKey($salt); $password = $cipher->decrypt($password); */ require_once 'Crypt/rc4.php'; $password = rc4Encrypt($salt, $password); // Put the username/password in POST fields where the authentication module // expects to find them: $_POST['username'] = $_GET['username']; $_POST['password'] = $password; // Authenticate the user: $user = UserAccount::login(); if (PEAR_Singleton::isError($user)) { return 'Error'; } else { return 'True'; } }
function sendSMS() { global $configArray; global $interface; // Get Holdings try { $catalog = new CatalogConnection($configArray['Catalog']['driver']); } catch (PDOException $e) { return new PEAR_Error('Cannot connect to ILS'); } $holdingsSummary = $catalog->getStatusSummary($_GET['id']); if (PEAR_Singleton::isError($holdingsSummary)) { return $holdingsSummary; } if (isset($holdingsSummary['callnumber'])) { $interface->assign('callnumber', $holdingsSummary['callnumber']); } if (isset($holdingsSummary['availableAt'])) { $interface->assign('availableAt', strip_tags($holdingsSummary['availableAt'])); } if (isset($holdingsSummary['downloadLink'])) { $interface->assign('downloadLink', $holdingsSummary['downloadLink']); } $interface->assign('title', $this->recordDriver->getBreadcrumb()); $interface->assign('recordID', $_GET['id']); $message = $interface->fetch('Emails/catalog-sms.tpl'); return $this->sms->text($_REQUEST['provider'], $_REQUEST['to'], $configArray['Site']['email'], $message); }
function launch() { global $interface; global $configArray; $id = strip_tags($_REQUEST['id']); $interface->assign('id', $id); if (isset($_POST['submit'])) { $result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']); if (!PEAR_Singleton::isError($result)) { require_once 'Home.php'; EcontentRecord_Home::launch(); exit; } else { $interface->assign('message', $result->getMessage()); } } // Display Page if (isset($_GET['lightbox'])) { $interface->assign('lightbox', true); echo $interface->fetch('EcontentRecord/email.tpl'); } else { $interface->setPageTitle('Email Record'); $interface->assign('subTemplate', 'email.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl', 'RecordEmail' . $_GET['id']); } }
function launch() { global $configArray; global $interface; global $user; global $timer; // Get My Transactions if ($this->catalog->status) { if ($user->cat_username) { $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); $timer->logTime("Logged in patron to get checked out items."); if (PEAR_Singleton::isError($patron)) { PEAR_Singleton::raiseError($patron); } $patronResult = $this->catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($patronResult)) { $interface->assign('profile', $patronResult); } $timer->logTime("Got patron profile to get checked out items."); // Define sorting options $sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format'); $interface->assign('sortOptions', $sortOptions); $selectedSortOption = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'dueDate'; $interface->assign('defaultSortOption', $selectedSortOption); $interface->assign('showNotInterested', false); require_once ROOT_DIR . '/Drivers/EContentDriver.php'; $driver = new EContentDriver(); if (isset($_REQUEST['multiAction']) && $_REQUEST['multiAction'] == 'suspendSelected') { $ids = array(); foreach ($_REQUEST['unavailableHold'] as $id => $selected) { $ids[] = $id; } $suspendDate = $_REQUEST['suspendDate']; $dateToReactivate = strtotime($suspendDate); $suspendResult = $driver->suspendHolds($ids, $dateToReactivate); //Redirect back to the EContentHolds page header("Location: " . $configArray['Site']['path'] . "/MyResearch/EContentHolds?section=unavailable"); } $result = $driver->getMyHolds($user); $interface->assign('holds', $result['holds']); $timer->logTime("Loaded econtent from catalog."); } } $hasSeparateTemplates = $interface->template_exists('MyResearch/eContentAvailableHolds.tpl'); if ($hasSeparateTemplates) { $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available'; $interface->assign('section', $section); if ($section == 'available') { $interface->setPageTitle('Available eContent'); $interface->setTemplate('eContentAvailableHolds.tpl'); } else { $interface->setPageTitle('eContent On Hold'); $interface->setTemplate('eContentUnavailableHolds.tpl'); } } else { $interface->setTemplate('eContentHolds.tpl'); $interface->setPageTitle('On Hold eContent'); } $interface->display('layout.tpl'); }
public function authenticate() { global $user; //Check to see if the username and password are provided if (!array_key_exists('username', $_REQUEST) && !array_key_exists('password', $_REQUEST)) { //If not, check to see if we have a valid user already authenticated if ($user) { return $user; } } $this->username = $_REQUEST['username']; $this->password = $_REQUEST['password']; if ($this->username == '' || $this->password == '') { $user = new PEAR_Error('authentication_error_blank'); } else { // Connect to Database $catalog = CatalogFactory::getCatalogConnectionInstance(); if ($catalog->status) { $patron = $catalog->patronLogin($this->username, $this->password); if ($patron && !PEAR_Singleton::isError($patron)) { $user = $this->processILSUser($patron); //Also call getPatronProfile to update extra fields $catalog = CatalogFactory::getCatalogConnectionInstance(); $catalog->getMyProfile($user); } else { $user = new PEAR_Error('authentication_error_invalid'); } } else { $user = new PEAR_Error('authentication_error_technical'); } } return $user; }
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')); } }
/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; // Retrieve the record from the index if (!($record = $this->db->getRecord($_GET['id']))) { PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist')); } // Send basic information to the template. $interface->setPageTitle(isset($record['heading']) ? $record['heading'] : 'Heading unavailable.'); $interface->assign('record', $record); // Load MARC data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if (!$marcRecord) { PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record')); } $xml = trim($marcRecord->toXML()); // Transform MARCXML $style = new DOMDocument(); $style->load('services/Record/xsl/record-marc.xsl'); $xsl = new XSLTProcessor(); $xsl->importStyleSheet($style); $doc = new DOMDocument(); if ($doc->loadXML($xml)) { $html = $xsl->transformToXML($doc); $interface->assign('details', $html); } // Assign the ID of the last search so the user can return to it. $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Display Page $interface->setTemplate('record.tpl'); $interface->display('layout.tpl'); }
/** * getWikipediaImageURL * * This method is responsible for obtaining an image URL based on a name. * * @param string $imageName The image name to look up * @return mixed URL on success, false on failure * @access private */ private function getWikipediaImageURL($imageName) { $url = "http://{$this->lang}.wikipedia.org/w/api.php" . '?prop=imageinfo&action=query&iiprop=url&iiurlwidth=150&format=php' . '&titles=Image:' . $imageName; $client = new Proxy_Request(); $client->setMethod(HTTP_REQUEST_METHOD_GET); $client->setURL($url); $result = $client->sendRequest(); if (PEAR_Singleton::isError($result)) { return false; } if ($response = $client->getResponseBody()) { if ($imageinfo = unserialize($response)) { if (isset($imageinfo['query']['pages']['-1']['imageinfo'][0]['url'])) { $imageUrl = $imageinfo['query']['pages']['-1']['imageinfo'][0]['url']; } // Hack for wikipedia api, just in case we couldn't find it // above look for a http url inside the response. if (!isset($imageUrl)) { preg_match('/\\"http:\\/\\/(.*)\\"/', $response, $matches); if (isset($matches[1])) { $imageUrl = 'http://' . substr($matches[1], 0, strpos($matches[1], '"')); } } } } return isset($imageUrl) ? $imageUrl : false; }
private function saveChanges($user) { global $interface; $resource = new Resource(); $resource->id = $_REQUEST['resourceId']; if ($resource->find(true)) { $interface->assign('resource', $resource); } else { PEAR_Singleton::raiseError(new PEAR_Error("Could not find resource {$_REQUEST['resourceId']}")); } // Loop through the list of lists on the edit screen: foreach ($_POST['lists'] as $listId) { // Create a list object for the current list: $list = new User_list(); if ($listId != '') { $list->id = $listId; $list->find(true); } else { PEAR_Singleton::raiseError(new PEAR_Error('List ID Missing')); } // Extract tags from the user input: preg_match_all('/"[^"]*"|[^ ]+/', $_POST['tags' . $listId], $tagArray); // Save extracted tags and notes: $user->addResource($resource, $list, $tagArray[0], $_POST['notes' . $listId]); } }
function launch() { global $interface; $id = $_GET['id']; $interface->assign('id', $id); $this->eContentRecord = new EContentRecord(); $this->eContentRecord->id = $_GET['id']; $this->eContentRecord->find(true); $recordDriver = new EcontentRecordDriver(); $recordDriver->setDataObject($this->eContentRecord); $interface->assign('sourceUrl', $this->eContentRecord->sourceUrl); $interface->assign('source', $this->eContentRecord->source); $interface->setPageTitle(translate('Copies') . ': ' . $recordDriver->getBreadcrumb()); $driver = new EContentDriver(); $holdings = $driver->getHolding($id); $showEContentNotes = false; foreach ($holdings as $holding) { if (strlen($holding->notes) > 0) { $showEContentNotes = true; } } $interface->assign('showEContentNotes', $showEContentNotes); $interface->assign('holdings', $holdings); //Load status summary $result = $driver->getStatusSummary($id, $holdings); if (PEAR_Singleton::isError($result)) { PEAR_Singleton::raiseError($result); } $holdingData->holdingsSummary = $result; $interface->assign('subTemplate', 'view-holdings.tpl'); $interface->setTemplate('view-alt.tpl'); // Display Page $interface->display('layout.tpl'); }
function initDatabase() { global $configArray; // Setup Local Database Connection define('DB_DATAOBJECT_NO_OVERLOAD', 0); $options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options'); $options = $configArray['Database']; }
function launch() { global $interface; global $configArray; if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); $this->id = strip_tags($_REQUEST['id']); $interface->assign('id', $this->id); $recordDriver = new OverDriveRecordDriver($this->id); if (!$recordDriver->isValid()) { $interface->setTemplate('../Record/invalidRecord.tpl'); $interface->display('layout.tpl'); die; } else { $interface->assign('recordDriver', $recordDriver); //Load status summary require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php'; $driver = OverDriveDriverFactory::getDriver(); $holdings = $driver->getHoldings($recordDriver); $scopedAvailability = $driver->getScopedAvailability($recordDriver); $holdingsSummary = $driver->getStatusSummary($this->id, $scopedAvailability, $holdings); if (PEAR_Singleton::isError($holdingsSummary)) { PEAR_Singleton::raiseError($holdingsSummary); } $interface->assign('holdingsSummary', $holdingsSummary); //Load the citations $this->loadCitations($recordDriver); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); // Set Show in Main Details Section options for templates // (needs to be set before moreDetailsOptions) global $library; foreach ($library->showInMainDetails as $detailoption) { $interface->assign($detailoption, true); } $interface->setPageTitle($recordDriver->getTitle()); $interface->assign('moreDetailsOptions', $recordDriver->getMoreDetailsOptions()); // Display Page $interface->assign('sidebar', 'OverDrive/full-record-sidebar.tpl'); $interface->assign('moreDetailsTemplate', 'GroupedWork/moredetails-accordion.tpl'); $interface->setTemplate('view.tpl'); $interface->display('layout.tpl'); } }
function launch() { global $configArray; global $interface; //Grab the tracking data $recordId = $_REQUEST['id']; $ipAddress = $_SERVER['REMOTE_ADDR']; $field856Index = isset($_REQUEST['index']) ? $_REQUEST['index'] : null; // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $this->db = new $class($url); // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordByILSId($recordId); if ($marcRecord) { $this->marcRecord = $marcRecord; } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the MAC record for this title.")); } /** @var File_MARC_Data_Field[] $linkFields */ $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $cur856Index = 0; foreach ($linkFields as $marcField) { $cur856Index++; if ($cur856Index == $field856Index) { //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); $externalLink = $link; } } } } $linkParts = parse_url($externalLink); //Insert into the purchaseLinkTracking table require_once ROOT_DIR . '/sys/BotChecker.php'; if (!BotChecker::isRequestFromBot()) { require_once ROOT_DIR . '/sys/ExternalLinkTracking.php'; $externalLinkTracking = new ExternalLinkTracking(); $externalLinkTracking->ipAddress = $ipAddress; $externalLinkTracking->recordId = $recordId; $externalLinkTracking->linkUrl = $externalLink; $externalLinkTracking->linkHost = $linkParts['host']; $result = $externalLinkTracking->insert(); } //redirects them to the link they clicked if ($externalLink != "") { header("Location:" . $externalLink); } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this record.")); } }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; // Include Search Engine Class require_once ROOT_DIR . "/sys/{$configArray['Index']['engine']}.php"; $timer->logTime('Include search engine'); $interface->assign('showBreadcrumbs', 0); if ($user) { $catalog = CatalogFactory::getCatalogConnectionInstance(); $patron = $catalog->patronLogin($user->cat_username, $user->cat_password); $profile = $catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } // Load browse categories require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; /** @var BrowseCategory[] $browseCategories */ $browseCategories = array(); // Get Location's Browse Categories if Location is set $activeLocation = $locationSingleton->getActiveLocation(); if ($activeLocation != null && $activeLocation->browseCategories) { $browseCategories = $this->getBrowseCategories($activeLocation->browseCategories); } // Get Library's Browse Categories if none were set for Location if (isset($library) && empty($browseCategories) && $library->browseCategories) { $browseCategories = $this->getBrowseCategories($library->browseCategories); } // Get All Browse Categories if Location & Library had none set if (empty($browseCategories)) { $browseCategories = $this->getBrowseCategories(); } $interface->assign('browseCategories', $browseCategories); //Get the Browse Results for the first list // browse results no longer needed. there is an embedded ajax call in home.tpl. plb 5-4-2015 // if (count($browseCategories) > 0){ // require_once ROOT_DIR . '/services/Browse/AJAX.php'; // $browseAJAX = new Browse_AJAX(); // $browseAJAX->setBrowseMode(); // set default browse mode in the case that the user hasn't chosen one. //// $browseResults = $browseAJAX->getBrowseCategoryInfo(reset($browseCategories)->textId); //// $interface->assign('browseResults', $browseResults); // } $interface->setPageTitle('Catalog Home'); $interface->assign('sidebar', 'Search/home-sidebar.tpl'); $interface->setTemplate('home.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; $interface->caching = false; // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Initialise from the current search globals $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init(); // TODO : Stats $result = $searchObject->processSearch(); if (PEAR_Singleton::isError($result)) { PEAR_Singleton::raiseError($result->getMessage()); } $interface->assign('sortList', $searchObject->getSortList()); $interface->assign('lookfor', $searchObject->displayQuery()); $interface->assign('searchType', $searchObject->getSearchType()); $interface->assign('searchIndex', $searchObject->getSearchIndex()); $interface->assign('qtime', round($searchObject->getQuerySpeed(), 2)); $summary = $searchObject->getResultSummary(); // Post processing, remember that the REAL results here with regards to // numbers and pagination are the author facet, not the document // results from the solr index. So access '$summary' with care. $page = $summary['page']; $limit = $summary['perPage']; // The search object will have returned an array of author facets that // is offset to display the current page of results but which has more // than a single page worth of content. This allows a user to dig deeper // and deeper into the result set even though we have no way of finding // out the exact count of results without risking a memory overflow or // long delay. We need to use the current page information to adjust the // known total count accordingly, and we need to use the page size to // crop off extra results when displaying the list to the user. // See VUFIND-127 in JIRA for more details. $authors = $result['facet_counts']['facet_fields']['authorStr']; $cnt = ($page - 1) * $limit + count($authors); $interface->assign('recordSet', array_slice($authors, 0, $limit)); $interface->assign('recordCount', $cnt); $interface->assign('recordStart', ($page - 1) * $limit + 1); if ($cnt < $limit || $page * $limit > $cnt) { $interface->assign('recordEnd', $cnt); } else { $interface->assign('recordEnd', $page * $limit); } $link = $searchObject->renderLinkPageTemplate(); $options = array('totalItems' => $cnt, 'fileName' => $link); $pager = new VuFindPager($options); $interface->assign('pageLinks', $pager->getLinks()); $interface->setPageTitle('Author Browse'); $interface->setTemplate('list.tpl'); $interface->display('layout.tpl'); }
public static function login() { global $configArray; // Perform authentication: $authN = AuthenticationFactory::initAuthentication($configArray['Authentication']['method']); $user = $authN->authenticate(); // If we authenticated, store the user in the session: if (!PEAR_Singleton::isError($user)) { self::updateSession($user); } // Send back the user object (which may be a PEAR error): return $user; }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; // Include Search Engine Class require_once ROOT_DIR . '/sys/' . $configArray['Index']['engine'] . '.php'; $timer->logTime('Include search engine'); $interface->assign('showBreadcrumbs', 0); if ($user) { $catalog = new CatalogConnection($configArray['Catalog']['driver']); $patron = $catalog->patronLogin($user->cat_username, $user->cat_password); $profile = $catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } //Get the lists to show on the home page require_once ROOT_DIR . '/sys/ListWidget.php'; $widgetId = 1; $activeLocation = $locationSingleton->getActiveLocation(); if ($activeLocation != null && $activeLocation->homePageWidgetId > 0) { $widgetId = $activeLocation->homePageWidgetId; $widget = new ListWidget(); $widget->id = $widgetId; if ($widget->find(true)) { $interface->assign('widget', $widget); } } else { if (isset($library) && $library->homePageWidgetId > 0) { $widgetId = $library->homePageWidgetId; $widget = new ListWidget(); $widget->id = $widgetId; if ($widget->find(true)) { $interface->assign('widget', $widget); } } } // Cache homepage $interface->caching = 0; $cacheId = 'homepage|' . $interface->lang; //Disable Home page caching for now. if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('Catalog Home'); $interface->setTemplate('home.tpl'); } $interface->display('layout.tpl', $cacheId); }
public function init($lt) { global $configArray; // Set defaults if nothing set in config file. self::$path = isset($configArray['Session']['file_save_path']) ? $configArray['Session']['file_save_path'] : '/tmp/vufind_sessions'; // Die if the session directory does not exist and cannot be created. if (!file_exists(self::$path) || !is_dir(self::$path)) { if (!@mkdir(self::$path)) { PEAR_Singleton::raiseError(new PEAR_Error("Cannot access session save path: " . self::$path)); } } // Call standard session initialization from this point. parent::init($lt); }
function launch() { global $configArray; global $interface; $libraryName = $configArray['Site']['title']; //Grab the tracking data $store = urldecode(strip_tags($_GET['store'])); $recordId = $_REQUEST['id']; $ipAddress = $_SERVER['REMOTE_ADDR']; // Retrieve Full Marc Record $eContentRecord = new EContentRecord(); $eContentRecord->id = $recordId; if (!$eContentRecord->find(true)) { PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist')); } $title = str_replace("/", "", $eContentRecord->title); if ($eContentRecord->purchaseUrl == null) { switch ($store) { case "Tattered Cover": $purchaseLinkUrl = "http://www.tatteredcover.com/search/apachesolr_search/" . urlencode($title) . "?source=" . urlencode($libraryName); break; case "Barnes and Noble": $purchaseLinkUrl = "http://www.barnesandnoble.com/s/?title=" . urlencode($title) . "&source=" . urlencode($libraryName); break; case "Amazon": $purchaseLinkUrl = "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" . urlencode($title) . "&source=" . urlencode($libraryName); break; } } else { // Process MARC Data $purchaseLinkUrl = $eContentRecord->purchaseUrl; } //Do not track purchases from Bots require_once ROOT_DIR . '/sys/BotChecker.php'; if (!BotChecker::isRequestFromBot()) { require_once ROOT_DIR . '/sys/PurchaseLinkTracking.php'; $tracking = new PurchaseLinkTracking(); $tracking->ipAddress = $ipAddress; $tracking->recordId = 'econtentRecord' . $recordId; $tracking->store = $store; $insertResult = $tracking->insert(); } //redirects them to the link they clicked if ($purchaseLinkUrl != "") { header("Location:" . $purchaseLinkUrl); } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this title.")); } }
function launch() { global $interface; // 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 ROOT_DIR . '/services/MyAccount/Login.php'; $loginAction = new MyAccount_Login(); $loginAction->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'); } }
public function init($lt, $rememberMeLifetime) { global $configArray; // Set defaults if nothing set in config file. $host = isset($configArray['Session']['memcache_host']) ? $configArray['Session']['memcache_host'] : 'localhost'; $port = isset($configArray['Session']['memcache_port']) ? $configArray['Session']['memcache_port'] : 11211; $timeout = isset($configArray['Session']['memcache_connection_timeout']) ? $configArray['Session']['memcache_connection_timeout'] : 1; // Connect to Memcache: self::$connection = new Memcache(); if (!@self::$connection->connect($host, $port, $timeout)) { PEAR_Singleton::raiseError(new PEAR_Error("Could not connect to Memcache (host = {$host}, port = {$port}).")); } // Call standard session initialization from this point. parent::init($lt, $rememberMeLifetime); }
function launch() { global $configArray; global $interface; // Load SOLR Statistics $solr = new SolrStats($configArray['Statistics']['solr']); if ($configArray['System']['debugSolr']) { $solr->debug = true; } // All Statistics $result = $solr->search('*:*', null, null, 0, null, array('field' => array('ipaddress', 'browser')), '', null, null, null, HTTP_REQUEST_METHOD_GET); if (!PEAR_Singleton::isError($result)) { if (isset($result['facet_counts']['facet_fields']['ipaddress'])) { $interface->assign('ipList', $result['facet_counts']['facet_fields']['ipaddress']); } if (isset($result['facet_counts']['facet_fields']['browser'])) { $interface->assign('browserList', $result['facet_counts']['facet_fields']['browser']); } } // Search Statistics $result = $solr->search('phrase:[* TO *]', null, null, 0, null, array('field' => array('noresults', 'phrase')), '', null, null, null, HTTP_REQUEST_METHOD_GET); if (!PEAR_Singleton::isError($result)) { $interface->assign('searchCount', $result['response']['numFound']); // Extract the count of no hit results by finding the "no hit" facet entry // set to boolean true. $nohitCount = 0; $nhFacet =& $result['facet_counts']['facet_fields']['noresults']; if (isset($nhFacet) && is_array($nhFacet)) { foreach ($nhFacet as $nhRow) { if ($nhRow[0] == 'true') { $nohitCount = $nhRow[1]; } } } $interface->assign('nohitCount', $nohitCount); $interface->assign('termList', $result['facet_counts']['facet_fields']['phrase']); } // Record View Statistics $result = $solr->search('recordId:[* TO *]', null, null, 0, null, array('field' => array('recordId')), '', null, null, null, HTTP_REQUEST_METHOD_GET); if (!PEAR_Singleton::isError($result)) { $interface->assign('recordViews', $result['response']['numFound']); $interface->assign('recordList', $result['facet_counts']['facet_fields']['recordId']); } $interface->setTemplate('statistics.tpl'); $interface->setPageTitle('Statistics'); $interface->display('layout.tpl'); }
function SaveRecord() { require_once ROOT_DIR . '/services/Resource/Save.php'; require_once ROOT_DIR . '/services/MyResearch/lib/User_list.php'; $result = array(); if (UserAccount::isLoggedIn()) { $saveService = new Save(); $result = $saveService->saveRecord(); if (!PEAR_Singleton::isError($result)) { $result['result'] = "Done"; } else { $result['result'] = "Error"; } } else { $result['result'] = "Unauthorized"; } return json_encode($result); }
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)); }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; if ($user) { $catalog = new CatalogConnection($configArray['Catalog']['driver']); $patron = $catalog->patronLogin($user->cat_username, $user->cat_password); $profile = $catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } if (!isset($_POST['overDriveId']) || !isset($_POST['overDriveFormatId']) || !isset($_POST['loanPeriod'])) { header('Location: /'); } else { require_once ROOT_DIR . '/services/EcontentRecord/AJAX.php'; $_REQUEST['overDriveId'] = $_POST['overDriveId']; $_REQUEST['formatId'] = $_POST['loanPeriod']; $_REQUEST['lendingPeriod'] = $_POST['overDriveFormatId']; $service = new AJAX(); $status = json_decode($service->CheckoutOverDriveItem()); if ($status->result) { $msg = 'Your titles were checked out successfully. You may now download the titles from your Account.'; } else { $msg = $status->message; } $interface->assign('message', $msg); $interface->assign('result', $msg); $interface->setPageTitle('OverDrive Loan Period'); $interface->setTemplate('od-checkedOut.tpl'); } //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', false); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'OverDrive Loan Period'); } else { header('Location: /'); exit; } $interface->display('layout.tpl'); }