From 3ae029cfa8a56f4f2e5b4602cf025f1eece0df69 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 19 Mar 2013 14:49:03 +0000 Subject: [PATCH] [PASSED QA] Bug 8435 [Follow-up] Check superserials permission on subscription-add So subscription creation is now possible for other branches when you have this permission enabled. Signed-off-by: Frederic Durand Signed-off-by: Katrin Fischer --- installer/data/mysql/updatedatabase.pl | 2 +- serials/subscription-add.pl | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 87d5f5d..cf84547 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6723,7 +6723,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } -$DBversion = "3.09.00.XXX"; +$DBversion = "XXX"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch')"); print "Upgrade to $DBversion done (Add superserials permission)\n"; diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 39efa9e..9a42468 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -121,10 +121,16 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { } } -my $onlymine=C4::Context->preference('IndependantBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags} % 2 !=1 && - C4::Context->userenv->{branch}; +my $userenv = C4::Context->userenv; +my $onlymine = + C4::Context->preference('IndependantBranches') + && $userenv + && $userenv->{flags} % 2 != 1 + && ( + not C4::Auth::haspermission( $userenv->{id}, { serials => 'superserials' } ) + ) + && $userenv->{branch}; + my $branches = GetBranches($onlymine); my $branchloop; for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) { -- 1.7.9.5