Revision 69df38d3
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/Controller/Admin.pm | ||
---|---|---|
14 | 14 |
|
15 | 15 |
use Rose::Object::MakeMethods::Generic |
16 | 16 |
( |
17 |
'scalar --get_set_init' => [ qw(client user nologin_file_name db_cfg all_dateformats all_numberformats all_countrycodes all_stylesheets all_menustyles all_clients all_groups all_users) ],
|
|
17 |
'scalar --get_set_init' => [ qw(client user group nologin_file_name db_cfg all_dateformats all_numberformats all_countrycodes all_stylesheets all_menustyles all_clients all_groups all_users all_rights is_locked) ],
|
|
18 | 18 |
); |
19 | 19 |
|
20 | 20 |
__PACKAGE__->run_before(\&setup_layout); |
... | ... | |
95 | 95 |
|
96 | 96 |
$self->render( |
97 | 97 |
"admin/show", |
98 |
CLIENTS => SL::DB::Manager::AuthClient->get_all_sorted, |
|
99 |
USERS => SL::DB::Manager::AuthUser->get_all_sorted, |
|
100 |
LOCKED => (-e $self->nologin_file_name), |
|
101 |
title => "kivitendo " . t8('Administration'), |
|
98 |
title => "kivitendo " . t8('Administration'), |
|
102 | 99 |
); |
103 | 100 |
} |
104 | 101 |
|
... | ... | |
242 | 239 |
error => $error); |
243 | 240 |
} |
244 | 241 |
|
242 |
# |
|
243 |
# actions: groups |
|
244 |
# |
|
245 |
|
|
246 |
sub action_new_group { |
|
247 |
my ($self) = @_; |
|
248 |
|
|
249 |
$self->group(SL::DB::AuthGroup->new); |
|
250 |
$self->edit_group_form(title => t8('Create a new group')); |
|
251 |
} |
|
252 |
|
|
253 |
sub action_edit_group { |
|
254 |
my ($self) = @_; |
|
255 |
$self->edit_group_form(title => t8('Edit User Group')); |
|
256 |
} |
|
257 |
|
|
258 |
sub action_save_group { |
|
259 |
my ($self) = @_; |
|
260 |
|
|
261 |
my $params = delete($::form->{group}) || { }; |
|
262 |
my $is_new = !$params->{id}; |
|
263 |
|
|
264 |
$self->group($is_new ? SL::DB::AuthGroup->new : SL::DB::AuthGroup->new(id => $params->{id})->load)->assign_attributes(%{ $params }); |
|
265 |
|
|
266 |
my @errors = $self->group->validate; |
|
267 |
|
|
268 |
if (@errors) { |
|
269 |
flash('error', @errors); |
|
270 |
$self->edit_group_form(title => $is_new ? t8('Create a new user group') : t8('Edit User Group')); |
|
271 |
return; |
|
272 |
} |
|
273 |
|
|
274 |
$self->group->save; |
|
275 |
|
|
276 |
flash_later('info', $is_new ? t8('The user group has been created.') : t8('The user group has been saved.')); |
|
277 |
$self->redirect_to(action => 'show'); |
|
278 |
} |
|
279 |
|
|
280 |
sub action_delete_group { |
|
281 |
my ($self) = @_; |
|
282 |
|
|
283 |
if (!$self->group->delete) { |
|
284 |
flash('error', t8('The user group could not be deleted.')); |
|
285 |
$self->edit_group_form(title => t8('Edit User Group')); |
|
286 |
return; |
|
287 |
} |
|
288 |
|
|
289 |
flash_later('info', t8('The user group has been deleted.')); |
|
290 |
$self->redirect_to(action => 'show'); |
|
291 |
} |
|
292 |
|
|
245 | 293 |
# |
246 | 294 |
# actions: locking, unlocking |
247 | 295 |
# |
... | ... | |
273 | 321 |
|
274 | 322 |
sub init_db_cfg { $::lx_office_conf{'authentication/database'} } |
275 | 323 |
sub init_nologin_file_name { $::lx_office_conf{paths}->{userspath} . '/nologin'; } |
324 |
sub init_is_locked { -e $_[0]->nologin_file_name } |
|
276 | 325 |
sub init_client { SL::DB::AuthClient->new(id => ($::form->{id} || ($::form->{client} || {})->{id}))->load } |
277 | 326 |
sub init_user { SL::DB::AuthUser ->new(id => ($::form->{id} || ($::form->{user} || {})->{id}))->load } |
327 |
sub init_group { SL::DB::AuthGroup ->new(id => ($::form->{id} || ($::form->{group} || {})->{id}))->load } |
|
278 | 328 |
sub init_all_clients { SL::DB::Manager::AuthClient->get_all_sorted } |
279 | 329 |
sub init_all_users { SL::DB::Manager::AuthUser->get_all_sorted } |
280 | 330 |
sub init_all_groups { SL::DB::Manager::AuthGroup->get_all_sorted } |
... | ... | |
289 | 339 |
]; |
290 | 340 |
} |
291 | 341 |
|
342 |
sub init_all_rights { |
|
343 |
my (@sections, $current_section); |
|
344 |
|
|
345 |
foreach my $entry ($::auth->all_rights_full) { |
|
346 |
if ($entry->[0] =~ m/^--/) { |
|
347 |
push @sections, { description => $entry->[1], rights => [] }; |
|
348 |
|
|
349 |
} elsif (@sections) { |
|
350 |
push @{ $sections[-1]->{rights} }, { |
|
351 |
name => $entry->[0], |
|
352 |
description => $entry->[1], |
|
353 |
}; |
|
354 |
|
|
355 |
} else { |
|
356 |
die "Right without sections: " . join('::', @{ $entry }); |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
return \@sections; |
|
361 |
} |
|
362 |
|
|
292 | 363 |
sub init_all_countrycodes { |
293 | 364 |
my %cc = User->country_codes; |
294 | 365 |
return [ map { id => $_, title => $cc{$_} }, sort { $cc{$a} cmp $cc{$b} } keys %cc ]; |
... | ... | |
310 | 381 |
# displaying forms |
311 | 382 |
# |
312 | 383 |
|
384 |
sub use_multiselect_js { |
|
385 |
my ($self) = @_; |
|
386 |
|
|
387 |
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side); |
|
388 |
return $self; |
|
389 |
} |
|
390 |
|
|
313 | 391 |
sub login_form { |
314 | 392 |
my ($self, %params) = @_; |
315 | 393 |
$::request->layout->focus('#admin_password'); |
... | ... | |
318 | 396 |
|
319 | 397 |
sub edit_user_form { |
320 | 398 |
my ($self, %params) = @_; |
321 |
|
|
322 |
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side); |
|
323 |
$self->render('admin/edit_user', %params); |
|
399 |
$self->use_multiselect_js->render('admin/edit_user', %params); |
|
324 | 400 |
} |
325 | 401 |
|
326 | 402 |
sub edit_client_form { |
327 | 403 |
my ($self, %params) = @_; |
404 |
$self->use_multiselect_js->render('admin/edit_client', %params); |
|
405 |
} |
|
328 | 406 |
|
329 |
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side); |
|
330 |
$self->render('admin/edit_client', %params); |
|
407 |
sub edit_group_form { |
|
408 |
my ($self, %params) = @_; |
|
409 |
$self->use_multiselect_js->render('admin/edit_group', %params); |
|
331 | 410 |
} |
332 | 411 |
|
333 | 412 |
# |
Auch abrufbar als: Unified diff
Gruppenverwaltung auf Controllermodel umgestellt
Dabei auch Verknüpfung Gruppen <-> Mandanten implementiert.