function library_anonymize_action in Library 7
File
- ./
library.actions.inc, line 94 - Hooks into core Drupal actions module
Code
function library_anonymize_action(&$object, $context = array()) {
$item = library_load($context['item']['id']);
$user = user_load($context['patron']['uid']);
if (isset($item->id) && isset($user->uid)) {
$query = db_update('library_transactions')
->fields(array(
'uid' => 0,
))
->condition('item_id', $item->id)
->condition('uid', $user->uid)
->execute();
if ($query) {
drupal_set_message(t('Transaction history regarding @user for item @item has been anonymized.', array(
'@user' => $user->name,
'@item' => $item->title,
)));
}
else {
drupal_set_message(t('An error occurred while anonymizing the transaction history on @item for @user.', array(
'@user' => $user->name,
'@item' => $item->title,
)), 'error');
watchdog('library', 'Anonymization for item @item failed in context user @user', array(
'@user' => $user->uid,
'@item' => $item->id,
), WATCHDOG_ALERT);
}
}
}