From fe777ef937007db24968944c485fccdda170118d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 17 Jul 2012 10:51:36 +0200 Subject: [PATCH] Bug 7295: (follow-up) several fixes - List of libraries in basket.pl is now sorted by branch name, not code - When IndependantBranches is ON, user has only the possibility to set basket branch to its own branch, or to no branch at all. - When basket do not belong to any branch, selected branch by default is connection branch (was 'no branch') - added id attributes to both added li elements - change description of 'order_manage_all' permission to make it clearer. - remove Test::MockModule dependency Signed-off-by: Sonia Bouis Signed-off-by: Kyle M Hall Signed-off-by: Chris Cormack Signed-off-by: Galen Charlton --- acqui/basket.pl | 38 ++++++++++++----- .../mysql/de-DE/mandatory/userpermissions.sql | 2 +- .../mysql/en/mandatory/userpermissions.sql | 2 +- .../mysql/es-ES/mandatory/userpermissions.sql | 2 +- .../fr-FR/1-Obligatoire/userpermissions.sql | 2 +- .../mysql/it-IT/necessari/userpermissions.sql | 2 +- .../nb-NO/1-Obligatorisk/userpermissions.sql | 2 +- .../mysql/pl-PL/mandatory/userpermissions.sql | 2 +- .../mandatory/permissions_and_user_flags.sql | 2 +- .../mandatory/permissions_and_user_flags.sql | 2 +- installer/data/mysql/updatedatabase.pl | 2 +- .../prog/en/modules/acqui/basket.tt | 41 +++++++++++-------- t/Acquisition/CanUserManageBasket.t | 10 ++--- 13 files changed, 67 insertions(+), 42 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index 05f419e5d2..e8b4199d59 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -217,6 +217,7 @@ if ( $op eq 'delete_confirm' ) { print $query->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=$basketno"); exit; } else { + my @branches_loop; # get librarian branch... if ( C4::Context->preference("IndependentBranches") ) { my $userenv = C4::Context->userenv; @@ -230,16 +231,32 @@ if ( $op eq 'delete_confirm' ) { exit 1; } } - } - # get branches - my $branches = C4::Branch::GetBranches; - my @branches_loop; - foreach my $branch (sort keys %$branches) { - push @branches_loop, { - branchcode => $branch, - branchname => $branches->{$branch}->{branchname}, - selected => (defined $basket->{branch} and $branch eq $basket->{branch}) ? 1 : 0 - }; + if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) { + push @branches_loop, { + branchcode => $userenv->{branch}, + branchname => $userenv->{branchname}, + selected => 1, + }; + } + } else { + # get branches + my $branches = C4::Branch::GetBranches; + my @branchcodes = sort { + $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} + } keys %$branches; + foreach my $branch (@branchcodes) { + my $selected = 0; + if (defined $basket->{branch}) { + $selected = 1 if $branch eq $basket->{branch}; + } else { + $selected = 1 if $branch eq C4::Context->userenv->{branch}; + } + push @branches_loop, { + branchcode => $branch, + branchname => $branches->{$branch}->{branchname}, + selected => $selected + }; + } } #if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups @@ -351,6 +368,7 @@ if ( $op eq 'delete_confirm' ) { $template->param( basketno => $basketno, basketname => $basket->{'basketname'}, + basketbranchname => C4::Branch::GetBranchName($basket->{branch}), basketnote => $basket->{note}, basketbooksellernote => $basket->{booksellernote}, basketcontractno => $basket->{contractnumber}, diff --git a/installer/data/mysql/de-DE/mandatory/userpermissions.sql b/installer/data/mysql/de-DE/mandatory/userpermissions.sql index 857b1a7807..ab02a93233 100644 --- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql +++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql @@ -16,7 +16,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Konten verändern (keine Neuen anlegen, aber Bestehende ändern)'), (11, 'planning_manage', 'Etatplanung verwalten'), (11, 'order_manage', 'Bestellungen verwalten'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Bestellgruppen vewalten'), (11, 'order_receive', 'Lieferungen verwalten'), (11, 'budget_add_del', 'Konten hinzufügen/ändern, aber bestehende nicht ändern'), diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql index 9b59c25d8c..50387c5acf 100644 --- a/installer/data/mysql/en/mandatory/userpermissions.sql +++ b/installer/data/mysql/en/mandatory/userpermissions.sql @@ -16,7 +16,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modify budget (can''t create lines, but can modify existing ones)'), (11, 'planning_manage', 'Manage budget plannings'), (11, 'order_manage', 'Manage orders & basket'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Manage orders & basketgroups'), (11, 'order_receive', 'Manage orders & basket'), (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), diff --git a/installer/data/mysql/es-ES/mandatory/userpermissions.sql b/installer/data/mysql/es-ES/mandatory/userpermissions.sql index 9b59c25d8c..50387c5acf 100644 --- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql +++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql @@ -16,7 +16,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modify budget (can''t create lines, but can modify existing ones)'), (11, 'planning_manage', 'Manage budget plannings'), (11, 'order_manage', 'Manage orders & basket'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Manage orders & basketgroups'), (11, 'order_receive', 'Manage orders & basket'), (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql index e385d4e1b1..1d77b85728 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql @@ -33,7 +33,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modifier les budgets (impossible de créer les lignes, mais possible de modifier celles qui existent'), (11, 'planning_manage', 'Gérer de la planification des budgets'), (11, 'order_manage', 'Gérer les commandes et les paniers'), - (11, 'order_manage_all', 'Gérer toutes les commandes et panier'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Gérer les commandes et les bons de commande'), (11, 'order_receive', 'Gérer les réceptions'), (11, 'budget_add_del', 'Ajouter et supprimer les budgets (mais pas modifier)'), diff --git a/installer/data/mysql/it-IT/necessari/userpermissions.sql b/installer/data/mysql/it-IT/necessari/userpermissions.sql index 292c6b4094..ac90a7df79 100644 --- a/installer/data/mysql/it-IT/necessari/userpermissions.sql +++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql @@ -18,7 +18,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modifica budget (non li crea ma modifica gli esistenti)'), (11, 'planning_manage', 'Intervieni sulla pianificazione dei budgets'), (11, 'order_manage', 'Gestisci ordini e raccoglitori'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Gestisci ordini e raccoglitori raggruppati'), (11, 'order_receive', 'Gestisci arrivi'), (11, 'budget_add_del', 'Aggiungi e cancella budgets (senza modificarli)'), diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql index 3217c30500..4371bfb312 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql @@ -36,7 +36,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Endre budsjetter (kan ikke legge til kontolinjer, men endre eksisterende)'), (11, 'planning_manage', 'Administrere budsjettplaner'), (11, 'order_manage', 'Administrere bestillinger og kurver'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Administrere bestillinger og kurv-grupper'), (11, 'order_receive', 'Administrere bestillinger og kurver'), (11, 'budget_add_del', 'Legge til og slette budsjetter (men ikke endre budsjetter)'), diff --git a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql index fa356b8ee3..496e69b3a6 100644 --- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql +++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql @@ -16,7 +16,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modify budget (can''t create lines, but can modify existing ones)'), (11, 'planning_manage', 'Manage budget plannings'), (11, 'order_manage', 'Manage orders & basket'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Manage orders & basketgroups'), (11, 'order_receive', 'Manage orders & basket'), (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), diff --git a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql index 553d9588fe..f7cb905c91 100644 --- a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql +++ b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql @@ -42,7 +42,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modify budget (can''t create lines, but can modify existing ones)'), (11, 'planning_manage', 'Manage budget plannings'), (11, 'order_manage', 'Manage orders & basket'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Manage orders & basketgroups'), (11, 'order_receive', 'Manage orders & basket'), (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), diff --git a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql index 1063c030df..347296c470 100644 --- a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql +++ b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql @@ -42,7 +42,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'budget_modify', 'Modify budget (can''t create lines, but can modify existing ones)'), (11, 'planning_manage', 'Manage budget plannings'), (11, 'order_manage', 'Manage orders & basket'), - (11, 'order_manage_all', 'Manage all orders & baskets'), + (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), (11, 'group_manage', 'Manage orders & basketgroups'), (11, 'order_receive', 'Manage orders & basket'), (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 283c716624..4310259fc5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7678,7 +7678,7 @@ if ( CheckVersion($DBversion) ) { "); $dbh->do(" INSERT INTO permissions (module_bit, code, description) - VALUES (11, 'order_manage_all', 'Manage all orders & baskets') + VALUES (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them') "); print "Upgrade to $DBversion done (Add branch and users list to baskets. " diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 0c4453adab..8e9322a41c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -242,7 +242,7 @@ [% IF ( deliveryplace ) %]
  • Delivery place: [% deliveryplace %]
  • [% END %] [% IF ( billingplace ) %]
  • Billing place: [% billingplace %]
  • [% END %] [% IF ( authorisedbyname ) %]
  • Created by: [% authorisedbyname %]
  • [% END %] -
  • +
  • Managed by:
    @@ -262,23 +262,30 @@
  • -
  • -
    - Branch: - + + [% FOREACH branch IN branches_loop %] + [% IF (branch.selected) %] + + [% ELSE %] + + [% END %] [% END %] - [% END %] - - - - -
    + + + + + + [% END %]
  • [% IF ( creationdate ) %]
  • Opened on: [% creationdate | $KohaDates %]
  • [% END %] [% IF ( closedate ) %]
  • Closed on: [% closedate | $KohaDates %]
  • [% END %] diff --git a/t/Acquisition/CanUserManageBasket.t b/t/Acquisition/CanUserManageBasket.t index e1855c3a02..0733474f97 100644 --- a/t/Acquisition/CanUserManageBasket.t +++ b/t/Acquisition/CanUserManageBasket.t @@ -1,15 +1,15 @@ #!/usr/bin/perl use Modern::Perl; -use Test::MockModule; use Test::More tests => 42; use C4::Acquisition; -my $C4_Acquisition_module = new Test::MockModule('C4::Acquisition'); -$C4_Acquisition_module->mock('GetBasketUsers', \&Mock_GetBasketUsers); -my $C4_Context_module = new Test::MockModule('C4::Context'); -$C4_Context_module->mock('preference', \&Mock_preference); +# Avoid "redefined subroutine" warnings +local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ }; + +*C4::Acquisition::GetBasketUsers = \&Mock_GetBasketUsers; +*C4::Context::preference = \&Mock_preference; my $AcqViewBaskets; my %basketusers = ( -- 2.39.5