Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4531a6c7

Von Sven Schöling vor fast 13 Jahren hinzugefügt

  • ID 4531a6c712b2529a01f31ddde2ef4d7045d173c7
  • Vorgänger 1c5d808c
  • Nachfolger fa6fbcf4

Usermaske im Adminbereich vor logins aus sessions geschützt.

Notwendigerweise zusätzlich User->new und Auth->read_user auf %params
umgeschrieben.

Unterschiede anzeigen:

SL/Auth.pm
54 54
  my ($self, $login, %params) = @_;
55 55
  my $may_fail = delete $params{may_fail};
56 56

  
57
  my %user = $self->read_user($login);
57
  my %user = $self->read_user(login => $login);
58 58
  my $dbh  = SL::DBConnect->connect(
59 59
    $user{dbconnect},
60 60
    $user{dbuser},
......
244 244
sub check_tables {
245 245
  $main::lxdebug->enter_sub();
246 246

  
247
  my $self    = shift;
247
  my ($self, $dbh)    = @_;
248 248

  
249
  my $dbh     = $self->dbconnect();
249
  $dbh   ||= $self->dbconnect();
250 250
  my $query   = qq|SELECT COUNT(*) FROM pg_tables WHERE (schemaname = 'auth') AND (tablename = 'user')|;
251 251

  
252 252
  my ($count) = $dbh->selectrow_array($query);
......
438 438
sub read_user {
439 439
  $main::lxdebug->enter_sub();
440 440

  
441
  my $self  = shift;
442
  my $login = shift;
441
  my ($self, %params) = @_;
443 442

  
444 443
  my $dbh   = $self->dbconnect();
444

  
445
  my (@where, @values);
446
  if ($params{login}) {
447
    push @where,  'u.login = ?';
448
    push @values, $params{login};
449
  }
450
  if ($params{id}) {
451
    push @where,  'u.id = ?';
452
    push @values, $params{id};
453
  }
454
  my $where = join ' AND ', '1 = 1', @where;
445 455
  my $query = qq|SELECT u.id, u.login, cfg.cfg_key, cfg.cfg_value
446 456
                 FROM auth.user_config cfg
447 457
                 LEFT JOIN auth."user" u ON (cfg.user_id = u.id)
448
                 WHERE (u.login = ?)|;
449
  my $sth   = prepare_execute_query($main::form, $dbh, $query, $login);
458
                 WHERE $where|;
459
  my $sth   = prepare_execute_query($main::form, $dbh, $query, @values);
450 460

  
451 461
  my %user_data;
452 462

  
......
485 495
  my $self  = shift;
486 496
  my $login = shift;
487 497

  
488
  my $u_dbh = $self->get_user_dbh($login, may_fail => 1);
489 498
  my $dbh   = $self->dbconnect;
499
  my $id    = $self->get_user_id($login);
500
  my $user_db_exists;
490 501

  
491
  $dbh->begin_work;
502
  $dbh->rollback and return $::lxdebug->leave_sub if (!$id);
492 503

  
493
  my $query = qq|SELECT id FROM auth."user" WHERE login = ?|;
504
  my $u_dbh = $self->get_user_dbh($login, may_fail => 1);
505
  $user_db_exists = $self->check_tables($u_dbh) if $u_dbh;
494 506

  
495
  my ($id)  = selectrow_query($::form, $dbh, $query, $login);
507
  $u_dbh->begin_work if $u_dbh && $user_db_exists;
496 508

  
497
  $dbh->rollback and return $::lxdebug->leave_sub if (!$id);
509
  $dbh->begin_work;
498 510

  
499 511
  do_query($::form, $dbh, qq|DELETE FROM auth.user_group WHERE user_id = ?|, $id);
500 512
  do_query($::form, $dbh, qq|DELETE FROM auth.user_config WHERE user_id = ?|, $id);
501
  do_query($::form, $u_dbh, qq|UPDATE employee SET deleted = 't' WHERE login = ?|, $login) if $u_dbh;
513
  do_query($::form, $dbh, qq|DELETE FROM auth.user WHERE id = ?|, $id);
514
  do_query($::form, $u_dbh, qq|UPDATE employee SET deleted = 't' WHERE login = ?|, $login) if $u_dbh && $user_db_exists;
502 515

  
503 516
  $dbh->commit;
504
  $u_dbh->commit if $u_dbh;
517
  $u_dbh->commit if $u_dbh && $user_db_exists;
505 518

  
506 519
  $::lxdebug->leave_sub;
507 520
}
SL/Dispatcher.pm
205 205

  
206 206
    } else {
207 207
      show_error('login/password_error', 'session') if SL::Auth::SESSION_EXPIRED == $session_result;
208
      %::myconfig = $::auth->read_user($::form->{login});
208
      %::myconfig = $::auth->read_user(login => $::form->{login});
209 209

  
210 210
      show_error('login/password_error', 'password') unless $::myconfig{login};
211 211

  
SL/User.pm
49 49
sub new {
50 50
  $main::lxdebug->enter_sub();
51 51

  
52
  my ($type, $login) = @_;
52
  my ($type, %params) = @_;
53 53

  
54 54
  my $self = {};
55 55

  
56
  if ($login ne "") {
57
    my %user_data = $main::auth->read_user($login);
56
  if ($params{id} || $params{login}) {
57
    my %user_data = $main::auth->read_user(%params);
58 58
    map { $self->{$_} = $user_data{$_} } keys %user_data;
59 59
  }
60 60

  
......
102 102
  my $rc = -3;
103 103

  
104 104
  if ($self->{login}) {
105
    my %myconfig = $main::auth->read_user($self->{login});
105
    my %myconfig = $main::auth->read_user(login => $self->{login});
106 106

  
107 107
    # check if database is down
108 108
    my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd})
......
787 787
  $main::lxdebug->leave_sub();
788 788
}
789 789

  
790
sub data {
791
  +{ %{ $_[0] } }
792
}
793

  
790 794
1;
791 795

  
bin/mozilla/admin.pl
73 73
our $locale;
74 74
our $auth;
75 75

  
76
my @valid_dateformats = qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd);
77
my @valid_numberformats = ('1,000.00', '1000.00', '1.000,00', '1000,00');
78
my @all_stylesheets = qw(lx-office-erp.css Win2000.css);
79
my @all_menustyles = (
80
  { id => 'old', title => $::locale->text('Old (on the side)') },
81
  { id => 'v3',  title => $::locale->text('Top (CSS)') },
82
  { id => 'v4',  title => $::locale->text('Top (CSS) new') },
83
  { id => 'neu', title => $::locale->text('Top (Javascript)') },
84
);
85

  
76 86
sub run {
77 87
  $::lxdebug->enter_sub;
78 88
  my $session_result = shift;
......
366 376
}
367 377

  
368 378
sub add_user {
369
  my $form         = $main::form;
370
  my $locale       = $main::locale;
371

  
372
  $form->{title}   = "Lx-Office ERP " . $locale->text('Administration') . " / " . $locale->text('Add User');
379
  $::form->{title}   = "Lx-Office ERP " . $::locale->text('Administration') . " / " . $::locale->text('Add User');
373 380

  
374 381
# Note: Menu Style 'v3' is not compatible to all browsers!
375 382
# "menustyle"    => "old" sets the HTML Menu to default.
376
  my $myconfig     = {
383
# User does not have a well behaved new constructor, so we#Ll just have to build one ourself
384
  my $user     = bless {
377 385
    "vclimit"      => 200,
378 386
    "countrycode"  => "de",
379 387
    "numberformat" => "1.000,00",
......
383 391
    dbport         => $::auth->{DB_config}->{port} || 5432,
384 392
    dbuser         => $::auth->{DB_config}->{user} || 'lxoffice',
385 393
    dbhost         => $::auth->{DB_config}->{host} || 'localhost',
386
  };
394
  }, 'User';
387 395

  
388

  
389
  edit_user_form($myconfig);
396
  edit_user_form($user);
390 397
}
391 398

  
392 399
sub edit_user {
393
  my $form       = $main::form;
394
  my $locale     = $main::locale;
395

  
396
  $form->{title} = "Lx-Office ERP " . $locale->text('Administration') . " / " . $locale->text('Edit User');
397
  $form->{edit}  = 1;
398

  
399
  $form->isblank("login", $locale->text("The login is missing."));
400
  $::form->{title} = "Lx-Office ERP " . $::locale->text('Administration') . " / " . $::locale->text('Edit User');
401
  $::form->{edit}  = 1;
400 402

  
401 403
  # get user
402
  my $myconfig = new User($form->{login});
404
  my $user = User->new(id => $::form->{user}{id});
403 405

  
404 406
  # strip basedir from templates directory
405
  $myconfig->{templates} =~ s|.*/||;
407
  $user->{templates} =~ s|.*/||;
406 408

  
407
  edit_user_form($myconfig);
409
  edit_user_form($user);
408 410
}
409 411

  
410 412
sub edit_user_form {
411
  my ($myconfig) = @_;
412

  
413
  my $form       = $main::form;
414
  my $locale     = $main::locale;
415

  
416
  my @valid_dateformats = qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd);
417
  $form->{ALL_DATEFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{dateformat} } } @valid_dateformats ];
418

  
419
  my @valid_numberformats = ('1,000.00', '1000.00', '1.000,00', '1000,00');
420
  $form->{ALL_NUMBERFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{numberformat} } } @valid_numberformats ];
421

  
422
  my %countrycodes = User->country_codes;
423
  $form->{ALL_COUNTRYCODES} = [];
424
  foreach my $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
425
    push @{ $form->{ALL_COUNTRYCODES} }, { "value"    => $countrycode,
426
                                           "name"     => $countrycodes{$countrycode},
427
                                           "selected" => $countrycode eq $myconfig->{countrycode} };
428
  }
429

  
430
  # is there a templates basedir
431
  if (!-d $::lx_office_conf{paths}->{templates}) {
432
    $form->error(sprintf($locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
433
  }
434

  
435
  opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO");
436
  my @all     = readdir(TEMPLATEDIR);
437
  my @alldir  = sort grep { -d ($::lx_office_conf{paths}->{templates} . "/$_") && !/^\.\.?$/ } @all;
438
  closedir TEMPLATEDIR;
439

  
440
  @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
441
  @alldir = grep !/^(webpages|print|\.svn)$/, @alldir;
442

  
443
  $form->{ALL_TEMPLATES} = [ map { { "name", => $_, "selected" => $_ eq $myconfig->{templates} } } @alldir ];
444

  
445
  # mastertemplates
446
  opendir TEMPLATEDIR, "$::lx_office_conf{paths}->{templates}/print" or $form->error("$::lx_office_conf{paths}->{templates}/print" . " : $ERRNO");
447
  my @allmaster = readdir(TEMPLATEDIR);
448
  closedir TEMPLATEDIR;
449

  
450
  @allmaster  = sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ } @allmaster;
451
  @allmaster = reverse grep !/Default/, @allmaster;
452
  push @allmaster, 'Default';
453
  @allmaster = reverse @allmaster;
454

  
455
  foreach my $item (@allmaster) {
456
    push @{ $form->{ALL_MASTER_TEMPLATES} }, { "name" => $item, "selected" => $item eq "German" };
457
  }
458

  
459
  # css dir has styles that are not intended as general layouts.
460
  # reverting to hardcoded list
461
  $form->{ALL_STYLESHEETS} = [ map { { "name" => $_, "selected" => $_ eq $myconfig->{stylesheet} } } qw(lx-office-erp.css Win2000.css) ];
462

  
463
  $form->{"menustyle_" . $myconfig->{menustyle} } = 1;
464

  
465
  map { $form->{"myc_${_}"} = $myconfig->{$_} } keys %{ $myconfig };
413
  my ($user) = @_;
466 414

  
415
  my %cc = $user->country_codes;
416
  my @all_countrycodes = map { id => $_, title => $cc{$_} }, sort { $cc{$a} cmp $cc{$b} } keys %cc;
417
  my ($all_dir, $all_master) = _search_templates();
467 418
  my $groups = [];
468 419

  
469
  if ($form->{edit}) {
470
    my $user_id    = $main::auth->get_user_id($form->{login});
471
    my $all_groups = $main::auth->read_groups();
420
  if ($::form->{edit}) {
421
    my $user_id    = $::auth->get_user_id($::form->{login});
422
    my $all_groups = $::auth->read_groups();
472 423

  
473
    foreach my $group (values %{ $all_groups }) {
424
    for my $group (values %{ $all_groups }) {
474 425
      push @{ $groups }, $group if (grep { $user_id == $_ } @{ $group->{members} });
475 426
    }
476 427

  
477 428
    $groups = [ sort { lc $a->{name} cmp lc $b->{name} } @{ $groups } ];
478 429
  }
479 430

  
480
  $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
481

  
482
  $form->header();
483
  print $form->parse_html_template("admin/edit_user", { 'GROUPS' => $groups });
431
  $::form->header;
432
  print $::form->parse_html_template("admin/edit_user", {
433
    GROUPS               => $groups,
434
    CAN_CHANGE_PASSWORD  => $::auth->can_change_password,
435
    user                 => $user->data,
436
    all_stylesheets      => \@all_stylesheets,
437
    all_numberformats    => \@valid_numberformats,
438
    all_dateformats      => \@valid_dateformats,
439
    all_countrycodes     => \@all_countrycodes,
440
    all_menustyles       => \@all_menustyles,
441
    all_templates        => $all_dir,
442
    all_master_templates => $all_master,
443
  });
484 444
}
485 445

  
486 446
sub save_user {
487 447
  my $form          = $main::form;
488 448
  my $locale        = $main::locale;
489 449

  
490
  $form->{dbdriver} = 'Pg';
450
  my $user = $form->{user};
451

  
452
  $user->{dbdriver} = 'Pg';
491 453

  
492
  # no spaces allowed in login name
493
  $form->{login} =~ s|\s||g;
494
  $form->isblank("login", $locale->text('Login name missing!'));
454
  if (!$::form->{edit}) {
455
    # no spaces allowed in login name
456
    $user->{login} =~ s/\s//g;
457
    $::form->show_generic_error($::locale->text('Login name missing!')) unless $user->{login};
495 458

  
496
  # check for duplicates
497
  if (!$form->{edit}) {
498
    my %members = $main::auth->read_all_users();
499
    if ($members{$form->{login}}) {
500
      $form->show_generic_error($locale->text('Another user with the login #1 does already exist.', $form->{login}), 'back_button' => 1);
459
    # check for duplicates
460
    my %members = $::auth->read_all_users;
461
    if ($members{$user->{login}}) {
462
      $::form->show_generic_error($locale->text('Another user with the login #1 does already exist.', $user->{login}), 'back_button' => 1);
501 463
    }
502 464
  }
503 465

  
504 466
  # no spaces allowed in directories
505
  ($form->{newtemplates}) = split / /, $form->{newtemplates};
506

  
507
  if ($form->{newtemplates}) {
508
    $form->{templates} = $form->{newtemplates};
509
  } else {
510
    $form->{templates} =
511
      ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
512
  }
467
  ($::form->{newtemplates}) = split / /, $::form->{newtemplates};
468
  $user->{templates} = $::form->{newtemplates} || $::form->{usetemplates} || $user->{login};
513 469

  
514 470
  # is there a basedir
515 471
  if (!-d $::lx_office_conf{paths}->{templates}) {
516
    $form->error(sprintf($locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
472
    $::form->error(sprintf($::locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
517 473
  }
518 474

  
519 475
  # add base directory to $form->{templates}
520
  $form->{templates} =~ s|.*/||;
521
  $form->{templates} =  $::lx_office_conf{paths}->{templates} . "/$form->{templates}";
522

  
523
  my $myconfig = new User($form->{login});
476
  $user->{templates} =~ s|.*/||;
477
  $user->{templates} =  $::lx_office_conf{paths}->{templates} . "/$user->{templates}";
524 478

  
525
  $form->isblank("dbname", $locale->text('Dataset missing!'));
526
  $form->isblank("dbuser", $locale->text('Database User missing!'));
479
  my $myconfig = new User(id => $form->{id});
527 480

  
528
  foreach my $item (keys %{$form}) {
529
    $myconfig->{$item} = $form->{$item};
530
  }
481
  $::form->show_generic_error($::locale->text('Dataset missing!'))       unless $user->{dbname};
482
  $::form->show_generic_error($::locale->text('Database User missing!')) unless $user->{dbuser};
531 483

  
532
  delete $myconfig->{stylesheet};
533
  if ($form->{userstylesheet}) {
534
    $myconfig->{stylesheet} = $form->{userstylesheet};
484
  foreach my $item (keys %{$user}) {
485
    $myconfig->{$item} = $user->{$item};
535 486
  }
536 487

  
537
  $myconfig->save_member();
488
  $myconfig->save_member;
538 489

  
539
  $form->{templates}       =~ s|.*/||;
540
  $form->{templates}       =  $::lx_office_conf{paths}->{templates} . "/$form->{templates}";
541
  $form->{mastertemplates} =~ s|.*/||;
490
  $user->{templates}       =~ s|.*/||;
491
  $user->{templates}       =  $::lx_office_conf{paths}->{templates} . "/$user->{templates}";
492
  $::form->{mastertemplates} =~ s|.*/||;
542 493

  
543 494
  # create user template directory and copy master files
544
  if (!-d "$form->{templates}") {
495
  if (!-d "$user->{templates}") {
545 496
    umask(002);
546 497

  
547
    if (mkdir "$form->{templates}", oct("771")) {
498
    if (mkdir "$user->{templates}", oct("771")) {
548 499

  
549 500
      umask(007);
550 501

  
551 502
      # copy templates to the directory
552 503

  
553 504
      my $oldcurrdir = getcwd();
554
      if (!chdir("$::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}")) {
555
        $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}");
505
      if (!chdir("$::lx_office_conf{paths}->{templates}/print/$::form->{mastertemplates}")) {
506
        $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/print/$::form->{mastertemplates}");
556 507
      }
557 508

  
558
      my $newdir = File::Spec->catdir($oldcurrdir, $form->{templates});
509
      my $newdir = File::Spec->catdir($oldcurrdir, $user->{templates});
559 510

  
560 511
      find(
561 512
        sub
......
584 535
      chdir($oldcurrdir);
585 536

  
586 537
    } else {
587
      $form->error("$ERRNO: $form->{templates}");
538
      $form->error("$ERRNO: $user->{templates}");
588 539
    }
589 540
  }
590 541

  
591 542
  # Add new user to his groups.
592 543
  if (ref $form->{new_user_group_ids} eq 'ARRAY') {
593 544
    my $all_groups = $main::auth->read_groups();
594
    my %user       = $main::auth->read_user($form->{login});
545
    my %user       = $main::auth->read_user(login => $user->{login});
595 546

  
596 547
    foreach my $group_id (@{ $form->{new_user_group_ids} }) {
597 548
      my $group = $all_groups->{$group_id};
......
604 555
  }
605 556

  
606 557
  if ($main::auth->can_change_password()
607
      && defined $form->{new_password}
608
      && ($form->{new_password} ne '********')) {
558
      && defined $::form->{new_password}
559
      && ($::form->{new_password} ne '********')) {
609 560
    my $verifier = SL::Auth::PasswordPolicy->new;
610
    my $result   = $verifier->verify($form->{new_password}, 1);
561
    my $result   = $verifier->verify($::form->{new_password}, 1);
611 562

  
612 563
    if ($result != SL::Auth::PasswordPolicy->OK()) {
613 564
      $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
614 565
    }
615 566

  
616
    $main::auth->change_password($form->{login}, $form->{new_password});
567
    $main::auth->change_password($user->{login}, $::form->{new_password});
617 568
  }
618 569

  
619
  $form->redirect($locale->text('User saved!'));
570
  $::form->redirect($::locale->text('User saved!'));
620 571
}
621 572

  
622 573
sub save_user_as_new {
623 574
  my $form       = $main::form;
624 575

  
625
  $form->{login} = $form->{new_user_login};
626
  delete @{$form}{qw(edit new_user_login)};
576
  $form->{user}{login} = $::form->{new_user_login};
577
  delete $form->{user}{id};
578
  delete @{$form}{qw(id edit new_user_login)};
627 579

  
628 580
  save_user();
629 581
}
......
632 584
  my $form      = $main::form;
633 585
  my $locale    = $main::locale;
634 586

  
587
  my $user = $::form->{user} || {};
588

  
589
  $::form->show_generic_error($::locale->text('Missing user id!')) unless $user->{id};
590

  
591
  my $loaded_user = User->new(id => $user->{id});
592

  
635 593
  my %members   = $main::auth->read_all_users();
636
  my $templates = $members{$form->{login}}->{templates};
594
  my $templates = $members{$loaded_user->{login}}->{templates};
637 595

  
638
  $main::auth->delete_user($form->{login});
596
  $main::auth->delete_user($loaded_user->{login});
639 597

  
640 598
  if ($templates) {
641 599
    my $templates_in_use = 0;
642 600

  
643 601
    foreach my $login (keys %members) {
644
      next if $form->{login} eq $login;
602
      next if $loaded_user->{login} eq $login;
645 603
      next if $members{$login}->{templates} ne $templates;
646 604
      $templates_in_use = 1;
647 605
      last;
......
1233 1191
  return $::lx_office_conf{paths}->{userspath} . '/nologin';
1234 1192
}
1235 1193

  
1194
sub _search_templates {
1195
  # is there a templates basedir
1196
  if (!-d $::lx_office_conf{paths}->{templates}) {
1197
    $::form->error(sprintf($::locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
1198
  }
1199

  
1200
  opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $::form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO");
1201
  my @all     = readdir(TEMPLATEDIR);
1202
  my @alldir  = sort grep { -d ($::lx_office_conf{paths}->{templates} . "/$_") && !/^\.\.?$/ } @all;
1203
  closedir TEMPLATEDIR;
1204

  
1205
  @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
1206
  @alldir = grep !/^(webpages|print|\.svn)$/, @alldir;
1207

  
1208
  # mastertemplates
1209
  opendir TEMPLATEDIR, "$::lx_office_conf{paths}->{templates}/print" or $::form->error("$::lx_office_conf{paths}->{templates}/print" . " : $ERRNO");
1210
  my @allmaster = readdir(TEMPLATEDIR);
1211
  closedir TEMPLATEDIR;
1212

  
1213
  @allmaster  = sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ } @allmaster;
1214
  @allmaster = reverse grep !/Default/, @allmaster;
1215
  push @allmaster, 'Default';
1216
  @allmaster = reverse @allmaster;
1217

  
1218
  return \@alldir, \@allmaster;
1219
}
1220

  
1236 1221
1;
bin/mozilla/login.pl
61 61
    $action = 'login';
62 62
  }
63 63
  if ($action) {
64
    %::myconfig = $auth->read_user($form->{login}) if ($form->{login});
64
    %::myconfig = $auth->read_user(login => $form->{login}) if ($form->{login});
65 65
    $::locale   = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode};
66 66

  
67 67
    if (SL::Auth::OK != $auth->authenticate($::myconfig{login}, $form->{password})) {
......
106 106
    ::end_of_request();
107 107
  }
108 108

  
109
  my $user = new User $form->{login};
109
  my $user = User->new(login => $form->{login});
110 110

  
111 111
  # if we get an error back, bale out
112 112
  my $result;
scripts/console
73 73

  
74 74
  require "bin/mozilla/common.pl";
75 75

  
76
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user($login);
76
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
77 77

  
78 78
  $::form->{login} = $login; # normaly implicit at login
79 79

  
scripts/dbupgrade2_tool.pl
429 429
                 "and to create them.");
430 430
  }
431 431

  
432
  %myconfig = $auth->read_user($opt_user);
432
  %myconfig = $auth->read_user(login => $opt_user);
433 433

  
434 434
  if (!$myconfig{login}) {
435 435
    $form->error($form->format_string("The user '#1' does not exist.", $opt_user));
scripts/rose_auto_create_model.pl
60 60
  $::form         = new Form;
61 61
  $::auth         = SL::Auth->new();
62 62
  $::user         = User->new($login);
63
  %::myconfig     = $auth->read_user($login);
63
  %::myconfig     = $auth->read_user(login => $login);
64 64
  $::request      = { cgi => CGI->new({}) };
65 65
  $form->{script} = 'rose_meta_data.pl';
66 66
  $form->{login}  = $login;
scripts/task_server.pl
50 50

  
51 51
  require "bin/mozilla/common.pl";
52 52

  
53
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user($login);
53
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
54 54
  die "cannot find locale for user $login" unless $::locale   = Locale->new('de');
55 55
}
56 56

  
t/Support/TestSetup.pm
33 33

  
34 34
  require "bin/mozilla/common.pl";
35 35

  
36
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user($login);
36
  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
37 37

  
38 38
  $::form->{login} = $login; # normaly implicit at login
39 39

  
templates/webpages/admin/edit_user.html
1 1
[%- USE T8 %]
2
[% USE HTML %]<body class="admin">
2
[%- USE HTML %]
3
[%- USE L %]
4
<body class="admin">
3 5

  
4 6
 <script type="text/javascript" src="js/common.js"></script>
5 7
 <script type="text/javascript" src="js/jquery.js"></script>
......
8 10
      function open_connection_test_window() {
9 11
        // host name port user passwd
10 12
        var url = "admin.pl?INPUT_ENCODING=UTF-8&action=test_db_connection&" +
11
          "dbhost="   + encodeURIComponent(get_input_value("dbhost"))   + "&" +
12
          "dbport="   + encodeURIComponent(get_input_value("dbport"))   + "&" +
13
          "dbname="   + encodeURIComponent(get_input_value("dbname"))   + "&" +
14
          "dbuser="   + encodeURIComponent(get_input_value("dbuser"))   + "&" +
15
          "dbpasswd=" + encodeURIComponent(get_input_value("dbpasswd")) + "&";
13
          "dbhost="   + encodeURIComponent(get_input_value("user.dbhost"))   + "&" +
14
          "dbport="   + encodeURIComponent(get_input_value("user.dbport"))   + "&" +
15
          "dbname="   + encodeURIComponent(get_input_value("user.dbname"))   + "&" +
16
          "dbuser="   + encodeURIComponent(get_input_value("user.dbuser"))   + "&" +
17
          "dbpasswd=" + encodeURIComponent(get_input_value("user.dbpasswd")) + "&";
16 18

  
17 19
        var parm = centerParms(400,300) + ",width=400,height=300,status=yes,scrollbars=yes";
18 20

  
......
34 36
       <th align="right">[% 'Login Name' | $T8 %]</th>
35 37
       <td>
36 38
        [%- IF edit %]
37
         <input type="hidden" name="login" value="[% HTML.escape(myc_login) %]">[% HTML.escape(myc_login) %]
39
         <input type="hidden" id='user.id' name="user.id" value="[% HTML.escape(user.id) %]">[% HTML.escape(user.login) %]
38 40
        [%- ELSE %]
39
         <input name="login" value="[% HTML.escape(myc_login) %]">
41
         <input name="user.login" value="[% HTML.escape(user.login) %]">
40 42
        [%- END %]
41 43
       </td>
42 44
      </tr>
......
48 50

  
49 51
      <tr>
50 52
       <th align="right">[% 'Name' | $T8 %]</th>
51
       <td><input name="name" size="15" value="[% HTML.escape(myc_name) %]"></td>
53
       <td><input name="user.name" size="15" value="[% HTML.escape(user.name) %]"></td>
52 54
      </tr>
53 55

  
54 56
      <tr>
55 57
       <th align="right">[% 'E-mail' | $T8 %]</th>
56
       <td><input name="email" size="30" value="[% HTML.escape(myc_email) %]"></td>
58
       <td><input name="user.email" size="30" value="[% HTML.escape(user.email) %]"></td>
57 59
      </tr>
58 60

  
59 61
      <tr valign="top">
60 62
       <th align="right">[% 'Signature' | $T8 %]</th>
61
       <td><textarea name="signature" rows="3" cols="35">[% HTML.escape(myc_signature) %]</textarea></td>
63
       <td><textarea name="user.signature" rows="3" cols="35">[% HTML.escape(user.signature) %]</textarea></td>
62 64
      </tr>
63 65

  
64 66
      <tr>
65 67
       <th align="right">[% 'Phone' | $T8 %]</th>
66
       <td><input name="tel" size="14" value="[% HTML.escape(myc_tel) %]"></td>
68
       <td><input name="user.tel" size="14" value="[% HTML.escape(user.tel) %]"></td>
67 69
      </tr>
68 70

  
69 71
      <tr>
70 72
       <th align="right">[% 'Fax' | $T8 %]</th>
71
       <td><input name="fax" size="14" value="[% HTML.escape(myc_fax) %]"></td>
73
       <td><input name="user.fax" size="14" value="[% HTML.escape(user.fax) %]"></td>
72 74
      </tr>
73 75

  
74 76
      <tr>
75 77
       <th align="right">[% 'Company' | $T8 %]</th>
76
       <td><input name="company" size="35" value="[% HTML.escape(myc_company) %]"></td>
78
       <td><input name="user.company" size="35" value="[% HTML.escape(user.company) %]"></td>
77 79
      </tr>
78 80

  
79 81
      <tr valign="top">
80 82
       <th align="right">[% 'Address' | $T8 %]</th>
81
       <td><textarea name="address" rows="4" cols="35">[% HTML.escape(myc_address) %]</textarea></td>
83
       <td><textarea name="user.address" rows="4" cols="35">[% HTML.escape(user.address) %]</textarea></td>
82 84
      </tr>
83 85

  
84 86
      <tr valign="top">
85 87
       <th align="right">[% 'Tax number' | $T8 %]</th>
86
       <td><input name="taxnumber" size="14" value="[% HTML.escape(myc_taxnumber) %]"></td>
88
       <td><input name="user.taxnumber" size="14" value="[% HTML.escape(user.taxnumber) %]"></td>
87 89
      </tr>
88 90

  
89 91
      <tr valign="top">
90 92
       <th align="right">[% 'Ust-IDNr' | $T8 %]</th>
91
       <td><input name="co_ustid" size="14" value="[% HTML.escape(myc_co_ustid) %]"></td>
93
       <td><input name="user.co_ustid" size="14" value="[% HTML.escape(user.co_ustid) %]"></td>
92 94
      </tr>
93 95

  
94 96
      <tr valign="top">
95 97
       <th align="right">[% 'DUNS-Nr' | $T8 %]</th>
96
       <td><input name="duns" size="14" value="[% HTML.escape(myc_duns) %]"></td>
98
       <td><input name="user.duns" size="14" value="[% HTML.escape(user.duns) %]"></td>
97 99
      </tr>
98 100

  
99 101
      <tr>
100 102
       <th align="right">[% 'SEPA creditor ID' | $T8 %]</th>
101
       <td><input name="sepa_creditor_id" size="35" maxlength="35" value="[% HTML.escape(myc_sepa_creditor_id) %]"></td>
103
       <td><input name="user.sepa_creditor_id" size="35" maxlength="35" value="[% HTML.escape(user.sepa_creditor_id) %]"></td>
102 104
      </tr>
103 105
     </table>
104 106
    </td>
......
107 109
     <table>
108 110
      <tr>
109 111
       <th align="right">[% 'Date Format' | $T8 %]</th>
110
       <td>
111
        <select name="dateformat">
112
         [% FOREACH row = ALL_DATEFORMATS %]<option [% IF row.selected %]selected[% END %]>[% HTML.escape(row.format) %]</option>
113
         [% END %]
114
        </select>
115
       </td>
112
       <td>[% L.select_tag('user.dateformat', L.options_for_select(all_dateformats, default=user.dateformat)) %]</td>
116 113
      </tr>
117 114

  
118 115
      <tr>
119 116
       <th align="right">[% 'Number Format' | $T8 %]</th>
120
       <td>
121
        <select name="numberformat">
122
         [% FOREACH row = ALL_NUMBERFORMATS %]<option [% IF row.selected %]selected[% END %]>[% HTML.escape(row.format) %]</option>
123
         [% END %]
124
        </select>
125
       </td>
117
       <td>[% L.select_tag('user.numberformat', L.options_for_select(all_numberformats, default=user.numberformat)) %]</td>
126 118
      </tr>
127 119

  
128 120
      <tr>
129 121
       <th align="right">[% 'Dropdown Limit' | $T8 %]</th>
130
       <td><input name="vclimit" value="[% HTML.escape(myc_vclimit) %]"></td>
122
       <td><input name="user.vclimit" value="[% HTML.escape(user.vclimit) %]"></td>
131 123
      </tr>
132 124

  
133 125
      <tr>
134 126
       <th align="right">[% 'Language' | $T8 %]</th>
135
       <td>
136
        <select name="countrycode">
137
         [% FOREACH row = ALL_COUNTRYCODES %]<option value="[% HTML.escape(row.value) %]" [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) %]</option>
138
         [% END %]
139
        </select>
140
       </td>
127
       <td>[% L.select_tag('user.countrycode', L.options_for_select(all_countrycodes, title='title', default=user.countrycode)) %]</td>
141 128
      </tr>
142 129

  
143 130
      <tr>
144 131
       <th align="right">[% 'Stylesheet' | $T8 %]</th>
145
       <td>
146
        <select name="userstylesheet">
147
         [% FOREACH row = ALL_STYLESHEETS %]<option [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) %]</option>
148
         [% END %]
149
        </select>
150
       </td>
132
       <td>[% L.select_tag('user.stylesheet', L.options_for_select(all_stylesheets, default=user.stylesheet)) %]</td>
151 133
      </tr>
152 134

  
153 135
      <tr>
154 136
       <th align="right">[% 'Printer' | $T8 %]</th>
155
       <td><input name="printer" size="20" value="[% HTML.escape(myc_printer) %]"></td>
137
       <td><input name="user.printer" size="20" value="[% HTML.escape(user.printer) %]"></td>
156 138
      </tr>
157 139
      <tr>
158 140
       <th align="right">[% 'Use Templates' | $T8 %]</th>
159
       <td>
160
        <select name="usetemplates">
161
         [% FOREACH row = ALL_TEMPLATES %]<option [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) %]</option>
162
         [% END %]
163
        </select>
164
       </td>
141
       <td>[% L.select_tag('usetemplates', L.options_for_select(all_templates, default=user.templates)) %]</td>
165 142
      </tr>
166 143
      <tr>
167 144
       <th align="right">[% 'New Templates' | $T8 %]</th>
......
169 146
      </tr>
170 147
      <tr>
171 148
       <th align="right">[% 'Setup Templates' | $T8 %]</th>
172
       <td>
173
        <select name="mastertemplates">
174
         [% FOREACH row = ALL_MASTER_TEMPLATES %]<option [% IF row.selected %]selected[% END %]>[% HTML.escape(row.name) %]</option>
175
         [% END %]
176
        </select>
177
       </td>
149
       <td>[% L.select_tag('mastertemplates', L.options_for_select(all_master_templates, default='German')) %]</td>
178 150
      </tr>
179 151
      <tr>
180 152
       <th align="right">[% 'Setup Menu' | $T8 %]</th>
181
       <td>
182
        <select name="menustyle">
183
         <option value="old"[% IF menustyle_old %] selected[% END %]>[% 'Old (on the side)' | $T8 %]</option>
184
         <option value="v3"[% IF menustyle_v3 %] selected[% END %]>[% 'Top (CSS)' | $T8 %]</option>
185
         <option value="v4"[% IF menustyle_v4 %] selected[% END %]>[% 'Top (CSS) new' | $T8 %]</option>
186
         <option value="neu"[% IF menustyle_neu %] selected[% END %]>[% 'Top (Javascript)' | $T8 %]</option>
187
        </select>
188
       </td>
153
       <td>[% L.select_tag('user.menustyle', L.options_for_select(all_menustyles, title='title', default=user.menustyle)) %]</td>
189 154
      </tr>
190 155
      <tr>
191 156
       <th align='right'>[% 'Mandatory Departments' | $T8 %]</th>
192 157
       <td>
193
        <input type='radio' name='mandatory_departments' value='0' [% IF !myc_mandatory_departments %] checked[% END %]> [% 'No' | $T8 %]
194
        <input type='radio' name='mandatory_departments' value='1' [% IF  myc_mandatory_departments %] checked[% END %]> [% 'Yes' | $T8 %]
158
        <input type='radio' name='user.mandatory_departments' value='0' [% IF !user.mandatory_departments %] checked[% END %]> [% 'No' | $T8 %]
159
        <input type='radio' name='user.mandatory_departments' value='1' [% IF  user.mandatory_departments %] checked[% END %]> [% 'Yes' | $T8 %]
195 160
       </td>
196 161
      </tr>
197 162

  
198
      <input type="hidden" name="templates" value="[% HTML.escape(myc_templates) %]">
163
      <input type="hidden" name="user.templates" value="[% HTML.escape(user.templates) %]">
199 164
     </table>
200 165
    </td>
201 166
   </tr>
......
211 176
       <th align="right">[% 'Driver' | $T8 %]</th>
212 177
       <td>PostgreSQL</td>
213 178
       <th align="right">[% 'Host' | $T8 %]</th>
214
       <td><input name="dbhost" size="30" value="[% HTML.escape(myc_dbhost) %]"></td>
179
       <td><input name="user.dbhost" size="30" value="[% HTML.escape(user.dbhost) %]"></td>
215 180
      </tr>
216 181

  
217 182
      <tr>
218 183
       <th align="right">[% 'Dataset' | $T8 %]</th>
219
       <td><input name="dbname" size="15" value="[% HTML.escape(myc_dbname) %]"></td>
184
       <td><input name="user.dbname" size="15" value="[% HTML.escape(user.dbname) %]"></td>
220 185
       <th align="right">[% 'Port' | $T8 %]</th>
221
       <td><input name="dbport" size="4" value="[% HTML.escape(myc_dbport) %]"></td>
186
       <td><input name="user.dbport" size="4" value="[% HTML.escape(user.dbport) %]"></td>
222 187
      </tr>
223 188

  
224 189
      <tr>
225 190
       <th align="right">[% 'Database User' | $T8 %]</th>
226
       <td><input name="dbuser" size="15" value="[% HTML.escape(myc_dbuser) %]"></td>
191
       <td><input name="user.dbuser" size="15" value="[% HTML.escape(user.dbuser) %]"></td>
227 192
       <th align="right">[% 'Password' | $T8 %]</th>
228
       <td><input name="dbpasswd" type="password" size="10" value="[% HTML.escape(myc_dbpasswd) %]"></td>
193
       <td><input name="user.dbpasswd" type="password" size="10" value="[% HTML.escape(user.dbpasswd) %]"></td>
229 194
      </tr>
230 195

  
231 196
      <tr>
......
285 250

  
286 251
        $("#action_save_user_as_new").attr('value', '1');
287 252
        $("#new_user_login").attr('value', new_user_login);
253
        $("#user_id").attr('value', '');
288 254
        $("#Form").submit();
289 255
      });
290 256
    });
templates/webpages/admin/list_users.html
21 21

  
22 22
    [% FOREACH row = MEMBERS %]
23 23
     <tr class="listrow[% loop.count % 2 %]">
24
      <td>&nbsp;<a href="admin.pl?action=edit&login=[% HTML.url(row.login_url) %]">[% HTML.escape(row.login) %]</a></td>
24
      <td>&nbsp;<a href="admin.pl?action=edit&user.id=[% HTML.url(row.id) %]">[% HTML.escape(row.login) %]</a></td>
25 25
      <td>&nbsp;[% HTML.escape(row.name) %]</td>
26 26
      <td>&nbsp;[% HTML.escape(row.company) %]</td>
27 27
      <td>&nbsp;[% HTML.escape(row.templates) %]</td>

Auch abrufbar als: Unified diff