# Written by Steve Tonnesen
# July 26, 2002 (my birthday!)
-use strict;
-use warnings;
+use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Output;
use Koha::Patrons;
use C4::Output;
-use Koha::Patron::Images;
use Koha::Token;
my $input = new CGI;
my $flagsrequired = { permissions => 1 };
my $member=$input->param('member');
my $patron = Koha::Patrons->find( $member );
+unless ( $patron ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member");
+ exit;
+}
+
my $category_type = $patron->category->category_type;
my $bor = $patron->unblessed;
-if( $category_type eq 'S' ) {
- $flagsrequired->{'staffaccess'} = 1;
+if( $category_type eq 'S' ) { # FIXME Is this really needed?
+ $flagsrequired->{'staffaccess'} = 1;
}
my ($template, $loggedinuser, $cookie) = get_template_and_user({
template_name => "members/member-flags.tt",
debug => 1,
});
+my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
+output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
my %member2;
$member2{'borrowernumber'}=$member;
}
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
+ my $old_flags = $patron->flags // 0;
+ if( ( $old_flags == 1 || $module_flags == 1 ) &&
+ $old_flags != $module_flags ) {
+ die "Non-superlibrarian is changing superlibrarian privileges" if !C4::Context->IsSuperLibrarian && C4::Context->preference('ProtectSuperlibrarianPrivileges'); # Interface should not allow this, so we can just die here
+ }
$sth->execute($module_flags, $member);
-
+
# deal with subpermissions
$sth = $dbh->prepare("DELETE FROM user_permissions WHERE borrowernumber = ?");
$sth->execute($member);
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
} else {
- my $flags = C4::Members::patronflags( $bor );
my $accessflags;
my $dbh = C4::Context->dbh();
# FIXME This needs to be improved to avoid doing the same query
my @loop;
while (my ($bit, $flag) = $sth->fetchrow) {
- my $checked='';
- if ($accessflags->{$flag}) {
- $checked= 1;
- }
-
- my %row = ( bit => $bit,
- flag => $flag,
- checked => $checked,
+ my $checked='';
+ if ($accessflags->{$flag}) {
+ $checked= 1;
+ }
+
+ my %row = ( bit => $bit,
+ flag => $flag,
+ checked => $checked,
);
my @sub_perm_loop = ();
if ($#sub_perm_loop > -1) {
$row{sub_perm_loop} = \@sub_perm_loop;
}
- push @loop, \%row;
+ push @loop, \%row;
}
- if ( $category_type eq 'C') {
+ if ( $patron->is_child ) {
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
$template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
- $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
+ $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1;
}
-
-$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
- $template->param( picture => 1 ) if $patron->image;
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
}
$template->param(
- borrowernumber => $bor->{'borrowernumber'},
- cardnumber => $bor->{'cardnumber'},
- surname => $bor->{'surname'},
- firstname => $bor->{'firstname'},
- othernames => $bor->{'othernames'},
- categorycode => $bor->{'categorycode'},
- category_type => $category_type,
- categoryname => $bor->{'description'},
- address => $bor->{address},
- address2 => $bor->{'address2'},
- streettype => $bor->{streettype},
- city => $bor->{'city'},
- state => $bor->{'state'},
- zipcode => $bor->{'zipcode'},
- country => $bor->{'country'},
- phone => $bor->{'phone'},
- phonepro => $bor->{'phonepro'},
- mobile => $bor->{'mobile'},
- email => $bor->{'email'},
- emailpro => $bor->{'emailpro'},
- branchcode => $bor->{'branchcode'},
- loop => \@loop,
- is_child => ($category_type eq 'C'),
- RoutingSerials => C4::Context->preference('RoutingSerials'),
- csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
- );
+ patron => $patron,
+ loop => \@loop,
+ csrf_token =>
+ Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
+ disable_superlibrarian_privs => C4::Context->preference('ProtectSuperlibrarianPrivileges') ? !C4::Context->IsSuperLibrarian : 0,
+);
output_html_with_http_headers $input, $cookie, $template->output;