function library_history_single_user in Library 7
The menu callback to show the transaction history of a single user.
@todo This function is not being used, this is a bug, we need it on the user's profile.
Parameters
object $patron: The user in question.
Return value
string Returns a themed list of a user's history.
1 string reference to 'library_history_single_user'
- library_menu in ./
library.module - Implements hook_menu().
File
- ./
library.pages.inc, line 486 - Functions for generating page displays related to the library module.
Code
function library_history_single_user($patron) {
$duedate_enabled = library_duedates_enabled();
$header = array(
t('Date'),
t('Item'),
t('Transaction'),
t('Notes'),
);
if ($duedate_enabled) {
$header[] = t('Due Date');
}
$header[] = t('Actions');
$rows = array();
$transactions = library_get_transactions_by_single_user($patron);
if (!empty($transactions)) {
$last_item = '';
foreach ($transactions as $transaction) {
$detail_link = '';
$action_link = '';
$cur_item = $transaction->item_id;
$created = format_date($transaction->created, 'small');
if ($duedate_enabled && $cur_item != $last_item && !empty($transaction->duedate)) {
$duedate = format_date($transaction->duedate, 'small');
}
elseif ($duedate_enabled) {
$duedate = '';
}
// @todo Passing the user might be redundant here.
if (user_access('administer transactions', $patron)) {
$detail_link = l(t('View Details'), 'library-items/transaction/view/' . $transaction->tid);
}
if ($cur_item != $last_item) {
$item = array(
'id' => $transaction->item_id,
'library_status' => $transaction->library_status,
'last_patron_uid' => $transaction->uid,
'in_circulation' => $transaction->in_circulation,
);
$links = library_get_action_links($item);
if (!empty($links)) {
$action_link = implode(" | ", $links);
}
}
$temp_array = array(
$created,
l($transaction->item_name, 'node/' . $transaction->nid),
$transaction->action_name,
$transaction->notes,
);
if (isset($duedate)) {
$temp_array[] = $duedate;
}
if (!empty($detail_link) && !empty($action_link)) {
$temp_array[] = $detail_link . ' | ' . $action_link;
}
elseif (!empty($action_link)) {
$temp_array[] = $action_link;
}
elseif (!empty($detail_link)) {
$temp_array[] = $detail_link;
}
else {
$temp_array[] = '';
}
$rows[] = $temp_array;
$last_item = $cur_item;
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
));
}
else {
return "<p>This user has not performed any library actions.</p>";
}
}