Bugzilla – Attachment 29211 Details for
Bug 8438
Allow staff to only claim serial issues of their own branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8438: Users can only claim for serials related to their branch.
Bug-8438-Users-can-only-claim-for-serials-related-.patch (text/plain), 6.60 KB, created by
Jonathan Druart
on 2014-06-25 10:55:07 UTC
(
hide
)
Description:
Bug 8438: Users can only claim for serials related to their branch.
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-06-25 10:55:07 UTC
Size:
6.60 KB
patch
obsolete
>From 45eaa13e6aa4a383c6d6f09a32c54daf6e1e81a3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 23 Aug 2012 13:53:21 +0200 >Subject: [PATCH] Bug 8438: Users can only claim for serials related to their > branch. > >Only superlibrarian users and users with superserials permission >can override this limitation. > >This patch adds a new subroutine C4::Serials::can_claim_subscription. >--- > C4/Serials.pm | 13 +++++++++ > .../prog/en/modules/serials/claims.tt | 2 ++ > serials/claims.pl | 5 ++++ > t/db_dependent/Serials_2.t | 32 +++++++++++++++++++++- > 4 files changed, 51 insertions(+), 1 deletion(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index bcb37e3..d3c9a30 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -2787,6 +2787,19 @@ sub subscriptionCurrentlyOnOrder { > return $sth->fetchrow_array; > } > >+=head2 can_claim_subscription >+ >+ $can = can_claim_subscription( $subscriptionid[, $userid] ); >+ >+Return 1 if the subscription can be claimed by the current logged user (or a given $userid), else 0. >+ >+=cut >+ >+sub can_claim_subscription { >+ my ( $subscription, $userid ) = @_; >+ return _can_do_on_subscription( $subscription, $userid, 'claim_serials' ); >+} >+ > =head2 can_edit_subscription > > $can = can_edit_subscription( $subscriptionid[, $userid] ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >index de9102e..6291904 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >@@ -275,7 +275,9 @@ > <tbody>[% FOREACH missingissue IN missingissues %] > <tr> > <td> >+ [% UNLESS missingissue.cannot_claim %] > <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" /> >+ [% END %] > </td> > <td> > [% missingissue.name %] >diff --git a/serials/claims.pl b/serials/claims.pl >index 13167d7..33bf799 100755 >--- a/serials/claims.pl >+++ b/serials/claims.pl >@@ -67,6 +67,11 @@ if ($supplierid) { > @supplierinfo=GetBookSeller($supplierid); > } > >+foreach my $issue (@missingissues) { >+ $issue->{cannot_claim} = 1 >+ unless C4::Serials::can_claim_subscription($issue); >+} >+ > my $branchloop = GetBranchesLoop(); > > my $preview=0; >diff --git a/t/db_dependent/Serials_2.t b/t/db_dependent/Serials_2.t >index c11c0d3..1433b1d 100644 >--- a/t/db_dependent/Serials_2.t >+++ b/t/db_dependent/Serials_2.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > use Modern::Perl; > >-use Test::More tests => 37; >+use Test::More tests => 47; > > use MARC::Record; > >@@ -71,6 +71,7 @@ my $subscriptionid_from_another_branch = NewSubscription( > > my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch ); > is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); > > my $userid = 'my_userid'; > my $borrowernumber = C4::Members::AddMember( >@@ -86,6 +87,7 @@ $userenv = { flags => 1, id => $borrowernumber, branch => '' }; > # Can edit a subscription > > is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); > > my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch ); > >@@ -107,6 +109,13 @@ is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, > is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, > "With IndependentBranches, superlibrarian can show a subscription from another branch" > ); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, >+"With IndependentBranches, superlibrarian can claim a subscription from his branch" >+); >+is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, >+"With IndependentBranches, superlibrarian can claim a subscription from another branch" >+); >+ > > set_flags( 'superserials', $borrowernumber ); > is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, >@@ -121,6 +130,13 @@ is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, > is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, > "With IndependentBranches, superserials can show a subscription from another branch" > ); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, >+"With IndependentBranches, superserials can claim a subscription from his branch" >+); >+is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, >+"With IndependentBranches, superserials can claim a subscription from another branch" >+); >+ > > > set_flags( 'edit_subscription', $borrowernumber ); >@@ -136,6 +152,13 @@ is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, > is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, > "With IndependentBranches, show_subscription cannot show a subscription from another branch" > ); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, >+"With IndependentBranches, claim_subscription cannot claim a subscription from his branch with the edit_subscription permission" >+); >+is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, >+"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" >+); >+ > > set_flags( 'renew_subscription', $borrowernumber ); > is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, >@@ -151,6 +174,13 @@ is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, > "With IndependentBranches, renew_subscription cannot show a subscription from another branch" > ); > >+set_flags( 'claim_serials', $borrowernumber ); >+is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, >+"With IndependentBranches, claim_subscription can claim a subscription from his branch with the edit_subscription permission" >+); >+is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, >+"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" >+); > > # Branches are not independent > t::lib::Mocks::mock_preference( "IndependentBranches", 0 ); >-- >2.0.0.rc2
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 8438
:
11778
|
12842
|
24074
|
26399
|
26400
|
29098
|
29099
|
29191
|
29192
|
29211
|
29212
|
35177
|
35178
|
35305
|
35306
|
35311
|
35312
|
43560