예제 #1
0
 /**
  * Get eContent and ILS holds for 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 eContent holds. Set to false to only include print titles.</li>
  * </ul>
  *
  * Returns:
  * <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>holds � information about each hold including when it was placed, when it expires, and whether or not it is available for pickup.  Holds are broken into two sections: available and unavailable.  Available holds are ready for pickup.</li>
  * <li>Id � the record/bib id of the title being held</li>
  * <li>location � The location where the title will be picked up</li>
  * <li>expire � the date the hold will expire if it is unavailable or the date that it must be picked up if the hold is available</li>
  * <li>expireTime � the expire information in number of days since January 1, 1970 </li>
  * <li>create � the date the hold was originally placed</li>
  * <li>createTime � the create information in number of days since January 1, 1970</li>
  * <li>reactivate � The date the hold will be reactivated if the hold is suspended</li>
  * <li>reactivateTime � the reactivate information in number of days since January 1, 1970</li>
  * <li>available � whether or not the hold is available for pickup</li>
  * <li>position � the patron's position in the hold queue</li>
  * <li>frozen � whether or not the hold is frozen</li>
  * <li>itemId � the barcode of the item that filled the hold if the hold has been filled.</li>
  * <li>Status � a textual status of the item (Available, Suspended, Active, In Transit)</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=getPatronHolds&username=23025003575917&password=7604
  * </code>
  *
  * Sample Response:
  * <code>
  * { "result" :
  *   { "holds" :
  *     { "unavailable" : [
  *       { "author" : "Bernhardt, Gale, 1958-",
  *            "available" : false,
  *            "availableTime" : null,
  *            "barcode" : "33025016545293",
  *            "create" : "2011-12-20 00:00:00",
  *            "createTime" : 15328,
  *            "expire" : "[No expiration date]",
  *            "expireTime" : null,
  *            "format" : "Book",
  *            "format_category" : [ "Books" ],
  *            "frozen" : false,
  *            "id" : 868679,
  *            "isbn" : [ "1931382921 (paper)",
  *                "9781931382922"
  *              ],
  *            "itemId" : 1559061,
  *            "location" : "Parker",
  *            "position" : 1,
  *            "reactivate" : "",
  *            "reactivateTime" : null,
  *            "sortTitle" : "training plans for multisport athletes",
  *            "status" : "In Transit",
  *            "title" : "Training plans for multisport athletes /",
  *            "upc" : ""
  *       } ]
  *     },
  *     { "available" : [
  *       { "author" : "Hunter, Erin.",
  *            "available" : true,
  *            "availableTime" : null,
  *            "barcode" : "33025025084185",
  *            "create" : "2011-09-27 00:00:00",
  *            "createTime" : 15244,
  *            "expire" : "2012-01-09 00:00:00",
  *            "expireTime" : 15348,
  *            "format" : "Book",
  *            "format_category" : [ "Books" ],
  *            "frozen" : false,
  *            "id" : 1012238,
  *            "isbn" : [ "9780061555220",
  *                "0061555223"
  *              ],
  *            "itemId" : 2216202,
  *            "location" : "Parker",
  *            "position" : 2,
  *            "reactivate" : "",
  *            "reactivateTime" : 15308,
  *            "sortTitle" : "forgotten warrior",
  *            "status" : "Available",
  *            "title" : "The forgotten warrior /",
  *            "upc" : ""
  *          } ]
  *     },
  *     "success" : true
  *  }
  * }
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function getPatronHolds()
 {
     $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)) {
         $patronHolds = $this->catalog->getMyHolds($user);
         if ($includeEContent === true || $includeEContent === 'true') {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentHolds = $eContentDriver->getMyHolds($user);
             $allHolds = array_merge_recursive($eContentHolds['holds'], $patronHolds['holds']);
         } else {
             $allHolds = $patronHolds['holds'];
         }
         return array('success' => true, 'holds' => $allHolds);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }