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');
 }
Beispiel #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 = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     $results = $catalog->doInventory($login, $password1, $initials, $password2, $barcodes, $updateIncorrectStatuses);
     return $results;
 }
Beispiel #3
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);
 }
Beispiel #4
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);
 }
 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');
 }
Beispiel #6
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);
 }
 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;
 }
Beispiel #8
0
 /**
  * Removes one or more titles from the user's reading history.
  *
  * Parameters:
  * <ul>
  * <li>username - The barcode of the user.  Can be truncated to the last 7 or 9 digits.</li>
  * <li>password - The pin number for the user. </li>
  * <li>selected - A list of record ids to be deleted from the reading history.</li>
  * </ul>
  *
  * Returns:
  * <ul>
  * <li>success � true if the account is valid and the items could be removed from the reading history, false if the username or password were incorrect or the items could not be removed from the reading history.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=deleteSelectedFromReadingHistory&username=23025003575917&password=1234&selected[]=25855
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{"success":true}}
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function deleteSelectedFromReadingHistory()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     $selectedTitles = $_REQUEST['selected'];
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         $this->catalog->doReadingHistoryAction('deleteMarked', $selectedTitles);
         return array('success' => true);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }
Beispiel #9
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);
 }
Beispiel #10
0
 /**
  * Public method for getting title level holds
  *
  * @param string $id     An Bib ID
  * @param array  $patron An array of patron data
  *
  * @return array A sorted results set
  * @access public
  */
 public function getHold($id, $patron = false)
 {
     // Get Holdings Data
     if ($this->catalog && $this->catalog->status) {
         $mode = CatalogConnection::getTitleHoldsMode();
         if ($mode == "disabled") {
             return false;
         } else {
             if ($mode == "driver") {
                 return $this->driverHold($id, $patron);
             } else {
                 return $this->generateHold($id, $mode);
             }
         }
     }
     return false;
 }
Beispiel #11
0
 /**
  * Log the current user into the catalog using stored credentials; if this
  * fails, clear the user's stored credentials so they can enter new, corrected
  * ones.
  *
  * @access  protected
  * @return  mixed               $user array (on success) or false (on failure)
  */
 protected function catalogLogin()
 {
     global $user;
     if ($this->catalog->status) {
         if ($user->cat_username) {
             $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
             if (empty($patron) || PEAR_Singleton::isError($patron)) {
                 // Problem logging in -- clear user credentials so they can be
                 // prompted again; perhaps their password has changed in the
                 // system!
                 unset($user->cat_username);
                 unset($user->cat_password);
             } else {
                 return $patron;
             }
         }
     }
     return false;
 }
Beispiel #12
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;
 }
Beispiel #13
0
 function placeHolds()
 {
     global $interface;
     global $configArray;
     global $user;
     if (!isset($_REQUEST['selected'])) {
         $hold_message_data = array('successful' => 'none', 'error' => 'No titles were selected', 'titles' => array());
         $showMessage = true;
     } else {
         $selectedIds = $_REQUEST['selected'];
         $eContentDriver = null;
         $showMessage = false;
         $holdings = array();
         //Check to see if all items are eContent
         $ids = array();
         $allItemsEContent = true;
         foreach ($selectedIds as $recordId => $onOff) {
             $ids[] = $recordId;
             //Get the title for the item
             $resource = new Resource();
             if (strpos($recordId, 'econtentRecord') !== 0) {
                 $allItemsEContent = false;
                 $resource->record_id = '.' . $recordId;
                 $resource->source = 'VuFind';
                 $resource->deleted = 0;
             } else {
                 $shortId = str_replace('econtentRecord', '', $recordId);
                 $resource->record_id = $shortId;
                 $resource->source = 'eContent';
                 $resource->deleted = 0;
             }
             if ($resource->find(true)) {
                 $holdings[] = $resource->title;
             } else {
                 echo "Could not find resource for record id {$recordId}";
             }
         }
         $interface->assign('ids', $ids);
         $interface->assign('holdings', $holdings);
         $hold_message_data = array('successful' => 'all', 'titles' => array());
         if (isset($_REQUEST['autologout'])) {
             $_SESSION['autologout'] = true;
         }
         //Check to see if we are ready to place the hold.
         $placeHold = false;
         if (isset($_REQUEST['holdType']) && isset($_REQUEST['campus'])) {
             $placeHold = true;
         } else {
             if ($user && $allItemsEContent) {
                 $placeHold = true;
             }
         }
         if ($placeHold) {
             $hold_message_data['campus'] = $_REQUEST['campus'];
             //This is a new login
             if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
                 $user = UserAccount::login();
             }
             if ($user == false) {
                 $hold_message_data['error'] = 'Incorrect Patron Information';
                 $showMessage = true;
             } else {
                 $atLeast1Successful = false;
                 foreach ($selectedIds as $recordId => $onOff) {
                     if (strpos($recordId, 'econtentRecord', 0) === 0) {
                         if ($eContentDriver == null) {
                             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                             $eContentDriver = new EContentDriver();
                         }
                         $return = $eContentDriver->placeHold($recordId, $user);
                     } else {
                         $return = $this->catalog->placeHold($recordId, $user->password, '', $_REQUEST['holdType']);
                     }
                     $hold_message_data['titles'][] = $return;
                     if (!$return['result']) {
                         $hold_message_data['successful'] = 'partial';
                     } else {
                         $atLeast1Successful = true;
                     }
                     //Check to see if there are item level holds that need follow-up by the user
                     if (isset($return['items'])) {
                         $hold_message_data['showItemForm'] = true;
                     }
                     $showMessage = true;
                 }
                 if (!$atLeast1Successful) {
                     $hold_message_data['successful'] = 'none';
                 }
             }
         } else {
             //Get the referrer so we can go back there.
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $referer = $_SERVER['HTTP_REFERER'];
                 $_SESSION['hold_referrer'] = $referer;
             }
             //Showing place hold form.
             if ($user) {
                 $profile = $this->catalog->getMyProfile($user);
                 $interface->assign('profile', $profile);
                 //Get information to show a warning if the user does not have sufficient holds
                 require_once ROOT_DIR . '/Drivers/marmot_inc/PType.php';
                 $maxHolds = -1;
                 //Determine if we should show a warning
                 $ptype = new PType();
                 $ptype->pType = $user->patronType;
                 if ($ptype->find(true)) {
                     $maxHolds = $ptype->maxHolds;
                 }
                 $currentHolds = $profile['numHolds'];
                 if ($maxHolds != -1 && $currentHolds + count($selectedIds) > $maxHolds) {
                     $interface->assign('showOverHoldLimit', true);
                     $interface->assign('maxHolds', $maxHolds);
                     $interface->assign('currentHolds', $currentHolds);
                 }
                 global $locationSingleton;
                 //Get the list of pickup branch locations for display in the user interface.
                 $locations = $locationSingleton->getPickupBranches($profile, $profile['homeLocationId']);
                 $interface->assign('pickupLocations', $locations);
                 //set focus to the submit button if the user is logged in since the campus will be correct most of the time.
                 $interface->assign('focusElementId', 'submit');
             } else {
                 //set focus to the username field by default.
                 $interface->assign('focusElementId', 'username');
             }
             global $library;
             $patronHomeBranch = Library::getPatronHomeLibrary();
             if ($patronHomeBranch != null) {
                 if ($patronHomeBranch->defaultNotNeededAfterDays > 0) {
                     $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $patronHomeBranch->defaultNotNeededAfterDays * 60 * 60 * 24));
                 } else {
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
                 $interface->assign('showHoldCancelDate', $patronHomeBranch->showHoldCancelDate);
             } else {
                 if ($library) {
                     //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                     if ($library->defaultNotNeededAfterDays > 0) {
                         $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $library->defaultNotNeededAfterDays * 60 * 60 * 24));
                     } else {
                         $interface->assign('defaultNotNeededAfterDays', '');
                     }
                     $interface->assign('showHoldCancelDate', $library->showHoldCancelDate);
                 } else {
                     //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                     $interface->assign('showHoldCancelDate', 1);
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
             }
             $activeLibrary = Library::getActiveLibrary();
             if ($activeLibrary != null) {
                 $interface->assign('holdDisclaimer', $activeLibrary->holdDisclaimer);
             } else {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 $interface->assign('holdDisclaimer', '');
             }
         }
     }
     if ($showMessage) {
         $hold_message_data['fromCart'] = isset($_REQUEST['fromCart']);
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') {
                 header("Location: " . $_SESSION['hold_referrer']);
             } else {
                 //Redirect for hold cancellation or update
                 header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
             }
             if (!isset($hold_message_data['showItemForm']) || $hold_message_data['showItemForm'] == false) {
                 unset($_SESSION['hold_referrer']);
                 if (isset($_SESSION['autologout'])) {
                     unset($_SESSION['autologout']);
                     UserAccount::softLogout();
                 }
             }
         } else {
             header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
         }
     } else {
         $interface->assign('fromCart', isset($_REQUEST['fromCart']));
         $interface->setPageTitle('Request Items');
         $interface->setTemplate('holdMultiple.tpl');
         $interface->display('layout.tpl', 'RecordHolds');
     }
 }
Beispiel #14
0
 /**
  * Get the text to represent this record in the body of an email.
  *
  * @access  public
  * @return  string              Text for inclusion in email.
  */
 public function getEmail()
 {
     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;
     }
     $email = "  " . $this->getTitle() . "\n";
     if (isset($holdingsSummary['callnumber'])) {
         $email .= "  Call Number: " . $holdingsSummary['callnumber'] . "\n";
     }
     if (isset($holdingsSummary['availableAt'])) {
         $email .= "  Available At: " . $holdingsSummary['availableAt'] . "\n";
     }
     if (isset($holdingsSummary['downloadLink'])) {
         $email .= "  Download from: " . $holdingsSummary['downloadLink'] . "\n";
     }
     return $email;
 }
Beispiel #15
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;
     $showOtherEditionsPopup = false;
     if ($configArray['Content']['showOtherEditionsPopup']) {
         if ($library) {
             $showOtherEditionsPopup = $library->showOtherEditionsPopup == 1;
         } else {
             $showOtherEditionsPopup = true;
         }
     }
     $interface->assign('showOtherEditionsPopup', $showOtherEditionsPopup);
     $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 = new CatalogConnection($configArray['Catalog']['driver']);
     $timer->logTime("Initialized Catalog Connection");
     $summaries = $catalog->getStatusSummaries($_GET['id'], true);
     $timer->logTime("Retrieved status summaries");
     $result = array();
     $result['items'] = array();
     // 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");
 }
Beispiel #16
0
 /**
  * Support method for getItemStatuses() -- Get Axiell Full Item Status
  *
  * @param array  $holdings Holdings for the record
  * @param object $catalog  Catalog connection
  * @param array  $patron   Patron
  *
  * @return void
  * @access public
  * @author Erik Henriksson <*****@*****.**>
  * @author Ere Maijala <*****@*****.**>
  */
 protected function getAxiellItemStatusFull($holdings, $catalog, $patron)
 {
     global $interface;
     global $configArray;
     $itemCount = 0;
     $requestCount = 0;
     $locationCount = 0;
     $branchCount = 0;
     $availableLocationCount = 0;
     $availableCount = 0;
     $itemStatusText = '';
     $closestDueDate = '';
     $closestDueDateStamp = 0;
     $journal = false;
     $itemStatusText = '';
     $isHoldable = false;
     foreach ($holdings as &$location) {
         if (is_array($location)) {
             $journal = isset($location['journal']) && $location['journal'];
             if (is_array($location['holdings'])) {
                 foreach ($location['holdings'] as $holding) {
                     if (isset($holding['total'])) {
                         $itemCount += $holding['total'];
                     }
                     if (isset($holding['status']) && trim($holding['status']) === JSON::REFERENCE_DESK_STATUS) {
                         $location['status']['availableCount']++;
                     }
                     $branchCount++;
                 }
             }
             if (isset($location['status'])) {
                 if (isset($location['status']['reservations']) && $location['status']['reservations'] > $requestCount) {
                     $requestCount = $location['status']['reservations'];
                 }
                 if (isset($location['status']['available']) && $location['status']['available']) {
                     $availableLocationCount++;
                 }
                 if (isset($location['status']['availableCount']) && $location['status']['availableCount'] > 0) {
                     $availableCount += $location['status']['availableCount'];
                 }
                 if (isset($location['status']['text']) && $location['status']['text'] != '' && $closestDueDate == '') {
                     $itemStatusText = $location['status']['text'];
                 }
                 if (isset($location['status']['dueDateStamp']) && $location['status']['dueDateStamp'] != '' && isset($location['status']['closestDueDate']) && $location['status']['closestDueDate'] != '') {
                     $dueDate = $location['status']['dueDateStamp'];
                     if ($closestDueDateStamp < $dueDate) {
                         $closestDueDate = $location['status']['closestDueDate'];
                         if (isset($location['status']['text']) && $location['status']['text'] != '') {
                             $itemStatusText = $location['status']['text'];
                         }
                     }
                 }
                 $locationCount++;
             }
             if (isset($location['is_holdable']) && $location['is_holdable']) {
                 $isHoldable = true;
             }
         }
     }
     $id = $holdings[0]['id'];
     $interface->assign('id', $id);
     $interface->assign('holdings', $holdings);
     $locationThreshold = isset($configArray['Site']['locationThreshold']) ? $configArray['Site']['locationThreshold'] : 5;
     $branchThreshold = isset($configArray['Site']['branchThreshold']) ? $configArray['Site']['branchThreshold'] : 15;
     $interface->assign('itemCount', $itemCount);
     $interface->assign('requestCount', $requestCount);
     $interface->assign('branchCount', $branchCount);
     $interface->assign('locationCount', $locationCount);
     $interface->assign('availableLocationCount', $availableLocationCount);
     $interface->assign('availableCount', $availableCount);
     $interface->assign('closestDueDate', $closestDueDate);
     $interface->assign('itemStatusText', $itemStatusText);
     $interface->assign('isHoldable', $isHoldable);
     $interface->assign('locationThreshold', $locationThreshold);
     $interface->assign('branchThreshold', $branchThreshold);
     $interface->assign('journal', $journal);
     $interface->assign('referenceDeskStatus', JSON::REFERENCE_DESK_STATUS);
     $db = ConnectionManager::connectToIndex();
     if (!($record = $db->getRecord($id))) {
         PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $recordDriver = RecordDriverFactory::initRecordDriver($record);
     $interface->assign('patronFunctions', $recordDriver->hasPatronFunctions());
     if ("driver" == CatalogConnection::getHoldsMode()) {
         $interface->assign('driverMode', true);
     }
     if ("driver" == CatalogConnection::getTitleHoldsMode()) {
         $interface->assign('titleDriverMode', true);
     }
     if (!PEAR::isError($patron)) {
         $holdLogic = new HoldLogicTitle($catalog);
         $holdingTitleHold = $holdLogic->getHold($id, $patron);
         $interface->assign('holdingTitleHold', $holdingTitleHold);
     }
     return $interface->fetch('AJAX/holdings-axiell.tpl');
 }
Beispiel #17
0
 /**
  * checkRequestIsValid
  *
  * This is responsible for determining if an item is requestable
  *
  * @param string $id     The Bib ID
  * @param array  $data   An Array of item data
  * @param patron $patron An array of patron data
  *
  * @return string True if request is valid, false if not
  * @access public
  */
 public function checkRequestIsValid($id, $data, $patron)
 {
     $holdType = isset($data['holdtype']) ? $data['holdtype'] : "auto";
     $level = isset($data['level']) ? $data['level'] : "copy";
     $mode = "title" == $level ? CatalogConnection::getTitleHoldsMode() : CatalogConnection::getHoldsMode();
     if ("driver" == $mode && "auto" == $holdType) {
         $itemID = isset($data['item_id']) ? $data['item_id'] : false;
         $result = $this->determineHoldType($patron['id'], $id, $itemID);
         if (!$result || $result == 'block') {
             return $result;
         }
     }
     if ('title' == $level && $this->requestGroups) {
         // Verify that there are valid request groups
         if (!$this->getRequestGroups($id, $patron['id'])) {
             return false;
         }
     }
     return true;
 }
Beispiel #18
0
ini_set('max_execution_time', '3600');
require_once 'util.inc.php';
// set up util environment
require_once 'sys/Solr.php';
require_once 'CatalogConnection.php';
// Read Config file
$configArray = parse_ini_file('../web/conf/config.ini', true);
// Setup Solr Connection
$url = $configArray['Index']['url'];
$solr = new Solr($url);
if ($configArray['System']['debugSolr']) {
    $solr->debug = true;
}
// Make ILS Connection
try {
    $catalog = new CatalogConnection($configArray['Catalog']['driver']);
} catch (PDOException $e) {
    // What should we do with this error?
    if ($configArray['System']['debugSolr']) {
        echo '<pre>';
        echo 'DEBUG: ' . $e->getMessage();
        echo '</pre>';
    }
}
// Get Suppressed Records and Delete from index
if ($catalog->status) {
    $result = $catalog->getSuppressedRecords();
    if (!PEAR::isError($result)) {
        $status = $solr->deleteRecords($result);
        if ($status) {
            // Commit and Optimize
Beispiel #19
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     if (isset($_REQUEST['returnUrl'])) {
         $followupUrl = $_REQUEST['returnUrl'];
         header("Location: " . $followupUrl);
         exit;
     }
     // Delete Resource
     if (isset($_GET['delete'])) {
         $resource = Resource::staticGet('record_id', strip_tags($_GET['delete']));
         $user->removeResource($resource);
     }
     // Narrow by Tag
     if (isset($_GET['tag'])) {
         $interface->assign('tags', strip_tags($_GET['tag']));
     }
     //We are going to the "main page of My Research"
     //Be smart about this depending on the user's information.
     $hasHomeTemplate = $interface->template_exists('MyResearch/home.tpl');
     if (!$user) {
         $action = 'Home';
     } elseif ($hasHomeTemplate) {
         //Var for the IDCLREADER TEMPLATE
         $interface->assign('ButtonBack', false);
         $interface->assign('ButtonHome', true);
         $interface->assign('MobileTitle', '&nbsp;');
         $interface->setTemplate('home.tpl');
     } else {
         if ($user && !$interface->isMobile()) {
             // Connect to Database
             $catalog = new CatalogConnection($configArray['Catalog']['driver']);
             $patron = $catalog->patronLogin($user->cat_username, $user->cat_password);
             $profile = $catalog->getMyProfile($patron);
             if ($profile['numCheckedOut'] > 0) {
                 $action = 'CheckedOut';
             } elseif ($profile['numHolds'] > 0) {
                 $action = 'Holds';
             } else {
                 $action = 'Favorites';
             }
             header("Location: /MyResearch/{$action}");
         } else {
             //Go to the login page which is the home page
             $action = 'Home';
         }
         // Build Favorites List
         $favorites = $user->getResources(isset($_GET['tag']) ? strip_tags($_GET['tag']) : null);
         $favList = new FavoriteHandler($favorites, $user);
         $favList->assign();
         // Get My Lists
         $listList = $user->getLists();
         $interface->assign('listList', $listList);
         // Get My Tags
         $tagList = $user->getTags();
         $interface->assign('tagList', $tagList);
         $interface->setPageTitle('Favorites');
         $interface->setTemplate('favorites.tpl');
     }
     $interface->display('layout.tpl');
 }
Beispiel #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 = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     $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 {
                     $holdings[$copy['location']][] = $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;
 }
Beispiel #21
0
    }
}
//Determine if we should include autoLogout Code
$ipLocation = $locationSingleton->getIPLocation();
$ipId = $locationSingleton->getIPid();
$interface->assign('automaticTimeoutLength', 0);
$interface->assign('automaticTimeoutLengthLoggedOut', 0);
if (!is_null($ipLocation) && $ipLocation != false) {
    $interface->assign('onInternalIP', true);
    if (isset($user->bypassAutoLogout) && $user->bypassAutoLogout == 1) {
        $interface->assign('includeAutoLogoutCode', false);
    } else {
        $includeAutoLogoutCode = true;
        //Get the PType for the user
        /** @var MillenniumDriver|CatalogConnection $catalog */
        $catalog = new CatalogConnection($configArray['Catalog']['driver']);
        if ($user && $catalog->checkFunction('isUserStaff')) {
            $userIsStaff = $catalog->isUserStaff();
            $interface->assign('userIsStaff', $userIsStaff);
            if ($userIsStaff) {
                //Check to see if the user has overridden the auto logout code.
                if ($user->bypassAutoLogout != 0) {
                    $includeAutoLogoutCode = false;
                }
            }
        }
        //Only include auto logout code if we are not on the home page
        if ($module == 'Search' && $action == 'Home') {
            $includeAutoLogoutCode = false;
        }
        $interface->assign('includeAutoLogoutCode', $includeAutoLogoutCode);
Beispiel #22
0
 /**
  * Get a link for placing a title level hold.
  *
  * @param array $patron An array of patron data
  *
  * @return mixed A url if a hold is possible, boolean false if not
  * @access protected
  */
 protected function getRealTimeTitleHold($patron = false)
 {
     global $configArray;
     $biblioLevel = $this->getBibliographicLevel();
     if ("monograph" == strtolower($biblioLevel) || stristr("part", $biblioLevel)) {
         $titleHoldEnabled = CatalogConnection::getTitleHoldsMode();
         if ($titleHoldEnabled != "disabled") {
             include_once 'sys/HoldLogicTitle.php';
             // Get ID and connect to catalog
             $id = $this->getUniqueID();
             $catalog = ConnectionManager::connectToCatalog();
             $holdLogic = new HoldLogicTitle($catalog);
             return $holdLogic->getHold($id, $patron);
         }
     }
     return false;
 }
Beispiel #23
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;
 }
Beispiel #24
0
 /**
  * Get a list of preferred hold pickup branches for a user.
  *
  * @return string XML representing the pickup branches.
  */
 function GetPreferredBranches()
 {
     require_once ROOT_DIR . '/Drivers/marmot_inc/Location.php';
     global $configArray;
     global $user;
     try {
         $catalog = new CatalogConnection($configArray['Catalog']['driver']);
     } catch (PDOException $e) {
         // What should we do with this error?
         if ($configArray['System']['debug']) {
             echo '<pre>';
             echo 'DEBUG: ' . $e->getMessage();
             echo '</pre>';
         }
     }
     $username = $_REQUEST['username'];
     $password = $_REQUEST['barcode'];
     //Get the list of pickup branch locations for display in the user interface.
     $patron = $catalog->patronLogin($username, $password);
     if ($patron == null) {
         $result = array('PickupLocations' => array(), 'loginFailed' => true);
     } else {
         $patronProfile = $catalog->getMyProfile($patron);
         $location = new Location();
         $locationList = $location->getPickupBranches($patronProfile, $patronProfile['homeLocationId']);
         $pickupLocations = array();
         foreach ($locationList as $curLocation) {
             $pickupLocations[] = array('id' => $curLocation->locationId, 'displayName' => $curLocation->displayName, 'selected' => $curLocation->selected);
         }
         require_once ROOT_DIR . '/Drivers/marmot_inc/PType.php';
         $maxHolds = -1;
         //Determine if we should show a warning
         $ptype = new PType();
         $ptype->pType = $patronProfile['ptype'];
         if ($ptype->find(true)) {
             $maxHolds = $ptype->maxHolds;
         }
         $currentHolds = $patronProfile['numHolds'];
         $holdCount = $_REQUEST['holdCount'];
         $showOverHoldLimit = false;
         if ($maxHolds != -1 && $currentHolds + $holdCount > $maxHolds) {
             $showOverHoldLimit = true;
         }
         //Also determine if the hold can be cancelled.
         global $librarySingleton;
         $patronHomeBranch = $librarySingleton->getPatronHomeLibrary();
         $showHoldCancelDate = 0;
         if ($patronHomeBranch != null) {
             $showHoldCancelDate = $patronHomeBranch->showHoldCancelDate;
         }
         $result = array('PickupLocations' => $pickupLocations, 'loginFailed' => false, 'AllowHoldCancellation' => $showHoldCancelDate, 'showOverHoldLimit' => $showOverHoldLimit, 'maxHolds' => $maxHolds, 'currentHolds' => $currentHolds);
     }
     return json_encode($result);
 }
Beispiel #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::isError($result)) {
             PEAR::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);
             }
         }
     }
     // Don't format holdings as we want to keep call numbers separate
     // and it would ruin notes and summaries
     //return $this->formatHoldings($holdings);
     return $this->sortHoldings($holdings);
 }