Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3bb4190a

Von Moritz Bunkus vor mehr als 3 Jahren hinzugefügt

  • ID 3bb4190a48d58f5a598b659c27b9a5bf233aa54b
  • Vorgänger 95f21f71
  • Nachfolger 2350fb7f

Kunden-/Lieferantenstammdaten: Berechtigungsmodell gefixt

Neues Modell sieht wie folgt aus:

1. Alle Personen haben Leserechte auf alle Kunden- &
Lieferantenstammdaten. Das betrifft nicht nur die Stammdatenmasken,
sondern auch die AJAJ-Autovervollständigung (Kunden-/
Lieferanten-Picker) oder die Detail-Popup-Fenster in Einkaufs-/
Verkaufsbelegmasken.

2. Personen mit »edit«-Recht aber ohne »edit all«-Recht dürfen nur die
eigenen Kundenstammdaten verändern (speichern/löschen), wobei
»eigen« definiert ist als »aktuelle Person ist Verkäufer*in des
Kunden«. Neue Kunden dürfen angelegt werden. Bei Lieferanten dürfen
hingegen alle Stammdaten bearbeitet werden.

3. Personen mit »edit all«-Recht haben Vollzugriff auf alle Kunden- &
Lieferantenstammdaten.

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
41 41
use Data::Dumper;
42 42

  
43 43
use Rose::Object::MakeMethods::Generic (
44
  scalar                  => [ qw(user_has_edit_rights) ],
44 45
  'scalar --get_set_init' => [ qw(customer_models vendor_models zugferd_settings) ],
45 46
);
46 47

  
47 48
# safety
48
__PACKAGE__->run_before(
49
  sub {
50
    $::auth->assert('customer_vendor_edit');
51
  },
52
  except => [ qw(ajaj_autocomplete) ],
53
);
54 49
__PACKAGE__->run_before(
55 50
  '_instantiate_args',
56 51
  only => [
......
81 76
);
82 77

  
83 78
# make sure this comes after _load_customer_vendor
84
__PACKAGE__->run_before(
85
  '_check_customer_vendor_all_edit',
86
  only => [
87
    'edit',
88
    'show',
89
    'update',
90
    'delete',
91
    'save',
92
    'save_and_ap_transaction',
93
    'save_and_ar_transaction',
94
    'save_and_close',
95
    'save_and_invoice',
96
    'save_and_order',
97
    'save_and_quotation',
98
    'save_and_rfq',
99
    'delete',
100
    'delete_contact',
101
    'delete_shipto',
102
  ]
103
);
79
__PACKAGE__->run_before('_check_auth');
104 80

  
105 81
__PACKAGE__->run_before(
106 82
  '_create_customer_vendor',
......
656 632
    if (1 == scalar @{ $exact_matches = $manager->get_all(
657 633
      query => [
658 634
        obsolete => 0,
659
        (salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
660 635
        or => [
661 636
          name    => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
662 637
          $number => { ilike => $::form->{filter}{'all:substr:multi::ilike'} },
......
912 887
  }
913 888
}
914 889

  
915
sub _check_customer_vendor_all_edit {
916
  my ($self) = @_;
890
sub _may_access_action {
891
  my ($self, $action)   = @_;
917 892

  
918
  unless ($::auth->assert('customer_vendor_all_edit', 1)) {
919
    die($::locale->text("You don't have the rights to edit this customer.") . "\n")
920
      if $self->{cv}->is_customer and
921
         SL::DB::Manager::Employee->current->id != $self->{cv}->salesman_id;
922
  };
923
};
893
  my $is_new            = !$self->{cv} || !$self->{cv}->id;
894
  my $is_own_customer   = !$is_new
895
                       && $self->{cv}->is_customer
896
                       && (SL::DB::Manager::Employee->current->id == $self->{cv}->salesman_id);
897
  my $has_edit_rights   = $::auth->assert('customer_vendor_all_edit', 1);
898
  $has_edit_rights    ||= $::auth->assert('customer_vendor_edit',     1) && ($is_new || $is_own_customer);
899
  my $needs_edit_rights = $action =~ m{^(?:add|save|delete|update)};
900

  
901
  $self->user_has_edit_rights($has_edit_rights);
902

  
903
  return 1 if $has_edit_rights;
904
  return 0 if $needs_edit_rights;
905
  return 1;
906
}
907

  
908
sub _check_auth {
909
  my ($self, $action) = @_;
910

  
911
  if (!$self->_may_access_action($action)) {
912
    $::auth->deny_access;
913
  }
914
}
924 915

  
925 916
sub _create_customer_vendor {
926 917
  my ($self) = @_;
......
1075 1066
sub _setup_form_action_bar {
1076 1067
  my ($self) = @_;
1077 1068

  
1069
  my $no_rights = $self->user_has_edit_rights ? undef
1070
                : $self->{cv}->is_customer    ? t8("You don't have the rights to edit this customer.")
1071
                :                               t8("You don't have the rights to edit this vendor.");
1072

  
1078 1073
  for my $bar ($::request->layout->get('actionbar')) {
1079 1074
    $bar->add(
1080 1075
      combobox => [
......
1083 1078
          submit    => [ '#form', { action => "CustomerVendor/save" } ],
1084 1079
          checks    => [ 'check_taxzone_and_ustid' ],
1085 1080
          accesskey => 'enter',
1081
          disabled  => $no_rights,
1086 1082
        ],
1087 1083
        action => [
1088 1084
          t8('Save and Close'),
1089 1085
          submit => [ '#form', { action => "CustomerVendor/save_and_close" } ],
1090 1086
          checks => [ 'check_taxzone_and_ustid' ],
1087
          disabled => $no_rights,
1091 1088
        ],
1092 1089
      ], # end of combobox "Save"
1093 1090

  
......
1097 1094
          t8('Save and AP Transaction'),
1098 1095
          submit => [ '#form', { action => "CustomerVendor/save_and_ap_transaction" } ],
1099 1096
          checks => [ 'check_taxzone_and_ustid' ],
1097
          disabled => $no_rights,
1100 1098
        ]) x !!$self->is_vendor,
1101 1099
        (action => [
1102 1100
          t8('Save and AR Transaction'),
1103 1101
          submit => [ '#form', { action => "CustomerVendor/save_and_ar_transaction" } ],
1104 1102
          checks => [ 'check_taxzone_and_ustid' ],
1103
          disabled => $no_rights,
1105 1104
        ]) x !$self->is_vendor,
1106 1105
        action => [
1107 1106
          t8('Save and Invoice'),
1108 1107
          submit => [ '#form', { action => "CustomerVendor/save_and_invoice" } ],
1109 1108
          checks => [ 'check_taxzone_and_ustid' ],
1109
          disabled => $no_rights,
1110 1110
        ],
1111 1111
        action => [
1112 1112
          t8('Save and Order'),
1113 1113
          submit => [ '#form', { action => "CustomerVendor/save_and_order" } ],
1114 1114
          checks => [ 'check_taxzone_and_ustid' ],
1115
          disabled => $no_rights,
1115 1116
        ],
1116 1117
        (action => [
1117 1118
          t8('Save and RFQ'),
1118 1119
          submit => [ '#form', { action => "CustomerVendor/save_and_rfq" } ],
1119 1120
          checks => [ 'check_taxzone_and_ustid' ],
1121
          disabled => $no_rights,
1120 1122
        ]) x !!$self->is_vendor,
1121 1123
        (action => [
1122 1124
          t8('Save and Quotation'),
1123 1125
          submit => [ '#form', { action => "CustomerVendor/save_and_quotation" } ],
1124 1126
          checks => [ 'check_taxzone_and_ustid' ],
1127
          disabled => $no_rights,
1125 1128
        ]) x !$self->is_vendor,
1126 1129
      ], # end of combobox "Workflow"
1127 1130

  
......
1131 1134
        confirm  => t8('Do you really want to delete this object?'),
1132 1135
        disabled => !$self->{cv}->id    ? t8('This object has not been saved yet.')
1133 1136
                  : !$self->is_orphaned ? t8('This object has already been used.')
1134
                  :                       undef,
1137
                  :                       $no_rights,
1135 1138
      ],
1136 1139

  
1137 1140
      'separator',
......
1214 1217
      },
1215 1218
      customernumber => t8('Customer Number'),
1216 1219
    },
1217
    query => [
1218
     ( salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1),
1219
    ],
1220 1220
  );
1221 1221
}
1222 1222

  

Auch abrufbar als: Unified diff