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;
 }
示例#2
0
 function processInventory()
 {
     global $configArray;
     global $interface;
     $login = $_REQUEST['login'];
     $interface->assign('lastLogin', $login);
     $password1 = $_REQUEST['password1'];
     $interface->assign('lastPassword1', $password1);
     /*
     $initials = $_REQUEST['initials'];
     $interface->assign('lastInitials', $initials);
     $password2 = $_REQUEST['password2'];
     $interface->assign('lastPassword2', $password2);
     */
     $barcodes = $_REQUEST['barcodes'];
     $updateIncorrectStatuses = isset($_REQUEST['updateIncorrectStatuses']);
     $interface->assign('lastUpdateIncorrectStatuses', $updateIncorrectStatuses);
     try {
         $catalog = CatalogFactory::getCatalogConnectionInstance();
         $results = $catalog->doInventory($login, $password1, null, null, $barcodes, $updateIncorrectStatuses);
         return $results;
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     return array('success' => false, 'message' => 'Could not load catalog connection');
 }
示例#3
0
 function launch()
 {
     global $configArray;
     $method = $_REQUEST['method'];
     // Connect to Catalog
     if ($method != 'getBookcoverById' && $method != 'getBookCover') {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         //header('Content-type: application/json');
         header('Content-type: text/html');
         header('Cache-Control: no-cache, must-revalidate');
         // HTTP/1.1
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         // Date in the past
     }
     if (is_callable(array($this, $method))) {
         if (in_array($method, array('getDescriptionByRecordId', 'getDescriptionByTitleAndAuthor'))) {
             $output = json_encode($this->{$method}());
         } else {
             $output = json_encode(array('result' => $this->{$method}()));
         }
     } else {
         $output = json_encode(array('error' => "invalid_method '{$method}'"));
     }
     echo $output;
 }
示例#4
0
 function UpdateInventoryForBarcode()
 {
     global $configArray;
     $barcode = is_array($_REQUEST['barcodes']) ? $_REQUEST['barcodes'] : array($_REQUEST['barcodes']);
     $login = $_REQUEST['login'];
     $password1 = $_REQUEST['password'];
     $initials = $_REQUEST['initials'];
     $password2 = $_REQUEST['password2'];
     $updateIncorrectStatuses = $_REQUEST['updateIncorrectStatuses'];
     $result = array('barcode' => $barcode[0]);
     try {
         $catalog = CatalogFactory::getCatalogConnectionInstance();
         $results = $catalog->doInventory($login, $password1, $initials, $password2, $barcode, $updateIncorrectStatuses);
         if ($results['success'] == false) {
             $result['success'] = false;
             $result['message'] = $results['message'];
         } else {
             $result['success'] = true;
             $result['barcodes'] = $results['barcodes'];
         }
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     return json_encode($result);
 }
示例#5
0
 function getCatalogConnection()
 {
     global $configArray;
     if ($this->catalog == null) {
         // Connect to Catalog
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     }
     return $this->catalog;
 }
示例#6
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');
 }
示例#7
0
 function launch($msg = null)
 {
     global $interface, $library, $configArray;
     /** @var  CatalogConnection $catalog */
     $catalog = CatalogFactory::getCatalogConnectionInstance();
     $selfRegFields = $catalog->getSelfRegistrationFields();
     if (isset($_REQUEST['submit'])) {
         $recaptchaValid = false;
         if (isset($configArray['ReCaptcha']['privateKey'])) {
             $privatekey = $configArray['ReCaptcha']['privateKey'];
             $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
             $recaptchaValid = $resp->is_valid;
         } else {
             $recaptchaValid = true;
         }
         if (!$recaptchaValid) {
             $interface->assign('captchaMessage', 'The CAPTCHA response was incorrect, please try again.');
             // Pre-fill form with user supplied data
             foreach ($selfRegFields as &$property) {
                 $uservalue = $_REQUEST[$property['property']];
                 $property['default'] = $uservalue;
             }
         } else {
             //Submit the form to ILS
             $result = $this->catalog->selfRegister();
             $interface->assign('selfRegResult', $result);
         }
     }
     $interface->assign('submitUrl', $configArray['Site']['path'] . '/MyAccount/SelfReg');
     $interface->assign('structure', $selfRegFields);
     $interface->assign('saveButtonText', 'Register');
     // Set up captcha to limit spam self registrations
     if (isset($configArray['ReCaptcha']['publicKey'])) {
         //			TODO: and not inside library
         $recaptchaPublicKey = $configArray['ReCaptcha']['publicKey'];
         $secureConnection = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on";
         // check that this request is using https
         $captchaCode = recaptcha_get_html($recaptchaPublicKey, null, $secureConnection);
         $interface->assign('captcha', $captchaCode);
     }
     $fieldsForm = $interface->fetch('DataObjectUtil/objectEditForm.tpl');
     $interface->assign('selfRegForm', $fieldsForm);
     $interface->assign('selfRegistrationFormMessage', $library->selfRegistrationFormMessage);
     $interface->assign('selfRegistrationSuccessMessage', $library->selfRegistrationSuccessMessage);
     $interface->assign('promptForBirthDateInSelfReg', $library->promptForBirthDateInSelfReg);
     $interface->setTemplate('selfReg.tpl');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->display('layout.tpl');
 }
示例#8
0
 function launch($msg = null)
 {
     global $interface;
     global $configArray;
     if (isset($_REQUEST['submit'])) {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         $driver = $this->catalog->driver;
         $registrationResult = $driver->selfRegister();
         $interface->assign('registrationResult', $registrationResult);
         $interface->setTemplate('getcardresult.tpl');
     } else {
         global $serverName;
         if (file_exists("../../sites/{$serverName}/conf/selfRegCityState.ini")) {
             $selfRegCityStates = parse_ini_file("../../sites/{$serverName}/conf/selfRegCityState.ini", true);
         } elseif (file_exists("../../sites/default/conf/selfRegCityState.ini")) {
             $selfRegCityStates = parse_ini_file("../../sites/default/conf/selfRegCityState.ini", true);
         } else {
             $selfRegCityStates = null;
         }
         $interface->assign('selfRegCityStates', $selfRegCityStates);
         if (file_exists("../../sites/{$serverName}/conf/selfRegLanguage.ini")) {
             $selfRegLanguages = parse_ini_file("../../sites/{$serverName}/conf/selfRegLanguage.ini", true);
         } elseif (file_exists("../../sites/default/conf/selfRegLanguage.ini")) {
             $selfRegLanguages = parse_ini_file("../../sites/default/conf/selfRegLanguage.ini", true);
         } else {
             $selfRegLanguages = null;
         }
         $interface->assign('selfRegLanguages', $selfRegLanguages);
         if (file_exists("../../sites/{$serverName}/conf/selfRegLocation.ini")) {
             $selfRegLocations = parse_ini_file("../../sites/{$serverName}/conf/selfRegLocation.ini", true);
         } elseif (file_exists("../../sites/default/conf/default/conf/selfRegLocation.ini")) {
             $selfRegLocations = parse_ini_file("../../sites/default/conf/selfRegLocation.ini", true);
         } else {
             $selfRegLocations = null;
         }
         $interface->assign('selfRegLocations', $selfRegLocations);
         if (file_exists("../../sites/{$serverName}/conf/selfRegPhoneType.ini")) {
             $selfRegPhoneType = parse_ini_file("../../sites/{$serverName}/conf/selfRegPhoneType.ini", true);
         } elseif (file_exists("../../sites/default/conf/selfRegPhoneType.ini")) {
             $selfRegPhoneType = parse_ini_file("../../sites/default/conf/selfRegPhoneType.ini", true);
         } else {
             $selfRegPhoneType = null;
         }
         $interface->assign('selfRegPhoneType', $selfRegPhoneType);
         $interface->setTemplate('getcard.tpl');
     }
     $interface->display('layout.tpl');
 }
示例#9
0
 function __construct()
 {
     global $interface;
     global $configArray;
     global $user;
     //If the user isn't logged in, take them to the login page
     if (!$user) {
         header("Location: {$configArray['Site']['path']}/MyAccount/Login");
         die;
     }
     //Make sure the user has permission to access the page
     $allowableRoles = $this->getAllowableRoles();
     $userCanAccess = false;
     foreach ($allowableRoles as $roleId => $roleName) {
         if ($user->hasRole($roleName)) {
             $userCanAccess = true;
             break;
         }
     }
     //Check to see if we have any acs or single use eContent in the catalog
     //to enable the holds and wishlist appropriately
     if (isset($configArray['EContent']['hasProtectedEContent'])) {
         $interface->assign('hasProtectedEContent', $configArray['EContent']['hasProtectedEContent']);
     } else {
         $interface->assign('hasProtectedEContent', false);
     }
     //This code is also in Search/History since that page displays in the My Account menu as well.
     //It is also in MyList.php
     if ($user !== false) {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         //Figure out if we should show a link to classic opac to pay holds.
         $ecommerceLink = $configArray['Site']['ecommerceLink'];
         $homeLibrary = Library::getLibraryForLocation($user->homeLocationId);
         if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) {
             $interface->assign('showEcommerceLink', true);
             $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
             $interface->assign('ecommerceLink', $ecommerceLink);
         } else {
             $interface->assign('showEcommerceLink', false);
             $interface->assign('minimumFineAmount', 0);
         }
     }
     if (!$userCanAccess) {
         $interface->setTemplate('../Admin/noPermission.tpl');
         $interface->display('layout.tpl');
         exit;
     }
 }
示例#10
0
 function launch()
 {
     global $configArray;
     global $user;
     try {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     } 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'] . '/MyAccount/CheckedOut');
 }
示例#11
0
 function launch()
 {
     global $configArray;
     try {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     } 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->placeHold();
     } else {
         PEAR_Singleton::raiseError('Cannot Process Place Hold - ILS Not Supported');
     }
 }
示例#12
0
 function launch($msg = null)
 {
     global $interface;
     if (isset($_REQUEST['submit'])) {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         $driver = $this->catalog->driver;
         if ($this->catalog->checkFunction('emailPin')) {
             $barcode = strip_tags($_REQUEST['barcode']);
             $emailResult = $driver->emailPin($barcode);
         } else {
             $emailResult = array('error' => 'This functionality is not available in the ILS.');
         }
         $interface->assign('emailResult', $emailResult);
         $interface->setTemplate('emailPinResults.tpl');
     } else {
         $interface->setTemplate('emailPin.tpl');
     }
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->display('layout.tpl');
 }
示例#13
0
 function launch()
 {
     global $configArray;
     global $user;
     try {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     } 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'] . '/MyAccount/CheckedOut');
 }
示例#14
0
 function launch()
 {
     global $configArray;
     global $user;
     global $logger;
     $logger->log("Starting renew action", PEAR_LOG_INFO);
     try {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     } 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'] . '/MyAccount/CheckedOut');
 }
示例#15
0
 function renewAll()
 {
     global $configArray;
     try {
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     } 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')) {
         $renewResults = $this->catalog->driver->renewAll();
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Renew All - ILS Not Supported'));
     }
     global $interface;
     $interface->assign('renew_message_data', $renewResults);
     $result = array('title' => translate('Renew') . ' All', 'modalBody' => $interface->fetch('Record/renew-results.tpl'), 'success' => $renewResults['result'], 'renewed' => $renewResults['Renewed']);
     return $result;
 }
示例#16
0
function loadUserData()
{
    global $user;
    global $interface;
    //Load profile information
    $catalog = CatalogFactory::getCatalogConnectionInstance();
    $profile = $catalog->getMyProfile($user);
    if (!PEAR_Singleton::isError($profile)) {
        $interface->assign('profile', $profile);
    }
    //Load a list of lists
    $lists = array();
    require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
    $tmpList = new UserList();
    $tmpList->user_id = $user->id;
    $tmpList->deleted = 0;
    $tmpList->orderBy("title ASC");
    $tmpList->find();
    if ($tmpList->N > 0) {
        while ($tmpList->fetch()) {
            $lists[$tmpList->id] = array('name' => $tmpList->title, 'url' => '/MyAccount/MyList/' . $tmpList->id, 'id' => $tmpList->id, 'numTitles' => $tmpList->num_titles());
        }
    }
    $interface->assign('lists', $lists);
    // Get My Tags
    $tagList = $user->getTags();
    $interface->assign('tagList', $tagList);
    if ($user->hasRole('opacAdmin') || $user->hasRole('libraryAdmin') || $user->hasRole('cataloging')) {
        $variable = new Variable();
        $variable->name = 'lastFullReindexFinish';
        if ($variable->find(true)) {
            $interface->assign('lastFullReindexFinish', date('m-d-Y H:i:s', $variable->value));
        } else {
            $interface->assign('lastFullReindexFinish', 'Unknown');
        }
        $variable = new Variable();
        $variable->name = 'lastPartialReindexFinish';
        if ($variable->find(true)) {
            $interface->assign('lastPartialReindexFinish', date('m-d-Y H:i:s', $variable->value));
        } else {
            $interface->assign('lastPartialReindexFinish', 'Unknown');
        }
    }
}
示例#17
0
 function __construct()
 {
     global $interface;
     global $configArray;
     global $user;
     $interface->assign('page_body_style', 'sidebar_left');
     if ($this->requireLogin && !UserAccount::isLoggedIn()) {
         require_once ROOT_DIR . '/services/MyAccount/Login.php';
         $myAccountAction = new MyAccount_Login();
         $myAccountAction->launch();
         exit;
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $this->db = new $class($configArray['Index']['url']);
     // Connect to Database
     $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     // Register Library Catalog Account
     if (isset($_POST['submit']) && !empty($_POST['submit'])) {
         if ($this->catalog && isset($_POST['cat_username']) && isset($_POST['cat_password'])) {
             $result = $this->catalog->patronLogin($_POST['cat_username'], $_POST['cat_password']);
             if ($result && !PEAR_Singleton::isError($result)) {
                 $user->cat_username = $_POST['cat_username'];
                 $user->cat_password = $_POST['cat_password'];
                 $user->update();
                 UserAccount::updateSession($user);
                 $interface->assign('user', $user);
             } else {
                 $interface->assign('loginError', 'Invalid Patron Login');
             }
         }
     }
     //Check to see if we have any acs or single use eContent in the catalog
     //to enable the holds and wishlist appropriately
     if (isset($configArray['EContent']['hasProtectedEContent'])) {
         $interface->assign('hasProtectedEContent', $configArray['EContent']['hasProtectedEContent']);
     } else {
         $interface->assign('hasProtectedEContent', false);
     }
     //This code is also in Search/History since that page displays in the My Account menu as well.
     //It is also in MyList.php and Admin.php
     if ($user !== false) {
         $interface->assign('user', $user);
         // Profile is already loaded by index.php. plb 4-17-2015
         // (keeping in case there is a exception )
         // Get My Profile
         //			if ($this->catalog->status) {
         //				if ($user->cat_username) {
         //					$patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
         //					if (PEAR_Singleton::isError($patron)){
         //						PEAR_Singleton::raiseError($patron);
         //					}
         //
         //					$profile = $this->catalog->getMyProfile($patron);
         //					//global $logger;
         //					//$logger->log("Patron profile phone number in MyResearch = " . $profile['phone'], PEAR_LOG_INFO);
         //					if (!PEAR_Singleton::isError($profile)) {
         //						$interface->assign('profile', $profile);
         //					}
         //				}
         //			}
         //Figure out if we should show a link to classic opac to pay holds.
         $ecommerceLink = $configArray['Site']['ecommerceLink'];
         $homeLibrary = Library::getLibraryForLocation($user->homeLocationId);
         if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) {
             $interface->assign('showEcommerceLink', true);
             $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
             if ($homeLibrary->payFinesLink == 'default') {
                 $interface->assign('ecommerceLink', $ecommerceLink);
             } else {
                 $interface->assign('ecommerceLink', $homeLibrary->payFinesLink);
             }
             $interface->assign('payFinesLinkText', $homeLibrary->payFinesLinkText);
         } else {
             $interface->assign('showEcommerceLink', false);
             $interface->assign('minimumFineAmount', 0);
         }
     }
 }
示例#18
0
 /**
  * @param UserListEntry $listEntry - The resource to be cleaned
  * @return UserListEntry|bool
  */
 function cleanListEntry($listEntry)
 {
     global $configArray;
     global $user;
     // Connect to Database
     $this->catalog = CatalogFactory::getCatalogConnectionInstance();
     //Filter list information for bad words as needed.
     if ($user == false || $this->user_id != $user->id) {
         //Load all bad words.
         global $library;
         require_once ROOT_DIR . '/Drivers/marmot_inc/BadWord.php';
         $badWords = new BadWord();
         $badWordsList = $badWords->getBadWordExpressions();
         //Determine if we should censor bad words or hide the comment completely.
         $censorWords = true;
         if (isset($library)) {
             $censorWords = $library->hideCommentsWithBadWords == 0 ? true : false;
         }
         if ($censorWords) {
             //Filter Title
             $titleText = $this->title;
             foreach ($badWordsList as $badWord) {
                 $titleText = preg_replace($badWord, '***', $titleText);
             }
             $this->title = $titleText;
             //Filter description
             $descriptionText = $this->description;
             foreach ($badWordsList as $badWord) {
                 $descriptionText = preg_replace($badWord, '***', $descriptionText);
             }
             $this->description = $descriptionText;
             //Filter notes
             $notesText = $listEntry->notes;
             foreach ($badWordsList as $badWord) {
                 $notesText = preg_replace($badWord, '***', $notesText);
             }
             $this->description = $notesText;
         } else {
             //Check for bad words in the title or description
             $titleText = $this->title;
             if (isset($listEntry->description)) {
                 $titleText .= ' ' . $listEntry->description;
             }
             //Filter notes
             $titleText .= ' ' . $listEntry->notes;
             foreach ($badWordsList as $badWord) {
                 if (preg_match($badWord, $titleText)) {
                     return false;
                 }
             }
         }
     }
     return $listEntry;
 }
示例#19
0
 function launch()
 {
     global $interface;
     global $user;
     // In some contexts, we want to require a login before showing search
     // history:
     if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
         require_once ROOT_DIR . '/services/MyAccount/Login.php';
         MyAccount_Login::launch();
         exit;
     }
     $interface->setPageTitle('Search History');
     // Retrieve search history
     $s = new SearchEntry();
     $searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
     if (count($searchHistory) > 0) {
         // Build an array of history entries
         $links = array();
         $saved = array();
         // Loop through the history
         foreach ($searchHistory as $search) {
             $size = strlen($search->search_object);
             $minSO = unserialize($search->search_object);
             $searchObject = SearchObjectFactory::deminify($minSO);
             // Make sure all facets are active so we get appropriate
             // descriptions in the filter box.
             $searchObject->activateAllFacets();
             $newItem = array('id' => $search->id, 'time' => date("g:ia, jS M y", $searchObject->getStartTime()), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal()), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb");
             // Saved searches
             if ($search->saved == 1) {
                 $saved[] = $newItem;
                 // All the others
             } else {
                 // If this was a purge request we don't need this
                 if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
                     $search->delete();
                     // We don't want to remember the last search after a purge:
                     unset($_SESSION['lastSearchURL']);
                     // Otherwise add to the list
                 } else {
                     $links[] = $newItem;
                 }
             }
         }
         // One final check, after a purge make sure we still have a history
         if (count($links) > 0 || count($saved) > 0) {
             $interface->assign('links', array_reverse($links));
             $interface->assign('saved', array_reverse($saved));
             $interface->assign('noHistory', false);
             // Nothing left in history
         } else {
             $interface->assign('noHistory', true);
         }
         // No history
     } else {
         $interface->assign('noHistory', true);
     }
     //Load profile information for display in My Account menu
     //This code is also in MyResearch.php
     if ($user !== false) {
         global $configArray;
         $this->catalog = CatalogFactory::getCatalogConnectionInstance();
         // Get My Profile
         if ($this->catalog->status) {
             if ($user->cat_username) {
                 $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
                 if (PEAR_Singleton::isError($patron)) {
                     PEAR_Singleton::raiseError($patron);
                 }
                 $result = $this->catalog->getMyProfile($patron);
                 if (!PEAR_Singleton::isError($result)) {
                     $interface->assign('profile', $result);
                 }
             }
         }
         //Figure out if we should show a link to classic opac to pay holds.
         global $library;
         $homeLibrary = $library->getLibraryForLocation($user->homeLocationId);
         if ($homeLibrary->showEcommerceLink == 1) {
             $interface->assign('showEcommerceLink', true);
             $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
         } else {
             $interface->assign('showEcommerceLink', false);
             $interface->assign('minimumFineAmount', 0);
         }
     }
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('history.tpl');
     $interface->display('layout.tpl');
 }
示例#20
0
 static function loadHoldings($id)
 {
     global $interface;
     global $configArray;
     global $library;
     $showCopiesLineInHoldingsSummary = true;
     $showCheckInGrid = true;
     if ($library && $library->showCopiesLineInHoldingsSummary == 0) {
         $showCopiesLineInHoldingsSummary = false;
     }
     $interface->assign('showCopiesLineInHoldingsSummary', $showCopiesLineInHoldingsSummary);
     if ($library && $library->showCheckInGrid == 0) {
         $showCheckInGrid = false;
     }
     $interface->assign('showCheckInGrid', $showCheckInGrid);
     try {
         $catalog = CatalogFactory::getCatalogConnectionInstance();
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
         return null;
     }
     $holdingData = new stdClass();
     // Get Holdings Data
     if ($catalog->status) {
         $result = $catalog->getHolding($id);
         if (PEAR_Singleton::isError($result)) {
             PEAR_Singleton::raiseError($result);
         }
         if (count($result)) {
             $holdings = array();
             $issueSummaries = array();
             foreach ($result as $copy) {
                 if (isset($copy['type']) && $copy['type'] == 'issueSummary') {
                     $issueSummaries = $result;
                     break;
                 } else {
                     $key = $copy['location'];
                     $key = preg_replace('~\\W~', '_', $key);
                     $holdings[$key][] = $copy;
                 }
             }
             if (isset($issueSummaries) && count($issueSummaries) > 0) {
                 $interface->assign('issueSummaries', $issueSummaries);
                 $holdingData->issueSummaries = $issueSummaries;
             } else {
                 $interface->assign('holdings', $holdings);
                 $holdingData->holdings = $holdings;
             }
         } else {
             $interface->assign('holdings', array());
             $holdingData->holdings = array();
         }
         // Get Acquisitions Data
         $result = $catalog->getPurchaseHistory($id);
         if (PEAR_Singleton::isError($result)) {
             PEAR_Singleton::raiseError($result);
         }
         $interface->assign('history', $result);
         $holdingData->history = $result;
         //Holdings summary
         $result = $catalog->getStatusSummary($id, false);
         if (PEAR_Singleton::isError($result)) {
             PEAR_Singleton::raiseError($result);
         }
         $holdingData->holdingsSummary = $result;
         $interface->assign('holdingsSummary', $result);
         $interface->assign('formattedHoldingsSummary', $interface->fetch('Record/holdingsSummary.tpl'));
     }
     return $holdingData;
 }
示例#21
0
 /**
  * Get Item Statuses
  *
  * This is responsible for getting holding summary information for a list of
  * records from the database.
  *
  * @access	public
  * @author	Mark Noble <*****@*****.**>
  */
 function GetStatusSummaries()
 {
     global $configArray;
     global $interface;
     global $timer;
     global $library;
     $showCopiesLineInHoldingsSummary = true;
     if ($library && $library->showCopiesLineInHoldingsSummary == 0) {
         $showCopiesLineInHoldingsSummary = false;
     }
     $interface->assign('showCopiesLineInHoldingsSummary', $showCopiesLineInHoldingsSummary);
     require_once ROOT_DIR . '/CatalogConnection.php';
     // Try to find a copy that is available
     /** @var $catalog CatalogConnection */
     $catalog = CatalogFactory::getCatalogConnectionInstance();
     $timer->logTime("Initialized Catalog Connection");
     $summaries = $catalog->getStatusSummaries($_GET['id'], true);
     $timer->logTime("Retrieved status summaries");
     $result = array();
     $result['items'] = array();
     if ($configArray['Catalog']['offline']) {
         $interface->assign('offline', true);
     } else {
         $interface->assign('offline', false);
     }
     // Loop through all the status information that came back
     foreach ($summaries as $id => $record) {
         // If we encountered errors, skip those problem records.
         if (PEAR_Singleton::isError($record)) {
             continue;
         }
         $itemResults = $record;
         $interface->assign('id', $id);
         $interface->assign('holdingsSummary', $record);
         $formattedHoldingsSummary = $interface->fetch('Record/holdingsSummary.tpl');
         $itemResults['formattedHoldingsSummary'] = $formattedHoldingsSummary;
         $result['items'][] = $itemResults;
     }
     echo json_encode($result);
     $timer->logTime("Formatted results");
 }
示例#22
0
 /**
  * Returns a summary of information about the user's account in OverDrive.
  *
  * @param User $user
  *
  * @return array
  */
 public function getOverDriveSummary($user)
 {
     global $configArray;
     $libraryILS = $configArray['OverDrive']['LibraryCardILS'];
     /** @var MillenniumDriver|DriverInterface $catalog */
     $catalog = CatalogFactory::getCatalogConnectionInstance();
     $patronBarcode = $catalog->_getBarcode();
     $apiURL = "https://temp-patron.api.overdrive.com/{$libraryILS}/{$libraryILS}/" . $patronBarcode;
     $summaryResultRaw = file_get_contents($apiURL);
     $summary = array('numCheckedOut' => 0, 'numAvailableHolds' => 0, 'numUnavailableHolds' => 0);
     if ($summaryResultRaw != "Library patron not found.") {
         $summaryResults = json_decode($summaryResultRaw, true);
         $summary['numCheckedOut'] = $summaryResults['CheckoutCount'];
         $summary['numAvailableHolds'] = $summaryResults['AvailableHoldCount'];
         $summary['numUnavailableHolds'] = $summaryResults['PendingHoldCount'];
     }
     return $summary;
 }
示例#23
0
 function getNumHolds()
 {
     if ($this->numHolds != -1) {
         return $this->numHolds;
     }
     global $configArray;
     global $timer;
     if ($configArray['Catalog']['ils'] == 'Horizon') {
         require_once ROOT_DIR . '/CatalogFactory.php';
         $catalog = CatalogFactory::getCatalogConnectionInstance();
         $this->numHolds = $catalog->getNumHolds($this->getUniqueID());
     } else {
         require_once ROOT_DIR . '/Drivers/marmot_inc/IlsHoldSummary.php';
         $holdSummary = new IlsHoldSummary();
         $holdSummary->ilsId = $this->getUniqueID();
         if ($holdSummary->find(true)) {
             $this->numHolds = $holdSummary->numHolds;
         } else {
             $this->numHolds = 0;
         }
     }
     $timer->logTime("Loaded number of holds");
     return $this->numHolds;
 }
示例#24
0
文件: language.php 项目: efoft/orion
// Used for multi-language sites
$lang->handleGet($_GET);
if ($lang->isMultiLang()) {
    // Cfg::LANGUAGES might be empty
    foreach ($lang->getAllLangs() as $lng) {
        if (!defined('Cfg::MENUFILE_' . strtoupper($lng))) {
            throw new Exception('Parameter Cfg::MENUFILE_' . strtoupper($lng) . ' is not set');
        }
        if (!property_exists('Cfg', 'pages_' . $lng)) {
            throw new Exception('Parameter Cfg::pages_' . $lng . ' is not set');
        }
        if (!property_exists('Cfg', 'menu_categories_' . $lng)) {
            throw new Exception('Parameter Cfg::menu_categories_' . $lng . ' is not set');
        }
    }
    // $pages_<lang>
    $pmgr = PageMgr::getInstance(Cfg::${'pages_' . $lang->getLang()}, Common::getAbsPath(Cfg::PAGES_PATH));
    $catalog = CatalogFactory::createCatalogProvider(Cfg::$structure, Cfg::CATALOG_SOURCE_TYPE);
    // MENUFILE_<LANG>
    $menufile = constant('Cfg::MENUFILE_' . strtoupper($lang->getLang()));
    $catalog->loadSource(Common::getAbsPath($menufile));
    $catalog->loadCategories(Cfg::${'menu_categories_' . $lang->getLang()});
    // remember current language
    $mem->store('langdir', $lang->getLang() . DIRECTORY_SEPARATOR);
    $view->set('multilang', true);
    $view->set('curlang', $lang->getLang());
    $view->set('lang_link_start', '?lang=' . $lang->getLang());
    $view->set('lang_link_append', '&lang=' . $lang->getLang());
} else {
    $view->set('multilang', false);
}
示例#25
0
 function placeHold()
 {
     global $user;
     global $configArray;
     global $interface;
     global $analytics;
     $analytics->enableTracking();
     $recordId = $_REQUEST['id'];
     if ($user) {
         //The user is already logged in
         $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
         $catalog = CatalogFactory::getCatalogConnectionInstance();
         if (isset($_REQUEST['selectedItem'])) {
             $return = $catalog->placeItemHold($recordId, $_REQUEST['selectedItem'], $user->{$barcodeProperty}, '', '');
         } else {
             $return = $catalog->placeHold($recordId, $user->{$barcodeProperty}, '', '');
         }
         if (isset($return['items'])) {
             $campus = $_REQUEST['campus'];
             $interface->assign('campus', $campus);
             $items = $return['items'];
             $interface->assign('items', $items);
             $interface->assign('message', $return['message']);
             $interface->assign('id', $recordId);
             global $library;
             $interface->assign('showDetailedHoldNoticeInformation', $library->showDetailedHoldNoticeInformation);
             $interface->assign('treatPrintNoticesAsPhoneNotices', $library->treatPrintNoticesAsPhoneNotices);
             //Need to place item level holds.
             $results = array('success' => true, 'needsItemLevelHold' => true, 'message' => $interface->fetch('Record/item-hold-popup.tpl'), 'title' => $return['title']);
         } else {
             // Completed Hold Attempt
             $interface->assign('message', $return['message']);
             $success = $return['result'];
             $interface->assign('success', $success);
             //Get library based on patron home library since that is what controls their notifications rather than the active interface.
             //$library = Library::getPatronHomeLibrary();
             global $library;
             $canUpdateContactInfo = $library->allowProfileUpdates == 1;
             // set update permission based on active library's settings. Or allow by default.
             $canChangeNoticePreference = $library->showNoticeTypeInProfile == 1;
             // when user preference isn't set, they will be shown a link to account profile. this link isn't needed if the user can not change notification preference.
             $interface->assign('canUpdate', $canUpdateContactInfo);
             $interface->assign('canChangeNoticePreference', $canChangeNoticePreference);
             $interface->assign('showDetailedHoldNoticeInformation', $library->showDetailedHoldNoticeInformation);
             $interface->assign('treatPrintNoticesAsPhoneNotices', $library->treatPrintNoticesAsPhoneNotices);
             $results = array('success' => $success, 'message' => $interface->fetch('Record/hold-success-popup.tpl'), 'title' => $return['title']);
             if (isset($_REQUEST['autologout'])) {
                 UserAccount::softLogout();
                 $results['autologout'] = true;
             }
         }
     } else {
         $results = array('success' => false, 'message' => 'You must be logged in to place a hold.  Please close this dialog and login.', 'title' => 'Please login');
         if (isset($_REQUEST['autologout'])) {
             UserAccount::softLogout();
             $results['autologout'] = true;
         }
     }
     return $this->json_utf8_encode($results);
 }