Bug 11751: remove dead code related to handling members of institution patrons
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 12 Feb 2014 15:34:01 +0000 (16:34 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 11 Mar 2014 15:05:14 +0000 (15:05 +0000)
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 <gmc@esilibrary.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

C4/Members.pm
circ/circulation.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
members/memberentry.pl

index a0769ca..a878a9c 100644 (file)
@@ -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();
index 8af776f..cdc40e3 100755 (executable)
@@ -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"),
index 66c2017..661910b 100644 (file)
@@ -182,7 +182,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'),
index 0768a88..c74ccb0 100755 (executable)
@@ -8036,6 +8036,14 @@ if(CheckVersion($DBversion)) {
     print "Upgrade to $DBversion done (Bug 3445: Add indexes to action_logs table)\n";
     SetVersion($DBversion);
 }
+$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
 
index 74d14af..41d6392 100644 (file)
@@ -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
index 429768a..a25e3de 100755 (executable)
@@ -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
   );