From 71d5d378d8b5da4f7395827212bc9eed2d9b94a9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Feb 2014 16:34:01 +0100 Subject: [PATCH] Bug 11751: remove dead code related to handling members of institution patrons This patch removes some dead code concerning the handling of patrons that are members of other, institutional patrons. This code did not work; removing it clears the field if somebody wants to do a better implementation of such relationships between patrons. This patch: [1] Removes the memberofinstitution system preference. [2] Removes the following routines: C4::Members::get_institutions() C4::Members::add_member_orgs() (and removing this routine removes a reference to a borrowers_to_borrowers table that does not exist). There should be no changes whatsoever to system functionality with this patch (with the trivial exception of the absence of the memberofinstitution system preference). Test plan: [1] Look at the code and use grep, git grep, etc. verify this patch does not remove something in use. [2] Verify that there are no regressions upon adding or editing a patron record. [3] Verify that the memberofinstitution system preference has been removed Signed-off-by: Galen Charlton --- C4/Members.pm | 47 -------------------- circ/circulation.pl | 22 --------- installer/data/mysql/sysprefs.sql | 1 - installer/data/mysql/updatedatabase.pl | 9 ++++ .../prog/en/modules/admin/preferences/patrons.pref | 6 --- members/memberentry.pl | 29 ------------ 6 files changed, 9 insertions(+), 105 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index a0769ca..a878a9c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -62,7 +62,6 @@ BEGIN { &GetPendingIssues &GetAllIssues - &get_institutions &getzipnamecity &getidcity @@ -122,7 +121,6 @@ BEGIN { push @EXPORT, qw( &AddMember &AddMember_Opac - &add_member_orgs &MoveMemberToDeleted &ExtendMemberSubscriptionTo ); @@ -1668,51 +1666,6 @@ sub GetAge{ return $age; } # sub get_age -=head2 get_institutions - - $insitutions = get_institutions(); - -Just returns a list of all the borrowers of type I, borrownumber and name - -=cut - -#' -sub get_institutions { - my $dbh = C4::Context->dbh(); - my $sth = - $dbh->prepare( -"SELECT borrowernumber,surname FROM borrowers WHERE categorycode=? ORDER BY surname" - ); - $sth->execute('I'); - my %orgs; - while ( my $data = $sth->fetchrow_hashref() ) { - $orgs{ $data->{'borrowernumber'} } = $data; - } - return ( \%orgs ); - -} # sub get_institutions - -=head2 add_member_orgs - - add_member_orgs($borrowernumber,$borrowernumbers); - -Takes a borrowernumber and a list of other borrowernumbers and inserts them into the borrowers_to_borrowers table - -=cut - -#' -sub add_member_orgs { - my ( $borrowernumber, $otherborrowers ) = @_; - my $dbh = C4::Context->dbh(); - my $query = - "INSERT INTO borrowers_to_borrowers (borrower1,borrower2) VALUES (?,?)"; - my $sth = $dbh->prepare($query); - foreach my $otherborrowernumber (@$otherborrowers) { - $sth->execute( $borrowernumber, $otherborrowernumber ); - } - -} # sub add_member_orgs - =head2 GetCities $cityarrayref = GetCities(); diff --git a/circ/circulation.pl b/circ/circulation.pl index 509cd1d..c80714d 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -133,7 +133,6 @@ my $stickyduedate = $query->param('stickyduedate') || $session->param('stickydu my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate'); my $issueconfirmed = $query->param('issueconfirmed'); my $cancelreserve = $query->param('cancelreserve'); -my $organisation = $query->param('organisations'); my $print = $query->param('print') || q{}; my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice my $charges = $query->param('charges') || q{}; @@ -658,25 +657,6 @@ if ( $borrower->{'category_type'} eq 'C') { $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; } -my $CGIorganisations; -my $member_of_institution; -if ( C4::Context->preference("memberofinstitution") ) { - my $organisations = get_institutions(); - my @orgs; - my %org_labels; - foreach my $organisation ( keys %$organisations ) { - push @orgs, $organisation; - $org_labels{$organisation} = $organisations->{$organisation}->{'surname'}; - } - $member_of_institution = 1; - $CGIorganisations = CGI::popup_menu( - -id => 'organisations', - -name => 'organisations', - -labels => \%org_labels, - -values => \@orgs, - ); -} - my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch ); if($lib_messages_loop){ $template->param(flagged => 1 ); } @@ -747,8 +727,6 @@ $template->param( relprevissues => \@relprevissues, displayrelissues => $displayrelissues, inprocess => $inprocess, - memberofinstution => $member_of_institution, - CGIorganisations => $CGIorganisations, is_child => ($borrower->{'category_type'} eq 'C'), circview => 1, soundon => C4::Context->preference("SoundOn"), diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 9df6f9b..01bf672 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -181,7 +181,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), -('memberofinstitution','0',NULL,'If ON, patrons can be linked to institutions','YesNo'), ('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index baf17e5..3a11e7d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8005,6 +8005,15 @@ if ( CheckVersion($DBversion) ) { $dbh->{RaiseError} = 0; } +$DBversion = "3.15.00.XXX"; +if (CheckVersion($DBversion)) { + $dbh->do(q| + DELETE FROM systempreferences WHERE variable= "memberofinstitution" + |); + print "Upgrade to $DBversion done (Bug 11751: Remove memberofinstitytion system preference)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 74d14af..41d6392 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -80,12 +80,6 @@ Patrons: - '[% local_currency %].' - Empty value means no limit. Single item caps are specified in the circulation rules matrix. - - - pref: memberofinstitution - choices: - yes: Do - no: "Don't" - - allow patrons to be linked to institutions (which must be set up as Institution patrons). - - - Login passwords for staff and patrons must be at least - pref: minPasswordLength class: integer diff --git a/members/memberentry.pl b/members/memberentry.pl index 429768a..a25e3de 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -400,11 +400,6 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ } } - if ($data{'organisations'}){ - # need to add the members organisations - my @orgs=split(/\|/,$data{'organisations'}); - add_member_orgs($borrowernumber,\@orgs); - } if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); } @@ -619,28 +614,6 @@ if($no_categories){ $template->param(no_categories => 1); } $template->param(no_add => $no_add); -my $CGIorganisations; -my $member_of_institution; -if (C4::Context->preference("memberofinstitution")){ - my $organisations=get_institutions(); - my @orgs; - my %org_labels; - foreach my $organisation (keys %$organisations) { - push @orgs,$organisation; - $org_labels{$organisation}=$organisations->{$organisation}->{'surname'}; - } - $member_of_institution=1; - - $CGIorganisations = CGI::scrolling_list( -id => 'organisations', - -name => 'organisations', - -labels => \%org_labels, - -values => \@orgs, - -size => 5, - -multiple => 'true' - - ); -} - # -------------------------------------------------------------------------------------------------------- my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'}); @@ -728,8 +701,6 @@ $template->param( category_type =>$category_type, modify => $modify, nok => $nok,#flag to konw if an error - memberofinstution => $member_of_institution, - CGIorganisations => $CGIorganisations, NoUpdateLogin => $NoUpdateLogin ); -- 1.7.10.4