From 029c4b334de1d5c0727ee840a91f114072c52995 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 6 May 2013 10:56:03 -0400 Subject: [PATCH] Bug 10201 - Old OPAC patron update system should be removed The old pages for viewing and updating patron details in the OPAC have been superceded by the new script opac-memberentry.pl. This patch removes he old scripts and templates and corrects links to them. This patch also removes reference to opac-userupdate.tt from opac-patron-image.pl and replaces the authentication process with one which uses check_cookie_auth, based on the example of opac-tags.pl. To test, edit a patron record and set the "Gone no address" flag. Log in to the OPAC with that account and view the patron details page. The warning about out of date contact information should link to the new update page. Next, attempt to place a hold. You should see the same warning, and it should also link to the new update page. Test the display of patron images: Log in as a user who has an image associated with their account and navigate to /cgi-bin/koha/opac-patron-image.pl. Their patron image should display. A search of Koha source files should return no results for the missing scripts or templates. Signed-off-by: Mirko Tietgen Signed-off-by: Katrin Fischer Comments on second patch. Signed-off-by: Jared Camins-Esakov --- .../opac-tmpl/prog/en/modules/opac-reserve.tt | 4 +- .../opac-tmpl/prog/en/modules/opac-user.tt | 2 +- .../prog/en/modules/opac-userdetails.tt | 87 -------- .../prog/en/modules/opac-userupdate.tt | 195 ------------------ opac/opac-patron-image.pl | 25 +-- opac/opac-userdetails.pl | 56 ----- opac/opac-userupdate.pl | 188 ----------------- 7 files changed, 14 insertions(+), 543 deletions(-) delete mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt delete mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt delete mode 100755 opac/opac-userdetails.pl delete mode 100755 opac/opac-userupdate.pl diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt index 65b177b12b..85f1c3008d 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt @@ -166,8 +166,8 @@ [% IF ( message ) %] [% IF ( GNA ) %]
-

Sorry, you cannot place holds because the library doesn't have up-to-date contact information on file.

-

Please contact your librarian, or use the online update form to submit current information (Please note: there may be a delay in restoring your account if you submit online)

+

Sorry, you cannot place holds because the library doesn't have up-to-date contact information on file.

+

Please contact your librarian, or use the online update form to submit current information (Please note: there may be a delay in restoring your account if you submit online)

[% END %] [% IF ( lost ) %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt index 96f6e8d35d..8b765f6b09 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt @@ -105,7 +105,7 @@ $.tablesorter.addParser({
  • Please note: Your account has been frozen[% IF ( BORROWER_INF.userdebarreddate ) %] until [% BORROWER_INF.userdebarreddate | $KohaDates %][% END %][% IF ( BORROWER_INF.debarredcomment ) %] with the comment "[% BORROWER_INF.debarredcomment %]"[% END %]. Usually the reason for freezing an account is old overdues or damage fees. If your account page shows your account to be clear, please contact the library.
  • [% END %] [% IF ( BORROWER_INF.gonenoaddress ) %] -
  • Please note: According to our records, we don't have up-to-date [% UNLESS ( BORROWER_INF.OPACPatronDetails ) %]contact information[% ELSE %]contact information[% END %] on file. Please contact the library[% IF ( BORROWER_INF.OPACPatronDetails ) %] or use the online update form to submit current information (Please note: there may be a delay in restoring your account if you submit online)[% END %].
  • +
  • Please note: According to our records, we don't have up-to-date [% UNLESS ( BORROWER_INF.OPACPatronDetails ) %]contact information[% ELSE %]contact information[% END %] on file. Please contact the library[% IF ( BORROWER_INF.OPACPatronDetails ) %] or use the online update form to submit current information (Please note: there may be a delay in restoring your account if you submit online)[% END %].
  • [% END %] [% IF ( BORROWER_INF.lost ) %]
  • Please note: Your library card has been marked as lost or stolen. If this is an error, please contact the library.
  • diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt deleted file mode 100644 index e695a7aa84..0000000000 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt +++ /dev/null @@ -1,87 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your personal details -[% INCLUDE 'doc-head-close.inc' %] - - -
    -
    -[% INCLUDE 'masthead.inc' %] - -
    -
    - -

    [% firstname %] [% surname %]'s account ⇢ Personal details

    - - - - -
    Name: [% firstname %] [% surname %]
    -Card number:[% cardnumber %]
    - - - - - - - - - - - - - - - -
    Contact details
    Mailing address:[% address %], [% city %]
    Permanent address: [% B_address %], [% B_address2 %], [% B_city %]
    Primary phone:[% IF ( phone ) %][% phone %][% ELSE %] [% END %]
    Secondary phone:[% IF ( mobile ) %][% mobile %][% ELSE %] [% END %]
    Fax:[% IF ( fax ) %][% fax %][% ELSE %] [% END %]
    Email:[% IF ( email ) %][% email %][% ELSE %] [% END %]
    - - - - - - - - - - - - - -[% IF ( joiningbranch ) %][% ELSE %] [% END %]
    Membership details
    Membership number: [% borrowernumber %]
    Membership category: [% categorycode %]
    Joined:[% dateenrolled %]
    Expires:[% dateexpiry %]
    Joining library:[% joiningbranch %]
    - - - - - -
    Identity details
    DoB: [% IF ( dateofbirth ) %][% dateofbirth %][% ELSE %] [% END %]
    Gender:[% IF ( sex ) %][% sex %][% ELSE %] [% END %]
    - -[% IF ( contactname ) %] - - - - - - - - - - -
    Alternate contact details
    Alternate contact: [% IF ( contactname ) %][% contactname %][% ELSE %] [% END %]
    Phone: [% IF ( B_phone ) %][% B_phone %][% ELSE %] [% END %]
    Relationship: [% IF ( relationship ) %][% relationship %][% ELSE %] [% END %]
    Notes: [% IF ( contactnote ) %][% contactnote %][% ELSE %] [% END %]
    Guarantor: [% IF ( guarantorid ) %][% guarantorid %][% ELSE %] [% END %]
    - -[% ELSE %] -

    No alternate contact on file.

    -[% END %] - -
    - -
    - -
    -
    -
    -
    -
    -[% INCLUDE 'navigation.inc' %] -[% INCLUDE 'usermenu.inc' %] -
    -
    -
    -[% INCLUDE 'opac-bottom.inc' %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt deleted file mode 100644 index 320b30b77f..0000000000 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt +++ /dev/null @@ -1,195 +0,0 @@ -[% USE KohaDates %] - -[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %][% ELSE %]Koha online[% END %] catalog › Your personal details -[% INCLUDE 'doc-head-close.inc' %] - - -
    -
    -[% INCLUDE 'masthead.inc' %] - -
    -
    - -
    -[% FOREACH BORROWER_INF IN BORROWER_INFO %] -

    [% INCLUDE 'patron-title.inc' firstname = BORROWER_INF.firstname surname = BORROWER_INF.surname othernames = BORROWER_INF.othernames cardnumber = BORROWER_INF.cardnumber %]'s account ⇢ Your personal details

    - -[% IF ( OPACPatronDetails ) %] -
    -
    - -[% IF ( display_patron_image ) %]

    - -

    [% END %] -
    Name
      -
    1. -
    2. -
    3. -
    -
    - -
    Contact information -
      -
    1. - - -
    2. -
    3. -
    4. -
    5. -
    6. -
    7. -
    8. -
    9. -
    10. -
    11. -
    12. -
    -
    - -
    -
    -
    -Alternate contact information -
      -
    1. - - - - -
    2. - -
    3. -
    4. -
    5. -
    6. -
    7. -
    8. -
    -
    -
    -
      -
    1. -
    2. -
    -
    -Library use: -
      -
    1. -
    2. -
    3. -
    4. -
    5. -
    6. - [% IF ( BORROWER_INF.ExtendedPatronAttributes ) %] - [% FOREACH patron_attribute IN BORROWER_INF.patron_attributes %] -
    7. - [% IF ( patron_attribute.value_description ) %] - [% patron_attribute.value_description %]" - [% ELSE %] - [% patron_attribute.value |html_line_break %] - [% END %] -
    8. - [% END %] - [% END %] -
    -
    -
    -

    Please make any necessary changes to your record. Submitting the form will notify a library staff member, who will make the changes permanent.

    - Cancel
    -
    - -
    -[% ELSE %] -

    To make changes to your record please contact the library.

    -
    -[% IF ( display_patron_image ) %]

    - -

    [% END %] -
    -Contact information -
      -
    1. Name: [% BORROWER_INF.firstname %] [% BORROWER_INF.surname %]
    2. -
    3. Other name: [% BORROWER_INF.othernames %]
    4. -
    5. Address: [% BORROWER_INF.streetnumber %] [% BORROWER_INF.address %]
    6. -
    7.  [% BORROWER_INF.address2 %]
    8. -
    9. City: [% BORROWER_INF.city %]
    10. -
    11. State: [% BORROWER_INF.state %]
    12. -
    13. Zip code: [% BORROWER_INF.zipcode %]
    14. -
    15. Country: [% BORROWER_INF.country %]
    16. -
    17. Primary phone: [% BORROWER_INF.phone %]
    18. -
    19. Secondary phone: [% BORROWER_INF.mobile %]
    20. -
    21. Other phone: [% BORROWER_INF.phonepro %]
    22. -
    23. Fax: [% BORROWER_INF.fax %]
    24. -
    25. Primary email: [% BORROWER_INF.email %]
    26. -
    27. Secondary email: [% BORROWER_INF.emailpro %]
    28. -
    -
    - -
    -Personal information -
      -
    1. Date of birth: [% BORROWER_INF.dateofbirth | $KohaDates %]
    2. -
    3. Gender: -[% IF ( sex == 'F' ) %]Female[% END %] -[% IF ( sex == 'M' ) %]Male[% END %] -
    4. -
    -
    -
    - -
    -
    -Alternate contact information -
      -
    1. Alternate address: [% BORROWER_INF.B_streetnumber %] [% BORROWER_INF.B_address %]
    2. -
    3.  [% BORROWER_INF.B_address2 %]
    4. -
    5. City: [% BORROWER_INF.B_city %]
    6. -
    7. State: [% BORROWER_INF.B_state %]
    8. -
    9. Zip code: [% BORROWER_INF.B_zipcode %]
    10. -
    11. Country: [% BORROWER_INF.B_country %]
    12. -
    13. Phone: [% BORROWER_INF.B_phone %]
    14. -
    15. Email: [% BORROWER_INF.B_email %]
    16. -
    -
    - -
    -Library use: -
      -
    1. Card number: [% BORROWER_INF.cardnumber %]
    2. -
    3. Home library: [% BORROWER_INF.branchname %]
    4. -
    5. Patron number: [% BORROWER_INF.borrowernumber %]
    6. -
    7. Patron category: [% BORROWER_INF.description %] ([% BORROWER_INF.categorycode %])
    8. -
    9. Joined: [% BORROWER_INF.dateenrolled | $KohaDates %]
    10. -
    11. Expires: [% BORROWER_INF.dateexpiry | $KohaDates %]
    12. - [% IF ( BORROWER_INF.ExtendedPatronAttributes ) %] - [% FOREACH patron_attribute IN BORROWER_INF.patron_attributes %] -
    13. [% patron_attribute.description %] - [% IF ( patron_attribute.value_description ) %] - [% patron_attribute.value_description %] - [% ELSE %] - [% patron_attribute.value %] - [% END %] -
    14. - [% END %] - [% END %] -
    -
    -
    -[% END %] -[% END %] -
    -
    -
    -
    -
    -
    -[% INCLUDE 'navigation.inc' IsPatronPage=1 %] -
    -
    -
    -[% INCLUDE 'opac-bottom.inc' %] diff --git a/opac/opac-patron-image.pl b/opac/opac-patron-image.pl index 1935beab0f..d1f4489476 100755 --- a/opac/opac-patron-image.pl +++ b/opac/opac-patron-image.pl @@ -21,27 +21,24 @@ use strict; use warnings; use C4::Members; -use C4::Auth; -my $query = new CGI; +use CGI; +use CGI::Cookie; # need to check cookies before having CGI parse the POST request +use C4::Auth qw(:DEFAULT check_cookie_auth); -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-userupdate.tt", - query => $query, - type => "opac", - authnotrequired => 0, - flagsrequired => { borrow => 1 }, - debug => 1, - } -); +my $query = new CGI; unless (C4::Context->preference('OPACpatronimages')) { print $query->header(status => '403 Forbidden - displaying patron images in the OPAC not enabled'); exit; } -my ($borrower)=GetMember('borrowernumber' => $borrowernumber); -my $cardnumber = $borrower->{'cardnumber'}; +my $needed_flags; +my %cookies = fetch CGI::Cookie; +my $sessid = $cookies{'CGISESSID'}->value; +my ($auth_status, $auth_sessid) = check_cookie_auth($sessid, $needed_flags); +my $borrowernumber = C4::Context->userenv->{'number'}; +my $cardnumber = C4::Context->userenv->{'cardnumber'}; + my ($imagedata, $dberror) = GetPatronImage($cardnumber); if ($dberror) { diff --git a/opac/opac-userdetails.pl b/opac/opac-userdetails.pl deleted file mode 100755 index ac10002c5c..0000000000 --- a/opac/opac-userdetails.pl +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use CGI; - -use C4::Auth; -use C4::Koha; -use C4::Circulation; - -use C4::Output; -use C4::Dates qw/format_date/; -use C4::Members; - -my $query = new CGI; -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-userdetails.tmpl", - query => $query, - type => "opac", - authnotrequired => 0, - flagsrequired => { borrow => 1 }, - debug => 1, - } -); - -# get borrower information .... -my ( $borr ) = GetMemberDetails( $borrowernumber ); - -$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} ); -$borr->{'dateexpiry'} = format_date( $borr->{'dateexpiry'} ); -$borr->{'dateofbirth'} = format_date( $borr->{'dateofbirth'} ); -$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); - -$template->param($borr); - -output_html_with_http_headers $query, $cookie, $template->output; - diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl deleted file mode 100755 index 3b90498ef5..0000000000 --- a/opac/opac-userupdate.pl +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use CGI; -use Mail::Sendmail; -use Encode; - -use C4::Auth; # checkauth, getborrowernumber. -use C4::Context; -use C4::Koha; -use C4::Circulation; -use C4::Output; -use C4::Dates qw/format_date/; -use C4::Members; -use C4::Members::Attributes; -use C4::Branch; - -my $query = new CGI; - -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-userupdate.tmpl", - query => $query, - type => "opac", - authnotrequired => 0, - flagsrequired => { borrow => 1 }, - debug => 1, - } -); - -# get borrower information .... -my ( $borr ) = GetMemberDetails( $borrowernumber ); -my ( $patronemail ) = GetFirstValidEmailAddress($borrowernumber); -my $lib = GetBranchDetail($borr->{'branchcode'}); - -# handle the new information.... -# collect the form values and send an email. -my @fields = ( - 'surname','firstname','othernames','streetnumber','address','address2','city','state','zipcode','country','phone','mobile','fax','phonepro', 'emailaddress','emailpro','B_streetnumber','B_address','B_address2','B_city','B_state','B_zipcode','B_country','B_phone','B_email','dateofbirth','sex' -); -my $update; -my $updateemailaddress = $lib->{'branchemail'}; -$updateemailaddress = C4::Context->preference('KohaAdminEmailAddress') unless( $updateemailaddress =~ /\w+@\w+/); -if ( !$updateemailaddress || $updateemailaddress eq '' ) { - warn -"KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n"; - my ($template) = get_template_and_user( - { - template_name => "kohaerror.tmpl", - query => $query, - type => "opac", - authnotrequired => 1, - flagsrequired => { borrow => 1 }, - debug => 1, - } - ); - - $template->param( - noadminemail => 1, - ); - - output_html_with_http_headers $query, $cookie, $template->output; - exit; -} - -if ( !$patronemail || $patronemail eq '' ) { - $patronemail = $updateemailaddress; -}; - -if ( $query->param('modify') ) { - - # get all the fields: - my $message = <<"EOF"; -Patron $borr->{'cardnumber'} has requested to change her/his personal details. -Please check these new details and make the changes to these fields: - -EOF - - my $streetnumber = $borr->{'streetnumber'} || ''; - my $address = $borr->{'address'} || ''; - my $address2 = $borr->{'address2'} || ''; - my $B_streetnumber = $borr->{'B_streetnumber'} || ''; - my $B_address = $borr->{'B_address'} || ''; - my $B_address2 = $borr->{'B_address2'} || ''; - - foreach my $field (@fields) { - my $newfield = decode('utf-8',$query->param($field)) || ''; - my $borrowerfield = ''; - if($borr->{$field}) { - $borrowerfield = $borr->{$field}; - } - - if($field eq "dateofbirth") { - $borrowerfield = format_date( $borr->{'dateofbirth'} ) || ''; - } - - if($borrowerfield ne $newfield) { - $message .= $field . " : $borrowerfield --> $newfield\n"; - } - } - - $message .= "\nEdit this patron's record: http://".C4::Context->preference('staffClientBaseURL ')."/cgi-bin/koha/members/memberentry.pl?op=modify&borrowernumber=".$borr->{'borrowernumber'}."&categorycode=".$borr->{'categorycode'} if C4::Context->preference('staffClientBaseURL '); - - $message .= "\n\nThanks,\nKoha\n\n"; - my %mail = ( - To => $updateemailaddress, - From => $patronemail, - Subject => "User Request for update of Record.", - Message => encode('utf-8', $message), # Mail::Sendmail doesn't like wide characters - 'Content-Type' => 'text/plain; charset="utf-8"', - ); - - if ( sendmail %mail ) { - - # do something if it works.... - print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent'); - exit; - } - else { - - # do something if it doesnt work.... - warn "Error sending mail: $Mail::Sendmail::error \n"; - } -} - -$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); -$borr->{'branchname'} = GetBranchName($borr->{'branchcode'}); - -if (C4::Context->preference('ExtendedPatronAttributes')) { - my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber, 'opac'); - if (scalar(@$attributes) > 0) { - $borr->{ExtendedPatronAttributes} = 1; - $borr->{patron_attributes} = $attributes; - } -} - -my $checkin_prefs = C4::Members::Messaging::GetMessagingPreferences({ - borrowernumber => $borrowernumber, - message_name => 'Item Checkout' -}); -for ( keys %{ $checkin_prefs->{transports} }) { - $borr->{"items_returned_$_"} = 1; -} -my $checkout_prefs = C4::Members::Messaging::GetMessagingPreferences({ - borrowernumber => $borrowernumber, - message_name => 'Item Check-in' -}); -for ( keys %{ $checkout_prefs->{transports} }) { - $borr->{"items_borrowed_$_"} = 1; -} - -if (C4::Context->preference('OPACpatronimages')) { - my ($image, $dberror) = GetPatronImage($borr->{'cardnumber'}); - if ($image) { - $template->param( - display_patron_image => 1 - ); - } -} - -my @bordat; -$bordat[0] = $borr; - -$template->param( - BORROWER_INFO => \@bordat, - userupdateview => 1, -); - -output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5