/** * 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); }
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() { 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'); } }
require "PType.php"; $dt = array('user' => array('name' => 'string', 'age' => 0), 'group' => array('user' => 'user', 'gname' => "test")); foreach ($dt as $k => $v) { PType::register($k, $v); } /* $t = array('foo'=>1, 'bar'=>array('foo'=>2, 'bar'=>3)); var_dump(PType::fill($t, array('bar'=>array('bar'=>4)))); var_dump($t); */ PType::register("student", array("_" => "user", "class" => "string")); //展开用户的所有项 //var_dump(PType::$dt); //var_dump(PType::$dt_default); //var_dump(PType::$dt_mix); $user1 = new PType("user", array('name' => 'wj')); //find dt var_dump($user1->hash()); var_dump($user1->toArray()); $group = new PType("group", array('user' => $user1, 'gname' => 'test2')); // $group['gname'] = 'this ok'; // var_dump($group->toArray()); exit; //匿名类型 $user2 = new PType(array("name" => "string", "age" => "integer kkk"), array('name' => "wy")); var_dump($user2->typeHash()); var_dump($user1->toJson()); //$user1['name'] = 'dj'; //var_dump($user1['name']);
function getObjectStructure() { return PType::getObjectStructure(); }
function getPlaceHoldForm() { global $interface; global $user; if ($user) { $id = $_REQUEST['id']; $catalog = CatalogFactory::getCatalogConnectionInstance(); $profile = $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. // using $user to be consistent with other code use of getPickupBranches() // $locations = $locationSingleton->getPickupBranches($profile, $profile['homeLocationId']); $locations = $locationSingleton->getPickupBranches($user, $user->homeLocationId); $interface->assign('pickupLocations', $locations); global $library; $interface->assign('showHoldCancelDate', $library->showHoldCancelDate); $interface->assign('defaultNotNeededAfterDays', $library->defaultNotNeededAfterDays); $interface->assign('showDetailedHoldNoticeInformation', $library->showDetailedHoldNoticeInformation); $interface->assign('treatPrintNoticesAsPhoneNotices', $library->treatPrintNoticesAsPhoneNotices); require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php'; $marcRecord = new MarcRecord($id); $interface->assign('id', $id); $title = $marcRecord->getTitle(); // $interface->assign('title', $title); // Title not referred to in hold-popup.tpl $results = array('title' => 'Place Hold on ' . $title, 'modalBody' => $interface->fetch("Record/hold-popup.tpl"), 'modalButtons' => "<input type='submit' name='submit' id='requestTitleButton' value='Submit Hold Request' class='btn btn-primary' onclick='return VuFind.Record.submitHoldForm();'/>"); } else { $results = array('title' => 'Please login', 'modalBody' => "You must be logged in. Please close this dialog and login before placing your hold.", 'modalButtons' => ""); } return $this->json_utf8_encode($results); }