}
my $ahr = construct_hold_request_object($params);
- my ($res2) = $self->method_lookup(
- $override
- ? 'open-ils.circ.holds.create.override'
- : 'open-ils.circ.holds.create'
- )->run($auth, $ahr, $oargs);
+ my ($res2) = create_hold($auth, $ahr, $oargs, $override);
$res2 = {
'target' => $$params{$target_field},
'result' => $res2
}
my $ahr = construct_hold_request_object($params);
- my ($res2) = $self->method_lookup(
- $override
- ? 'open-ils.circ.holds.create.override'
- : 'open-ils.circ.holds.create'
- )->run($auth, $ahr, $oargs);
+ my ($res2) = create_hold($auth, $ahr, $oargs, $override);
$res2 = {
total => $total, count => $count,
'patronid' => $$params{patronid},
return $ahr;
}
-__PACKAGE__->register_method(
- method => "create_hold_batch",
- api_name => "open-ils.circ.holds.create.batch",
- stream => 1,
- signature => {
- desc => q/@see open-ils.circ.holds.create.batch/,
- params => [
- { desc => 'Authentication token', type => 'string' },
- { desc => 'Array of hold objects', type => 'array' }
- ],
- return => {
- desc => 'Array of hold ID on success, -1 on missing arg, event (or ref to array of events) on error(s)',
- },
- }
-);
-
-__PACKAGE__->register_method(
- method => "create_hold_batch",
- api_name => "open-ils.circ.holds.create.override.batch",
- stream => 1,
- signature => {
- desc => '@see open-ils.circ.holds.create.batch',
- }
-);
-
-
-sub create_hold_batch {
- my( $self, $conn, $auth, $hold_list, $oargs ) = @_;
- (my $method = $self->api_name) =~ s/\.batch//og;
- foreach (@$hold_list) {
- my ($res) = $self->method_lookup($method)->run($auth, $_, $oargs);
- $conn->respond($res);
- }
- return undef;
-}
-
-
-__PACKAGE__->register_method(
- method => "create_hold",
- api_name => "open-ils.circ.holds.create",
- signature => {
- desc => "Create a new hold for an item. From a permissions perspective, " .
- "the login session is used as the 'requestor' of the hold. " .
- "The hold recipient is determined by the 'usr' setting within the hold object. " .
- 'First we verify the requestor has holds request permissions. ' .
- 'Then we verify that the recipient is allowed to make the given hold. ' .
- 'If not, we see if the requestor has "override" capabilities. If not, ' .
- 'a permission exception is returned. If permissions allow, we cycle ' .
- 'through the set of holds objects and create. ' .
- 'If the recipient does not have permission to place multiple holds ' .
- 'on a single title and said operation is attempted, a permission ' .
- 'exception is returned',
- params => [
- { desc => 'Authentication token', type => 'string' },
- { desc => 'Hold object for hold to be created',
- type => 'object', class => 'ahr' }
- ],
- return => {
- desc => 'New ahr ID on success, -1 on missing arg, event (or ref to array of events) on error(s)',
- },
- }
-);
-
-__PACKAGE__->register_method(
- method => "create_hold",
- api_name => "open-ils.circ.holds.create.override",
- notes => '@see open-ils.circ.holds.create',
- signature => {
- desc => "If the recipient is not allowed to receive the requested hold, " .
- "call this method to attempt the override",
- params => [
- { desc => 'Authentication token', type => 'string' },
- {
- desc => 'Hold object for hold to be created',
- type => 'object', class => 'ahr'
- }
- ],
- return => {
- desc => 'New hold (ahr) ID on success, -1 on missing arg, event (or ref to array of events) on error(s)',
- },
- }
-);
-
sub create_hold {
- my( $self, $conn, $auth, $hold, $oargs ) = @_;
+ my( $self, $conn, $auth, $hold, $oargs, $override) = @_;
return -1 unless $hold;
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
- my $override = 0;
- if ($self->api_name =~ /override/) {
- $override = 1;
+ if ($override) {
$oargs = { all => 1 } unless defined $oargs;
}