# if we want to represent the old patron.
my $old_patron;
+ my $barred_hook = '';
if($patron->isnew()) {
( $new_patron, $evt ) = _add_patron($session, _clone_patron($patron), $user_obj);
if($U->is_true($old_patron->barred) != $U->is_true($new_patron->barred)) {
$evt = $U->check_perms($user_obj->id, $patron->home_ou, $U->is_true($old_patron->barred) ? 'UNBAR_PATRON' : 'BAR_PATRON');
return $evt if $evt;
+
+ $barred_hook = $U->is_true($new_patron->barred) ?
+ 'au.barred' : 'au.unbarred';
}
}
$tses->request('open-ils.trigger.event.autocreate', 'au.create', $new_patron, $new_patron->home_ou);
} else {
$tses->request('open-ils.trigger.event.autocreate', 'au.update', $new_patron, $new_patron->home_ou);
+
+ $tses->request('open-ils.trigger.event.autocreate', $barred_hook,
+ $new_patron, $new_patron->home_ou) if $barred_hook;
}
return flesh_user($new_patron->id(), new_editor(requestor => $user_obj, xact => 1));
'"6 months"'
);
+INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'au.barred',
+ 'au',
+ 'A user was barred by staff',
+ FALSE
+ );
+
+INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'au.unbarred',
+ 'au',
+ 'A user was un-barred by staff',
+ FALSE
+ );
+
+INSERT INTO action_trigger.validator (
+ module,
+ description
+ ) VALUES (
+ 'PatronBarred',
+ 'Tests if a patron is currently marked as barred'
+ );
+
+INSERT INTO action_trigger.validator (
+ module,
+ description
+ ) VALUES (
+ 'PatronNotBarred',
+ 'Tests if a patron is currently not marked as barred'
+ );
+
--- /dev/null
+
+BEGIN;
+
+INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'au.barred',
+ 'au',
+ 'A user was barred by staff',
+ FALSE
+ );
+
+INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'au.unbarred',
+ 'au',
+ 'A user was un-barred by staff',
+ FALSE
+ );
+
+INSERT INTO action_trigger.validator (
+ module,
+ description
+ ) VALUES (
+ 'PatronBarred',
+ 'Tests if a patron is currently marked as barred'
+ );
+
+INSERT INTO action_trigger.validator (
+ module,
+ description
+ ) VALUES (
+ 'PatronNotBarred',
+ 'Tests if a patron is currently not marked as barred'
+ );
+
+COMMIT;