Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5c0c9e67

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

Mehrere Sanity Checks um zu verhindern, dass $group->{members} Dublikate enthält.

Hoffentlich Fix für Bug 1057.

Unterschiede anzeigen:

SL/Auth.pm
11 11
use Digest::MD5 qw(md5_hex);
12 12
use IO::File;
13 13
use Time::HiRes qw(gettimeofday);
14
use List::MoreUtils qw(uniq);
14 15

  
15 16
use SL::Auth::DB;
16 17
use SL::Auth::LDAP;
......
704 705
  $sth   = prepare_query($form, $dbh, $query);
705 706

  
706 707
  foreach $group (values %{$groups}) {
707
    $group->{members} = [];
708
    my @members;
708 709

  
709 710
    do_statement($form, $sth, $query, $group->{id});
710 711

  
711 712
    while ($row = $sth->fetchrow_hashref()) {
712
      push @{$group->{members}}, $row->{user_id};
713
      push @members, $row->{user_id};
713 714
    }
715
    $group->{members} = [ uniq @members ];
714 716
  }
715 717
  $sth->finish();
716 718

  
......
760 762
  $query  = qq|INSERT INTO auth.user_group (user_id, group_id) VALUES (?, ?)|;
761 763
  $sth    = prepare_query($form, $dbh, $query);
762 764

  
763
  foreach my $user_id (@{ $group->{members} }) {
765
  foreach my $user_id (uniq @{ $group->{members} }) {
764 766
    do_statement($form, $sth, $query, $user_id, $group->{id});
765 767
  }
766 768
  $sth->finish();
bin/mozilla/admin_groups.pl
32 32
#
33 33
#======================================================================
34 34

  
35
use List::MoreUtils qw(uniq);
36

  
35 37
sub edit_groups {
36 38
  $lxdebug->enter_sub();
37 39

  
......
114 116
  my %all_users   = $auth->read_all_users();
115 117
  my %users_by_id = map { $_->{id} => $_ } values %all_users;
116 118

  
117
  my @members     = sort { lc $a->{login} cmp lc $b->{login} } @users_by_id{ @{ $group->{members} } };
119
  my @members     = uniq sort { lc $a->{login} cmp lc $b->{login} } @users_by_id{ @{ $group->{members} } };
118 120

  
119
  my %grouped     = map { $_ => 1 } @{ $group->{members} };
121
  my %grouped     = map { $_ => 1 } uniq @{ $group->{members} };
120 122
  my @non_members = sort { lc $a->{login} cmp lc $b->{login} } grep { !$grouped{$_->{id}} } values %all_users;
121 123

  
122 124
  my @rights = map {
......
173 175
  }
174 176

  
175 177
  $group = $groups->{$form->{group_id}};
176
  push @{ $group->{members} }, $form->{user_id_not_in_group};
178
  $group->{members} = [ uniq @{ $group->{members} }, $form->{user_id_not_in_group} ];
177 179

  
178 180
  $auth->save_group($group);
179 181

  
......
195 197
  }
196 198

  
197 199
  $group            = $groups->{$form->{group_id}};
198
  $group->{members} = [ grep { $_ ne $form->{user_id_in_group} } @{ $group->{members} } ];
200
  $group->{members} = [ uniq grep { $_ ne $form->{user_id_in_group} } @{ $group->{members} } ];
199 201

  
200 202
  $auth->save_group($group);
201 203

  

Auch abrufbar als: Unified diff