/** * Places a hold on an item that is available within the ILS. The location where the user would like to pickup * the title must be specified as well als the record the user would like a hold placed on. * * 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>bibId - The id of the record within the ILS.</li> * <li>campus � the location where the patron would like to pickup the title (optional). If not provided, the patron's home location will be used.</li> * </ul> * * Returns JSON encoded data as follows: * <ul> * <li>success � true if the account is valid and the hold could be placed, false if the username or password were incorrect or the hold could not be placed.</li> * <li>holdMessage � a reason why the method failed if success is false, or information about hold queue position if successful.</li> * </ul> * * Sample Call: * <code> * http://catalog.douglascountylibraries.org/API/UserAPI?method=renewAll&username=23025003575917&password=7604&bibId=1004012&campus=pa * </code> * * Sample Response (successful hold): * <code> * {"result":{ * "success":true, * "holdMessage":"Placement of hold request successful. You are number 1 in the queue." * }} * </code> * * Sample Response (failed hold): * <code> * {"result":{ * "success":false, * "holdMessage":"Unable to place a hold request. You have already requested this." * }} * </code> * * @author Mark Noble <*****@*****.**> */ function placeHold() { $username = $_REQUEST['username']; $password = $_REQUEST['password']; $bibId = $_REQUEST['bibId']; global $user; $user = UserAccount::validateAccount($username, $password); if ($user && !PEAR_Singleton::isError($user)) { $holdMessage = $this->catalog->placeHold($bibId, $user->cat_username, '', 'request'); return array('success' => $holdMessage['result'], 'holdMessage' => $holdMessage['message']); } else { return array('success' => false, 'message' => 'Login unsuccessful'); } }
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'); } }