Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 471d166b

Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt

  • ID 471d166b4b6a7214d8df6ca8882a8f1a98709634
  • Vorgänger ffddb5c0
  • Nachfolger f825d995

SL::Menu: Negierung (!) beim access_string erlauben

und Tests hierzu

Unterschiede anzeigen:

SL/Menu.pm
180 180

  
181 181
  my $access = $node->{access};
182 182

  
183
  while ($access =~ m/^([a-z_\/]+|\||\&|\(|\)|\s+)/) {
183
  while ($access =~ m/^([a-z_\/]+|\!|\||\&|\(|\)|\s+)/) {
184 184
    my $token = $1;
185 185
    substr($access, 0, length($1)) = "";
186 186

  
......
199 199
      }
200 200
      $cur_ary = $stack[-1];
201 201

  
202
    } elsif (($token eq "|") || ($token eq "&")) {
202
    } elsif (($token eq "|") || ($token eq "&") || ($token eq "!")) {
203 203
      push @{$cur_ary}, $token;
204 204

  
205 205
    } else {
......
273 273
}
274 274

  
275 275
1;
276

  
menus/user/00-erp.yaml
11 11
#          ( ) & | are supported.  if binary operator is missing the last
12 12
#          operator in same scope is repeated, or "|" if none used in scope
13 13
#          yet. client config entries can be used as rights by prefixing them
14
#          with "client/". If missing, access will be granted.
14
#          with "client/".
15
#          ! is supported to negate the subsequent expression.
16
#          If missing, access will be granted.
15 17
#
16 18
#          Example:
17 19
#            client/feature_default_enabled | ( feature & system )
t/menu/parse_access_string.t
57 57
$node{access} = 'sales_quotation_edit & client/feature_experimental';
58 58
ok($menu->parse_access_string(\%node), 'client');
59 59

  
60
$node{access} = '!no_such_right';
61
ok($menu->parse_access_string(\%node), 'simple negation 1');
62

  
63
$node{access} = '!sales_order_edit';
64
ok(!$menu->parse_access_string(\%node), 'simple negation 2');
65

  
66
$node{access} = '!!sales_order_edit';
67
ok($menu->parse_access_string(\%node), 'double negation');
68

  
69
$node{access} = '(no_such_right & sales_order_edit | !(no_such_right & sales_order_edit))';
70
ok($menu->parse_access_string(\%node), 'parenthesis with negation 1');
71

  
72
$node{access} = '(no_such_right & sales_order_edit | (!no_such_right | !sales_order_edit))';
73
ok($menu->parse_access_string(\%node), 'parenthesis with negation 2');
74

  
75
$node{access} = 'sales_quotation_edit & !client/feature_experimental';
76
ok(!$menu->parse_access_string(\%node), 'client negation');
77

  
60 78
done_testing;
61 79

  
62 80
1;

Auch abrufbar als: Unified diff