Exemplo n.º 1
0
 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]);
     }
 }
Exemplo n.º 2
0
 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');
 }
Exemplo n.º 3
0
 function getLightbox()
 {
     global $configArray;
     global $interface;
     // Assign our followup
     $interface->assign('followupModule', $_GET['followupModule']);
     $interface->assign('followupAction', $_GET['followupAction']);
     $interface->assign('followupId', $_GET['followupId']);
     // Sanitize incoming parameters
     $module = preg_replace('/[^\\w]/', '', $_GET['submodule']);
     $action = preg_replace('/[^\\w]/', '', $_GET['subaction']);
     // Call Action
     $path = 'services/' . $module . '/' . $action . '.php';
     if (is_readable($path)) {
         require_once $path;
         if (class_exists($action)) {
             $service = new $action();
             $page = $service->launch();
             $interface->assign('page', $page);
         } else {
             PEAR_Singleton::raiseError(new PEAR_Error('Unknown Action'));
         }
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Cannot Load Action '{$action}' for Module '{$module}'"));
     }
     return $interface->fetch('AJAX/lightbox.tpl');
 }
Exemplo n.º 4
0
 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');
 }
Exemplo n.º 5
0
 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');
 }
Exemplo n.º 6
0
 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'));
     }
 }
Exemplo n.º 7
0
 /**
  * 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');
 }
Exemplo n.º 8
0
 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');
 }
Exemplo n.º 9
0
 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');
     }
 }
Exemplo n.º 10
0
 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."));
     }
 }
Exemplo n.º 11
0
 public function __construct($record)
 {
     // Call the parent's constructor...
     parent::__construct($record);
     // Also process the MARC record:
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $this->marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if (!$this->marcRecord) {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record for record ' . $record['id']));
     }
 }
Exemplo n.º 12
0
 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');
 }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 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."));
     }
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 /**
  * Send an NCIP request.
  *
  * @access  private
  * @param   string  $xml            XML request document
  * @return  object                  SimpleXMLElement parsed from response
  */
 private function sendRequest($xml)
 {
     // Make the NCIP request:
     $client = new Proxy_Request(null, array('useBrackets' => false));
     $client->setMethod(HTTP_REQUEST_METHOD_POST);
     $client->setURL($this->config['Catalog']['url']);
     $client->addPostData('NCIP', $xml);
     $result = $client->sendRequest();
     if (PEAR_Singleton::isError($result)) {
         PEAR_Singleton::raiseError($result);
     }
     // Process the NCIP response:
     $response = $client->getResponseBody();
     if ($result = @simplexml_load_string($response)) {
         return $result;
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Problem parsing XML"));
     }
 }
Exemplo n.º 17
0
 function launch()
 {
     global $configArray;
     global $user;
     try {
         $this->catalog = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     //Renew the hold
     if (method_exists($this->catalog->driver, 'renewItem')) {
         $selectedItems = $_GET['selected'];
         $renewMessages = array();
         $_SESSION['renew_message']['Unrenewed'] = 0;
         $_SESSION['renew_message']['Renewed'] = 0;
         $i = 0;
         foreach ($selectedItems as $itemInfo => $selectedState) {
             if ($i != 0) {
                 usleep(1000);
             }
             $i++;
             list($itemId, $itemIndex) = explode('|', $itemInfo);
             $renewResult = $this->catalog->driver->renewItem($itemId, $itemIndex);
             $_SESSION['renew_message'][$renewResult['itemId']] = $renewResult;
             $_SESSION['renew_message']['Total']++;
             if ($renewResult['result']) {
                 $_SESSION['renew_message']['Renewed']++;
             } else {
                 $_SESSION['renew_message']['Unrenewed']++;
             }
         }
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Renew Item - ILS Not Supported'));
     }
     //Redirect back to the hold screen with status from the renewal
     header("Location: " . $configArray['Site']['path'] . '/MyResearch/CheckedOut');
 }
Exemplo n.º 18
0
 function launch()
 {
     global $configArray;
     try {
         $this->catalog = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     // Check How to Process Hold
     if (method_exists($this->catalog->driver, 'placeHold')) {
         $this->placeHolds();
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process Place Hold - ILS Not Supported'));
     }
 }
Exemplo n.º 19
0
 function GetHoldingsInfo()
 {
     global $interface;
     $id = strip_tags($_REQUEST['id']);
     $interface->assign('id', $id);
     require_once ROOT_DIR . '/RecordDrivers/OverDriveRecordDriver.php';
     $overDriveRecordDriver = new OverDriveRecordDriver($id);
     //Load holdings information from the driver
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $driver = OverDriveDriverFactory::getDriver();
     /** @var OverDriveAPIProductFormats[] $holdings */
     $holdings = $driver->getHoldings($overDriveRecordDriver);
     $scopedAvailability = $driver->getScopedAvailability($overDriveRecordDriver);
     $interface->assign('availability', $scopedAvailability['mine']);
     $interface->assign('availabilityOther', $scopedAvailability['other']);
     $showAvailability = true;
     $showAvailabilityOther = true;
     $interface->assign('showAvailability', $showAvailability);
     $interface->assign('showAvailabilityOther', $showAvailabilityOther);
     $showOverDriveConsole = false;
     $showAdobeDigitalEditions = false;
     foreach ($holdings as $item) {
         if (in_array($item->textId, array('ebook-epub-adobe', 'ebook-pdf-adobe'))) {
             $showAdobeDigitalEditions = true;
         } else {
             if (in_array($item->textId, array('video-wmv', 'music-wma', 'music-wma', 'audiobook-wma', 'audiobook-mp3'))) {
                 $showOverDriveConsole = true;
             }
         }
     }
     $interface->assign('showOverDriveConsole', $showOverDriveConsole);
     $interface->assign('showAdobeDigitalEditions', $showAdobeDigitalEditions);
     $interface->assign('holdings', $holdings);
     //Load status summary
     $result = $driver->getStatusSummary($id, $scopedAvailability, $holdings);
     if (PEAR_Singleton::isError($result)) {
         PEAR_Singleton::raiseError($result);
     }
     $interface->assign('holdingsSummary', $result);
     return $interface->fetch('EcontentRecord/ajax-holdings.tpl');
 }
Exemplo n.º 20
0
function initMemcache()
{
    //Connect to memcache
    /** @var Memcache $memCache */
    global $memCache;
    global $timer;
    global $configArray;
    // Set defaults if nothing set in config file.
    $host = isset($configArray['Caching']['memcache_host']) ? $configArray['Caching']['memcache_host'] : 'localhost';
    $port = isset($configArray['Caching']['memcache_port']) ? $configArray['Caching']['memcache_port'] : 11211;
    $timeout = isset($configArray['Caching']['memcache_connection_timeout']) ? $configArray['Caching']['memcache_connection_timeout'] : 1;
    // Connect to Memcache:
    $memCache = new Memcache();
    if (!@$memCache->pconnect($host, $port, $timeout)) {
        //Try again with a non-persistent connection
        if (!$memCache->connect($host, $port, $timeout)) {
            PEAR_Singleton::raiseError(new PEAR_Error("Could not connect to Memcache (host = {$host}, port = {$port})."));
        }
    }
    $timer->logTime("Initialize Memcache");
}
Exemplo n.º 21
0
 function launch()
 {
     global $configArray;
     global $interface;
     //Grab the tracking data
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     $itemId = $_REQUEST['itemId'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $eContentItem = new EContentItem();
     $eContentItem->id = $itemId;
     if (!$eContentItem->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Item Does Not Exist'));
     }
     $linkUrl = $eContentItem->link;
     $linkParts = parse_url($linkUrl);
     $title = str_replace("/", "", $eContentRecord->title);
     //Insert into the externalLinkTracking 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 = "econtentRecord" . $recordId;
         $externalLinkTracking->linkUrl = $linkUrl;
         $externalLinkTracking->linkHost = $linkParts['host'];
         $result = $externalLinkTracking->insert();
     }
     //redirects them to the link they clicked
     if ($linkUrl != "") {
         header("Location:" . $linkUrl);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this title."));
     }
 }
Exemplo n.º 22
0
 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);
             //Vars for the IDCLREADER TEMPLATE
             $interface->assign('ButtonBack', true);
             $interface->assign('ButtonHome', true);
             $interface->assign('MobileTitle', 'eContents Checked Out');
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             $result = $driver->getMyTransactions($user);
             $interface->assign('checkedOut', $result['transactions']);
             $timer->logTime("Loaded econtent from catalog.");
         }
     }
     $interface->setTemplate('eContentCheckedOut.tpl');
     $interface->setPageTitle('Checked Out eContent');
     $interface->display('layout.tpl');
 }
Exemplo n.º 23
0
 /**
  * Send an NCIP request.
  *
  * @param string $xml XML request document
  *
  * @return object     SimpleXMLElement parsed from response
  * @access private
  */
 private function _sendRequest($xml)
 {
     // Make the NCIP request:
     $client = new Proxy_Request(null, array('useBrackets' => false));
     $client->setMethod(HTTP_REQUEST_METHOD_POST);
     $client->setURL($this->_config['Catalog']['url']);
     $client->addHeader('Content-type', 'application/xml; "charset=utf-8"');
     $client->setBody($xml);
     $result = $client->sendRequest();
     if (PEAR_Singleton::isError($result)) {
         PEAR_Singleton::raiseError($result);
     }
     // Process the NCIP response:
     $response = $client->getResponseBody();
     $result = @simplexml_load_string($response);
     if (is_a($result, 'SimpleXMLElement')) {
         $result->registerXPathNamespace('ns1', 'http://www.niso.org/2008/ncip');
         return $result;
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Problem parsing XML"));
     }
 }
Exemplo n.º 24
0
 /**
  * Public method for getting item holdings from the catalog and selecting which
  * holding method to call
  *
  * @param string $id     An Bib ID
  * @param array  $patron An array of patron data
  *
  * @return array A sorted results set
  * @access public
  */
 public function getHoldings($id, $patron = false)
 {
     $holdings = array();
     // Get Holdings Data
     if ($this->catalog && $this->catalog->status) {
         $result = $this->catalog->getHolding($id, $patron);
         if (PEAR_Singleton::isError($result)) {
             PEAR_Singleton::raiseError($result);
         }
         $mode = CatalogConnection::getHoldsMode();
         if ($mode == "disabled") {
             $holdings = $this->standardHoldings($result);
         } else {
             if ($mode == "driver") {
                 $holdings = $this->driverHoldings($result);
             } else {
                 $holdings = $this->generateHoldings($result, $mode);
             }
         }
     }
     return $holdings;
 }
Exemplo n.º 25
0
 function launch()
 {
     global $interface;
     global $configArray;
     if (isset($_POST['submit'])) {
         $result = $this->sendEmail($_POST['url'], $_POST['to'], $_POST['from'], $_POST['message']);
         if (!PEAR_Singleton::isError($result)) {
             header('Location: ' . $_POST['url']);
             exit;
         } else {
             $interface->assign('message', "Email this");
         }
     }
     // Display Page
     if (isset($_GET['lightbox'])) {
         $interface->assign('title', "Email this");
         echo $interface->fetch('Search/email.tpl');
     } else {
         // If the user has disabled HTTP referer, we can't email their search
         // link without Javascript.
         if (!isset($_POST['url']) && !isset($_SERVER['HTTP_REFERER'])) {
             PEAR_Singleton::raiseError(new PEAR_Error('HTTP Referer missing.'));
             exit;
         }
         // If the user resubmits the form after an error, the $_POST url
         // variable will be set and we should use that.  If this is the first
         // time through, we need to rely on the referer to find out the target.
         $searchURL = isset($_POST['url']) ? $_POST['url'] : $_SERVER['HTTP_REFERER'];
         $interface->setPageTitle('Email This Search');
         $interface->assign('subTemplate', 'email.tpl');
         // For form POST:
         $interface->assign('searchURL', $searchURL);
         // For "back to search" link:
         $interface->assign('lastsearch', $searchURL);
         $interface->setTemplate('view-alt.tpl');
         $interface->display('layout.tpl');
     }
 }
Exemplo n.º 26
0
 function launch()
 {
     global $configArray;
     global $user;
     try {
         $this->catalog = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     //Renew the hold
     if (method_exists($this->catalog->driver, 'renewAll')) {
         $renewResult = $this->catalog->driver->renewAll();
         $_SESSION['renew_message'] = $renewResult;
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Renew Item - ILS Not Supported'));
     }
     //Redirect back to the hold screen with status from the renewal
     header("Location: " . $configArray['Site']['path'] . '/MyResearch/CheckedOut');
 }
Exemplo n.º 27
0
 function launch()
 {
     global $configArray;
     global $user;
     global $logger;
     $logger->log("Starting renew action", PEAR_LOG_INFO);
     try {
         $this->catalog = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     //Renew the hold
     if (method_exists($this->catalog->driver, 'renewItem')) {
         $logger->log("Renewing item " . $_REQUEST['itemId'], PEAR_LOG_INFO);
         $renewResult = $this->catalog->driver->renewItem($_REQUEST['itemId'], $_REQUEST['itemIndex']);
         $logger->log("Result = " . print_r($renewResult, true), PEAR_LOG_INFO);
         $_SESSION['renew_message']['Total'] = 1;
         $_SESSION['renew_message']['Renewed'] = 0;
         $_SESSION['renew_message']['Unrenewed'] = 0;
         if ($renewResult['result']) {
             $_SESSION['renew_message']['Renewed']++;
         } else {
             $_SESSION['renew_message']['Unrenewed']++;
         }
         $_SESSION['renew_message'][$renewResult['itemId']] = $renewResult;
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Renew Item - ILS Not Supported'));
     }
     //Redirect back to the hold screen with status from the renewal
     header("Location: " . $configArray['Site']['path'] . '/MyResearch/CheckedOut');
 }
Exemplo n.º 28
0
 /**
  * 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');
 }
Exemplo n.º 29
0
 function selfRegister()
 {
     global $logger;
     //Setup Curl
     $header = array();
     $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
     $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     $header[] = "Cache-Control: max-age=0";
     $header[] = "Connection: keep-alive";
     $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
     $header[] = "Accept-Language: en-us,en;q=0.5";
     $cookie = tempnam("/tmp", "CURLCOOKIE");
     //Start at My Account Page
     $curl_url = $this->hipUrl . "/ipac20/ipac.jsp?profile={$this->selfRegProfile}&menu=account";
     $curl_connection = curl_init($curl_url);
     curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
     curl_setopt($curl_connection, CURLOPT_HTTPHEADER, $header);
     curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
     curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($curl_connection, CURLOPT_UNRESTRICTED_AUTH, true);
     curl_setopt($curl_connection, CURLOPT_COOKIEJAR, $cookie);
     curl_setopt($curl_connection, CURLOPT_COOKIESESSION, true);
     curl_setopt($curl_connection, CURLOPT_REFERER, $curl_url);
     curl_setopt($curl_connection, CURLOPT_FORBID_REUSE, false);
     curl_setopt($curl_connection, CURLOPT_HEADER, false);
     curl_setopt($curl_connection, CURLOPT_HTTPGET, true);
     $sresult = curl_exec($curl_connection);
     $logger->log("Loading Full Record {$curl_url}", PEAR_LOG_INFO);
     //Extract the session id from the requestcopy javascript on the page
     if (preg_match('/\\?session=(.*?)&/s', $sresult, $matches)) {
         $sessionId = $matches[1];
     } else {
         PEAR_Singleton::raiseError('Could not load session information from page.');
     }
     //Login by posting username and password
     $post_data = array('aspect' => 'overview', 'button' => 'New User', 'login_prompt' => 'true', 'menu' => 'account', 'newuser_prompt' => 'true', 'profile' => $this->selfRegProfile, 'ri' => '', 'sec1' => '', 'sec2' => '', 'session' => $sessionId);
     $post_items = array();
     foreach ($post_data as $key => $value) {
         $post_items[] = $key . '=' . urlencode($value);
     }
     $post_string = implode('&', $post_items);
     $curl_url = $this->hipUrl . "/ipac20/ipac.jsp";
     curl_setopt($curl_connection, CURLOPT_POST, true);
     curl_setopt($curl_connection, CURLOPT_URL, $curl_url);
     curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
     $sresult = curl_exec($curl_connection);
     $firstName = strip_tags($_REQUEST['firstName']);
     $lastName = strip_tags($_REQUEST['lastName']);
     $streetAddress = strip_tags($_REQUEST['streetAddress']);
     $apartment = strip_tags($_REQUEST['apartment']);
     $citySt = strip_tags($_REQUEST['citySt']);
     $zip = strip_tags($_REQUEST['zip']);
     $email = strip_tags($_REQUEST['email']);
     $sendNoticeBy = strip_tags($_REQUEST['sendNoticeBy']);
     $pin = strip_tags($_REQUEST['pin']);
     $confirmPin = strip_tags($_REQUEST['confirmPin']);
     $phone = strip_tags($_REQUEST['phone']);
     //Register the patron
     $post_data = array('address1' => $streetAddress, 'address2' => $apartment, 'aspect' => 'basic', 'pin#' => $pin, 'button' => 'I accept', 'city_st' => $citySt, 'confirmpin#' => $confirmPin, 'email_address' => $email, 'firstname' => $firstName, 'ipp' => 20, 'lastname' => $lastName, 'menu' => 'account', 'newuser_info' => 'true', 'npp' => 30, 'postal_code' => $zip, 'phone_no' => $phone, 'profile' => $this->selfRegProfile, 'ri' => '', 'send_notice_by' => $sendNoticeBy, 'session' => $sessionId, 'spp' => 20);
     $post_items = array();
     foreach ($post_data as $key => $value) {
         $post_items[] = $key . '=' . urlencode($value);
     }
     $post_string = implode('&', $post_items);
     curl_setopt($curl_connection, CURLOPT_POST, true);
     curl_setopt($curl_connection, CURLOPT_URL, $curl_url . '#focus');
     curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
     $sresult = curl_exec($curl_connection);
     //Get the temporary barcode from the page
     if (preg_match('/Here is your temporary barcode\\. Use it for future authentication:&nbsp;([\\d-]+)/s', $sresult, $regs)) {
         $tempBarcode = $regs[1];
         //Append the library prefix to the card number
         $tempBarcode = '220460' . $tempBarcode;
         $success = true;
     } else {
         $success = false;
     }
     unlink($cookie);
     return array('tempBarcode' => $tempBarcode, 'result' => $success);
 }
Exemplo n.º 30
0
 private function process($result)
 {
     $unxml = new XML_Unserializer();
     $result = $unxml->unserialize($result);
     if (!PEAR_Singleton::isError($result)) {
         return $unxml->getUnserializedData();
     } else {
         PEAR_Singleton::raiseError($result);
     }
     return null;
 }