From 8b4ff253e3498121df023a65bc502d5e099b15e8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 20 Jan 2014 16:27:41 +0100 Subject: [PATCH] =?utf8?q?Pflichtenhefte:=20eigenes=20Recht=20einf=C3=BChr?= =?utf8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Auth.pm | 3 ++- SL/Controller/RequirementSpec.pm | 2 +- SL/Controller/RequirementSpecItem.pm | 2 +- SL/Controller/RequirementSpecOrder.pm | 10 ++++++- SL/Controller/RequirementSpecTextBlock.pm | 6 +++++ SL/Controller/RequirementSpecVersion.pm | 2 +- locale/de/all | 3 ++- menus/erp.ini | 5 +++- .../requirement_spec_rights.pl | 26 +++++++++++++++++++ 9 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 sql/Pg-upgrade2-auth/requirement_spec_rights.pl diff --git a/SL/Auth.pm b/SL/Auth.pm index 13044e776..5a8ee225b 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -1059,6 +1059,7 @@ sub all_rights_full { ["part_service_assembly_details", $locale->text("Show details and reports of parts, services, assemblies")], ["project_edit", $locale->text("Create and edit projects")], ["--ar", $locale->text("AR")], + ["requirement_spec_edit", $locale->text("Create and edit requirement specs")], ["sales_quotation_edit", $locale->text("Create and edit sales quotations")], ["sales_order_edit", $locale->text("Create and edit sales orders")], ["sales_delivery_order_edit", $locale->text("Create and edit sales delivery orders")], @@ -1479,7 +1480,7 @@ Returns C<$self>. Nothing here yet. =head1 AUTHOR - +pp Moritz Bunkus Em.bunkus@linet-services.deE =cut diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index 2a04cf7fb..2f31f97a8 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -289,7 +289,7 @@ sub action_paste_template { sub setup { my ($self) = @_; - $::auth->assert('sales_quotation_edit'); + $::auth->assert('requirement_spec_edit'); $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec); $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery); $self->init_visible_section; diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index 9b8f6436b..44a260219 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -496,7 +496,7 @@ sub action_ajax_paste { sub check_auth { my ($self) = @_; - $::auth->assert('sales_quotation_edit'); + $::auth->assert('requirement_spec_edit'); } sub load_requirement_spec_item { diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index 2bfb1cffd..a3b6889d3 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -54,6 +54,10 @@ sub action_new { sub action_create { my ($self) = @_; + if (!$::auth->assert($::form->{quotation} ? 'sales_quotation_edit' : 'sales_order_edit', 1)) { + return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render($self); + } + # 1. Update sections with selected part IDs. my $section_attrs = $::form->{sections} || []; my $sections = SL::DB::Manager::RequirementSpecItem->get_all(where => [ id => [ map { $_->{id} } @{ $section_attrs } ] ]); @@ -93,6 +97,10 @@ sub action_update { my $order = $self->rs_order->order; my $sections = $self->requirement_spec->sections_sorted; + if (!$::auth->assert($order->quotation ? 'sales_quotation_edit' : 'sales_order_edit', 1)) { + return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render($self); + } + my (@orderitems, %sections_seen); foreach my $item (@{ $order->items_sorted }) { my $section = first { my $num = $_->fb_number; $item->description =~ m{\b\Q${num}\E\b} && !$sections_seen{ $_->id } } @{ $sections }; @@ -204,7 +212,7 @@ sub action_delete { sub setup { my ($self) = @_; - $::auth->assert('sales_quotation_edit'); + $::auth->assert('requirement_spec_edit'); $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec autocomplete_part); $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu client_js requirement_spec); diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index 737f748e8..86f09c2dd 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -26,6 +26,7 @@ use Rose::Object::MakeMethods::Generic 'scalar --get_set_init' => [ qw(predefined_texts js picture) ], ); +__PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete ajax_flag dragged_and_dropped ajax_copy ajax_add_picture)]); # @@ -398,6 +399,11 @@ sub action_reorder_pictures { # filters # +sub check_auth { + my ($self) = @_; + $::auth->assert('requirement_spec_edit'); +} + sub load_requirement_spec_text_block { my ($self) = @_; $self->text_block(SL::DB::RequirementSpecTextBlock->new(id => $::form->{id})->load || die "No such requirement spec text block"); diff --git a/SL/Controller/RequirementSpecVersion.pm b/SL/Controller/RequirementSpecVersion.pm index e1d737ddb..eab34d64e 100644 --- a/SL/Controller/RequirementSpecVersion.pm +++ b/SL/Controller/RequirementSpecVersion.pm @@ -95,7 +95,7 @@ sub action_create { sub check_auth { my ($self, %params) = @_; - $::auth->assert('sales_quotation_edit'); + $::auth->assert('requirement_spec_edit'); } # diff --git a/locale/de/all b/locale/de/all index 756247713..ee87ccd22 100755 --- a/locale/de/all +++ b/locale/de/all @@ -580,6 +580,7 @@ $self->{texts} = { 'Create and edit projects' => 'Projekte erfassen und bearbeiten', 'Create and edit purchase delivery orders' => 'Lieferscheine von Lieferanten erfassen und bearbeiten', 'Create and edit purchase orders' => 'Lieferantenaufträge erfassen und bearbeiten', + 'Create and edit requirement specs' => 'Pflichtenhefte erstellen und bearbeiten', 'Create and edit sales delivery orders' => 'Lieferscheine für Kunden erfassen und bearbeiten', 'Create and edit sales orders' => 'Auftragsbestätigungen erfassen und bearbeiten', 'Create and edit sales quotations' => 'Angebote erfassen und bearbeiten', @@ -2807,7 +2808,7 @@ $self->{texts} = { 'You cannot create an invoice for delivery orders for different customers.' => 'Sie können keine Rechnung zu Lieferscheinen für verschiedene Kunden erstellen.', 'You cannot create an invoice for delivery orders from different vendors.' => 'Sie können keine Rechnung aus Lieferscheinen von verschiedenen Lieferanten erstellen.', 'You cannot paste function blocks or sub function blocks if there is no section.' => 'Sie können keine Funktionsblöcke oder Unterfunktionsblöcke einfügen, wenn es noch keinen Abschnitt gibt.', - 'You do not have the permissions to access this function.' => 'Sie verfügen nicht über die notwendigen Rechte, um auf diese Funktion zuzugreifen.', + 'You do not have the permissions to access this function.' => 'Sie verfügen nicht über die notwendigen Rechte, um auf diese Funktion zuzugreifen.', 'You have entered or selected the following shipping address for this customer:' => 'Sie haben die folgende Lieferadresse eingegeben oder ausgewählt:', 'You have never worked with currencies.' => 'Sie haben noch nie mit Währungen gearbeitet.', 'You have not added bank accounts yet.' => 'Sie haben noch keine Bankkonten angelegt.', diff --git a/menus/erp.ini b/menus/erp.ini index b700dd6a1..dd43bdf8c 100644 --- a/menus/erp.ini +++ b/menus/erp.ini @@ -36,7 +36,7 @@ module=controller.pl action=Project/new [Master Data--Add Requirement Spec Template] -ACCESS=project_edit +ACCESS=requirement_spec_edit module=controller.pl action=RequirementSpec/new is_template=1 @@ -96,6 +96,7 @@ filter.active=active filter.valid=valid [Master Data--Reports--Requirement Spec Templates] +ACCESS=requirement_spec_edit module=controller.pl action=RequirementSpec/list is_template=1 @@ -103,6 +104,7 @@ is_template=1 [AR] [AR--Add Requirement Spec] +ACCESS=requirement_spec_edit module=controller.pl action=RequirementSpec/new @@ -147,6 +149,7 @@ action=acc_menu submenu=1 [AR--Reports--Requirement Specs] +ACCESS=requirement_spec_edit module=controller.pl action=RequirementSpec/list diff --git a/sql/Pg-upgrade2-auth/requirement_spec_rights.pl b/sql/Pg-upgrade2-auth/requirement_spec_rights.pl new file mode 100644 index 000000000..76a9215c6 --- /dev/null +++ b/sql/Pg-upgrade2-auth/requirement_spec_rights.pl @@ -0,0 +1,26 @@ +# @tag: requirement_spec_rights +# @description: Neues Gruppenrecht für Pflichtenhefte +# @depends: release_3_0_0 +package SL::DBUpgrade2::requirement_spec_rights; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +use SL::DBUtils; + +sub run { + my ($self) = @_; + + my $groups = $::auth->read_groups; + + foreach my $group (values %{$groups}) { + $group->{rights}->{requirement_spec_edit} = $group->{rights}->{sales_quotation_edit} ? 1 : 0; + $::auth->save_group($group); + } + + return 1; +} + +1; -- 2.20.1