From 433bfb561ec18e1767a78b50c1bbd9d399396c74 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 10 Sep 2012 08:06:09 -0400 Subject: [PATCH] Bug 7067 - OPAC Borrower Self Registration - Followup Content-Type: text/plain; charset="utf-8" * Rename PatronSelfRegistrationUseTemporaryStatus to PatronSelfRegistrationDefaultCategory * Allow patron self registration via the opac - Followup - Hide register link unless PatronSelfRegistrationDefaultCategory is set. * Allow patron self registration via the opac - Followup - Add invalid token page --- C4/Auth.pm | 2 + C4/Members.pm | 11 +- C4/SQLHelper.pm | 15 ++-- Koha/Borrower/Modifications.pm | 32 ++++-- installer/data/mysql/sysprefs.sql | 4 +- installer/data/mysql/updatedatabase.pl | 4 +- .../prog/en/modules/admin/preferences/opac.pref | 2 +- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 3 +- .../prog/en/modules/members/members-update.tt | 113 ++++++++++---------- koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt | 2 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt | 2 +- .../opac-tmpl/prog/en/modules/opac-memberentry.tt | 45 ++++++-- .../prog/en/modules/opac-registration-invalid.tt | 30 +++++ mainpage.pl | 10 ++- members/members-update-do.pl | 2 +- members/members-update.pl | 10 ++- misc/cronjobs/delete_expired_opac_registrations.pl | 2 +- opac/opac-memberentry.pl | 29 +++--- opac/opac-registration-verify.pl | 34 ++++--- 19 files changed, 225 insertions(+), 127 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-registration-invalid.tt diff --git a/C4/Auth.pm b/C4/Auth.pm index cec68bc..78eb06a 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -458,6 +458,7 @@ sub get_template_and_user { SyndeticsCoverImageSize => C4::Context->preference("SyndeticsCoverImageSize"), OPACLocalCoverImages => C4::Context->preference("OPACLocalCoverImages"), PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"), + PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"), ); $template->param(OpacPublic => '1') if ($user || C4::Context->preference("OpacPublic")); @@ -969,6 +970,7 @@ sub checkauth { AutoLocation => C4::Context->preference("AutoLocation"), wrongip => $info{'wrongip'}, PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"), + PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"), ); $template->param( OpacPublic => C4::Context->preference("OpacPublic")); diff --git a/C4/Members.pm b/C4/Members.pm index 5cf65e3..879e3a8 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -757,10 +757,6 @@ sub AddMember { # generate a proper login if none provided $data{'userid'} = Generate_Userid($data{'borrowernumber'}, $data{'firstname'}, $data{'surname'}) if $data{'userid'} eq ''; - # create a disabled account if no password provided - $data{'password'} = ($data{'password'})? md5_base64($data{'password'}) : '!'; - $data{'borrowernumber'}=InsertInTable("borrowers",\%data); - # add expiration date if it isn't already there unless ( $data{'dateexpiry'} ) { $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, C4::Dates->new()->output("iso") ); @@ -771,6 +767,11 @@ sub AddMember { $data{'dateenrolled'} = C4::Dates->new()->output("iso"); } + # create a disabled account if no password provided + $data{'password'} = ($data{'password'})? md5_base64($data{'password'}) : '!'; + $data{'borrowernumber'}=InsertInTable("borrowers",\%data); + + # mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best. logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); @@ -2383,7 +2384,7 @@ sub GetBorrowersWithEmail { sub AddMember_Opac { my ( %borrower ) = @_; - $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationUseTemporaryStatus'); + $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); my $sr = new String::Random; $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ]; diff --git a/C4/SQLHelper.pm b/C4/SQLHelper.pm index e86d2b7..09a0e81 100644 --- a/C4/SQLHelper.pm +++ b/C4/SQLHelper.pm @@ -233,23 +233,24 @@ Get the Primary Key field names of the table =cut sub GetPrimaryKeys($) { - my $tablename=shift; - my $result; + my $tablename = shift; + + my @results; my $cache; if (Koha::Cache->is_cache_active()) { $cache = Koha::Cache->new(); if (defined $cache) { - $result = $cache->get_from_cache("sqlhelper:GetPrimaryKeys:$tablename"); + @results = $cache->get_from_cache("sqlhelper:GetPrimaryKeys:$tablename"); } } - unless (defined $result) { + unless (@results) { my $hash_columns=_get_columns($tablename); - $result = grep { $hash_columns->{$_}->{'Key'} =~/PRI/i} keys %$hash_columns; + @results = grep { $hash_columns->{$_}->{'Key'} =~/PRI/i} keys %$hash_columns; if (Koha::Cache->is_cache_active() && defined $cache) { - $cache->set_in_cache("sqlhelper:GetPrimaryKeys:$tablename", $result); + $cache->set_in_cache("sqlhelper:GetPrimaryKeys:$tablename", @results); } } - return $result; + return @results; } diff --git a/Koha/Borrower/Modifications.pm b/Koha/Borrower/Modifications.pm index a986599..f83b61d 100644 --- a/Koha/Borrower/Modifications.pm +++ b/Koha/Borrower/Modifications.pm @@ -144,17 +144,24 @@ Returns the number of pending modifications for existing borrowers. =cut sub GetPendingModificationsCount { - my ($self) = @_; + my ( $self, $branchcode ) = @_; my $dbh = C4::Context->dbh; my $query = " SELECT COUNT(*) AS count - FROM borrower_modifications - WHERE borrowernumber > 0 + FROM borrower_modifications, borrowers + WHERE borrower_modifications.borrowernumber > 0 + AND borrower_modifications.borrowernumber = borrowers.borrowernumber "; + my @params; + if ($branchcode) { + $query .= " AND borrowers.branchcode = ? "; + push( @params, $branchcode ); + } + my $sth = $dbh->prepare($query); - $sth->execute(); + $sth->execute(@params); my $result = $sth->fetchrow_hashref(); return $result->{'count'}; @@ -169,17 +176,24 @@ Returns an arrayref of hashrefs for all pending modifications for existing borro =cut sub GetPendingModifications { - my ($self) = @_; + my ( $self, $branchcode ) = @_; my $dbh = C4::Context->dbh; my $query = " - SELECT * - FROM borrower_modifications - WHERE borrowernumber > 0 + SELECT borrower_modifications.* + FROM borrower_modifications, borrowers + WHERE borrower_modifications.borrowernumber > 0 + AND borrower_modifications.borrowernumber = borrowers.borrowernumber "; + my @params; + if ($branchcode) { + $query .= " AND borrowers.branchcode = ? "; + push( @params, $branchcode ); + } + my $sth = $dbh->prepare($query); - $sth->execute(); + $sth->execute(@params); my @m; while ( my $row = $sth->fetchrow_hashref() ) { diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 861e430..409c5cd 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -374,7 +374,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'), ('PatronSelfRegistrationVerifyByEmail', '0', NULL, 'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.', 'YesNo'), -('PatronSelfRegistrationUseTemporaryStatus', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'), -('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationUseTemporaryStatus is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'), +('PatronSelfRegistrationDefaultCategory', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'), +('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'), ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'), ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 495b02f..d8b6b36 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5779,8 +5779,8 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'), ('PatronSelfRegistrationVerifyByEmail', '0', NULL, 'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.', 'YesNo'), - ('PatronSelfRegistrationUseTemporaryStatus', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'), - ('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationUseTemporaryStatus is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'), + ('PatronSelfRegistrationDefaultCategory', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'), + ('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'), ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'), ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free'); "); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index a2b005b..7e87a60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -515,7 +515,7 @@ OPAC: - "that a self-registering patron verify his or herself via email." - - "Use the patron category code" - - pref: PatronSelfRegistrationUseTemporaryStatus + - pref: PatronSelfRegistrationDefaultCategory class: short - "as the default patron category for patrons registered via the OPAC." - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 8242d23..8e9ecf4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -100,6 +100,7 @@
[% IF ( ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) + || ( CAN_user_borrowers && pending_borrower_modifications ) || ( CAN_user_acquisition && pendingsuggestions ) ) %]
[% IF ( CAN_user_acquisition && pendingsuggestions ) %] @@ -125,7 +126,7 @@ [% END %] - [% IF ( CAN_user_borrowers && pending_borrower_modifications )%] + [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
Patrons requesting modifications: [% pending_borrower_modifications %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt index 8878b7f..228ccf2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt @@ -64,72 +64,75 @@
+ [% IF PendingModifications %] +
- - - - - - - - - - - - - - - - +
ActionPatronChanges
ApproveDenyIgnore
+ + + + + + - - [% FOREACH pm IN PendingModifications %] - [% SET borrowernumber = pm.borrowernumber %] - - - + + + + + + + + [% FOREACH pm IN PendingModifications %] + [% SET borrowernumber = pm.borrowernumber %] + + + + - + -
ActionPatronChanges
- - - - - - ApproveDenyIgnore
+ + + + + + - [% borrowers.$borrowernumber.firstname %] [% borrowers.$borrowernumber.surname %] - + [% borrowers.$borrowernumber.firstname %] [% borrowers.$borrowernumber.surname %] + - - - - - - + - - [% END %] - -
FieldFromTo
+ + + + + + - [% FOREACH key IN pm.keys %] - [% IF field_display_names.$key %] - [% IF ( ( pm.$key OR borrowers.$borrowernumber.$key ) && ( pm.$key != borrowers.$borrowernumber.$key ) ) %] - - - - - + [% FOREACH key IN pm.keys %] + [% IF field_display_names.$key %] + [% IF ( ( pm.$key OR borrowers.$borrowernumber.$key ) && ( pm.$key != borrowers.$borrowernumber.$key ) ) %] + + + + + + [% END %] [% END %] [% END %] - [% END %] -
FieldFromTo
[% field_display_names.$key %][% borrowers.$borrowernumber.$key %][% pm.$key %]
[% field_display_names.$key %][% borrowers.$borrowernumber.$key %][% pm.$key %]
-
+
+ + + [% END %] + + -

+

-
+ + [% ELSE %] +

There are no pending patron modifications.

+ [% END %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt index b890529..6a6e1ee 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt @@ -86,7 +86,7 @@ please choose against which one you would like to authenticate:

Don't have a password yet?

If you don't have a password yet, stop by the circulation desk the next time you're in the library. We'll happily set one up for you.

-
Don't have a library card?

If you don't have a library card, stop by your local library to sign up[% IF PatronSelfRegistration %] or register here[% END %].

+
Don't have a library card?

If you don't have a library card, stop by your local library to sign up[% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %] or register here[% END %].

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt index db5c021..596ce52 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt @@ -55,7 +55,7 @@
  • - [% IF PatronSelfRegistration %]
    Don't have an account? Register here.
    [% END %] + [% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %]
    Don't have an account? Register here.
    [% END %]
    diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt index 38c0bc7..ac2cb02 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt @@ -7,7 +7,16 @@ @@ -21,6 +30,9 @@
    + [% UNLESS OPACPatronDetails %] +
    To make changes to your record please contact the library.
    + [% END %] [% IF empty_mandatory_fields %]
    You have not filled out all required fields. Please fill in all missing fields and resubmit.
    @@ -30,7 +42,7 @@
    You typed in the wrong characters in the box before submitting. Please try again.
    [% END %] -
    + [% UNLESS hidden.defined('branchcode') @@ -132,9 +144,11 @@ [% END %] Date of birth: - + - Clear date

    + [% UNLESS action == 'edit' && !OPACPatronDetails %] + Clear date

    + [% END %] [% IF mandatory.defined('dateofbirth') %]Required[% END %] @@ -682,16 +696,25 @@ [% END %] [% UNLESS action == 'edit' %] -

    Please type this following characters into the box below : [% captcha %]

    -

    - - -

    +
    +
      +
    1. + + + + + + Please type this following characters into the preceding box: [% captcha %] +
    2. +
    +
    [% END %] [% IF action == 'edit' %] - - + [% IF OPACPatronDetails %] + + + [% END %] [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-registration-invalid.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-registration-invalid.tt new file mode 100644 index 0000000..12dac1d --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-registration-invalid.tt @@ -0,0 +1,30 @@ +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog +[% INCLUDE 'doc-head-close.inc' %] + + +[% IF ( OpacNav ) %]
    [% ELSE %]
    [% END %] +
    +[% INCLUDE 'masthead.inc' %] + +
    +
    +
    +
    +

    Registration invalid!

    + +

    There were problems processing your registration. Please contact your library for help.

    + +
    +
    +
    +
    + +[% IF ( OpacNav ) %]
    +
    + [% INCLUDE 'navigation.inc' %] +
    +[% END %] + +
    +[% INCLUDE 'opac-bottom.inc' %] diff --git a/mainpage.pl b/mainpage.pl index 78dbe66..259380b 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -32,7 +32,7 @@ use Koha::Borrower::Modifications; my $query = new CGI; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( { template_name => "intranet-main.tmpl", query => $query, @@ -50,11 +50,17 @@ $template->param( koha_news_count => $koha_news_count ); +my $branch = + C4::Context->preference("IndependantBranches") + && !$flags->{'superlibrarian'} + ? C4::Context->userenv()->{'branch'} + : undef; + my $pendingcomments = numberofreviews(0); my $pendingtags = get_count_by_tag_status(0); my $pendingsuggestions = CountSuggestion("ASKED"); my $pending_borrower_modifications = - Koha::Borrower::Modifications->GetPendingModificationsCount(); + Koha::Borrower::Modifications->GetPendingModificationsCount( $branch ); $template->param( pendingcomments => $pendingcomments, diff --git a/members/members-update-do.pl b/members/members-update-do.pl index 147975a..e7b7b28 100755 --- a/members/members-update-do.pl +++ b/members/members-update-do.pl @@ -61,4 +61,4 @@ foreach my $param (@params) { } } -print $query->redirect("/cgi-bin/koha/mainpage.pl"); +print $query->redirect("/cgi-bin/koha/members/members-update.pl"); diff --git a/members/members-update.pl b/members/members-update.pl index 9ffcf42..334d83b 100755 --- a/members/members-update.pl +++ b/members/members-update.pl @@ -30,7 +30,7 @@ use Koha::Borrower::Modifications; my $query = new CGI; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( { template_name => "members/members-update.tmpl", query => $query, @@ -41,8 +41,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $branch = + C4::Context->preference("IndependantBranches") + && !$flags->{'superlibrarian'} + ? C4::Context->userenv()->{'branch'} + : undef; + my $pending_modifications = - Koha::Borrower::Modifications->GetPendingModifications(); + Koha::Borrower::Modifications->GetPendingModifications($branch); my $borrowers; foreach my $pm (@$pending_modifications) { diff --git a/misc/cronjobs/delete_expired_opac_registrations.pl b/misc/cronjobs/delete_expired_opac_registrations.pl index c588b03..52929ed 100755 --- a/misc/cronjobs/delete_expired_opac_registrations.pl +++ b/misc/cronjobs/delete_expired_opac_registrations.pl @@ -34,7 +34,7 @@ use C4::Members qw/ DelMember /; my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay'); my $category_code = - C4::Context->preference('PatronSelfRegistrationUseTemporaryStatus'); + C4::Context->preference('PatronSelfRegistrationDefaultCategory'); my $query = " SELECT borrowernumber diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index cf24176..b133af8 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -30,11 +30,6 @@ use C4::Branch qw(GetBranchesLoop); my $cgi = new CGI; my $dbh = C4::Context->dbh; -unless ( C4::Context->preference('PatronSelfRegistration') ) { - print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); - exit; -} - my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-memberentry.tmpl", @@ -44,11 +39,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +unless ( C4::Context->preference('PatronSelfRegistration') || $borrowernumber ) { + print $cgi->redirect("/cgi-bin/koha/opac-main.pl"); + exit; +} + $template->param( - hidden => GetHiddenFields(), - mandatory => GetMandatoryFields(), - member_titles => GetTitles(), - branches => GetBranchesLoop() + hidden => GetHiddenFields(), + mandatory => GetMandatoryFields(), + member_titles => GetTitles(), + branches => GetBranchesLoop(), + OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), ); my $action = $cgi->param('action') || q{}; @@ -167,7 +168,8 @@ elsif ($borrowernumber) { #Display logged in borrower's data $action = 'edit'; $template->param( - borrower => GetMember( borrowernumber => $borrowernumber ) ); + borrower => GetMember( borrowernumber => $borrowernumber ), + ); } my $captcha = random_string("CCCCC"); @@ -236,9 +238,10 @@ sub ParseCgiForBorrower { my %borrower; foreach ( $cgi->param ) { - my ($key) = substr( $_, 9 ); - $borrower{$key} = $cgi->param($_) - if ( $_ =~ '^borrower_' ); + if ( $_ =~ '^borrower_' ) { + my ($key) = substr( $_, 9 ); + $borrower{$key} = $cgi->param($_); + } } $borrower{'dateofbirth'} = diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index bf0eae4..682dacb 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -32,22 +32,23 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) { exit; } -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-registration-confirmation.tmpl", - type => "opac", - query => $cgi, - authnotrequired => 1, - } -); - -$template->param( - OpacPasswordChange => C4::Context->preference('OpacPasswordChange') ); - my $token = $cgi->param('token'); my $m = Koha::Borrower::Modifications->new( verification_token => $token ); +my ( $template, $borrowernumber, $cookie ); if ( $m->Verify() ) { + ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-registration-confirmation.tmpl", + type => "opac", + query => $cgi, + authnotrequired => 1, + } + ); + + $template->param( + OpacPasswordChange => C4::Context->preference('OpacPasswordChange') ); + my $borrower = $m->GetModifications(); my $password; @@ -68,7 +69,14 @@ if ( $m->Verify() ) { } else { - + ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-registration-invalid.tmpl", + type => "opac", + query => $cgi, + authnotrequired => 1, + } + ); } output_html_with_http_headers $cgi, $cookie, $template->output; -- 1.7.2.5