X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=members%2Fmembers-update-do.pl;h=a42c1ff9633eceba763fbb1d771c250d5b56c338;hb=a3087d76bd31f59ac437e63d7031b2202cb64e5c;hp=f55b7abfac44642cb79a3d7e6097662d547a7d5f;hpb=3691bd8419ee9a481b95af525bc7e0c08f4c4640;p=koha-ffzg.git diff --git a/members/members-update-do.pl b/members/members-update-do.pl index f55b7abfac..a42c1ff963 100755 --- a/members/members-update-do.pl +++ b/members/members-update-do.pl @@ -16,30 +16,20 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; use CGI qw ( -utf8 ); -use C4::Auth; +use C4::Auth qw( checkauth ); use C4::Output; use C4::Context; -use C4::Members; -use C4::Branch; -use C4::Category; +use Koha::Patrons; use Koha::Patron::Modifications; -my $query = new CGI; +my $query = CGI->new; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "about.tt", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { borrowers => 1 }, - debug => 1, - } -); +my ( $userid, $cookie, $sessionID, $flags ) = checkauth($query, 0, { borrowers => 'edit_borrowers' }, 'intranet'); + +my $logged_in_user = Koha::Patrons->find({ userid => $userid }); my @params = $query->param; @@ -47,17 +37,28 @@ foreach my $param (@params) { if ( $param =~ "^modify_" ) { my (undef, $borrowernumber) = split( /_/, $param ); + my $patron = Koha::Patrons->find($borrowernumber); + next unless $logged_in_user->can_see_patron_infos( $patron ); + my $action = $query->param($param); if ( $action eq 'approve' ) { - Koha::Patron::Modifications->ApproveModifications( $borrowernumber ); + my $m = Koha::Patron::Modifications->find( { borrowernumber => $borrowernumber } ); + + if ($query->param("unset_gna_$borrowernumber")) { + # Unset gone no address + # FIXME Looks like this could go to $m->approve + my $patron = Koha::Patrons->find( $borrowernumber ); + $patron->gonenoaddress(undef)->store; + } + + $m->approve() if $m; } elsif ( $action eq 'deny' ) { - Koha::Patron::Modifications->DenyModifications( $borrowernumber ); - } - elsif ( $action eq 'ignore' ) { - + my $m = Koha::Patron::Modifications->find( { borrowernumber => $borrowernumber } ); + $m->delete() if $m; } + # elsif ( $action eq 'ignore' ) { } } }