-sub login {
- list_users();
-}
-
-sub list_users {
-
- $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
-
- open(FH, "$memberfile") or $form->error("$memberfile : $!");
-
- my %members;
-
- while (<FH>) {
- chomp;
-
- if (/^\[.*\]/) {
- $login = $_;
- $login =~ s/(\[|\])//g;
-
- $members{$login} = { "login" => $login };
- }
-
- if (/^([a-z]+)=(.*)/) {
- $members{$login}->{$1} = $2;
- }
- }
-
- close(FH);
-
- delete $members{"root login"};
- map { $_->{templates} =~ s|.*/||; } values %members;
-
- $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
- $form->{LOCKED} = -e "$userspath/nologin";
- $form->{MEMBERS} = [ @members{sort { lc $a cmp lc $b } keys %members} ];
-
- $form->header();
- print $form->parse_html_template("admin/list_users");
-}
-
-sub add_user {
-
- $form->{title} =
- "Lx-Office ERP "
- . $locale->text('Administration') . " / "
- . $locale->text('Add User');
-
- my $myconfig = {
- "vclimit" => 200,
- "countrycode" => "de",
- "numberformat" => "1000,00",
- "dateformat" => "dd.mm.yy",
- "stylesheet" => "lx-office-erp.css",
- "menustyle" => "v3",
- };
-
- edit_user_form($myconfig);
-}
-
-sub edit {
-
- $form->{title} =
- "Lx-Office ERP "
- . $locale->text('Administration') . " / "
- . $locale->text('Edit User');
- $form->{edit} = 1;
-
- $form->isblank("login", $locale->text("The login is missing."));
-
- # get user
- my $myconfig = new User "$memberfile", "$form->{login}";
-
- $myconfig->{signature} =~ s/\\n/\r\n/g;
- $myconfig->{address} =~ s/\\n/\r\n/g;
-
- # strip basedir from templates directory
- $myconfig->{templates} =~ s|.*/||;
-
- edit_user_form($myconfig);
-}
-
-sub edit_user_form {
- my ($myconfig) = @_;
-
- my @valid_dateformats = qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd);
- $form->{ALL_DATEFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{dateformat} } } @valid_dateformats ];
-
- my @valid_numberformats = qw(1,000.00 1000.00 1.000,00 1000,00);
- $form->{ALL_NUMBERFORMATS} = [ map { { "format" => $_, "selected" => $_ eq $myconfig->{numberformat} } } @valid_numberformats ];
-
- %countrycodes = User->country_codes;
- $form->{ALL_COUNTRYCODES} = [];
- foreach $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
- push @{ $form->{ALL_COUNTRYCODES} }, { "value" => $countrycode,
- "name" => $countrycodes{$countrycode},
- "selected" => $countrycode eq $myconfig->{countrycode} };
- }
-
- # is there a templates basedir
- if (!-d "$templates") {
- $form->error(sprintf($locale->text("The directory %s does not exist."), $templates));
- }
-
- opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
- my @all = readdir(TEMPLATEDIR);
- my @alldir = sort grep { -d "$templates/$_" && !/^\.\.?$/ } @all;
- my @allhtml = sort grep { -f "$templates/$_" && /\.html$/ } @all;
- closedir TEMPLATEDIR;
-
- @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
- @alldir = grep !/^(webpages|\.svn)$/, @alldir;
-
- @allhtml = reverse grep !/Default/, @allhtml;
- push @allhtml, 'Default';
- @allhtml = reverse @allhtml;
-
- $form->{ALL_TEMPLATES} = [ map { { "name", => $_, "selected" => $_ eq $myconfig->{templates} } } @alldir ];
-
- $lastitem = $allhtml[0];
- $lastitem =~ s/-.*//g;
- $form->{ALL_MASTER_TEMPLATES} = [ { "name" => $lastitem, "selected" => $lastitem eq "German" } ];
- foreach $item (@allhtml) {
- $item =~ s/-.*//g;
- next if ($item eq $lastitem);
-
- push @{ $form->{ALL_MASTER_TEMPLATES} }, { "name" => $item, "selected" => $item eq "German" };
- $lastitem = $item;
- }
-
- # css dir has styles that are not intended as general layouts.
- # reverting to hardcoded list
- $form->{ALL_STYLESHEETS} = [ map { { "name" => $_, "selected" => $_ eq $myconfig->{stylesheet} } } qw(lx-office-erp.css Win2000.css) ];
-
- $form->{"menustyle_" . $myconfig->{menustyle} } = 1;
-
- map { $form->{"myc_${_}"} = $myconfig->{$_} } keys %{ $myconfig };
-
- # access control
- my @acsorder = ();
- my %acs = ();
- my %excl = ();
- open(FH, $menufile) or $form->error("$menufile : $!");
-
- while ($item = <FH>) {
- next unless $item =~ /\[/;
- next if $item =~ /\#/;
-
- $item =~ s/(\[|\])//g;
- chomp $item;
-
- my ($level, $menuitem);
-
- if ($item =~ /--/) {
- ($level, $menuitem) = split /--/, $item, 2;