Bugzilla – Attachment 25079 Details for
Bug 7292
New permission for claims
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7292: More granular permissions for claiming orders
Bug-7292-More-granular-permissions-for-claiming-or.patch (text/plain), 5.75 KB, created by
Julian Maurice
on 2014-02-06 14:30:24 UTC
(
hide
)
Description:
Bug 7292: More granular permissions for claiming orders
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2014-02-06 14:30:24 UTC
Size:
5.75 KB
patch
obsolete
>From 38c24beb11f6039a9c6e06828c1157689563f879 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 6 Feb 2014 15:28:44 +0100 >Subject: [PATCH] Bug 7292: More granular permissions for claiming orders > >Add a new permission order_claim_for_all. >Without this permission, user can only claim for orders in baskets he's >authorised to manage >--- > acqui/lateorders.pl | 87 +++++++++++++++----- > .../prog/en/modules/acqui/lateorders.tt | 15 ++++ > 2 files changed, 80 insertions(+), 22 deletions(-) > >diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl >index 1a64a4c..f881aff 100755 >--- a/acqui/lateorders.pl >+++ b/acqui/lateorders.pl >@@ -56,15 +56,36 @@ use C4::Branch; # GetBranches > use Koha::DateUtils; > > my $input = new CGI; >-my ($template, $loggedinuser, $cookie) = get_template_and_user({ >- template_name => "acqui/lateorders.tmpl", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {acquisition => 'order_receive'}, >- debug => 1, >+my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ >+ template_name => "acqui/lateorders.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => {acquisition => 'order_receive'}, >+ debug => 1, > }); > >+# Check if user has rights to access this page >+my $can_claim_for_all = 0; >+if ($userflags->{superlibrarian} >+ or (!ref $userflags->{acquisition} and $userflags->{acquisition}) >+ or (ref $userflags->{acquisition} >+ and $userflags->{acquisition}->{order_claim_for_all} >+ ) >+) { >+ $can_claim_for_all = 1; >+} >+ >+if ( !$can_claim_for_all >+ and ( >+ ref $userflags->{acquisition} >+ and not $userflags->{acquisition}->{order_receive} >+ ) >+) { >+ # Will fail to authenticate, so redirect to login screen >+ checkauth($input, 0, { acquisition => 'order_receive' }, "intranet"); >+} >+ > my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 > my $delay = $input->param('delay') // 0; > >@@ -101,22 +122,39 @@ if ( $delay and not $delay =~ /^\d{1,3}$/ ) { > } > > if ($op and $op eq "send_alert"){ >- my @ordernums = $input->param("ordernumber");# FIXME: Fallback values? >- my $err; >- eval { >- $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? >- if ( not ref $err or not exists $err->{error} ) { >- AddClaim ( $_ ) for @ordernums; >+ my @claim_for = $input->param('claim_for'); # FIXME: Fallback values? >+ my (@ordernums, @not_claimed); >+ if (not $can_claim_for_all) { >+ foreach my $ordernumber (@claim_for) { >+ my $order = GetOrder($ordernumber); >+ if (CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) { >+ push @ordernums, $ordernumber; >+ } else { >+ push @not_claimed, $ordernumber; >+ } > } >- }; >- >- if ( $@ ) { >- $template->param(error_claim => $@); >- } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { >- $template->{VARS}->{'error_claim'} = "no_email"; > } else { >- $template->{VARS}->{'info_claim'} = 1; >+ @ordernums = @claim_for; >+ } >+ if (scalar @ordernums > 0) { >+ my $err; >+ eval { >+ $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? >+ if ( not ref $err or not exists $err->{error} ) { >+ foreach my $ordernumber (@ordernums) { >+ AddClaim($ordernumber); >+ } >+ } >+ }; >+ if ( $@ ) { >+ $template->param(error_claim => $@); >+ } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { >+ $template->param(error_claim => "no_email"); >+ } else { >+ $template->param(info_claim => 1); >+ } > } >+ $template->param(not_claimed => \@not_claimed); > } > > my @parameters = ( $delay ); >@@ -155,8 +193,13 @@ if ($estimateddeliverydateto_dt) { > my @lateorders = GetLateOrders( @parameters ); > > my $total; >-foreach (@lateorders){ >- $total += $_->{subtotal}; >+foreach my $order (@lateorders){ >+ if ( (not $can_claim_for_all) >+ and (not CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) >+ ) { >+ $order->{cannot_claim} = 1; >+ } >+ $total += $order->{subtotal}; > } > > my @letters; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >index c76cf2d..7e0410e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >@@ -87,6 +87,19 @@ $(document).ready(function() { > <div class="error">[% error_claim %]</div> > [% END %] > [% END %] >+[% IF not_claimed.size %] >+ <div class="error"> >+ <p> >+ The following orders were not claimed because you are not >+ authorised to claim for them: >+ </p> >+ <ul> >+ [% FOREACH ordernumber IN not_claimed %] >+ <li>[% ordernumber %]</li> >+ [% END %] >+ </ul> >+ </div> >+[% END %] > [% IF info_claim %] > <div class="dialog message">Email has been sent.</div> > [% END %] >@@ -126,7 +139,9 @@ $(document).ready(function() { > [% UNLESS ( loop.odd ) %]<tr class="highlight"> > [% ELSE %]<tr>[% END %] > <td> >+ [% UNLESS lateorder.cannot_claim %] > <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber"> >+ [% END %] > </td> > <td> > [% lateorder.orderdate %] >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7292
:
9618
|
10968
|
11284
|
14518
|
21354
|
25078
|
25079
|
26355
|
26356
|
26357
|
26677
|
28462
|
28463
|
28464
|
28465
|
28484
|
28485
|
28486
|
28487
|
30341
|
30342
|
30343
|
30344
|
30345