Exemple #1
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $configArray;
     // Don't let bots crawl holdings
     $this->disallowBots();
     if (!$this->hasHoldings && !(isset($configArray['Site']['ajaxRecordTabs']) && $configArray['Site']['ajaxRecordTabs'])) {
         $url = $configArray['Site']['url'] . "/Record/" . $_REQUEST['id'] . "/Description";
         header('Location: ' . $url);
     }
     // Do not cache holdings page
     $interface->caching = 0;
     // See if patron is logged in to pass details onto get holdings for
     // holds / recalls
     $patron = UserAccount::isLoggedIn() ? UserAccount::catalogLogin() : false;
     if (PEAR::isError($patron)) {
         $patron = false;
     }
     $interface->setPageTitle($this->recordDriver->getBreadcrumb());
     // Only fetch holdings if we actually need them (not needed for the basic page part of holdings when using ajax record tabs)
     if (!isset($configArray['Site']['ajaxRecordTabs']) || !$configArray['Site']['ajaxRecordTabs'] || isset($_REQUEST['subPage'])) {
         $interface->assign('holdingsMetadata', $this->recordDriver->getHoldings($patron));
     }
     $interface->assign('subTemplate', 'view-holdings.tpl');
     $interface->setTemplate('view.tpl');
     // Set Messages
     $interface->assign('infoMsg', $this->infoMsg);
     $interface->assign('errorMsg', $this->errorMsg);
     // Display Page
     $interface->display('layout.tpl');
 }
Exemple #2
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Get My Transactions
     if ($patron = UserAccount::catalogLogin()) {
         if (PEAR::isError($patron)) {
             $this->handleCatalogError($patron);
         } else {
             // Renew Items
             if (isset($_POST['renewAll']) || isset($_POST['renewSelected'])) {
                 $renewResult = $this->_renewItems($patron);
             }
             $result = $this->catalog->getMyTransactions($patron);
             if (PEAR::isError($result)) {
                 PEAR::raiseError($result);
             }
             $transList = array();
             foreach ($result as $data) {
                 $current = array('ils_details' => $data);
                 if ($record = $this->db->getRecord($data['id'])) {
                     $formats = isset($record['format']) ? $record['format'] : '';
                     if (!is_array($formats)) {
                         $formats = array($formats);
                     }
                     foreach ($formats as &$format) {
                         $format = preg_replace('/^\\d\\//', '', $format);
                         $format = rtrim($format, "/");
                     }
                     $driver = RecordDriverFactory::initRecordDriver($record);
                     if (!empty($data['title'])) {
                         $title = $data['title'];
                     } else {
                         $title = isset($record['title']) ? $record['title'] : null;
                     }
                     $current += array('id' => $record['id'], 'isbn' => isset($record['isbn']) ? $record['isbn'] : null, 'author' => isset($record['author']) ? $record['author'] : null, 'title' => $title, 'format' => $formats, 'summImages' => $driver ? $driver->getAllImages() : null, 'summThumb' => $driver ? $driver->getThumbnail() : null);
                 }
                 $transList[] = $current;
             }
             if ($this->checkRenew) {
                 $transList = $this->_addRenewDetails($transList);
             }
             $interface->assign('transList', $transList);
             $profile = $this->catalog->getMyProfile($patron);
             if (!PEAR::isError($profile)) {
                 $interface->assign('profile', $profile);
             }
         }
     }
     Login::setupLoginFormVars();
     $interface->setTemplate('checkedout.tpl');
     $interface->setPageTitle('Checked Out Items');
     $interface->display('layout.tpl');
 }
Exemple #3
0
 /**
  * Check Request is Valid
  *
  * @return void
  * @access public
  */
 public function checkRequestIsValid()
 {
     if (isset($_REQUEST['id']) && isset($_REQUEST['data'])) {
         // check if user is logged in
         $user = UserAccount::isLoggedIn();
         if (!$user) {
             return $this->output(array('status' => false, 'msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH);
         }
         $catalog = ConnectionManager::connectToCatalog();
         if ($catalog && $catalog->status) {
             if ($patron = UserAccount::catalogLogin()) {
                 if (!PEAR::isError($patron)) {
                     $results = $catalog->checkCallSlipRequestIsValid($_REQUEST['id'], $_REQUEST['data'], $patron);
                     if (!PEAR::isError($results)) {
                         $msg = $results ? translate('call_slip_place_text') : translate('call_slip_error_blocked');
                         return $this->output(array('status' => $results, 'msg' => $msg), JSON::STATUS_OK);
                     }
                 }
             }
         }
     }
     return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR);
 }
Exemple #4
0
 /**
  * Checks whether the user is authorized to access
  * restricted resources.
  *
  * @return bool Is the user authorized
  * @access public
  */
 public static function isAuthorized()
 {
     global $configArray;
     if (isset($_SESSION['userAuthorized']) && $_SESSION['userAuthorized']) {
         return true;
     }
     if (isset($configArray['Authorization']['ip']) && $configArray['Authorization']['ip']) {
         if (UserAccount::isInIpRange()) {
             return true;
         }
     }
     if (isset($_SESSION['authMethod']) && isset($configArray['Authorization']['authentication_methods'])) {
         if (in_array($_SESSION['authMethod'], $configArray['Authorization']['authentication_methods'])) {
             if ($_SESSION['authMethod'] == 'ILS') {
                 if (!isset($_SESSION['userAuthorized'])) {
                     // Check ILS-based authorization
                     $patron = UserAccount::catalogLogin();
                     if ($patron !== false && !PEAR::isError($patron)) {
                         $catalog = ConnectionManager::connectToCatalog();
                         if ($catalog->checkFunction('getPatronAuthorizationStatus')) {
                             $status = $catalog->getPatronAuthorizationStatus($patron);
                             if (!PEAR::isError($status)) {
                                 $_SESSION['userAuthorized'] = $status;
                                 if ($status) {
                                     return true;
                                 }
                             }
                         }
                     }
                 }
             } else {
                 return true;
             }
         }
     }
     return false;
 }
Exemple #5
0
 /**
  * Get Item Statuses
  *
  * This is responsible for printing the holdings information for a
  * collection of records in JSON format.
  *
  * @return void
  * @access public
  * @author Chris Delis <*****@*****.**>
  * @author Tuan Nguyen <*****@*****.**>
  */
 public function getItemStatuses()
 {
     global $interface;
     global $configArray;
     $catalog = ConnectionManager::connectToCatalog();
     if (!$catalog || !$catalog->status) {
         return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR);
     }
     $results = $catalog->getStatuses($_GET['id']);
     if (PEAR::isError($results)) {
         return $this->output($results->getMessage(), JSON::STATUS_ERROR);
     } else {
         if (!is_array($results)) {
             // If getStatuses returned garbage, let's turn it into an empty array
             // to avoid triggering a notice in the foreach loop below.
             $results = array();
         }
     }
     // In order to detect IDs missing from the status response, create an
     // array with a key for every requested ID.  We will clear keys as we
     // encounter IDs in the response -- anything left will be problems that
     // need special handling.
     $missingIds = array_flip($_GET['id']);
     // Load messages for response:
     $messages = array('available' => $interface->fetch('AJAX/status-available.tpl'), 'unavailable' => $interface->fetch('AJAX/status-unavailable.tpl'), 'unknown' => $interface->fetch('AJAX/status-unknown.tpl'));
     // Load callnumber and location settings:
     $callnumberSetting = isset($configArray['Item_Status']['multiple_call_nos']) ? $configArray['Item_Status']['multiple_call_nos'] : 'msg';
     $locationSetting = isset($configArray['Item_Status']['multiple_locations']) ? $configArray['Item_Status']['multiple_locations'] : 'msg';
     $showFullStatus = isset($configArray['Item_Status']['show_full_status']) ? $configArray['Item_Status']['show_full_status'] : false;
     // Loop through all the status information that came back
     $statuses = array();
     $patron = null;
     foreach ($results as $record) {
         // Skip errors and empty records:
         if (!PEAR::isError($record) && count($record)) {
             // Filter out suppressed locations, and skip record if none remain:
             $record = $this->_filterSuppressedLocations($record);
             if (empty($record)) {
                 continue;
             }
             // Special case for Axiell holdings
             if (isset($record[0]['holdings'])) {
                 if ($patron === null) {
                     $patron = UserAccount::catalogLogin();
                 }
                 $current = array('id' => $record[0]['id'], 'full_status' => $this->getAxiellItemStatusFull($record, $catalog, $patron));
             } else {
                 if ($locationSetting == "group") {
                     $current = $this->_getItemStatusGroup($record, $messages, $callnumberSetting);
                 } else {
                     $current = $this->_getItemStatus($record, $messages, $locationSetting, $callnumberSetting);
                 }
                 // If a full status display has been requested, append the HTML:
                 if ($showFullStatus) {
                     $current['full_status'] = $this->_getItemStatusFull($record);
                 }
             }
             $statuses[] = $current;
             // The current ID is not missing -- remove it from the missing list.
             unset($missingIds[$current['id']]);
         }
     }
     // If any IDs were missing, send back appropriate dummy data, including a
     // "missing data" flag which can be used to completely suppress status info:
     foreach ($missingIds as $missingId => $junk) {
         $statuses[] = array('id' => $missingId, 'availability' => 'false', 'availability_message' => $messages['unavailable'], 'location' => translate('Unknown'), 'locationList' => false, 'reserve' => 'false', 'reserve_message' => translate('Not On Reserve'), 'callnumber' => '', 'missing_data' => true);
     }
     // Done
     return $this->output($statuses, JSON::STATUS_OK);
 }
Exemple #6
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // Are UB Requests Allowed?
     $this->checkUBRequests = $this->catalog->checkFunction("UBRequests", $this->recordDriver->getUniqueID());
     if ($this->checkUBRequests != false) {
         // Do we have valid information?
         // Sets $this->logonURL and $this->gatheredDetails
         $validate = $this->_validateUBRequestData($this->checkUBRequests['HMACKeys']);
         if (!$validate) {
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('lightbox', true);
                 $interface->assign('results', array('status' => 'ub_request_error_blocked'));
                 $interface->display('Record/ub-request-submit.tpl');
             } else {
                 header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()));
             }
             return false;
         }
         // Assign FollowUp Details required for login and catalog login
         $interface->assign('followup', true);
         $interface->assign('recordId', $this->recordDriver->getUniqueID());
         $interface->assign('followupModule', 'Record');
         $interface->assign('followupAction', 'UBRequest' . $this->logonURL);
         // User Must be logged In to Place Holds
         if (UserAccount::isLoggedIn()) {
             if ($patron = UserAccount::catalogLogin()) {
                 // Block invalid requests:
                 $result = PEAR::isError($patron) ? false : $this->catalog->checkUBRequestIsValid($this->recordDriver->getUniqueID(), $this->gatheredDetails, $patron);
                 if (!$result) {
                     $errorMsg = PEAR::isError($patron) ? $patron->getMessage() : 'ub_request_error_blocked';
                     if (isset($_REQUEST['lightbox'])) {
                         $interface->assign('lightbox', true);
                         $interface->assign('results', array('status' => $errorMsg));
                         $interface->display('Record/ub-request-submit.tpl');
                     } else {
                         header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()) . "?errorMsg={$errorMsg}#top");
                     }
                     return false;
                 }
                 $interface->assign('items', $result['items']);
                 $interface->assign('libraries', $result['libraries']);
                 $interface->assign('locations', $result['locations']);
                 $interface->assign('requiredBy', $result['requiredBy']);
                 $interface->assign('formURL', $this->logonURL);
                 $interface->assign('gatheredDetails', $this->gatheredDetails);
                 $extraFields = isset($this->checkUBRequests['extraFields']) ? explode(":", $this->checkUBRequests['extraFields']) : array();
                 $interface->assign('extraFields', $extraFields);
                 $language = $interface->getLanguage();
                 if (isset($this->checkUBRequests['helpText'][$language])) {
                     $interface->assign('helpText', $this->checkUBRequests['helpText'][$language]);
                 } elseif (isset($this->checkUBRequests['helpText'])) {
                     $interface->assign('helpText', $this->checkUBRequests['helpText']);
                 }
                 if (isset($_POST['placeRequest'])) {
                     if ($this->_placeRequest($patron)) {
                         // If we made it this far, we're ready to place the request;
                         // if successful, we will redirect and can stop here.
                         return;
                     }
                 }
             }
             $interface->setPageTitle(translate('ub_request_place_text') . ': ' . $this->recordDriver->getBreadcrumb());
             // Display Form
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('lightbox', true);
                 $interface->display('Record/ub-request-submit.tpl');
             } else {
                 $interface->assign('subTemplate', 'ub-request-submit.tpl');
                 // Main Details
                 $interface->setTemplate('view.tpl');
                 // Display Page
                 $interface->display('layout.tpl');
             }
         } else {
             // User is not logged in
             // Display Login Form
             Login::setupLoginFormVars();
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('title', $_GET['message']);
                 $interface->assign('message', 'You must be logged in first');
                 $interface->assign('followup', true);
                 $interface->assign('followupModule', 'Record');
                 $interface->assign('followupAction', 'UBRequest');
                 $interface->display('AJAX/login.tpl');
             } else {
                 $interface->setTemplate('../MyResearch/login.tpl');
                 // Display Page
                 $interface->display('layout.tpl');
             }
         }
     } else {
         // Shouldn't Be Here
         if (isset($_REQUEST['lightbox'])) {
             $interface->assign('lightbox', true);
             $interface->assign('results', array('status' => 'ub_request_error_blocked'));
             $interface->display('Record/ub-request-submit.tpl');
         } else {
             header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()));
         }
         return false;
     }
 }
Exemple #7
0
 /**
  * Register payment provided in the request.
  * This is called by JSON_Transaction.
  *
  * @param array   $params       Key-value list of request variables.
  * @param boolean $userLoggedIn Is user logged in at the time of method call.
  *
  * @return array array with keys
  *   - 'success' (boolean)
  *   - 'msg' (string) error message if payment could not be processed.
  * @access public
  */
 public function processPayment($params, $userLoggedIn = true)
 {
     global $interface;
     global $user;
     $error = false;
     $msg = null;
     $transactionId = $params['transaction'];
     $tr = new Transaction();
     if (!($t = $tr->getTransaction($transactionId))) {
         error_log("Error processing payment: transaction {$transactionId} not found");
         $error = true;
     }
     if (!$tr->isTransactionInProgress($transactionId)) {
         error_log("Error processing payment: transaction {$transactionId} already processed.");
         $error = true;
     }
     if (!$error) {
         $patron = null;
         $patronId = $t->cat_username;
         if (!$userLoggedIn) {
             // MultiBackend::getConfig expects global user object and user->cat_username to be defined.
             $user = new User();
             $user->cat_username = $patronId;
             $account = new User_account();
             $account->user_id = $t->user_id;
             $account->cat_username = $t->cat_username;
             if ($account->find(true)) {
                 $patron = $this->catalog->patronLogin($t->cat_username, $account->cat_password);
             }
             if (!$patron) {
                 error_log("Error processing payment: could not perform patron login (transaction {$transactionId})");
                 $error = true;
             }
         } else {
             $patron = UserAccount::catalogLogin();
         }
         $config = $this->catalog->getConfig('OnlinePayment');
         if ($config && $config['enabled']) {
             $paymentHandler = CatalogConnection::getOnlinePaymentHandler($patronId);
             $res = $paymentHandler->processResponse($params);
             if (is_array($res) && isset($res['markFeesAsPaid']) && $res['markFeesAsPaid']) {
                 $finesAmount = $this->catalog->getOnlinePayableAmount($patron);
                 // Check that payable sum has not been updated
                 if ($finesAmount == $res['amount']) {
                     $paidRes = $this->catalog->markFeesAsPaid($patron, $res['amount']);
                     if ($paidRes === true) {
                         $t = new Transaction();
                         if (!$t->setTransactionRegistered($res['transactionId'])) {
                             error_log("Error updating transaction {$transactionId} status: registered");
                         }
                         $_SESSION['payment_ok'] = true;
                     } else {
                         $t = new Transaction();
                         if (!$t->setTransactionRegistrationFailed($res['transactionId'], $paidRes)) {
                             error_log("Error updating transaction {$transactionId} status: registering failed");
                         }
                         $error = true;
                         $msg = translate($paidRes);
                     }
                 } else {
                     // Payable sum updated. Skip registration and inform user that payment processing has been delayed..
                     $t = new Transaction();
                     if (!$t->setTransactionFinesUpdated($res['transactionId'])) {
                         error_log("Error updating transaction {$transactionId} status: payable sum updated");
                     }
                     $error = true;
                     $msg = translate('online_payment_registration_failed');
                 }
             } else {
                 $error = true;
                 $msg = translate($res);
             }
         }
     }
     $res = array('success' => !$error);
     if ($msg) {
         $res['msg'] = $msg;
     }
     return $res;
 }
 /**
  * Get a list of pickup locations for the given library
  *
  * @return void
  * @access public
  */
 public function getPickUpLocations()
 {
     if (isset($_REQUEST['id']) && isset($_REQUEST['pickupLib'])) {
         // check if user is logged in
         $user = UserAccount::isLoggedIn();
         if (!$user) {
             return $this->output(array('msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH);
         }
         $catalog = ConnectionManager::connectToCatalog();
         if ($catalog && $catalog->status) {
             if ($patron = UserAccount::catalogLogin()) {
                 if (!PEAR::isError($patron)) {
                     $results = $catalog->getUBPickupLocations(array('id' => $_REQUEST['id'], 'patron' => $patron, 'pickupLibrary' => $_REQUEST['pickupLib']));
                     if (!PEAR::isError($results)) {
                         foreach ($results as &$result) {
                             $result['name'] = translate(array('prefix' => 'location_', 'text' => $result['name']));
                         }
                         return $this->output(array('locations' => $results), JSON::STATUS_OK);
                     }
                 }
             }
         }
     }
     return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR);
 }
Exemple #9
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     if (isset($_REQUEST['lightbox'])) {
         $interface->assign('lightbox', true);
     }
     // Are Holds Allowed?
     $this->checkHolds = $this->catalog->checkFunction("Holds", $this->recordDriver->getUniqueID());
     if ($this->checkHolds != false) {
         // Do we have valid information?
         // Sets $this->logonURL and $this->gatheredDetails
         $validate = $this->_validateHoldData($this->checkHolds['HMACKeys']);
         if (!$validate) {
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('lightbox', true);
                 $interface->assign('results', array('status' => 'hold_error_blocked'));
                 $interface->display('Record/hold-submit.tpl');
             } else {
                 header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()));
             }
             return false;
         }
         // Assign FollowUp Details required for login and catalog login
         $interface->assign('followup', true);
         $interface->assign('recordId', $this->recordDriver->getUniqueID());
         $interface->assign('followupModule', 'Record');
         $interface->assign('followupAction', 'Hold' . $this->logonURL);
         // User Must be logged In to Place Holds
         if (UserAccount::isLoggedIn()) {
             if ($patron = UserAccount::catalogLogin()) {
                 // Block invalid requests:
                 $result = PEAR::isError($patron) ? false : $this->catalog->checkRequestIsValid($this->recordDriver->getUniqueID(), $this->gatheredDetails, $patron);
                 if (!$result || $result === 'block') {
                     $errorMsg = PEAR::isError($patron) ? $patron->getMessage() : 'hold_error_blocked';
                     // This might display login form, so setup login vars
                     Login::setupLoginFormVars();
                     if (isset($_REQUEST['lightbox'])) {
                         $interface->assign('lightbox', true);
                         $interface->assign('results', array('status' => $errorMsg));
                         $interface->display('Record/hold-submit.tpl');
                     } else {
                         header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()) . "?errorMsg={$errorMsg}#top");
                     }
                     return false;
                 }
                 $interface->assign('formURL', $this->logonURL);
                 $interface->assign('gatheredDetails', $this->gatheredDetails);
                 // Get List of PickUp Libraries
                 $libs = $this->catalog->getPickUpLocations($patron, $this->gatheredDetails);
                 $interface->assign('pickup', $libs);
                 $interface->assign('home_library', $user->home_library);
                 if ($this->gatheredDetails['level'] != 'item') {
                     // Get list of request groups
                     $requestGroups = $this->catalog->getRequestGroups($this->recordDriver->getUniqueID(), $patron['id']);
                     if (PEAR::isError($requestGroups)) {
                         PEAR::raiseError($requestGroups);
                     }
                     $interface->assign('requestGroups', $requestGroups);
                 }
                 $interface->assign('defaultDuedate', $this->getDefaultDueDate());
                 $extraHoldFields = isset($this->checkHolds['extraHoldFields']) ? explode(":", $this->checkHolds['extraHoldFields']) : array();
                 $interface->assign('extraHoldFields', $extraHoldFields);
                 $defaultPickUpLoc = $this->catalog->getDefaultPickUpLocation($patron, $this->gatheredDetails);
                 $interface->assign('defaultPickUpLocation', $defaultPickUpLoc);
                 $defaultRequestGroup = $this->catalog->getDefaultRequestGroup($patron, $this->gatheredDetails);
                 $interface->assign('defaultRequestGroup', $defaultRequestGroup);
                 $language = $interface->getLanguage();
                 if (isset($this->checkHolds['helpText'][$language])) {
                     $interface->assign('helpText', $this->checkHolds['helpText'][$language]);
                 } elseif (isset($this->checkHolds['helpText'])) {
                     $interface->assign('helpText', $this->checkHolds['helpText']);
                 }
                 if (isset($_POST['placeHold'])) {
                     // If the form contained a pickup location, make sure that
                     // the value has not been tampered with:
                     if (!$this->validatePickUpInput($extraHoldFields, $libs)) {
                         $this->assignError(array('status' => 'hold_invalid_pickup'));
                     } else {
                         if ($this->_placeHold($patron)) {
                             // If we made it this far, we're ready to place the hold;
                             // if successful, we will redirect and can stop here.
                             return;
                         }
                     }
                 }
             }
             $interface->setPageTitle(translate('request_place_text') . ': ' . $this->recordDriver->getBreadcrumb());
             // Display Hold Form
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('lightbox', true);
                 $interface->display('Record/hold-submit.tpl');
             } else {
                 $interface->assign('subTemplate', 'hold-submit.tpl');
                 // Main Details
                 $interface->setTemplate('view.tpl');
                 // Display Page
                 $interface->display('layout.tpl');
             }
         } else {
             // User is not logged in
             // Display Login Form
             Login::setupLoginFormVars();
             if (isset($_REQUEST['lightbox'])) {
                 $interface->assign('title', $_GET['message']);
                 $interface->assign('message', 'You must be logged in first');
                 $interface->assign('followup', true);
                 $interface->assign('followupModule', 'Record');
                 $interface->assign('followupAction', 'Hold');
                 $interface->display('AJAX/login.tpl');
             } else {
                 $interface->setTemplate('../MyResearch/login.tpl');
                 // Display Page
                 $interface->display('layout.tpl');
             }
         }
     } else {
         // Shouldn't Be Here
         if (isset($_REQUEST['lightbox'])) {
             $interface->assign('lightbox', true);
             $interface->assign('results', array('status' => 'hold_error_blocked'));
             $interface->display('Record/hold-submit.tpl');
         } else {
             header('Location: ../../Record/' . urlencode($this->recordDriver->getUniqueID()));
         }
         return false;
     }
 }
Exemple #10
0
 /**
  * Change pick up location of a hold
  *
  * @return void
  * @access public
  */
 public function changePickUpLocation()
 {
     if (isset($_REQUEST['reservationId'])) {
         // check if user is logged in
         $user = UserAccount::isLoggedIn();
         if (!$user) {
             return $this->output(array('msg' => translate('You must be logged in first')), JSON::STATUS_NEED_AUTH);
         }
         $catalog = ConnectionManager::connectToCatalog();
         if ($catalog && $catalog->status) {
             if ($patron = UserAccount::catalogLogin()) {
                 if (!PEAR::isError($patron)) {
                     $result = $catalog->changePickupLocation($patron, array('pickup' => $_REQUEST['pickup'], 'reservationId' => $_REQUEST['reservationId'], 'created' => $_REQUEST['created'], 'expires' => $_REQUEST['expires']));
                     if (!$result['success']) {
                         return $this->output(array($result['sysMessage']), JSON::STATUS_ERROR);
                     }
                     return $this->output(array($result), JSON::STATUS_OK);
                 } else {
                     return $this->output($patron->getMessage(), JSON::STATUS_ERROR);
                 }
             }
         }
     }
     return $this->output(translate('An error has occurred'), JSON::STATUS_ERROR);
 }
Exemple #11
0
 /**
  * Change patron's password (PIN code)
  *
  * @param string $oldPassword Old password for verification
  * @param string $newPassword New password
  *
  * @return mixed Array of information on success/failure, PEAR_Error on error
  */
 protected function changePassword($oldPassword, $newPassword)
 {
     if ($patron = UserAccount::catalogLogin()) {
         if (PEAR::isError($patron)) {
             PEAR::raiseError($patron);
         }
         $data = array('patron' => $patron, 'oldPassword' => $oldPassword, 'newPassword' => $newPassword);
         return $this->catalog->changePassword($data);
     }
 }
Exemple #12
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Get My Holds
     if ($patron = UserAccount::catalogLogin()) {
         if (PEAR::isError($patron)) {
             $this->handleCatalogError($patron);
         } else {
             // Get Message from Hold.php
             if (isset($_GET['success']) && $_GET['success'] != "") {
                 $this->holdResults = array('success' => true, 'status' => "hold_place_success");
                 $interface->assign('holdResults', $this->holdResults);
             }
             // Get Message from CallSlip.php
             if (isset($_GET['callslip_success']) && $_GET['callslip_success'] != "") {
                 $this->callSlipResults = array('success' => true, 'status' => "call_slip_success");
                 $interface->assign('callSlipResults', $this->callSlipResults);
             }
             // Get Message from UBRequest.php
             if (isset($_GET['ub_request_success']) && $_GET['ub_request_success'] != "") {
                 $this->UBRequestResults = array('success' => true, 'status' => "ub_request_success");
                 $interface->assign('UBRequestResults', $this->UBRequestResults);
             }
             // Is cancelling Holds Available
             if ($this->cancelHolds != false) {
                 // Process Submitted Form
                 if (isset($_POST['cancelSelected']) || isset($_POST['cancelAll'])) {
                     $cancelRequest = $this->_cancelHolds($patron);
                 }
                 $interface->assign('cancelResults', $this->cancelResults);
             }
             if (isset($_POST['cancelSelectedCallSlips']) || isset($_POST['cancelAllCallSlips'])) {
                 $cancelCallSlipRequest = $this->_cancelCallSlips($patron);
                 $interface->assign('cancelCallSlipResults', $this->cancelCallSlipResults);
             }
             // Get List of PickUp Libraries based on patrons home library
             $libs = $this->catalog->getPickUpLocations($patron);
             $interface->assign('pickup', $libs);
             $result = $this->catalog->getMyHolds($patron);
             if (!PEAR::isError($result)) {
                 if (count($result)) {
                     $recordList = array();
                     foreach ($result as $row) {
                         $record = $this->db->getRecord($row['id']);
                         $record['ils_details'] = $row;
                         $formats = array();
                         foreach (isset($record['format']) ? $record['format'] : array() as $format) {
                             $formatRaw = preg_replace('/^\\d\\//', '', $format);
                             $format = rtrim($formatRaw, "/");
                             $formats[] = $format;
                         }
                         $record['format'] = $formats;
                         $driver = RecordDriverFactory::initRecordDriver($record);
                         if ($driver) {
                             $record['summImages'] = $driver->getAllImages();
                             $record['summThumb'] = $driver->getThumbnail();
                         }
                         $recordList[] = $record;
                     }
                     if ($this->cancelHolds != false) {
                         $recordList = $this->_addCancelDetails($recordList);
                     }
                     $interface->assign('recordList', $recordList);
                 } else {
                     $interface->assign('recordList', false);
                 }
             } else {
                 PEAR::raiseError($result);
             }
             $result = $this->catalog->getMyCallSlips($patron);
             if (!PEAR::isError($result)) {
                 if ($result !== false && count($result)) {
                     $recordList = array();
                     foreach ($result as $row) {
                         if ($row['id']) {
                             $record = $this->db->getRecord($row['id']);
                             $record['ils_details'] = $row;
                             $formats = array();
                             foreach (isset($record['format']) ? $record['format'] : array() as $format) {
                                 $formatRaw = preg_replace('/^\\d\\//', '', $format);
                                 $format = rtrim($formatRaw, "/");
                                 $formats[] = $format;
                             }
                             $record['format'] = $formats;
                             $driver = RecordDriverFactory::initRecordDriver($record);
                             if ($driver) {
                                 $record['summImages'] = $driver->getAllImages();
                                 $record['title'] = $driver->getTitle();
                                 $record['summThumb'] = $driver->getThumbnail();
                             }
                         } else {
                             $record = array();
                             $record['ils_details'] = $row;
                         }
                         $recordList[] = $record;
                     }
                     $recordList = $this->_addCallSlipCancelDetails($recordList, $patron);
                     $interface->assign('callSlipList', $recordList);
                 } else {
                     $interface->assign('callSlipList', false);
                 }
             } else {
                 PEAR::raiseError($result);
             }
             $profile = $this->catalog->getMyProfile($patron);
             if (!PEAR::isError($profile)) {
                 $interface->assign('profile', $profile);
             }
         }
         $driver = isset($patron['driver']) ? $patron['driver'] : '';
         $interface->assign('driver', $driver);
     }
     Login::setupLoginFormVars();
     $interface->setTemplate('holds.tpl');
     $interface->setPageTitle('Holds and Requests');
     $interface->display('layout.tpl');
 }