示例#1
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     // Get My Transactions
     if ($this->catalog->status) {
         if ($user->cat_username) {
             $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
             $timer->logTime("Logged in patron to get checked out items.");
             if (PEAR_Singleton::isError($patron)) {
                 PEAR_Singleton::raiseError($patron);
             }
             $patronResult = $this->catalog->getMyProfile($patron);
             if (!PEAR_Singleton::isError($patronResult)) {
                 $interface->assign('profile', $patronResult);
             }
             $timer->logTime("Got patron profile to get checked out items.");
             // Define sorting options
             $sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format');
             $interface->assign('sortOptions', $sortOptions);
             $selectedSortOption = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'dueDate';
             $interface->assign('defaultSortOption', $selectedSortOption);
             $interface->assign('showNotInterested', false);
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             if (isset($_REQUEST['multiAction']) && $_REQUEST['multiAction'] == 'suspendSelected') {
                 $ids = array();
                 foreach ($_REQUEST['unavailableHold'] as $id => $selected) {
                     $ids[] = $id;
                 }
                 $suspendDate = $_REQUEST['suspendDate'];
                 $dateToReactivate = strtotime($suspendDate);
                 $suspendResult = $driver->suspendHolds($ids, $dateToReactivate);
                 //Redirect back to the EContentHolds page
                 header("Location: " . $configArray['Site']['path'] . "/MyResearch/EContentHolds?section=unavailable");
             }
             $result = $driver->getMyHolds($user);
             $interface->assign('holds', $result['holds']);
             $timer->logTime("Loaded econtent from catalog.");
         }
     }
     $hasSeparateTemplates = $interface->template_exists('MyResearch/eContentAvailableHolds.tpl');
     if ($hasSeparateTemplates) {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available';
         $interface->assign('section', $section);
         if ($section == 'available') {
             $interface->setPageTitle('Available eContent');
             $interface->setTemplate('eContentAvailableHolds.tpl');
         } else {
             $interface->setPageTitle('eContent On Hold');
             $interface->setTemplate('eContentUnavailableHolds.tpl');
         }
     } else {
         $interface->setTemplate('eContentHolds.tpl');
         $interface->setPageTitle('On Hold eContent');
     }
     $interface->display('layout.tpl');
 }
示例#2
0
 /**
  * Freezes an eContent hold.
  *
  * 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>ids[] - an array of ids that should be frozen.</li>
  * <li>suspendDate - The date that the hold should be automatically reactivated.</li>
  * </ul>
  *
  * Returns:
  * <ul>
  * <li>success � true if the account is valid and the hold could be frozen, false if the username or password were incorrect or the hold could not be frozen.</li>
  * <li>freezeResults � a list of results for each id that was frozen.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=freezeEContentHold&username=23025003575917&password=1234&ids[]=532&suspendDate=1/25/2012
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{
  *   "success":false,
  *   "freezeResults":{
  *     "531":{
  *       "success":false,
  *       "title":"Toothful tales how we survived the sweet attack \/",
  *       "error":"Could not find an active hold to suspend."
  *     },
  *     "521":{
  *       "success":true,
  *       "title":"Turn eye appeal into buy appeal how to easily transform your marketing pieces into dazzling, persuasive sales tools! \/",
  *       "error":"The hold was suspended."
  *     }
  *   }
  * }}
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function freezeEContentHold()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         require_once ROOT_DIR . '/Drivers/EContentDriver.php';
         $eContentDriver = new EContentDriver();
         $ids = $_REQUEST['ids'];
         $suspendDate = strtotime($_REQUEST['suspendDate']);
         $suspendResults = $eContentDriver->suspendHolds($ids, $suspendDate);
         $success = true;
         foreach ($suspendResults as $suspendResult) {
             if ($suspendResult['success'] == false) {
                 $success = false;
             }
         }
         return array('success' => $success, 'freezeResults' => $suspendResults);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }