View | Details | Raw Unified | Return to bug 10612
Collapse All | Expand All

(-)a/C4/Members.pm (-6 / +15 lines)
Lines 36-41 use C4::Letters; Link Here
36
use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
36
use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
37
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
37
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
38
use C4::NewsChannels; #get slip news
38
use C4::NewsChannels; #get slip news
39
use C4::VirtualShelves qw(HandleDelBorrower);
39
use DateTime;
40
use DateTime;
40
use DateTime::Format::DateParse;
41
use DateTime::Format::DateParse;
41
use Koha::DateUtils;
42
use Koha::DateUtils;
Lines 1819-1837 sub MoveMemberToDeleted { Link Here
1819
1820
1820
=head2 DelMember
1821
=head2 DelMember
1821
1822
1822
    DelMember($borrowernumber);
1823
    DelMember({ borrowernumber => $borrowernumber [, permanently => 1 ]);
1823
1824
1824
This function remove directly a borrower whitout writing it on deleteborrower.
1825
    * Deletes reserves for the borrower
1825
+ Deletes reserves for the borrower
1826
    * Calls C4::VirtualShelfs::HandleDelBorrower
1827
    * Calls MoveMemberToDelete unless the parameter 'permanently' is true
1826
1828
1827
=cut
1829
=cut
1828
1830
1829
sub DelMember {
1831
sub DelMember {
1830
    my $dbh            = C4::Context->dbh;
1832
    my ( $params ) = @_;
1831
    my $borrowernumber = shift;
1833
1832
    #warn "in delmember with $borrowernumber";
1834
    my $borrowernumber = $params->{borrowernumber};
1835
    my $permanently = $params->{permanently};
1836
1837
    my $dbh = C4::Context->dbh;
1838
1833
    return unless $borrowernumber;    # borrowernumber is mandatory.
1839
    return unless $borrowernumber;    # borrowernumber is mandatory.
1834
1840
1841
    MoveMemberToDeleted( $borrowernumber ) unless $permanently;
1842
    C4::VirtualShelves::HandleDelBorrower( $borrowernumber );
1843
1835
    my $query = qq|DELETE 
1844
    my $query = qq|DELETE 
1836
          FROM  reserves 
1845
          FROM  reserves 
1837
          WHERE borrowernumber=?|;
1846
          WHERE borrowernumber=?|;
(-)a/C4/VirtualShelves.pm (-2 / +2 lines)
Lines 45-51 BEGIN { Link Here
45
            &GetBibliosShelves
45
            &GetBibliosShelves
46
    );
46
    );
47
        @EXPORT_OK = qw(
47
        @EXPORT_OK = qw(
48
            &GetAllShelves &ShelvesMax
48
            &GetAllShelves &ShelvesMax &HandleDelBorrower
49
        );
49
        );
50
}
50
}
51
51
Lines 601-607 sub ShelvesMax { Link Here
601
601
602
     HandleDelBorrower($borrower);
602
     HandleDelBorrower($borrower);
603
603
604
When a member is deleted (DelMember in Members.pm), you should call me first.
604
When a member is deleted, this subroutine is called.
605
This routine deletes/moves lists and entries for the deleted member/borrower.
605
This routine deletes/moves lists and entries for the deleted member/borrower.
606
You could just delete everything (and lose more than you want), but instead we
606
You could just delete everything (and lose more than you want), but instead we
607
now try to save all public/shared stuff and keep others happy.
607
now try to save all public/shared stuff and keep others happy.
(-)a/members/deletemem.pl (-3 / +1 lines)
Lines 118-126 if ($countissues > 0 or $flags->{'CHARGES'} or $data->{'borrowernumber'}){ Link Here
118
output_html_with_http_headers $input, $cookie, $template->output;
118
output_html_with_http_headers $input, $cookie, $template->output;
119
119
120
} else {
120
} else {
121
    MoveMemberToDeleted($member);
121
    DelMember({ borrowernumber => $member });
122
    C4::VirtualShelves::HandleDelBorrower($member);
123
    DelMember($member);
124
    print $input->redirect("/cgi-bin/koha/members/members-home.pl");
122
    print $input->redirect("/cgi-bin/koha/members/members-home.pl");
125
}
123
}
126
124
(-)a/misc/cronjobs/delete_expired_opac_registrations.pl (-1 / +1 lines)
Lines 76-80 my $sth = $dbh->prepare($query); Link Here
76
$sth->execute( $category_code, $delay );
76
$sth->execute( $category_code, $delay );
77
77
78
while ( my ($borrowernumber) = $sth->fetchrow_array() ) {
78
while ( my ($borrowernumber) = $sth->fetchrow_array() ) {
79
    DelMember($borrowernumber);
79
    DelMember({ borrowernumber => $borrowernumber, permanently => 1 });
80
}
80
}
(-)a/misc/cronjobs/delete_unverified_opac_registrations.pl (-1 lines)
Lines 29-35 BEGIN { Link Here
29
}
29
}
30
30
31
use C4::Context;
31
use C4::Context;
32
use C4::Members qw/ DelMember /;
33
32
34
my $help;
33
my $help;
35
my $confirm;
34
my $confirm;
(-)a/t/db_dependent/Members.t (-1 / +1 lines)
Lines 171-177 is ($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when Link Here
171
171
172
172
173
# clean up 
173
# clean up 
174
DelMember($member->{borrowernumber});
174
DelMember({ borrowernumber => $member->{borrowernumber}, permanently => 1 });
175
$results = Search($CARDNUMBER,undef,undef,undef,["cardnumber"]);
175
$results = Search($CARDNUMBER,undef,undef,undef,["cardnumber"]);
176
ok (!_find_member($results), "Delete member")
176
ok (!_find_member($results), "Delete member")
177
  or diag("Card $CARDNUMBER found for the deleted member in the resultset: ".Dumper($results));
177
  or diag("Card $CARDNUMBER found for the deleted member in the resultset: ".Dumper($results));
(-)a/tools/cleanborrowers.pl (-5 / +2 lines)
Lines 126-140 if ( $params->{'step3'} ) { Link Here
126
        if ( $radio eq 'trash' ) {
126
        if ( $radio eq 'trash' ) {
127
            my $i;
127
            my $i;
128
            for ( $i = 0 ; $i < $totalDel ; $i++ ) {
128
            for ( $i = 0 ; $i < $totalDel ; $i++ ) {
129
                MoveMemberToDeleted( $membersToDelete->[$i]->{'borrowernumber'} );
129
                DelMember({ borrowernumber => $membersToDelete->[$i]->{'borrowernumber'} });
130
                C4::VirtualShelves::HandleDelBorrower( $membersToDelete->[$i]->{'borrowernumber'} );
131
                DelMember( $membersToDelete->[$i]->{'borrowernumber'} );
132
            }
130
            }
133
        } else {    # delete completly.
131
        } else {    # delete completly.
134
            my $i;
132
            my $i;
135
            for ( $i = 0 ; $i < $totalDel ; $i++ ) {
133
            for ( $i = 0 ; $i < $totalDel ; $i++ ) {
136
                C4::VirtualShelves::HandleDelBorrower( $membersToDelete->[$i]->{'borrowernumber'} );
134
                DelMember({ borrowernumber => $membersToDelete->[$i]->{'borrowernumber'}, permanently => 1 });
137
                DelMember( $membersToDelete->[$i]->{'borrowernumber'} );
138
            }
135
            }
139
        }
136
        }
140
        $template->param(
137
        $template->param(
(-)a/tools/modborrowers.pl (-3 / +1 lines)
Lines 259-266 if ( $op eq 'do' ) { Link Here
259
                    { error => "fees_owed", borrower => $borrower } );
259
                    { error => "fees_owed", borrower => $borrower } );
260
            }
260
            }
261
            else {
261
            else {
262
                MoveMemberToDeleted($borrowernumber);
262
                DelMember({ borrowernumber => $borrowernumber });
263
                DelMember($borrowernumber);
264
                push( @deleted_borrowers, $borrower );
263
                push( @deleted_borrowers, $borrower );
265
            }
264
            }
266
        }
265
        }
267
- 

Return to bug 10612