Exemplo n.º 1
0
 /**
  * Get eContent and ILS records that are checked out to a user based on username and password.
  *
  * 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>includeEContent - Optional flag for whether or not to include checked out eContent. Set to false to only include print titles.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=getPatronCheckedOutItems&username=23025003575917&password=7604
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{
  *   "success":true,
  *   "checkedOutItems":{
  *     "0":{
  *       "id":"534",
  *       "source":"CIPA",
  *       "title":"Unsinkable the Molly Brown story \/",
  *       "author":"Lohse, Joyce B.",
  *       "duedate":"1326135657",
  *       "checkoutdate":"1325962857",
  *       "daysUntilDue":2,
  *       "holdQueueLength":0,
  *       "links":[
  *         {"url":"\/EContent\/534\/Viewer?item=130",
  *          "text":"Read Online"
  *         },
  *         {"url":"http:\/\/fulfillment.douglascountylibraries.org\/fulfillment\/URLLink.acsm?action=enterloan&ordersource=DCL+Test&orderid=ACS4-1206216092244346610125819&resid=urn%3Auuid%3A130b9d63-5e4f-430c-aa16-8fb33822aba8&gbauthdate=Sat%2C+07+Jan+2012+19%3A00%3A58+%2B0000&dateval=1325962858&gblver=4&auth=8c6e70a135a7418c441a9b2b32b9ff6cb413e4cf",
  *          "text":"Download"
  *         },
  *         {"text":"Return Now",
  *          "onclick":"if (confirm('Are you sure you want to return this title?')){returnEpub('\/EContentRecord\/534\/ReturnTitle')};return false;"
  *         }
  *       ]
  *     },
  *     "33025021368319":{
  *       "id":"966379",
  *       "itemid":"33025021368319",
  *       "duedate":"01\/24\/2012",
  *       "checkoutdate":"2011-12-27 00:00:00",
  *       "barcode":"33025021368319",
  *       "renewCount":"1",
  *       "request":null,
  *       "overdue":false,
  *       "daysUntilDue":16,
  *       "title":"Be iron fit : time-efficient training secrets for ultimate fitness \/",
  *       "sortTitle":"be iron fit : time-efficient training secrets for ultimate fitness \/ time-efficient training secrets for ultimate fitness \/",
  *       "author":"Fink, Don.",
  *       "format":"Book",
  *       "isbn":"9781599218571"
  *       ,"upc":"",
  *       "format_category":"Books",
  *       "holdQueueLength":3
  *     }
  *   }
  * }}
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function getPatronCheckedOutItems()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     $includeEContent = true;
     if (isset($_REQUEST['includeEContent'])) {
         $includeEContent = $_REQUEST['includeEContent'];
     }
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         $checkedOutItems = $this->catalog->getMyTransactions($user);
         if ($includeEContent === true || $includeEContent === 'true') {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentTransactions = $eContentDriver->getMyTransactions($user);
             $allTransactions = array_merge($eContentTransactions['transactions'], $checkedOutItems['transactions']);
         } else {
             $allTransactions = $checkedOutItems['transactions'];
         }
         return array('success' => true, 'checkedOutItems' => $allTransactions);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }