From 37ca0cac1f899a127435b2220b4d5ba7a6f286d6 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Fri, 4 Jan 2008 22:14:34 -0500 Subject: [PATCH] fix for bug 1697, as well as repairing inability to change category to Staff Signed-off-by: Joshua Ferraro --- .../mysql/en/optional/patron_categories.sql | 9 ++- .../prog/en/modules/members/moremember.tmpl | 8 +++ members/deletemem.pl | 71 +++++++++---------- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/installer/data/mysql/en/optional/patron_categories.sql b/installer/data/mysql/en/optional/patron_categories.sql index 9cd4921c2f..56439b4fbb 100644 --- a/installer/data/mysql/en/optional/patron_categories.sql +++ b/installer/data/mysql/en/optional/patron_categories.sql @@ -1,18 +1,23 @@ INSERT INTO `categories` (`categorycode`, `description`, `enrolmentperiod`, `upperagelimit`, `dateofbirthrequired`, `finetype`, `bulk`, `enrolmentfee`, `overduenoticerequired`, `issuelimit`, `reservefee`, `category_type`) VALUES +-- Adult Patrons ('PT','Patron',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','A'), ('ST','Student',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','A'), ('HB','Home Bound',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','A'), +-- Children ('K','Kid',99,17,5,NULL,NULL,'0.000000',1,NULL,'0.000000','C'), ('J','Juvenile',99,17,5,NULL,NULL,'0.000000',1,NULL,'0.000000','C'), ('YA','Young Adult',99,17,5,NULL,NULL,'0.000000',1,NULL,'0.000000','C'), +-- Professionals ('T','Teacher',99,999,18,NULL,NULL,'0.000000',0,NULL,'0.000000','P'), -('S','Staff',99,999,18,NULL,NULL,'0.000000',0,NULL,'0.000000','P'), ('B','Board',99,17,5,NULL,NULL,'0.000000',1,NULL,'0.000000','P'), +-- Institutional ('IL','Inter-Library Loan',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','I'), ('SC','School',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','I'), -('L','Library',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','I'); +('L','Library',99,999,18,NULL,NULL,'0.000000',1,NULL,'0.000000','I'), +-- Staff +('S','Staff',99,999,18,NULL,NULL,'0.000000',0,NULL,'0.000000','S'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl index 187efec619..f3b5dd5730 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl @@ -32,6 +32,14 @@ $(document).ready(function() { Insufficient privileges.

Other fields updated.

+ +

Unable to delete staff user

+

Insufficient privileges.

+ + +

Unable to delete patrons from other libraries with current settings

+

Insufficient privileges.

+

Unable to delete patron:

Insufficient privileges.

diff --git a/members/deletemem.pl b/members/deletemem.pl index e1f8a59e62..33f35ae9a9 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -36,9 +36,14 @@ my $input = new CGI; my $flagsrequired; $flagsrequired->{borrowers}=1; -my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired); - - +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "members/deletemem.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); #print $input->header; my $member=$input->param('member'); @@ -48,21 +53,22 @@ my ($countissues,$issues)=GetPendingIssues($member); my ($bor)=GetMemberDetails($member,''); my $flags=$bor->{flags}; - my $userenv = C4::Context->userenv; -if(C4::Auth::haspermission(undef,$userenv->{'id'},{'staffaccess'=>1})) { - print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE"); - exit 1; +if ($bor->{category_type} eq "S") { + unless(C4::Auth::haspermission(undef,$userenv->{'id'},{'staffaccess'=>1})) { + print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_STAFF"); + exit 1; + } } if (C4::Context->preference("IndependantBranches")) { - unless ($userenv->{flags} == 1){ - unless ($userenv->{'branch'} eq $bor->{'branchcode'}){ -# warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'}; - print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE"); - exit 1; - } - } + unless ($userenv->{flags} == 1){ + unless ($userenv->{'branch'} eq $bor->{'branchcode'}){ +# warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'}; + print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY"); + exit 1; + } + } } my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?"); @@ -70,32 +76,23 @@ $sth->execute($member); my $data=$sth->fetchrow_hashref; $sth->finish; if ($countissues > 0 or $flags->{'CHARGES'} or $data->{'borrowernumber'}){ - - my ($template, $borrowernumber, $cookie) - = get_template_and_user({template_name => "members/deletemem.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1}, - debug => 1, - }); - # print $input->header; - $template->param(borrowernumber => $member); - if ($countissues >0) { - $template->param(ItemsOnIssues => $countissues); - } - if ($flags->{'CHARGES'} ne '') { - $template->param(charges => $flags->{'CHARGES'}->{'amount'}); - } - if ($data ne '') { - $template->param(guarantees => 1); - } + # print $input->header; + $template->param(borrowernumber => $member); + if ($countissues >0) { + $template->param(ItemsOnIssues => $countissues); + } + if ($flags->{'CHARGES'} ne '') { + $template->param(charges => $flags->{'CHARGES'}->{'amount'}); + } + if ($data ne '') { + $template->param(guarantees => 1); + } output_html_with_http_headers $input, $cookie, $template->output; } else { - MoveMemberToDeleted($member); - DelMember($member); - print $input->redirect("/cgi-bin/koha/members/members-home.pl"); + MoveMemberToDeleted($member); + DelMember($member); + print $input->redirect("/cgi-bin/koha/members/members-home.pl"); } -- 2.39.5