Exemplo n.º 1
0
 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');
 }
Exemplo n.º 2
0
 /**
  * Load patron profile information for a user based on username and password.
  * Includes information about print titles and eContent titles that the user has checked out.
  * Does not include information about OverDrive titles since tat
  *
  * Usage:
  * <code>
  * {siteUrl}/API/UserAPI?method=getPatronProfile&username=patronBarcode&password=pin
  * </code>
  *
  * 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>
  * </ul>
  *
  * Returns JSON encoded data as follows:
  * <ul>
  * <li>success � true if the account is valid, false if the username or password were incorrect</li>
  * <li>message � a reason why the method failed if success is false</li>
  * <li>profile � profile information including name, address, e-mail, number of holds, number of checked out items, fines.</li>
  * <li>firstname � The first name of the patron in the ILS</li>
  * <li>lastname � The last name of the patron in the ILS</li>
  * <li>fullname � The combined first and last name for the patron in the ILS</li>
  * <li>address1 � The street information for the patron</li>
  * <li>city � The city where the patron lives</li>
  * <li>state � The state where the patron lives</li>
  * <li>zip � The zip code for the patron</li>
  * <li>phone � The phone number for the patron</li>
  * <li>email � The email for the patron</li>
  * <li>homeLocationId � The id of the patron's home branch within VuFind</li>
  * <li>homeLocationName � The full name of the patron's home branch</li>
  * <li>expires � The expiration date of the patron's library card</li>
  * <li>fines � the amount of fines on the patron's account formatted for display</li>
  * <li>finesVal � the amount of  fines on the patron's account without formatting</li>
  * <li>numHolds � The number of holds the patron currently has</li>
  * <li>numHoldsAvailable � The number of holds the patron currently has that are available</li>
  * <li>numHoldsRequested � The number of holds the patron currently has that are not available</li>
  * <li>numCheckedOut � The number of items the patron currently has checked out.</li>
  * <li>bypassAutoLogout - 1 if the user has chosen to bypass te automatic logout script or 0 if they have not.</li>
  * <li>numEContentCheckedOut - The number of eContent items that the user currently has checked out. </li>
  * <li>numEContentAvailableHolds - The number of available eContent holds for the user that can be checked out. </li>
  * <li>numEContentUnavailableHolds - The number of unavailable eContent holds for the user.</li>
  * <li>numEContentWishList - The number of eContent titles the user has added to their wishlist.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=getPatronProfile&username=23025003575917&password=7604
  * </code>
  *
  * Sample Response failed login:
  * <code>
  * {"result":{
  *   "success":false,
  *   "message":"Login unsuccessful"
  * }}
  * </code>
  *
  * Sample Response:
  * <code>
  * { "result" : { "profile" : {
  *   "address1" : "P O BOX 283",
  *   "bypassAutoLogout" : "0",
  *   "city" : "LOUVIERS",
  *   "displayName" : "",
  *   "email" : "*****@*****.**",
  *   "expires" : "02/03/2039",
  *   "fines" : 0,
  *   "finesval" : "",
  *   "firstname" : "",
  *   "fullname" : "POS test 1",
  *   "homeLocationId" : "3",
  *   "homeLocationName" : "Philip S. Miller",
  *   "lastname" : "POS test 1",
  *    "numCheckedOut" : 0,
  *   "numEContentAvailableHolds" : 0,
  *   "numEContentCheckedOut" : 0,
  *   "numEContentUnavailableHolds" : 0,
  *   "numEContentWishList" : 0,
  *   "numHolds" : 0,
  *   "numHoldsAvailable" : 0,
  *   "numHoldsRequested" : 0,
  *   "phone" : "303-555-5555",
  *   "state" : "CO",
  *   "zip" : "80131"
  * },
  * "success" : true
  * } }
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function getPatronProfile()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         $profile = $this->catalog->getMyProfile($user);
         return array('success' => true, 'profile' => $profile);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 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');
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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');
     }
 }
Exemplo n.º 9
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');
 }