function library_load in Library 7
Same name and namespace in other branches
- 5.2 library.module \library_load()
- 6.2 library.module \library_load()
- 6 library.module \library_load()
Menu callback; loads a library object.
Parameters
int $item_id: The item to load.
Return value
bool|object The loaded item as an object or false.
6 calls to library_load()
- LibraryWebTestCase::testNodeCreation in tests/
library.unit.test - library_anonymize_action in ./
library.actions.inc - library_get_item_by_barcode in ./
library.module - Returns the full item from barcode.
- library_get_overdue_items in ./
library.module - Returns a list of overdue library items.
- library_renew_action in ./
library.actions.inc - Implementation of a Drupal action.
File
- ./
library.module, line 358
Code
function library_load($item_id) {
if (!is_numeric($item_id)) {
return FALSE;
}
else {
$select = db_select('library', 'l');
$select
->join('node', 'n', 'n.nid = l.nid');
$select
->addField('l', 'id');
$select
->addField('l', 'barcode');
$select
->addField('l', 'nid');
$select
->addField('l', 'in_circulation');
$select
->addField('l', 'library_status');
$select
->addField('l', 'notes');
$select
->addField('l', 'created');
$select
->addField('n', 'title');
$select
->addField('n', 'type');
$select
->addField('n', 'status');
$select
->condition('l.id', $item_id);
$select
->range(0, 1);
$item = $select
->execute()
->fetchObject();
// @todo This should return false if object is not found.
if ($item->in_circulation == LIBRARY_CIRCULATION && $item->library_status == LIBRARY_ITEM_UNAVAILABLE) {
$last = library_get_last_transaction_by_item($item, LIBRARY_ACTION_TYPE_UNAVAILABLE);
if ($last) {
$item->last_patron_uid = $last->uid;
$item->last_transaction_id = $last->tid;
$item->last_transaction_name = $last->action_name;
if (!empty($last->duedate)) {
$item->last_due_date = $last->duedate;
}
}
}
}
return $item;
}