It would be nice if other modules could interact and modify transactions before they are written to the database. For example, I would like to write a booking module for scheduling of materials and need a greater control over due dates. I think there are a number of other cases where you might want to modify transaction information before it is written to the database.
This could be done using drupal_alter as such at line 237, of library.pages.inc:
$transaction = array(
'nid' => $form_state['values']['nid'],
'item_id' => $form_state['values']['item_id'],
'patron_id' => $form_state['values']['patron_id'],
'action' => $form_state['values']['action_aid'],
'due_date' => $duedate,
'notes' => check_plain($form_state['values']['notes']),
'loan_date' => $now,
);
drupal_alter('library_transaction', $transaction);
db_query("INSERT {library_transactions} (nid, item_id, patron_id, action_aid, duedate, notes, created) VALUES (%d, %d, %d, %d, %d, '%s', %d)", $transaction['nid'], $transaction['item_id'], $transaction['patron_id'], $transaction['action'], $transaction['due_date'], $transaction['notes'], $transaction['loan_date']);
Then another module could write a simple hook_library_transaction function to modify the transaction
function booking_library_transaction_alter(&$transaction){
$transaction['due_date'] = booking_check_conflict($transaction['due_date'], $transaction['nid']);
}
Obviously, something similar would need to be added for library.actions.inc for renews and anywhere else where the library_transactions table was being updated.
Comments
Comment #1
grahlPlease reopen if still relevant with a patch.