use Modern::Perl;
use CGI qw ( -utf8 );
-use C4::Output;
-use C4::Auth qw(:DEFAULT :EditPermissions);
+use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
+use C4::Auth qw( get_template_and_user get_all_subpermissions get_user_subpermissions );
use C4::Context;
-use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
-#use C4::Acquisitions;
use Koha::Patron::Categories;
use Koha::Patrons;
-use C4::Output;
+use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
use Koha::Token;
-my $input = new CGI;
+my $input = CGI->new;
my $flagsrequired = { permissions => 1 };
my $member=$input->param('member');
template_name => "members/member-flags.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => $flagsrequired,
- debug => 1,
});
-my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
+my $logged_in_user = Koha::Patrons->find( $loggedinuser );
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
my %member2;
if ($input->param('newflags')) {
- die "Wrong CSRF token"
+ output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
unless Koha::Token->new->check_csrf({
session_id => scalar $input->cookie('CGISESSID'),
token => scalar $input->param('csrf_token'),
}
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
- if( !C4::Context->preference('ProtectSuperlibPrivs') || C4::Context->IsSuperLibrarian ) {
- $sth->execute($module_flags, $member);
- } else {
- my $old_flags = $patron->flags // 0;
- if( ( $old_flags == 1 || $module_flags == 1 ) &&
- $old_flags != $module_flags ) {
- die "Non-superlibrarian is changing superlibrarian privileges"; # Interface should not allow this, so we can just die here
- } else {
- $sth->execute($module_flags, $member);
- }
+ 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);
if ($#sub_perm_loop > -1) {
$row{sub_perm_loop} = \@sub_perm_loop;
}
+ next if ( ( $row{flag} eq 'cash_management' ) && !C4::Context->preference('UseCashRegisters') );
push @loop, \%row;
}
- 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->categorycode ) if $patron_categories->count == 1;
- }
-
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
loop => \@loop,
csrf_token =>
Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID'), } ),
- disable_superlibrarian_privs => C4::Context->preference('ProtectSuperlibPrivs') ? !C4::Context->IsSuperLibrarian : 0,
+ disable_superlibrarian_privs => C4::Context->preference('ProtectSuperlibrarianPrivileges') ? !C4::Context->IsSuperLibrarian : 0,
);
output_html_with_http_headers $input, $cookie, $template->output;