From b4c23e1a3e6ed5299cf41c9a29432b13f57654ff Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 1 Jun 2017 13:29:45 -0300 Subject: [PATCH] Bug 18789: Use Koha::Patron->image from the templates Now that we have the 'patron' variable in all our templates, we can call Koha::Patron->image and do the check from the templates. Test plan: On the different pages of the patron module, you should see the default image if there is no image attached or the one that has been attached (see pref patronimages) Signed-off-by: Kyle M Hall Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- circ/circulation.pl | 1 - .../intranet-tmpl/prog/en/includes/circ-menu.inc | 4 ++-- .../prog/en/modules/members/moremember.tt | 12 ++++++------ members/boraccount.pl | 2 -- members/deletemem.pl | 1 - members/discharge.pl | 2 -- members/files.pl | 1 - members/housebound.pl | 4 +--- members/mancredit.pl | 1 - members/maninvoice.pl | 1 - members/member-flags.pl | 2 -- members/member-password.pl | 2 -- members/moremember.pl | 5 ----- members/notices.pl | 2 -- members/pay.pl | 3 --- members/paycollect.pl | 4 ---- members/printfeercpt.pl | 2 -- members/printinvoice.pl | 2 -- members/purchase-suggestions.pl | 2 -- members/readingrec.pl | 2 -- members/routing-lists.pl | 2 -- members/statistics.pl | 2 -- 22 files changed, 9 insertions(+), 50 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index aa98f9af1f..5657bfb525 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -619,7 +619,6 @@ if ( $patron ) { categoryname => $patron->category->description, expiry => $patron->dateexpiry, is_child => ( $patron->category->category_type eq 'C' ), - picture => ( $patron->image ? 1 : 0 ), ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index 2b29bfcb9e..dce95f1daf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -7,7 +7,7 @@
    [% IF ( patronimages ) %] - [% IF ( picture ) %] + [% IF ( patron.image ) %]
  • [% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])
  • @@ -97,7 +97,7 @@ [% IF ( logview ) %]
  • [% ELSE %]
  • [% END %]Modification log
  • [% END %] [% IF CAN_user_borrowers_edit_borrowers %] - [% IF ( sentnotices ) %]
  • [% ELSE %]
  • [% END %]Notices
  • + [% IF ( sentnotices ) %]
  • [% ELSE %]
  • [% END %]Notices
  • [% END %] [% IF CAN_user_borrowers_edit_borrowers %] [% IF ( statisticsview ) %]
  • [% ELSE %]
  • [% END %]Statistics
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index e1af48d5b2..44cdb94df9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -186,7 +186,7 @@ [% IF ( CAN_user_tools_batch_upload_patron_images ) %]
    - [% IF ( picture ) %] + [% IF ( patron.image ) %] Manage patron image
    To update the image for [% patron.title | html %] [% patron.surname | html %], select a new image file and click 'Upload.'
    Click the 'Delete' button to remove the current image. [% ELSE %] @@ -207,7 +207,7 @@ - [% IF ( picture ) %]Delete[% END %] + [% IF ( patron.image ) %]Delete[% END %]
    @@ -297,7 +297,7 @@
  • Borrowernumber: [% patron.borrowernumber %]
  • Category: [% patron.category.description %] ([% patron.categorycode %])
  • Registration date: [% patron.dateenrolled | $KohaDates %]
  • - +
  • Expiration date: [% IF ( was_renewed ) %] [% patron.dateexpiry | $KohaDates %] @@ -390,10 +390,10 @@
  • First name: [% patron.altcontactfirstname | html %]
  • Address: [% patron.altcontactaddress1 | html %]
  • Address 2: [% patron.altcontactaddress2 | html %]
  • -
  • City: [% patron.altcontactaddress3 | html %]
  • +
  • City: [% patron.altcontactaddress3 | html %]
  • [% IF ( patron.altcontactstate ) %]
  • State: [% patron.altcontactstate | html %]
  • [% END %]
  • ZIP/Postal code: [% patron.altcontactzipcode | html %]
  • - [% IF ( patron.altcontactcountry ) %]
  • Country: [% patron.altcontactcountry | html %]
  • [% END %] + [% IF ( patron.altcontactcountry ) %]
  • Country: [% patron.altcontactcountry | html %]
  • [% END %] [% IF ( patron.altcontactphone ) %]
  • Phone: [% patron.altcontactphone | html %]
  • [% END %] @@ -606,7 +606,7 @@ ], "bPaginate": false })); - [% IF ( picture ) %] + [% IF ( patron.image ) %] $('#delpicture').click(function(){ return confirm(_("Are you sure you want to delete this patron image? This cannot be undone.")); }); diff --git a/members/boraccount.pl b/members/boraccount.pl index c07239a711..f4bf63f45f 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -98,8 +98,6 @@ foreach my $accountline ( @{$accts}) { $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ ); -$template->param( picture => 1 ) if $patron->image; - if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($borrowernumber); $template->param( diff --git a/members/deletemem.pl b/members/deletemem.pl index c67586f3cf..ec5abe167b 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -108,7 +108,6 @@ my $op = $input->param('op') || 'delete_confirm'; my $dbh = C4::Context->dbh; my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member); if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_guarantor or $deletelocal == 0) { - $template->param( picture => 1 ) if $patron->image; $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/; diff --git a/members/discharge.pl b/members/discharge.pl index bd425684f9..db74cfcd1c 100755 --- a/members/discharge.pl +++ b/members/discharge.pl @@ -103,8 +103,6 @@ my @validated_discharges = Koha::Patron::Discharge::get_validated({ borrowernumber => $borrowernumber, }); -$template->param( picture => 1 ) if $patron->image; - $template->param( patron => $patron, can_be_discharged => $can_be_discharged, diff --git a/members/files.pl b/members/files.pl index 8a1f66d740..4fc42fc1ac 100755 --- a/members/files.pl +++ b/members/files.pl @@ -114,7 +114,6 @@ else { ); } - $template->param( picture => 1 ) if $patron->image; $template->param( adultborrower => 1 ) if ( $patron_category->category_type eq 'A' || $patron_category->category_type eq 'I' ); diff --git a/members/housebound.pl b/members/housebound.pl index c659d0c14e..0e52085193 100755 --- a/members/housebound.pl +++ b/members/housebound.pl @@ -62,9 +62,8 @@ my $patron = Koha::Patrons->find($borrowernumber); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); # Get supporting cast -my ( $branch, $category, $houseboundprofile, $visit, $patron_image ); +my ( $branch, $category, $houseboundprofile, $visit ); if ( $patron ) { # FIXME This test is not needed - output_and_exit_if_error handles it - $patron_image = $patron->image; $category = Koha::Patron::Categories->new->find($patron->categorycode); $houseboundprofile = $patron->housebound_profile; } @@ -170,7 +169,6 @@ if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) { $template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' ); $template->param( - picture => $patron_image, housebound_profile => $houseboundprofile, visit => $houseboundvisit, messages => \@messages, diff --git a/members/mancredit.pl b/members/mancredit.pl index ac6df223f6..fe7c24be05 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -86,7 +86,6 @@ if ($add){ } $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ ); - $template->param( picture => 1 ) if $patron->image; if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($borrowernumber); diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 117a7ae21d..22711649dd 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -114,7 +114,6 @@ if ($add){ } $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ ); - $template->param( picture => 1 ) if $patron->image; if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($borrowernumber); diff --git a/members/member-flags.pl b/members/member-flags.pl index be9dc08653..bc6237e4b0 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -18,7 +18,6 @@ use Koha::Patron::Categories; use Koha::Patrons; use C4::Output; -use Koha::Patron::Images; use Koha::Token; my $input = new CGI; @@ -189,7 +188,6 @@ if ($input->param('newflags')) { } $template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ ); - $template->param( picture => 1 ) if $patron->image; if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'}); diff --git a/members/member-password.pl b/members/member-password.pl index 3d72349d10..6a078258bd 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -103,8 +103,6 @@ if ( $category_type eq 'C') { $template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ ); -$template->param( picture => 1 ) if $patron->image; - if ( C4::Context->preference('ExtendedPatronAttributes') ) { my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} ); $template->param( diff --git a/members/moremember.pl b/members/moremember.pl index 888fe914e6..be981f99ab 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -53,7 +53,6 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::AuthorisedValues; use Koha::CsvProfiles; use Koha::Patron::Debarments qw(GetDebarments); -use Koha::Patron::Images; use Koha::Patron::Messages; use Module::Load; if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { @@ -275,10 +274,6 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen } } -# check to see if patron's image exists in the database -# basically this gives us a template var to condition the display of -# patronimage related interface on -$template->param( picture => 1 ) if $patron->image; # Generate CSRF token for upload and delete image buttons $template->param( csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}), diff --git a/members/notices.pl b/members/notices.pl index 4537138203..0541fd834f 100755 --- a/members/notices.pl +++ b/members/notices.pl @@ -51,8 +51,6 @@ my ($template, $loggedinuser, $cookie) my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); -$template->param( picture => 1 ) if $patron->image; - # Allow resending of messages in Notices tab my $op = $input->param('op') || q{}; if ( $op eq 'resend_notice' ) { diff --git a/members/pay.pl b/members/pay.pl index cb612315d8..c42c631e72 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -40,7 +40,6 @@ use C4::Koha; use C4::Overdues; use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Patrons; -use Koha::Patron::Images; use Koha::Patron::Categories; use URI::Escape; @@ -140,8 +139,6 @@ sub add_accounts_to_template { } borrower_add_additional_fields($patron->unblessed); - my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber}); - $template->param( picture => 1 ) if $patron_image; $template->param( patron => $patron, accounts => \@accounts, diff --git a/members/paycollect.pl b/members/paycollect.pl index 9a14284aba..5d8d994a53 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -27,7 +27,6 @@ use C4::Members; use C4::Members::Attributes qw(GetBorrowerAttributes); use C4::Accounts; use C4::Koha; -use Koha::Patron::Images; use Koha::Patrons; use Koha::Account; use Koha::Token; @@ -200,9 +199,6 @@ sub borrower_add_additional_fields { $b_ref->{adultborrower} = 1; } - my $patron_image = Koha::Patron::Images->find($b_ref->{borrowernumber}); - $template->param( picture => 1 ) if $patron_image; - if (C4::Context->preference('ExtendedPatronAttributes')) { $b_ref->{extendedattributes} = GetBorrowerAttributes($b_ref->{borrowernumber}); } diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl index 36a0aa4131..8979ae6c19 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -116,8 +116,6 @@ for (my $i=0;$i<$numaccts;$i++){ $template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' ); -$template->param( picture => 1 ) if $patron->image; - $template->param( patron => $patron, finesview => 1, diff --git a/members/printinvoice.pl b/members/printinvoice.pl index d553713cd8..7b110e9a19 100755 --- a/members/printinvoice.pl +++ b/members/printinvoice.pl @@ -116,8 +116,6 @@ for ( my $i = 0 ; $i < $numaccts ; $i++ ) { $template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' ); -$template->param( picture => 1 ) if $patron->image; - $template->param( patron => $patron, finesview => 1, diff --git a/members/purchase-suggestions.pl b/members/purchase-suggestions.pl index 74ca8f7bb1..026ab89209 100755 --- a/members/purchase-suggestions.pl +++ b/members/purchase-suggestions.pl @@ -60,8 +60,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) { ); } -$template->param( picture => 1 ) if $patron->image; - my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } ); $template->param( suggestions => $suggestions ); diff --git a/members/readingrec.pl b/members/readingrec.pl index 295a43cd42..327c5732d1 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -104,8 +104,6 @@ if (! $limit){ $limit = 'full'; } -$template->param( picture => 1 ) if $patron->image; - if (C4::Context->preference('ExtendedPatronAttributes')) { my $attributes = GetBorrowerAttributes($patron->borrowernumber); $template->param( diff --git a/members/routing-lists.pl b/members/routing-lists.pl index 28d4d1cb10..ff2de5189d 100755 --- a/members/routing-lists.pl +++ b/members/routing-lists.pl @@ -88,6 +88,4 @@ if (C4::Context->preference('ExtendedPatronAttributes')) { ); } -$template->param( picture => 1 ) if $patron and $patron->image; - output_html_with_http_headers $query, $cookie, $template->output; diff --git a/members/statistics.pl b/members/statistics.pl index c268f0ef7f..98c157e404 100755 --- a/members/statistics.pl +++ b/members/statistics.pl @@ -84,8 +84,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) { ); } -$template->param( picture => 1 ) if $patron->image; - $template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' ); $template->param( -- 2.39.5