/** * Get Patron Profile * * This is responsible for retrieving the profile for a specific patron. * * @param array|User $patron The patron array * * @return mixed Array of the patron's profile data on success, * PEAR_Error otherwise. * @access public */ public function getMyProfile($patron) { /** @var Memcache $memCache */ global $memCache; global $serverName; $memCacheProfileKey = "patronProfile_{$serverName}_"; if (is_object($patron)) { $memCacheProfileKey .= $patron->username; } else { $memCacheProfileKey .= $patron['username']; } $forceReload = isset($_REQUEST['reload']); if (!$forceReload && $memCacheProfileKey) { $cachedValue = $memCache->get($memCacheProfileKey); if (!$cachedValue) { $forceReload = true; } // when not found in memcache turn on reload to short-circuit redundant memcache checks in each of the ILS drivers for getMyProfile() } if ($forceReload) { $profile = $this->driver->getMyProfile($patron, $forceReload); if (PEAR_Singleton::isError($profile)) { // echo("Error loading profile " . print_r($profile, true)); return $profile; } $profile['readingHistorySize'] = ''; global $user; if ($user && $user->trackReadingHistory && $user->initialReadingHistoryLoaded) { require_once ROOT_DIR . '/sys/ReadingHistoryEntry.php'; $readingHistoryDB = new ReadingHistoryEntry(); $readingHistoryDB->userId = $user->id; $readingHistoryDB->deleted = 0; $profile['readingHistorySize'] = $readingHistoryDB->count(); } $cachedValue = $profile; global $configArray; $memCacheResult = $memCache->replace($memCacheProfileKey, $cachedValue, 0, $configArray['Caching']['patron_profile']); // Update the existing key } return $cachedValue; }
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']); } }
/** * Get Patron Profile * * This is responsible for retrieving the profile for a specific patron. * * @param array $patron The patron array * * @return mixed Array of the patron's profile data on success, * PEAR_Error otherwise. * @access public */ public function getMyProfile($patron) { return $this->driver->getMyProfile($patron); }