# Now, we place the hold on the newly created copy on behalf
# of the patron retrieved above.
- my $hold = $self->place_hold($item, $user, $location);
+ my $hold = $self->place_hold($item, $user, $location, undef, undef, 1);
if (ref($hold) eq 'NCIP::Problem') {
$response->problem($hold);
return $response;
'open-ils.actor.user.fleshed.retrieve',
$self->{session}->{authtoken},
$id,
- [ 'card', 'cards', 'standing_penalties', 'addresses', 'home_ou' ]
+ [ 'card', 'cards', 'standing_penalties', 'addresses', 'home_ou', 'settings' ]
);
# Check for an error.
undef($result) if ($result && $U->event_code($result));
=head2 place_hold
- $hold = $ils->place_hold($item, $user, $location, $expiration, $org_unit);
+ $hold = $ils->place_hold($item, $user, $location, $expiration, $org_unit, $do_notification);
This function places a hold on $item for $user for pickup at
$location. If location is not provided or undefined, the user's home
essentially limits the hold to being filled by copies belonging to the
specified org_unit or its children.
+The $do_notification parameter is true or false for whether or not to
+add the patron's default notification options to the hold when placed.
+
$item can be a copy (asset::copy), volume (asset::call_number), or bib
(biblio::record_entry). The appropriate hold type will be placed
depending on the object.
my $location = shift;
my $expiration = shift;
my $org_unit = shift;
+ my $do_notification = shift;
# If $location is undefined, use the user's home_ou, which should
# have been fleshed when the user was retrieved.
}
}
+ # Notification params.
+ if ($do_notification) {
+ my ($hold_notify) = grep {$_->name() eq 'opac.hold_notify'} @{$user->settings()};
+ if ($hold_notify) {
+ if ($hold_notify->value() =~ /email/) {
+ $params->{email_notify} = 1;
+ }
+ if ($hold_notify->value() =~ /phone/) {
+ my ($default_phone) = grep {$_->name() eq 'opac.default_phone'} @{$user->settings()};
+ if ($default_phone) {
+ $params->{phone_notify} = $default_phone->value();
+ $params->{phone_notify} =~ s/"//g;
+ } elsif ($user->day_phone()) {
+ $params->{phone_notify} = $user->day_phone();
+ }
+ }
+ if ($hold_notify->value() =~ /sms/) {
+ my ($sms_carrier) = grep {$_->name() eq 'opac.default_sms_carrier'} @{$user->settings()};
+ my ($sms_notify) = grep {$_->name() eq 'opac.default_sms_notify'} @{$user->settings()};
+ if ($sms_carrier && $sms_notify) {
+ $params->{sms_carrier} = $sms_carrier->value();
+ $params->{sms_notify} = $sms_notify->value();
+ $params->{sms_carrier} =~ s/"//g;
+ $params->{sms_notify} =~ s/"//g;
+ }
+ }
+ } else {
+ if ($user->email()) {
+ $params->{email_notify} = 1;
+ }
+ if ($user->day_phone()) {
+ $params->{phone_notify} = $user->day_phone();
+ }
+ }
+ }
+
my $response = $U->simplereq(
'open-ils.circ',
'open-ils.circ.holds.test_and_create.batch',