if($patron->isnew()) {
( $new_patron, $evt ) = _add_patron($session, _clone_patron($patron), $user_obj);
return $evt if $evt;
+ if($U->is_true($patron->barred)) {
+ $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'BAR_PATRON');
+ return $evt if $evt;
+ }
} else {
$new_patron = $patron;
$old_patron = $e->retrieve_actor_user($patron->id) or
return $e->die_event;
$e->disconnect;
+ 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;
+ }
}
( $new_patron, $evt ) = _add_update_addresses($session, $patron, $new_patron, $user_obj);
var fmObject = null;
switch(fmcls) {
- case 'au' : fmObject = patron; break;
+ case 'au' :
+ fmObject = patron;
+ if(fmfield == 'barred') {
+ // Are we allowed to touch the barred state?
+ var permission = 'BAR_PATRON';
+ if(fmObject.barred() == 't') {
+ permission = 'UNBAR_PATRON';
+ }
+ var ou = staff.ws_ou();
+ if(fmObject.home_ou() != null) {
+ ou = fmObject.home_ou();
+ }
+ var resp = fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.user.perm.check'],
+ { params : [openils.User.authtoken, staff.id(), ou, [permission] ] }
+ );
+ if(resp[0]) { // No permission to adjust barred state from current
+ disabled = true;
+ }
+ }
+ break;
case 'ac' : if(!editCard) editCard = patron.card(); fmObject = editCard; break;
case 'aua' :
fmObject = patron.addresses().filter(