From 0f82f6c71eb75d79584c162ba22c46c5a4165fb6 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 21 Feb 2019 10:47:25 -0500 Subject: [PATCH] LP#1749475 Improve API variable handling Because we are using positional arguments, but the position is off by one due to the previous API, these arguments were difficult to assign cleanly. This is an attempt to make it a little more legible, though ultimately, we should strongly consider an options hash for the new additions. Signed-off-by: Dan Wells Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Search/Biblio.pm | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index ae4490fe54..36af9358f4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -1914,6 +1914,7 @@ __PACKAGE__->register_method( { desc => 'Biblio record entry ID or array of IDs', type => 'number' }, { desc => 'Context library for holdings, if applicable' => 'number' }, { desc => 'Sort order, if applicable' => 'string' }, + { desc => 'Sort direction, if applicable' => 'string' }, { desc => 'Definition Group Member id' => 'number' }, ], return => { @@ -1946,32 +1947,31 @@ __PACKAGE__->register_method( ); sub format_biblio_record_entry { - my($self, $conn, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $captcha_pass, $email, $subject) = @_; + my ($self, $conn) = splice @_, 0, 2; my $for_print = ($self->api_name =~ /print/); my $for_email = ($self->api_name =~ /email/); my $preview = ($self->api_name =~ /preview/); - my $e; my $auth; my $bib_id; my $context_org; my $holdings_context; my $bib_sort; my $group_member; my $type = 'brief'; my $sort_dir; + my ($auth, $captcha_pass, $email, $subject); + if ($for_email) { + $auth = shift @_; + ($captcha_pass, $email, $subject) = splice @_, -3, 3; + } + my ($bib_id, $holdings_context, $bib_sort, $sort_dir, $group_member) = @_; + $holdings_context ||= $U->get_org_tree->id; + $bib_sort ||= 'author'; + $sort_dir ||= 'ascending'; + + my $e; my $context_org; my $type = 'brief'; if ($for_print) { - $bib_id = $arg1; - $context_org = $arg2 || $U->get_org_tree->id; - $holdings_context = $context_org; - $bib_sort = $arg3 || 'author'; - $sort_dir = $arg4 || 'ascending'; - $group_member = $arg5; + $context_org = $holdings_context; $e = new_editor(xact => 1); } elsif ($for_email) { - $auth = $arg1; - $bib_id = $arg2; - $bib_sort = $arg4 || 'author'; - $sort_dir = $arg5 || 'ascending'; - $group_member = $arg6; $e = new_editor(authtoken => $auth, xact => 1); return $e->die_event unless $captcha_pass || $e->checkauth; - $holdings_context = $arg3 || $U->get_org_tree->id; - $context_org = $e->requestor ? $e->requestor->home_ou : $arg3; + $context_org = $e->requestor ? $e->requestor->home_ou : $holdings_context; $email ||= $e->requestor ? $e->requestor->email : ''; } -- 2.11.0