Revision c0994930
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
bin/mozilla/admin_groups.pl | ||
---|---|---|
73 | 73 |
$form->isblank('name', $locale->text('The group name is missing.')); |
74 | 74 |
|
75 | 75 |
my $groups = $main::auth->read_groups(); |
76 |
my %users = map { ( $_->{id} => 1 ) } values %{ { $::auth->read_all_users() } }; |
|
76 | 77 |
|
77 | 78 |
foreach my $group (values %{$groups}) { |
78 | 79 |
if (($form->{group_id} != $group->{id}) |
... | ... | |
92 | 93 |
|
93 | 94 |
$group->{name} = $form->{name}; |
94 | 95 |
$group->{description} = $form->{description}; |
95 |
$group->{rights} = {}; |
|
96 |
|
|
97 |
map { $group->{rights}->{$_} = $form->{"${_}_granted"} ? 1 : 0 } SL::Auth::all_rights(); |
|
96 |
$group->{rights} = { map { ( $_ => $form->{"${_}_granted"} ? 1 : 0 ) } SL::Auth::all_rights() }; |
|
97 |
$group->{members} = [ grep { $users{$_} } @{ $form->{user_ids} || [] } ]; |
|
98 | 98 |
|
99 | 99 |
my $is_new = !$form->{group_id}; |
100 | 100 |
|
... | ... | |
124 | 124 |
$form->show_generic_error($locale->text("No group has been selected, or the group does not exist anymore.")); |
125 | 125 |
} |
126 | 126 |
|
127 |
my $group = $groups->{$form->{group_id}}; |
|
128 |
|
|
129 |
my %all_users = $main::auth->read_all_users(); |
|
130 |
my %users_by_id = map { $_->{id} => $_ } values %all_users; |
|
131 |
|
|
132 |
my @members = uniq sort { lc $a->{login} cmp lc $b->{login} } @users_by_id{ @{ $group->{members} } }; |
|
133 |
|
|
134 |
my %grouped = map { $_ => 1 } uniq @{ $group->{members} }; |
|
135 |
my @non_members = sort { lc $a->{login} cmp lc $b->{login} } grep { !$grouped{$_->{id}} } values %all_users; |
|
136 |
|
|
137 |
my @rights = map { |
|
127 |
my $group = $groups->{$form->{group_id}}; |
|
128 |
my %all_users = $main::auth->read_all_users(); |
|
129 |
my @rights = map { |
|
138 | 130 |
{ "right" => $_->[0], |
139 | 131 |
"description" => $_->[1], |
140 | 132 |
"is_section" => '--' eq substr($_->[0], 0, 2), |
... | ... | |
143 | 135 |
} SL::Auth::all_rights_full(); |
144 | 136 |
|
145 | 137 |
$form->header(); |
146 |
print $form->parse_html_template("admin/edit_group", { "USERS_IN_GROUP" => \@members,
|
|
147 |
"USERS_NOT_IN_GROUP" => \@non_members,
|
|
138 |
print $form->parse_html_template("admin/edit_group", { ALL_USERS => [ values %all_users ],
|
|
139 |
USER_IDS_IN_GROUP => $group->{members},
|
|
148 | 140 |
"RIGHTS" => \@rights, |
149 | 141 |
"name" => $group->{name}, |
150 | 142 |
"description" => $group->{description} }); |
... | ... | |
179 | 171 |
$main::lxdebug->leave_sub(); |
180 | 172 |
} |
181 | 173 |
|
182 |
sub add_to_group { |
|
183 |
$main::lxdebug->enter_sub(); |
|
184 |
|
|
185 |
my $form = $main::form; |
|
186 |
my $locale = $main::locale; |
|
187 |
|
|
188 |
$form->isblank('user_id_not_in_group', $locale->text('No user has been selected.')); |
|
189 |
|
|
190 |
my $groups = $main::auth->read_groups(); |
|
191 |
|
|
192 |
if (!$form->{group_id} || !$groups->{$form->{group_id}}) { |
|
193 |
$form->show_generic_error($locale->text('No group has been selected, or the group does not exist anymore.')); |
|
194 |
} |
|
195 |
|
|
196 |
my $group = $groups->{$form->{group_id}}; |
|
197 |
$group->{members} = [ uniq @{ $group->{members} }, $form->{user_id_not_in_group} ]; |
|
198 |
|
|
199 |
$main::auth->save_group($group); |
|
200 |
|
|
201 |
$form->{message} = $locale->text('The user has been added to this group.'); |
|
202 |
edit_group(); |
|
203 |
|
|
204 |
$main::lxdebug->leave_sub(); |
|
205 |
} |
|
206 |
|
|
207 |
sub remove_from_group { |
|
208 |
$main::lxdebug->enter_sub(); |
|
209 |
|
|
210 |
my $form = $main::form; |
|
211 |
my $locale = $main::locale; |
|
212 |
|
|
213 |
$form->isblank('user_id_in_group', $locale->text('No user has been selected.')); |
|
214 |
|
|
215 |
my $groups = $main::auth->read_groups(); |
|
216 |
|
|
217 |
if (!$form->{group_id} || !$groups->{$form->{group_id}}) { |
|
218 |
$form->show_generic_error($locale->text('No group has been selected, or the group does not exist anymore.')); |
|
219 |
} |
|
220 |
|
|
221 |
my $group = $groups->{$form->{group_id}}; |
|
222 |
$group->{members} = [ uniq grep { $_ ne $form->{user_id_in_group} } @{ $group->{members} } ]; |
|
223 |
|
|
224 |
$main::auth->save_group($group); |
|
225 |
|
|
226 |
$form->{message} = $locale->text('The user has been removed from this group.'); |
|
227 |
edit_group(); |
|
228 |
|
|
229 |
$main::lxdebug->leave_sub(); |
|
230 |
} |
|
231 |
|
|
232 | 174 |
sub edit_group_membership { |
233 | 175 |
$main::lxdebug->enter_sub(); |
234 | 176 |
|
Auch abrufbar als: Unified diff
Gruppenmitgliedschaft via multiselect2side bearbeiten & Cleanup
Conflicts: