From 45ef6f62a1830d4eb53b176a790d307b38827aa8 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 --- acqui/basket.pl | 38 +++++++++++++----- .../data/mysql/de-DE/mandatory/userpermissions.sql | 2 +- .../data/mysql/en/mandatory/userpermissions.sql | 2 +- .../data/mysql/es-ES/mandatory/userpermissions.sql | 2 +- .../mysql/fr-FR/1-Obligatoire/userpermissions.sql | 2 +- .../data/mysql/it-IT/necessari/userpermissions.sql | 2 +- .../mysql/nb-NO/1-Obligatorisk/userpermissions.sql | 2 +- .../data/mysql/pl-PL/mandatory/userpermissions.sql | 2 +- .../ru-RU/mandatory/permissions_and_user_flags.sql | 2 +- .../uk-UA/mandatory/permissions_and_user_flags.sql | 2 +- installer/data/mysql/updatedatabase.pl | 2 +- .../intranet-tmpl/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 ef4295b..ad9249c 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -219,6 +219,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("IndependantBranches") ) { my $userenv = C4::Context->userenv; @@ -232,16 +233,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 @@ -362,6 +379,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 9d2c375..cccbff2 100644 --- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql +++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql @@ -15,7 +15,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 a6a0005..0c9c952 100644 --- a/installer/data/mysql/en/mandatory/userpermissions.sql +++ b/installer/data/mysql/en/mandatory/userpermissions.sql @@ -15,7 +15,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 a6a0005..0c9c952 100644 --- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql +++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql @@ -15,7 +15,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 f387a82..7add197 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql @@ -32,7 +32,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 6b0bba8..9f8d7f8 100644 --- a/installer/data/mysql/it-IT/necessari/userpermissions.sql +++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql @@ -17,7 +17,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 327e647..41388df 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql @@ -35,7 +35,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 76f1f5d..a3d487d 100644 --- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql +++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql @@ -15,7 +15,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 268e48c..f7bf478 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 @@ -39,7 +39,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 ce6a271..deae407 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 @@ -39,7 +39,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 4e49b3a..8cad05b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6364,7 +6364,7 @@ if ( C4::Context->preference("Version") < TransformToNum($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 e9111c2..e00fc81 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -261,7 +261,7 @@ [% IF ( deliveryplace ) %]
  • Delivery place: [% deliveryplace %]
  • [% END %] [% IF ( billingplace ) %]
  • Billing place: [% billingplace %]
  • [% END %] [% IF ( authorisedbyname ) %]
  • Created by: [% authorisedbyname %]
  • [% END %] -
  • +
  • Managed by:
    @@ -281,23 +281,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 e1855c3..0733474 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 = ( -- 1.7.2.5