X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fadmin.pl;h=37ac193c21a66cbdead668df258b67770c807df4;hb=6a9ef5df5fb7f1ce451e8d492e3b2b3291eb55a3;hp=cd08e3f9f050f44d412586e2c53ce7b762f38f84;hpb=d9cb2f120ebebd2f7cf1018691fd7c8e8c54f496;p=kivitendo-erp.git diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index cd08e3f9f..37ac193c2 100644 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -34,20 +34,26 @@ $menufile = "menu.ini"; +use DBI; +use CGI; + use SL::Form; use SL::User; +use SL::Common; +use SL::Inifile; + +require "bin/mozilla/common.pl"; + +our $cgi = new CGI(''); $form = new Form; $form->{"root"} = "root login"; $locale = new Locale $language, "admin"; -eval { require DBI; }; -$form->error($locale->text('DBI not installed!')) if ($@); - # customization -if (-f "$form->{path}/custom_$form->{script}") { - eval { require "$form->{path}/custom_$form->{script}"; }; +if (-f "bin/mozilla/custom_$form->{script}") { + eval { require "bin/mozilla/custom_$form->{script}"; }; $form->error($@) if ($@); } @@ -65,9 +71,9 @@ if ($form->{action}) { } } - &check_password; + check_password(); - &$subroutine; + call_sub($subroutine); } else { @@ -87,7 +93,7 @@ password= close FH; } - &adminlogin; + adminlogin(); } @@ -100,52 +106,48 @@ sub adminlogin { $form->{title} = qq|Lx-Office ERP $form->{version} | . $locale->text('Administration'); - $form->header; - - print qq| - - + $form->header(); + print $form->parse_html_template('admin/adminlogin'); +} -
+sub login { + list_users(); +} - -

| - . $locale->text('Version') - . qq| $form->{version}

| - . $locale->text('Administration') - . qq|

+sub list_users { -
+ $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK"); - - - - - - - -{path}> -
| . $locale->text('Password') . qq|
+ open(FH, "$memberfile") or $form->error("$memberfile : $!"); + my %members; -
+ while () { + chomp; -Lx-Office | - . $locale->text('website') . qq| + if (/^\[.*\]/) { + $login = $_; + $login =~ s/(\[|\])//g; -
+ $members{$login} = { "login" => $login }; + } - - -|; + if (/^([a-z]+)=(.*)/) { + $members{$login}->{$1} = $2; + } + } -} + close(FH); -sub login { + delete $members{"root login"}; + map { $_->{templates} =~ s|.*/||; } values %members; - &list_users; + $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 { @@ -155,22 +157,16 @@ sub add_user { . $locale->text('Administration') . " / " . $locale->text('Add User'); - $form->{Oracle_sid} = $sid; - $form->{Oracle_dbport} = '1521'; - $form->{Oracle_dbhost} = `hostname`; - - if (-f "css/lx-office-erp.css") { - $myconfig->{stylesheet} = "lx-office-erp.css"; - } - $myconfig->{vclimit} = 200; - - $myconfig->{"countrycode"} = "de"; - $myconfig->{"numberformat"} = "1000,00"; - $myconfig->{"dateformat"} = "dd.mm.yy"; - - &form_header; - &form_footer; + 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 { @@ -181,268 +177,46 @@ sub edit { . $locale->text('Edit User'); $form->{edit} = 1; - &form_header; - &form_footer; + $form->isblank("login", $locale->text("The login is missing.")); -} + # get user + my $myconfig = new User "$memberfile", "$form->{login}"; -sub form_footer { + $myconfig->{signature} =~ s/\\n/\r\n/g; + $myconfig->{address} =~ s/\\n/\r\n/g; - if ($form->{edit}) { - $delete = - qq| -|; - } - - print qq| - - -{path}> -{rpw}> - - -$delete - - - - - -|; + # strip basedir from templates directory + $myconfig->{templates} =~ s|.*/||; + edit_user_form($myconfig); } -sub list_users { - - $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK"); +sub edit_user_form { + my ($myconfig) = @_; - open(FH, "$memberfile") or $form->error("$memberfile : $!"); + 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 ]; - $nologin = qq| -|; - - if (-e "$userspath/nologin") { - $nologin = qq| -|; - } - - while () { - chop; - - if (/^\[.*\]/) { - $login = $_; - $login =~ s/(\[|\])//g; - } - - if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) { - chop($var = $&); - ($null, $member{$login}{$var}) = split(/=/, $_, 2); - } - } - - close(FH); - - # type=submit $locale->text('Pg Database Administration') - # type=submit $locale->text('Oracle Database Administration') - - foreach $item (User->dbdrivers) { - $dbdrivers .= - qq||; - } - - $column_header{login} = qq|| . $locale->text('Login') . qq||; - $column_header{name} = qq|| . $locale->text('Name') . qq||; - $column_header{company} = qq|| . $locale->text('Company') . qq||; - $column_header{dbdriver} = qq|| . $locale->text('Driver') . qq||; - $column_header{dbhost} = qq|| . $locale->text('Host') . qq||; - $column_header{dataset} = qq|| . $locale->text('Dataset') . qq||; - $column_header{templates} = - qq|| . $locale->text('Templates') . qq||; - - @column_index = qw(login name company dbdriver dbhost dataset templates); - - $form->{title} = "Lx-Office ERP " . $locale->text('Administration'); - - $form->header; - - print qq| - - -
{script}> - - - - - - - - - - - - - -
$form->{title}
- - |; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $key (sort keys %member) { - $href = - "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}"; - $href =~ s/ /%20/g; - - $member{$key}{templates} =~ s/^$templates\///; - $member{$key}{dbhost} = $locale->text('localhost') - unless $member{$key}{dbhost}; - $member{$key}{dbname} = $member{$key}{dbuser} - if ($member{$key}{dbdriver} eq 'Oracle'); - - $column_data{login} = qq||; - $column_data{name} = qq||; - $column_data{company} = qq||; - $column_data{dbdriver} = qq||; - $column_data{dbhost} = qq||; - $column_data{dataset} = qq||; - $column_data{templates} = qq||; - - $i++; - $i %= 2; - print qq| - |; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - |; - } - - print qq| -
$key$member{$key}{name}$member{$key}{company}$member{$key}{dbdriver}$member{$key}{dbhost}$member{$key}{dbname}$member{$key}{templates}
-

- -{path}> -{rpw}> - -
- - -$dbdrivers -$nologin - -
- -| . $locale->text('Click on login name to edit!') . qq| -
-| - . $locale->text( - 'To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.' - ) - . qq| - -

- -

- - - - - - - - -
Lx-Office ERP | . $locale->text('Login') . qq|
- - - - - - - - - - - -{path}> -
| . $locale->text('Name') . qq| 
| . $locale->text('Password') . qq|
-
- -
- -
- - - -|; - -} - -sub form_header { - - # if there is a login, get user - if ($form->{login}) { - - # get user - $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/^$templates\///; - - # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd}; - } - - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $myconfig->{dateformat}) - ? "