@@ -, +, @@ --- 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 | 28 +++++- .../delete_unverified_opac_registrations.pl | 34 ++++++- opac/opac-memberentry.pl | 29 +++--- opac/opac-registration-verify.pl | 34 ++++--- 20 files changed, 283 insertions(+), 129 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-registration-invalid.tt --- a/C4/Auth.pm +++ a/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")); --- a/C4/Members.pm +++ a/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' ]; --- a/C4/SQLHelper.pm +++ a/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; } --- a/Koha/Borrower/Modifications.pm +++ a/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() ) { --- a/installer/data/mysql/sysprefs.sql +++ a/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'); --- a/installer/data/mysql/updatedatabase.pl +++ a/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'); "); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/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." - --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -100,6 +100,7 @@
There are no pending patron modifications.
+ [% END %]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.
-If you don't have a library card, stop by your local library to sign up[% IF PatronSelfRegistration %] or register here[% END %].
+If you don't have a library card, stop by your local library to sign up[% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %] or register here[% END %].