function placeHold() { global $interface; global $configArray; global $user; global $logger; //TODO: Clean this up so there is only ever one id. if (isset($_REQUEST['recordId'])) { $recordId = $_REQUEST['recordId']; } else { $recordId = $_REQUEST['id']; } $interface->assign('id', $recordId); //Get title information for the record. $holding = $this->catalog->getHolding($recordId); if (PEAR_Singleton::isError($holding)) { PEAR_Singleton::raiseError($holding); } $interface->assign('holding', $holding); if (isset($_REQUEST['autologout'])) { $_SESSION['autologout'] = true; } $showMessage = false; $type = isset($_REQUEST['holdType']) ? $_REQUEST['holdType'] : ''; if (isset($_POST['submit']) || $type == 'recall' || $type == 'update' || $type == 'hold') { if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { //Log the user in $user = UserAccount::login(); } if ($user) { //The user is already logged in $barcodeProperty = $configArray['Catalog']['barcodeProperty']; $return = $this->catalog->placeHold($recordId, $user->{$barcodeProperty}, '', $type); $interface->assign('result', $return['result']); $message = $return['message']; $interface->assign('message', $message); $showMessage = true; } else { $message = 'Incorrect Patron Information'; $interface->assign('message', $message); $interface->assign('focusElementId', 'username'); $showMessage = true; } } 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 + 1 > $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', ''); } } $record = RecordDriverFactory::initRecordDriverById('ils:' . $_GET['id']); if ($record) { $interface->assign('record', $record); } else { PEAR_Singleton::raiseError('Cannot find record ' . $_GET['id']); } $interface->assign('id', $_GET['id']); if ($showMessage && isset($return)) { $hold_message_data = array('successful' => $return['result'] == true ? 'all' : 'none', 'error' => isset($return['error']) ? $return['error'] : '', 'titles' => array($return), 'campus' => $_REQUEST['campus']); //Check to see if there are item level holds that need follow-up by the user if (isset($return['items']) && count($return['items']) > 0) { $hold_message_data['showItemForm'] = true; $hold_message_data['items'] = $return['items']; } $_SESSION['hold_message'] = $hold_message_data; if (isset($_SESSION['hold_referrer'])) { $logger->log('Hold Referrer is set, redirecting to there. location ' . $_SESSION['hold_referrer'], PEAR_LOG_INFO); if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') { header("Location: " . $_SESSION['hold_referrer']); } else { //Redirect for hold cancellation or update $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'unavailable'; header("Location: " . '/MyResearch/Holds?section=' . $section); } 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 { $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO); header("Location: " . '/MyResearch/Holds'); die; } } else { //$logger->log('placeHold finished, do not need to show a message', PEAR_LOG_INFO); $interface->setPageTitle('Request an Item'); $interface->assign('subTemplate', 'hold.tpl'); $interface->setTemplate('hold.tpl'); $interface->display('layout.tpl', 'RecordHold' . $_GET['id']); } }
function placeHolds() { $selectedTitles = $_REQUEST['title']; global $interface; global $configArray; global $user; global $logger; $holdings = array(); $ids = array(); foreach ($selectedTitles as $recordId => $itemNumber) { $ids[] = $recordId; } $interface->assign('ids', $ids); $hold_message_data = array('successful' => 'all', 'campus' => $_REQUEST['campus'], 'titles' => array()); $atLeast1Successful = false; foreach ($selectedTitles as $recordId => $itemNumber) { $return = $this->catalog->placeItemHold($recordId, $itemNumber, $user->password, '', $_REQUEST['type']); $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'; } $class = $configArray['Index']['engine']; $db = new $class($configArray['Index']['url']); $_SESSION['hold_message'] = $hold_message_data; if (isset($_SESSION['hold_referrer'])) { $logger->log('Hold Referrer is set, redirecting to there. type = ' . $_REQUEST['type'], PEAR_LOG_INFO); //Redirect for hold cancellation or update header("Location: " . $_SESSION['hold_referrer']); unset($_SESSION['hold_referrer']); if (isset($_SESSION['autologout'])) { unset($_SESSION['autologout']); UserAccount::softLogout(); } } else { $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO); header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds'); } }
function launch() { global $interface; global $configArray; global $user; $driver = new EContentDriver(); $id = strip_tags($_REQUEST['id']); $interface->assign('id', $id); global $logger; //Get title information for the record. $eContentRecord = new EContentRecord(); $eContentRecord->id = $id; if (!$eContentRecord->find(true)) { PEAR_Singleton::raiseError("Unable to find eContent record for id: {$id}"); } if (isset($_REQUEST['autologout'])) { $_SESSION['autologout'] = true; } if (isset($_POST['submit']) || $user) { if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { //Log the user in $user = UserAccount::login(); } if (!PEAR_Singleton::isError($user) && $user) { //The user is already logged in $return = $driver->placeHold($id, $user); $interface->assign('result', $return['result']); $message = $return['message']; $interface->assign('message', $message); $showMessage = true; } else { $message = 'Incorrect Patron Information'; $interface->assign('message', $message); $interface->assign('focusElementId', 'username'); $showMessage = true; } } 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 (!PEAR_Singleton::isError($user) && $user) { //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'); } } if (isset($return) && $showMessage) { $hold_message_data = array('successful' => $return['result'] ? 'all' : 'none', 'error' => $return['error'], 'titles' => array($return)); $_SESSION['hold_message'] = $hold_message_data; if (isset($_SESSION['hold_referrer'])) { $logger->log('Hold Referrer is set, redirecting to there. type = ' . $_REQUEST['type'], PEAR_LOG_INFO); header("Location: " . $_SESSION['hold_referrer']); unset($_SESSION['hold_referrer']); if (isset($_SESSION['autologout'])) { unset($_SESSION['autologout']); UserAccount::softLogout(); } } else { $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO); header("Location: " . $configArray['Site']['path'] . '/MyResearch/EContentHolds?section=unavailable'); } } else { $logger->log('placeHold finished, do not need to show a message', PEAR_LOG_INFO); $interface->setPageTitle('Request an Item'); $interface->assign('subTemplate', 'hold.tpl'); $interface->setTemplate('hold.tpl'); $interface->display('layout.tpl', 'RecordHold' . $_GET['id']); } }
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 $librarySingleton; $patronHomeBranch = $librarySingleton->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 { //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 = $librarySingleton->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'); } }
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); }
function launch() { global $interface; global $configArray; global $user; $driver = new EContentDriver(); $id = strip_tags($_REQUEST['id']); $interface->assign('id', $id); global $logger; //Get title information for the record. $eContentRecord = new EContentRecord(); $eContentRecord->id = $id; if (!$eContentRecord->find(true)) { PEAR_Singleton::raiseError("Unable to find eContent record for id: {$id}"); } if (isset($_POST['submit']) || $user) { if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { //Log the user in $user = UserAccount::login(); } if (!PEAR_Singleton::isError($user) && $user) { //The user is already logged in $return = $driver->checkoutRecord($id, $user); $interface->assign('result', $return['result']); $message = $return['message']; $interface->assign('message', $message); global $logger; $logger->log("Result of checkout " . print_r($return, true), PEAR_LOG_DEBUG); $showMessage = true; } else { $message = 'Incorrect Patron Information'; $interface->assign('message', $message); $interface->assign('focusElementId', 'username'); $showMessage = true; } } else { //Get the referrer so we can go back there. if (isset($_SERVER['HTTP_REFERER'])) { $referer = $_SERVER['HTTP_REFERER']; $_SESSION['checkout_referrer'] = $referer; } //Showing checkout form. if (!PEAR_Singleton::isError($user) && $user) { //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'); } } if (isset($return) && $showMessage) { $hold_message_data = array('successful' => $return['result'] ? 'all' : 'none', 'error' => isset($return['error']) ? $return['error'] : null, 'titles' => array($return)); $_SESSION['checkout_message'] = $hold_message_data; if (isset($_SESSION['checkout_referrer'])) { $logger->log('Checkout Referrer is set, redirecting to there. referrer = ' . $_SESSION['checkout_referrer'], PEAR_LOG_INFO); header("Location: " . $_SESSION['checkout_referrer']); unset($_SESSION['checkout_referrer']); if (isset($_SESSION['autologout'])) { unset($_SESSION['autologout']); UserAccount::softLogout(); } } else { $logger->log('No referrer set, but there is a message to show, go to the main eContent page', PEAR_LOG_INFO); header("Location: /MyResearch/EContentCheckedOut"); } } else { //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'Login to your account'); $logger->log('eContent checkout finished, do not need to show a message', PEAR_LOG_INFO); $interface->setPageTitle('Checkout Item'); $interface->assign('subTemplate', 'checkout.tpl'); $interface->setTemplate('checkout.tpl'); $interface->display('layout.tpl', 'RecordHold' . $_GET['id']); } }