Exemplo n.º 1
0
 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');
 }
Exemplo n.º 2
0
 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';
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
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.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
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.º 9
0
 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']);
     }
 }
Exemplo n.º 10
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.º 11
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.º 12
0
 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');
 }
Exemplo n.º 13
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.º 14
0
 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;
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 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');
     }
 }
Exemplo n.º 17
0
 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');
 }
Exemplo n.º 18
0
 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);
 }
Exemplo n.º 19
0
 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));
 }
Exemplo n.º 20
0
 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');
 }
Exemplo n.º 21
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.º 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
 function launch()
 {
     global $interface;
     global $configArray;
     if (isset($_POST['submit'])) {
         $result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']);
         if (!PEAR_Singleton::isError($result)) {
             require_once 'MyList.php';
             $_GET['id'] = $_REQUEST['listId'];
             MyList::launch();
             exit;
         } else {
             $interface->assign('message', $result->getMessage());
         }
     }
     // Display Page
     $interface->assign('listId', strip_tags($_REQUEST['id']));
     $interface->assign('popupTitle', 'Email a list');
     $pageContent = $interface->fetch('MyResearch/emailListPopup.tpl');
     $interface->assign('popupContent', $pageContent);
     echo $interface->fetch('popup-wrapper.tpl');
 }
Exemplo n.º 24
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.º 25
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.º 26
0
 /**
  * initSearchObject
  *
  * This constructs a search object for the specified engine.
  *
  * @access  public
  * @param   array   $record     The fields retrieved from the Solr index.
  * @return  object              The record driver for handling the record.
  */
 static function initRecordDriver($record)
 {
     global $configArray;
     // Determine driver path based on record type:
     $driver = ucwords($record['recordtype']) . 'Record';
     $path = "{$configArray['Site']['local']}/RecordDrivers/{$driver}.php";
     // If we can't load the driver, fall back to the default, index-based one:
     if (!is_readable($path)) {
         //Try without appending Record
         $recordType = $record['recordtype'];
         $driverNameParts = explode('_', $recordType);
         $recordType = '';
         foreach ($driverNameParts as $driverPart) {
             $recordType .= ucfirst($driverPart);
         }
         $driver = $recordType . 'Driver';
         $path = "{$configArray['Site']['local']}/RecordDrivers/{$driver}.php";
         // If we can't load the driver, fall back to the default, index-based one:
         if (!is_readable($path)) {
             $driver = 'IndexRecord';
             $path = "{$configArray['Site']['local']}/RecordDrivers/{$driver}.php";
         }
     }
     // Build the object:
     require_once $path;
     if (class_exists($driver)) {
         disableErrorHandler();
         $obj = new $driver($record);
         if (PEAR_Singleton::isError($obj)) {
             global $logger;
             $logger->log("Error loading record driver", PEAR_LOG_DEBUG);
         }
         enableErrorHandler();
         return $obj;
     }
     // If we got here, something went very wrong:
     return new PEAR_Error("Problem loading record driver: {$driver}");
 }
Exemplo n.º 27
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $library;
     global $locationSingleton;
     global $timer;
     global $user;
     if ($user) {
         if (isset($_GET['overDriveId']) && isset($_GET['formatId']) || isset($_POST['overDriveId']) && isset($_POST['formatId'])) {
             $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);
             }
             $overDriveId = isset($_GET['overDriveId']) ? $_GET['overDriveId'] : $_POST['overDriveId'];
             $formatId = isset($_GET['formatId']) ? $_GET['formatId'] : $_POST['formatId'];
             require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
             $driver = OverDriveDriverFactory::getDriver();
             $holdMessage = $driver->placeOverDriveHold($overDriveId, $formatId, $user);
             $interface->assign('message', $holdMessage['message']);
             $interface->assign('MobileTitle', 'OverDrive Place Hold');
             $interface->assign('ButtonBack', false);
             $interface->assign('ButtonHome', true);
             $interface->setTemplate('od-placeHold.tpl');
         }
     } else {
         if (isset($_GET['overDriveId']) && isset($_GET['formatId'])) {
             $interface->assign('overDriveId', $_GET['overDriveId']);
             $interface->assign('formatId', $_GET['formatId']);
             $interface->setTemplate('login.tpl');
         } else {
             header('Location: /');
         }
     }
     $interface->display('layout.tpl', $cacheId);
 }
Exemplo n.º 28
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.º 29
0
 public function authenticate()
 {
     global $configArray;
     $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 = new CatalogConnection($configArray['Catalog']['driver']);
         if ($catalog->status) {
             $patron = $catalog->patronLogin($this->username, $this->password);
             if ($patron && !PEAR_Singleton::isError($patron)) {
                 $user = $this->processILSUser($patron);
             } else {
                 $user = new PEAR_Error('authentication_error_invalid');
             }
         } else {
             $user = new PEAR_Error('authentication_error_technical');
         }
     }
     return $user;
 }
Exemplo n.º 30
0
 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');
     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 AVG Rating eContent
     $listAPI = new ListAPI();
     //New Ebooks
     $listTitlesNE = $listAPI->getListTitles('newebooks');
     //Check if the list is empty or not
     //Assign lists to Smarty var
     $interface->assign('NE', !empty($listTitlesNE['titles']) ? $listTitlesNE['titles'] : "");
     // Cache homepage
     $interface->caching = 0;
     $cacheId = 'homepage|' . $interface->lang;
     //Disable Home page caching for now.
     if (!$interface->is_cached('layout.tpl', $cacheId)) {
         $interface->setPageTitle('iDCLReader Catalog Home');
         $interface->setTemplate('home.tpl');
     }
     $interface->display('layout.tpl', $cacheId);
 }