function library_get_status_item in Library 6
Same name and namespace in other branches
- 6.2 library.module \library_get_status_item()
- 7 library.module \library_get_status_item()
2 calls to library_get_status_item()
- library_get_table_row in ./
library.module - library_handler_field_library_status::render in includes/
views/ handlers/ library_handler_field_library_status.inc
File
- ./
library.module, line 1455
Code
function library_get_status_item($node) {
if ($node->items) {
$unavailable = array();
$reference = array();
foreach ($node->items as $item) {
if ($item['in_circulation'] == LIBRARY_CIRCULATION && $item['library_status'] == LIBRARY_ITEM_AVAILABLE) {
return $item;
}
elseif ($item['in_circulation'] == LIBRARY_CIRCULATION && $item['library_status'] == LIBRARY_ITEM_UNAVAILABLE) {
if (!empty($item['last_due_date'])) {
$unavailable[$item['last_due_date']][] = $item;
}
else {
$unavailable[time()][] = $item;
}
}
else {
$reference[] = $item;
}
}
if (!empty($reference)) {
return $reference[0];
}
elseif (!empty($unavailable)) {
foreach ($unavailable as $un_item) {
return $un_item[0];
}
}
}
return FALSE;
}