function getAllObjects()
 {
     $library = new EContentItem();
     $library->orderBy('filename');
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->id] = clone $library;
     }
     return $libraryList;
 }
Exemple #2
0
 function launch()
 {
     global $interface;
     global $configArray;
     $epubFile = new EContentItem();
     $epubFile->id = $_REQUEST['id'];
     $epubFile->find();
     if ($epubFile->N > 0) {
         $epubFile->fetch();
         $epubFile->delete();
     }
     //Redirect back to the PMDA home page
     header('Location:' . $configArray['Site']['path'] . "/EContent/Search");
     exit;
 }
Exemple #3
0
 function launch()
 {
     global $interface;
     global $configArray;
     $interface->assign('id', $_REQUEST['id']);
     $epubFile = new EContentItem();
     $epubFile->id = $_REQUEST['id'];
     $epubFile->find();
     if ($epubFile->N > 0) {
         $epubFile->fetch();
         $interface->assign('epubFile', $epubFile);
     }
     //Load the pillar to display
     $structure = EContentItem::getObjectStructure();
     $interface->setTemplate('view.tpl');
     $interface->display('layout.tpl');
 }
Exemple #4
0
 function launch()
 {
     global $interface;
     global $configArray;
     $isNew = true;
     if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0) {
         $epubFile = new EContentItem();
         $epubFile->id = $_REQUEST['id'];
         $epubFile->find();
         if ($epubFile->N > 0) {
             $epubFile->fetch();
             $interface->assign('object', $epubFile);
             $interface->setPageTitle('Edit EPUB File');
             $isNew = false;
         }
     }
     $structure = EContentItem::getObjectStructure();
     if (isset($_REQUEST['submit'])) {
         //Save the object
         $results = DataObjectUtil::saveObject($structure, 'EContentItem');
         $epubFile = $results['object'];
         //redirect to the view of the competency if we saved ok.
         if (!$results['validatedOk'] || !$results['saveOk']) {
             //Display the errors for the user.
             $interface->assign('errors', $results['errors']);
             $interface->assign('object', $epubFile);
             $_REQUEST['id'] = $epubFile->id;
         } else {
             //Show the new tip that was created
             header('Location:' . $configArray['Site']['path'] . "/EContent/{$epubFile->id}/View");
             exit;
         }
     }
     //Manipulate the structure as needed
     if ($isNew) {
     } else {
     }
     $interface->assign('isNew', $isNew);
     $interface->assign('submitUrl', $configArray['Site']['path'] . '/EContent/Edit');
     $interface->assign('editForm', DataObjectUtil::getEditForm($structure));
     $interface->setTemplate('edit.tpl');
     $interface->display('layout.tpl');
 }
 function getItems($reload = false, $allowReindex = true)
 {
     if ($this->items == null || $reload) {
         $this->items = array();
         require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
         $eContentItem = new EContentItem();
         $eContentItem->recordId = $this->id;
         $eContentItem->find();
         while ($eContentItem->fetch()) {
             $this->items[] = clone $eContentItem;
         }
     }
     return $this->items;
 }
 /**
  * Get Holding
  *
  * This is responsible for retrieving the holding information of a certain
  * record.
  *
  * @param   string  $recordId   The record id to retrieve the holdings for
  * @return  mixed               An associative array with the following keys:
  *                              availability (boolean), status, location,
  *                              reserve, callnumber, duedate, number,
  *                              holding summary, holding notes
  *                              If an error occurs, return a PEAR_Error
  * @access  public
  */
 public function getHolding($id, $allowReindex = true)
 {
     if (array_key_exists($id, EContentDriver::$holdings)) {
         return EContentDriver::$holdings[$id];
     }
     global $user;
     global $configArray;
     $libaryScopeId = $this->getLibraryScopingId();
     //Get any items that are stored for the record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     if ($eContentRecord->accessType != 'external') {
         //Check to see if the record is checked out or on hold within VuFind
         $checkedOutToUser = false;
         $onHoldForUser = false;
         $holdPosition = 0;
         if ($user) {
             $eContentCheckout = new EContentCheckout();
             $eContentCheckout->userId = $user->id;
             $eContentCheckout->status = 'out';
             $eContentCheckout->recordId = $id;
             $eContentCheckout->find();
             if ($eContentCheckout->N > 0) {
                 //The item is checked out to the current user
                 $eContentCheckout->fetch();
                 $checkedOutToUser = true;
             } else {
                 $eContentHold = new EContentHold();
                 $eContentHold->userId = $user->id;
                 $eContentHold->whereAdd("status in ('active', 'suspended', 'available')");
                 $eContentHold->recordId = $id;
                 $eContentHold->find();
                 if ($eContentHold->N > 0) {
                     $onHoldForUser = true;
                     $eContentHold->fetch();
                     $holdPosition = $this->_getHoldPosition($eContentHold);
                 }
             }
         }
         $eContentItem = new EContentItem();
         $eContentItem->recordId = $id;
         if ($libaryScopeId != -1) {
             $eContentItem->whereAdd("libraryId = -1 or libraryId = {$libaryScopeId}");
         }
         $items = array();
         $eContentItem->find();
         while ($eContentItem->fetch()) {
             $item = clone $eContentItem;
             $item->source = $eContentRecord->source;
             //Generate links for the items
             $links = array();
             if ($checkedOutToUser) {
                 $links = $this->_getCheckedOutEContentLinks($eContentRecord, $item, $eContentCheckout);
             } else {
                 if ($eContentRecord->accessType == 'free' && $item->isExternalItem()) {
                     $links = $this->_getFreeExternalLinks($eContentRecord, $item);
                 } else {
                     if ($onHoldForUser) {
                         $links = $this->getOnHoldEContentLinks($eContentHold);
                     }
                 }
             }
             $item->checkedOut = $checkedOutToUser;
             $item->onHold = $onHoldForUser;
             $item->holdPosition = $holdPosition;
             $item->links = $links;
             $items[] = $item;
         }
     } else {
         $items = $eContentRecord->getItems();
         //We have econtent stored on an external server. Check to see if it is available there (if possible)
         if (strcasecmp($eContentRecord->source, 'OverDrive') == 0) {
             //Add links as needed
             $availability = $eContentRecord->getAvailability();
             $addCheckoutLink = false;
             $addPlaceHoldLink = false;
             foreach ($availability as $availableFrom) {
                 if ($availableFrom->libraryId == -1) {
                     if ($availableFrom->availableCopies > 0) {
                         $addCheckoutLink = true;
                     } else {
                         $addPlaceHoldLink = true;
                     }
                 } else {
                     //Non shared item, check to see if we are in the correct scope to show it
                     if ($libaryScopeId == -1 || $availableFrom->libraryId == $libaryScopeId) {
                         if ($availableFrom->availableCopies > 0) {
                             $addCheckoutLink = true;
                         } else {
                             $addPlaceHoldLink = true;
                         }
                     }
                 }
             }
             foreach ($items as $key => $item) {
                 $item->links = array();
                 if ($addCheckoutLink) {
                     if ($configArray['OverDrive']['interfaceVersion'] == 1) {
                         $checkoutLink = "return checkoutOverDriveItem('{$eContentRecord->externalId}', '{$item->externalFormatNumeric}');";
                     } else {
                         $checkoutLink = "return checkoutOverDriveItemOneClick('{$eContentRecord->externalId}', '{$item->externalFormatNumeric}');";
                     }
                     $item->links[] = array('onclick' => $checkoutLink, 'text' => 'Check Out', 'overDriveId' => $eContentRecord->externalId, 'formatId' => $item->externalFormatNumeric, 'action' => 'CheckOut');
                 } else {
                     if ($addPlaceHoldLink) {
                         $item->links[] = array('onclick' => "return placeOverDriveHold('{$eContentRecord->externalId}', '{$item->externalFormatNumeric}');", 'text' => 'Place Hold', 'overDriveId' => $eContentRecord->externalId, 'formatId' => $item->externalFormatNumeric, 'action' => 'Hold');
                     }
                 }
                 $items[$key] = $item;
             }
         } else {
             foreach ($items as $key => $item) {
                 $item->links = $this->_getFreeExternalLinks($eContentRecord, $item);
                 $items[$key] = $item;
             }
         }
         if ($libaryScopeId != -1) {
             foreach ($items as $key => $item) {
                 if ($item->libraryId != -1 && $item->libraryId != $libaryScopeId) {
                     unset($items[$key]);
                 }
             }
         }
     }
     EContentDriver::$holdings[$id] = $items;
     return $items;
 }