1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  16 # This program is free software; you can redistribute it and/or modify
 
  17 # it under the terms of the GNU General Public License as published by
 
  18 # the Free Software Foundation; either version 2 of the License, or
 
  19 # (at your option) any later version.
 
  21 # This program is distributed in the hope that it will be useful,
 
  22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  24 # GNU General Public License for more details.
 
  25 # You should have received a copy of the GNU General Public License
 
  26 # along with this program; if not, write to the Free Software
 
  27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  28 #======================================================================
 
  31 # add/edit/delete users
 
  33 #======================================================================
 
  35 $menufile = "menu.ini";
 
  41 $form->{"root"} = "root login";
 
  43 $locale = new Locale $language, "admin";
 
  45 eval { require DBI; };
 
  46 $form->error($locale->text('DBI not installed!')) if ($@);
 
  49 if (-f "$form->{path}/custom_$form->{script}") {
 
  50   eval { require "$form->{path}/custom_$form->{script}"; };
 
  51   $form->error($@) if ($@);
 
  54 $form->{stylesheet} = "lx-office-erp.css";
 
  55 $form->{favicon}    = "favicon.ico";
 
  57 if ($form->{action}) {
 
  60   $subroutine = $locale->findsub($form->{action});
 
  62   if ($subroutine eq 'login') {
 
  64       $form->{rpw} = crypt $form->{rpw}, "ro";
 
  74   # if there are no drivers bail out
 
  75   $form->error($locale->text('No Database Drivers available!'))
 
  76     unless (User->dbdrivers);
 
  79   if (!-f $memberfile) {
 
  80     open(FH, ">$memberfile") or $form->error("$memberfile : $!");
 
  81     print FH qq|# SQL-Ledger Accounting members
 
 101     qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
 
 111 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
 
 113     . $locale->text('Version')
 
 114     . qq| $form->{version}<p>|
 
 115     . $locale->text('Administration')
 
 118 <form method=post action="$form->{script}">
 
 122     <th>| . $locale->text('Password') . qq|</th>
 
 123     <td><input type=password name=rpw></td>
 
 124     <td><input type=submit class=submit name=action value="|
 
 125     . $locale->text('Login') . qq|"></td>
 
 127 <input type=hidden name=action value=login>
 
 128 <input type=hidden name=path value=$form->{path}>
 
 134 <a href=http://www.lx-office.org>Lx-Office |
 
 135     . $locale->text('website') . qq|</a>
 
 155     . $locale->text('Administration') . " / "
 
 156     . $locale->text('Add User');
 
 158   $form->{Oracle_sid}    = $sid;
 
 159   $form->{Oracle_dbport} = '1521';
 
 160   $form->{Oracle_dbhost} = `hostname`;
 
 162   if (-f "css/lx-office-erp.css") {
 
 163     $myconfig->{stylesheet} = "lx-office-erp.css";
 
 165   $myconfig->{vclimit} = 200;
 
 167   $myconfig->{"countrycode"} = "de";
 
 168   $myconfig->{"numberformat"} = "1000,00";
 
 169   $myconfig->{"dateformat"} = "dd.mm.yy";
 
 180     . $locale->text('Administration') . " / "
 
 181     . $locale->text('Edit User');
 
 193       qq|<input type=submit class=submit name=action value="|
 
 194       . $locale->text('Delete') . qq|">
 
 195 <input type=hidden name=edit value=1>|;
 
 200 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
 
 201 <input type=hidden name=path value=$form->{path}>
 
 202 <input type=hidden name=rpw value=$form->{rpw}>
 
 204 <input type=submit class=submit name=action value="|
 
 205     . $locale->text('Save') . qq|">
 
 218   $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
 
 220   open(FH, "$memberfile") or $form->error("$memberfile : $!");
 
 223 <input type=submit class=submit name=action value="|
 
 224     . $locale->text('Lock System') . qq|">|;
 
 226   if (-e "$userspath/nologin") {
 
 228 <input type=submit class=submit name=action value="|
 
 229       . $locale->text('Unlock System') . qq|">|;
 
 237       $login =~ s/(\[|\])//g;
 
 240     if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
 
 242       ($null, $member{$login}{$var}) = split(/=/, $_, 2);
 
 248   # type=submit $locale->text('Pg Database Administration')
 
 249   # type=submit $locale->text('Oracle Database Administration')
 
 251   foreach $item (User->dbdrivers) {
 
 253       qq|<input name=action type=submit class=submit value="|
 
 254       . $locale->text("$item Database Administration") . qq|">|;
 
 257   $column_header{login}     = qq|<th>| . $locale->text('Login') . qq|</th>|;
 
 258   $column_header{name}      = qq|<th>| . $locale->text('Name') . qq|</th>|;
 
 259   $column_header{company}   = qq|<th>| . $locale->text('Company') . qq|</th>|;
 
 260   $column_header{dbdriver}  = qq|<th>| . $locale->text('Driver') . qq|</th>|;
 
 261   $column_header{dbhost}    = qq|<th>| . $locale->text('Host') . qq|</th>|;
 
 262   $column_header{dataset}   = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
 
 263   $column_header{templates} =
 
 264     qq|<th>| . $locale->text('Templates') . qq|</th>|;
 
 266   @column_index = qw(login name company dbdriver dbhost dataset templates);
 
 268   $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
 
 275 <form method=post action=$form->{script}>
 
 279   <tr class=listheading>
 
 280     <th>$form->{title}</th>
 
 286         <tr class=listheading>|;
 
 288   map { print "$column_header{$_}\n" } @column_index;
 
 294   foreach $key (sort keys %member) {
 
 296       "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}";
 
 299     $member{$key}{templates} =~ s/^$templates\///;
 
 300     $member{$key}{dbhost} = $locale->text('localhost')
 
 301       unless $member{$key}{dbhost};
 
 302     $member{$key}{dbname} = $member{$key}{dbuser}
 
 303       if ($member{$key}{dbdriver} eq 'Oracle');
 
 305     $column_data{login}     = qq|<td><a id="$key" href="$href">$key</a></td>|;
 
 306     $column_data{name}      = qq|<td>$member{$key}{name}</td>|;
 
 307     $column_data{company}   = qq|<td>$member{$key}{company}</td>|;
 
 308     $column_data{dbdriver}  = qq|<td>$member{$key}{dbdriver}</td>|;
 
 309     $column_data{dbhost}    = qq|<td>$member{$key}{dbhost}</td>|;
 
 310     $column_data{dataset}   = qq|<td>$member{$key}{dbname}</td>|;
 
 311     $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
 
 316         <tr class="listrow$i">|;
 
 318     map { print "$column_data{$_}\n" } @column_index;
 
 329     <td><hr size=3 noshade></td>
 
 333 <input type=hidden name=path value=$form->{path}>
 
 334 <input type=hidden name=rpw value=$form->{rpw}>
 
 336 <br><input type=submit class=submit name=action value="|
 
 337     . $locale->text('Add User') . qq|">
 
 338 <input type=submit class=submit name=action value="|
 
 339     . $locale->text('Change Admin Password') . qq|">
 
 346 | . $locale->text('Click on login name to edit!') . qq|
 
 350     '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.'
 
 356 <form method=post action=login.pl>
 
 358 <table border=0 width=100%>
 
 359   <tr class=listheading>
 
 360     <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
 
 366           <th align=right>| . $locale->text('Name') . qq|</th>
 
 367           <td><input class=login name=login></td>
 
 371           <th align=right>| . $locale->text('Password') . qq|</th>
 
 372           <td><input class=login type=password name=password></td>
 
 373           <td><input type=submit name=action value="|
 
 374     . $locale->text('Login') . qq|"></td>
 
 376 <input type=hidden name=path value=$form->{path}>
 
 394   # if there is a login, get user
 
 395   if ($form->{login}) {
 
 398     $myconfig = new User "$memberfile", "$form->{login}";
 
 400     $myconfig->{signature} =~ s/\\n/\r\n/g;
 
 401     $myconfig->{address}   =~ s/\\n/\r\n/g;
 
 403     # strip basedir from templates directory
 
 404     $myconfig->{templates} =~ s/^$templates\///;
 
 406     # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
 
 409   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
 411       ($item eq $myconfig->{dateformat})
 
 412       ? "<option selected>$item\n"
 
 416   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
 418       ($item eq $myconfig->{numberformat})
 
 419       ? "<option selected>$item\n"
 
 423   %countrycodes = User->country_codes;
 
 425   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
 
 429       ($myconfig->{countrycode} eq $key)
 
 430       ? "<option selected value=$key>$countrycodes{$key}"
 
 431       : "<option value=$key>$countrycodes{$key}";
 
 433   $countrycodes = qq|<option value="">American English\n$countrycodes|;
 
 435   # is there a templates basedir
 
 436   if (!-d "$templates") {
 
 437     $form->error(  $locale->text('Directory')
 
 439                  . $locale->text('does not exist'));
 
 442   opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
 
 443   my @all = readdir(TEMPLATEDIR);
 
 444   my @alldir = sort(grep({ -d "$templates/$_" && !/^\.\.?$/ } @all));
 
 445   my @allhtml = sort(grep({ -f "$templates/$_" && /\.html$/ } @all));
 
 446   closedir TEMPLATEDIR;
 
 448   @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
 
 449   @alldir = grep !/^(webpages|\.svn)$/, @alldir;
 
 451   @allhtml = reverse grep !/Default/, @allhtml;
 
 452   push @allhtml, 'Default';
 
 453   @allhtml = reverse @allhtml;
 
 455   foreach $item (@alldir) {
 
 456     if ($item eq $myconfig->{templates}) {
 
 457       $usetemplates .= qq|<option selected>$item\n|;
 
 459       $usetemplates .= qq|<option>$item\n|;
 
 463   $lastitem = $allhtml[0];
 
 464   $lastitem =~ s/-.*//g;
 
 465   $mastertemplates = qq|<option>$lastitem\n|;
 
 466   foreach $item (@allhtml) {
 
 469     if ($item ne $lastitem) {
 
 470       my $selected = $item eq "German" ? " selected" : "";
 
 471       $mastertemplates .= qq|<option$selected>$item\n|;
 
 476   opendir CSS, "css/.";
 
 477   @all = sort(grep({ /\.css$/ && ($_ ne "tabcontent.css") } readdir(CSS)));
 
 480   foreach $item (@all) {
 
 481     if ($item eq $myconfig->{stylesheet}) {
 
 482       $selectstylesheet .= qq|<option selected>$item\n|;
 
 484       $selectstylesheet .= qq|<option>$item\n|;
 
 490   if ($myconfig->{menustyle} eq "v3") {
 
 491     $menustyle_v3 = "checked";
 
 492   } elsif ($myconfig->{menustyle} eq "neu") {
 
 493     $menustyle_neu = "checked";
 
 495     $menustyle_old = "checked";
 
 501 <form method=post action=$form->{script}>
 
 504   <tr class=listheading><th colspan=2>$form->{title}</th></tr>
 
 510           <th align=right>| . $locale->text('Login') . qq|</th>
 
 511           <td><input name="login" value="$myconfig->{login}"></td>
 
 514           <th align=right>| . $locale->text('Password') . qq|</th>
 
 515           <td><input type="password" name="password" size="8" value="$myconfig->{password}"></td>
 
 516           <input type="hidden" name="old_password" value="$myconfig->{password}">
 
 519           <th align=right>| . $locale->text('Name') . qq|</th>
 
 520           <td><input name="name" size="15" value="$myconfig->{name}"></td>
 
 523           <th align=right>| . $locale->text('E-mail') . qq|</th>
 
 524           <td><input name=email size=30 value="$myconfig->{email}"></td>
 
 527           <th align=right>| . $locale->text('Signature') . qq|</th>
 
 528           <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
 
 531           <th align=right>| . $locale->text('Phone') . qq|</th>
 
 532           <td><input name=tel size=14 value="$myconfig->{tel}"></td>
 
 535           <th align=right>| . $locale->text('Fax') . qq|</th>
 
 536           <td><input name=fax size=14 value="$myconfig->{fax}"></td>
 
 539           <th align=right>| . $locale->text('Company') . qq|</th>
 
 540           <td><input name=company size=35 value="$myconfig->{company}"></td>
 
 543           <th align=right>| . $locale->text('Address') . qq|</th>
 
 544           <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
 
 547           <th align=right>| . $locale->text('Tax number') . qq|</th>
 
 548           <td><input name=taxnumber size=14 value="$myconfig->{taxnumber}"></td>
 
 551           <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
 
 552           <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
 
 555           <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
 
 556           <td><input name=duns size=14 value="$myconfig->{duns}"></td>
 
 563           <th align=right>| . $locale->text('Date Format') . qq|</th>
 
 564           <td><select name=dateformat>$dateformat</select></td>
 
 567           <th align=right>| . $locale->text('Number Format') . qq|</th>
 
 568           <td><select name=numberformat>$numberformat</select></td>
 
 571           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
 
 572           <td><input name=vclimit value="$myconfig->{vclimit}"></td>
 
 575           <th align=right>| . $locale->text('Language') . qq|</th>
 
 576           <td><select name=countrycode>$countrycodes</select></td>
 
 579           <th align=right>| . $locale->text('Character Set') . qq|</th>
 
 580           <td><input name=charset value="$myconfig->{charset}"></td>
 
 583           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
 
 584           <td><select name=userstylesheet>$selectstylesheet</select></td>
 
 587           <th align=right>| . $locale->text('Printer') . qq|</th>
 
 588           <td><input name=printer size=20 value="$myconfig->{printer}"></td>
 
 591           <th align=right>| . $locale->text('Use Templates') . qq|</th>
 
 592           <td><select name=usetemplates>$usetemplates</select></td>
 
 595           <th align=right>| . $locale->text('New Templates') . qq|</th>
 
 596           <td><input name=newtemplates></td>
 
 599           <th align=right>| . $locale->text('Setup Templates') . qq|</th>
 
 600           <td><select name=mastertemplates>$mastertemplates</select></td>
 
 603            <th align=right>| . $locale->text('Setup Menu') . qq|</th>
 
 604            <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
 
 605            $locale->text("Top (CSS)") . qq|
 
 606            <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
 
 607            $locale->text("Top (Javascript)") . qq|
 
 608            <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
 
 609            $locale->text("Old (on the side)") . qq|
 
 612         <input type=hidden name=templates value=$myconfig->{templates}>
 
 616   <tr class=listheading>
 
 617     <th colspan=2>| . $locale->text('Database') . qq|</th>
 
 620   # list section for database drivers
 
 621   foreach $item (User->dbdrivers) {
 
 630     if ($myconfig->{dbdriver} eq $item) {
 
 631       map { $form->{"${item}_$_"} = $myconfig->{$_} }
 
 632         qw(dbhost dbport dbuser dbpasswd dbname sid);
 
 633       $checked = "checked";
 
 637           <th align=right>| . $locale->text('Driver') . qq|</th>
 
 638           <td><input name="dbdriver" type="radio" class="radio" value="$item" $checked> $item</td>
 
 639           <th align=right>| . $locale->text('Host') . qq|</th>
 
 640           <td><input name="${item}_dbhost" size=30 value="$form->{"${item}_dbhost"}"></td>
 
 647           <th align=right>| . $locale->text('Dataset') . qq|</th>
 
 648           <td><input name="Pg_dbname" size="15" value="$form->{Pg_dbname}"></td>
 
 649           <th align=right>| . $locale->text('Port') . qq|</th>
 
 650           <td><input name="Pg_dbport" size="4" value="$form->{Pg_dbport}"></td>
 
 653           <th align=right>| . $locale->text('User') . qq|</th>
 
 654           <td><input name="${item}_dbuser" size=15 value="$form->{"${item}_dbuser"}"></td>
 
 655           <th align=right>| . $locale->text('Password') . qq|</th>
 
 656           <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
 
 661     if ($item eq 'Oracle') {
 
 663           <th align=right>SID</th>
 
 664           <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
 
 665           <th align=right>| . $locale->text('Port') . qq|</th>
 
 666           <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
 
 669           <th align=right>| . $locale->text('Dataset') . qq|</th>
 
 670           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
 
 671           <th align=right>| . $locale->text('Password') . qq|</th>
 
 672           <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
 
 678         <input type="hidden" name="old_dbpasswd" value="$myconfig->{dbpasswd}">
 
 683     <td colspan=2><hr size=2 noshade></td>
 
 690   open(FH, $menufile) or $form->error("$menufile : $!");
 
 692   # scan for first menu level
 
 696   if (open(FH, "custom_$menufile")) {
 
 702     next unless $item =~ /\[/;
 
 703     next if $item =~ /\#/;
 
 705     $item =~ s/(\[|\])//g;
 
 709       ($level, $menuitem) = split /--/, $item, 2;
 
 713       push @acsorder, $item;
 
 716     push @{ $acs{$level} }, $menuitem;
 
 720   %role = ('admin'      => $locale->text('Administrator'),
 
 721            'user'       => $locale->text('User'),
 
 722            'manager'    => $locale->text('Manager'),
 
 723            'supervisor' => $locale->text('Supervisor'));
 
 726   foreach $item (qw(user supervisor manager admin)) {
 
 728       ($myconfig->{role} eq $item)
 
 729       ? "<option selected value=$item>$role{$item}\n"
 
 730       : "<option value=$item>$role{$item}\n";
 
 734   <tr class=listheading>
 
 735     <th colspan=2>| . $locale->text('Access Control') . qq|</th>
 
 738     <td><select name=role>$selectrole</select></td>
 
 742   foreach $item (split(/;/, $myconfig->{acs})) {
 
 743     ($key, $value) = split /--/, $item, 2;
 
 744     $excl{$key}{$value} = 1;
 
 747   foreach $key (@acsorder) {
 
 749     $checked = "checked";
 
 750     if ($form->{login}) {
 
 751       $checked = ($excl{$key}{$key}) ? "" : "checked";
 
 754     # can't have variable names with spaces
 
 755     # the 1 is for apache 2
 
 756     $item = $form->escape("${key}--$key", 1);
 
 759     $acsheading =~ s/ / /g;
 
 762     <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
 
 763     $menuitems .= "$item;";
 
 767     foreach $item (@{ $acs{$key} }) {
 
 768       next if ($key eq $item);
 
 770       $checked = "checked";
 
 771       if ($form->{login}) {
 
 772         $checked = ($excl{$key}{$item}) ? "" : "checked";
 
 775       $acsitem = $form->escape("${key}--$item", 1);
 
 778     <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
 
 779       $menuitems .= "$acsitem;";
 
 786   <tr valign=top>$acsheading $acsdata
 
 791   print qq|<input type=hidden name=acs value="$menuitems">
 
 795       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
 
 796     foreach $directory (@webdavdirs) {
 
 797       if ($myconfig->{$directory}) {
 
 798         $webdav{"${directory}c"} = "checked";
 
 800         $webdav{"${directory}c"} = "";
 
 805     <td colspan=2><hr size=3 noshade></td>
 
 807   <tr class=listheading>
 
 808     <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
 
 812         <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
 
 813         <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
 
 814         <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
 
 817         <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
 
 818         <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
 
 819         <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
 
 823     <td colspan=2><hr size=3 noshade></td>
 
 837   $form->error($locale->text('Database Driver not checked!'))
 
 838     unless $form->{dbdriver};
 
 840   # no spaces allowed in login name
 
 841   ($form->{login}) = split / /, $form->{login};
 
 843   $form->isblank("login", $locale->text('Login name missing!'));
 
 845   # check for duplicates
 
 846   if (!$form->{edit}) {
 
 847     $temp = new User "$memberfile", "$form->{login}";
 
 849     if ($temp->{login}) {
 
 850       $form->error("$form->{login} " . $locale->text('is already a member!'));
 
 854   # no spaces allowed in directories
 
 855   ($form->{newtemplates}) = split / /, $form->{newtemplates};
 
 857   if ($form->{newtemplates}) {
 
 858     $form->{templates} = $form->{newtemplates};
 
 861       ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
 
 865   if (!-d "$templates") {
 
 866     $form->error(  $locale->text('Directory')
 
 868                  . $locale->text('does not exist'));
 
 871   # add base directory to $form->{templates}
 
 872   $form->{templates} = "$templates/$form->{templates}";
 
 874   $myconfig = new User "$memberfile", "$form->{login}";
 
 876   # redo acs variable and delete all the acs codes
 
 877   @acs = split(/;/, $form->{acs});
 
 880   foreach $item (@acs) {
 
 881     $item = $form->escape($item, 1);
 
 883     if (!$form->{$item}) {
 
 884       $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
 
 886     delete $form->{$item};
 
 889   # check which database was filled in
 
 890   if ($form->{dbdriver} eq 'Oracle') {
 
 891     $form->{sid}      = $form->{Oracle_sid},;
 
 892     $form->{dbhost}   = $form->{Oracle_dbhost},;
 
 893     $form->{dbport}   = $form->{Oracle_dbport};
 
 894     $form->{dbpasswd} = $form->{Oracle_dbpasswd};
 
 895     $form->{dbuser}   = $form->{Oracle_dbuser};
 
 896     $form->{dbname}   = $form->{Oracle_dbuser};
 
 898     $form->isblank("dbhost", $locale->text('Hostname missing!'));
 
 899     $form->isblank("dbport", $locale->text('Port missing!'));
 
 900     $form->isblank("dbuser", $locale->text('Dataset missing!'));
 
 902   if ($form->{dbdriver} eq 'Pg') {
 
 903     $form->{dbhost}   = $form->{Pg_dbhost};
 
 904     $form->{dbport}   = $form->{Pg_dbport};
 
 905     $form->{dbpasswd} = $form->{Pg_dbpasswd};
 
 906     $form->{dbuser}   = $form->{Pg_dbuser};
 
 907     $form->{dbname}   = $form->{Pg_dbname};
 
 909     $form->isblank("dbname", $locale->text('Dataset missing!'));
 
 910     $form->isblank("dbuser", $locale->text('Database User missing!'));
 
 915       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
 
 916     foreach $directory (@webdavdirs) {
 
 917       if ($form->{$directory}) {
 
 918         $form->{$directory} = $form->{$directory};
 
 920         $form->{$directory} = 0;
 
 925   foreach $item (keys %{$form}) {
 
 926     $myconfig->{$item} = $form->{$item};
 
 929   delete $myconfig->{stylesheet};
 
 930   if ($form->{userstylesheet}) {
 
 931     $myconfig->{stylesheet} = $form->{userstylesheet};
 
 934   $myconfig->save_member($memberfile, $userspath);
 
 938       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
 
 939     foreach $directory (@webdavdirs) {
 
 940       $file = "webdav/" . $directory . "/webdav-user";
 
 941       if ($form->{$directory}) {
 
 942         if (open(HTACCESS, "$file")) {
 
 944             ($login, $password) = split(/:/, $_);
 
 945             if ($login ne $form->{login}) {
 
 951         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
 
 952         $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
 
 953         print(HTACCESS $newfile);
 
 956         $form->{$directory} = 0;
 
 957         if (open(HTACCESS, "$file")) {
 
 959             ($login, $password) = split(/:/, $_);
 
 960             if ($login ne $form->{login}) {
 
 966         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
 
 967         print(HTACCESS $newfile);
 
 973   # create user template directory and copy master files
 
 974   if (!-d "$form->{templates}") {
 
 977     if (mkdir "$form->{templates}", oct("771")) {
 
 981       # copy templates to the directory
 
 982       opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
 
 983       @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|xml|txb)$/,
 
 985       closedir TEMPLATEDIR;
 
 987       foreach $file (@templates) {
 
 988         open(TEMP, "$templates/$file")
 
 989           or $form->error("$templates/$file : $!");
 
 991         $file =~ s/$form->{mastertemplates}-//;
 
 992         open(NEW, ">$form->{templates}/$file")
 
 993           or $form->error("$form->{templates}/$file : $!");
 
 995         while ($line = <TEMP>) {
 
1002       $form->error("$!: $form->{templates}");
 
1006   $form->redirect($locale->text('User saved!'));
 
1012   $form->{templates} =
 
1013     ($form->{templates})
 
1014     ? "$templates/$form->{templates}"
 
1015     : "$templates/$form->{login}";
 
1017   $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
 
1018   open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
 
1021   open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
 
1028   while ($line = shift @config) {
 
1030     if ($line =~ /^\[/) {
 
1031       last if ($line =~ /\[$form->{login}\]/);
 
1032       $login = &login_name($line);
 
1035     if ($line =~ /^templates=/) {
 
1036       $user{$login} = &get_value($line);
 
1042   # remove everything up to next login or EOF
 
1043   # and save template variable
 
1044   while ($line = shift @config) {
 
1045     if ($line =~ /^templates=/) {
 
1046       $templatedir = &get_value($line);
 
1048     last if ($line =~ /^\[/);
 
1051   # this one is either the next login or EOF
 
1054   $login = &login_name($line);
 
1056   while ($line = shift @config) {
 
1057     if ($line =~ /^\[/) {
 
1058       $login = &login_name($line);
 
1061     if ($line =~ /^templates=/) {
 
1062       $user{$login} = &get_value($line);
 
1069   unlink "${memberfile}.LCK";
 
1071   # scan %user for $templatedir
 
1072   foreach $login (keys %user) {
 
1073     last if ($found = ($templatedir eq $user{$login}));
 
1076   # if found keep directory otherwise delete
 
1079     # delete it if there is a template directory
 
1080     $dir = "$form->{templates}";
 
1082       unlink <$dir/*.html>;
 
1083       unlink <$dir/*.tex>;
 
1084       unlink <$dir/*.sty>;
 
1089   # delete config file for user
 
1090   unlink "$userspath/$form->{login}.conf";
 
1092   $form->redirect($locale->text('User deleted!'));
 
1099   $login =~ s/\[\]//g;
 
1100   return ($login) ? $login : undef;
 
1107   my ($null, $value) = split(/=/, $line, 2);
 
1110   $value =~ s/\s#.*//g;
 
1112   # remove any trailing whitespace
 
1113   $value =~ s/^\s*(.*?)\s*$/$1/;
 
1118 sub change_admin_password {
 
1122     . $locale->text('Administration') . " / "
 
1123     . $locale->text('Change Admin Password');
 
1131 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
 
1133 <form method=post action=$form->{script}>
 
1137     <td><b>| . $locale->text('Password') . qq|</b></td>
 
1138     <td><input type=password name=password size=8></td>
 
1141     <td><b>| . $locale->text('Repeat the password') . qq|</b></td>
 
1142     <td><input type=password name=password_again size=8></b></td>
 
1146 <input type=hidden name=path value=$form->{path}>
 
1147 <input type=hidden name=rpw value=$form->{rpw}>
 
1150 <input type=submit class=submit name=action value="|
 
1151     . $locale->text('Change Password') . qq|">
 
1161 sub change_password {
 
1162   if ($form->{"password"} ne $form->{"password_again"}) {
 
1165       . $locale->text('Administration') . " / "
 
1166       . $locale->text('Change Admin Password');
 
1174 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
 
1176 <p>| . $locale->text("The passwords do not match.") . qq|<br>
 
1177 <input type="button" onclick="history.back()" value="| . $locale->text("Back") . qq|">|;
 
1181   $root->{password} = $form->{password};
 
1183   $root->{'root login'} = 1;
 
1184   $root->save_member($memberfile);
 
1187     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
 
1189   $form->redirect($locale->text('Password changed!'));
 
1193 sub check_password {
 
1194   $root = new User "$memberfile", $form->{root};
 
1196   if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
 
1197     $form->error($locale->text('Incorrect Password!'));
 
1202 sub pg_database_administration {
 
1204   $form->{dbdriver} = 'Pg';
 
1209 sub oracle_database_administration {
 
1211   $form->{dbdriver} = 'Oracle';
 
1216 sub dbdriver_defaults {
 
1218   # load some defaults for the selected driver
 
1220                      'Pg' => { dbport        => '5432',
 
1221                                dbuser        => 'postgres',
 
1222                                dbdefault     => 'template1',
 
1223                                dbhost        => 'localhost',
 
1224                                connectstring => $locale->text('Connect to')
 
1226                      'Oracle' => { dbport        => '1521',
 
1229                                    dbhost        => `hostname`,
 
1230                                    connectstring => 'SID'
 
1233   map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
 
1234     keys %{ $driverdefaults{Pg} };
 
1238 sub dbselect_source {
 
1244     'Leave host and port field empty unless you want to make a remote connection.'
 
1248            'You must enter a host and port for local and remote connections!');
 
1251     "Lx-Office ERP / " . $locale->text('Database Administration');
 
1260 <h2>$form->{title}</h2>
 
1262 <form method=post action=$form->{script}>
 
1269   <tr class=listheading>
 
1270     <th colspan=4>| . $locale->text('Database') . qq|</th>
 
1273 <input type=hidden name=dbdriver value=$form->{dbdriver}>
 
1280     <th align=right>| . $locale->text('Host') . qq|</th>
 
1281     <td><input name=dbhost size=25 value=$form->{dbhost}></td>
 
1282     <th align=right>| . $locale->text('Port') . qq|</th>
 
1283     <td><input name=dbport size=5 value=$form->{dbport}></td>
 
1289     <th align=right>| . $locale->text('User') . qq|</th>
 
1290     <td><input name="dbuser" size="10" value="$form->{dbuser}"></td>
 
1291     <th align=right>| . $locale->text('Password') . qq|</th>
 
1292     <td><input type="password" name="dbpasswd" size="10"></td>
 
1298     <th align=right>$form->{connectstring}</th>
 
1299     <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
 
1308 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
 
1309 <input type=hidden name=path value=$form->{path}>
 
1310 <input type=hidden name=rpw value=$form->{rpw}>
 
1314 <input type=submit class=submit name=action value="|
 
1315     . $locale->text('Create Dataset') . qq|">|;
 
1316 # Vorübergehend Deaktiviert
 
1317 # <input type=submit class=submit name=action value="|
 
1318 #     . $locale->text('Update Dataset') . qq|">
 
1319 print qq| <input type=submit class=submit name=action value="|
 
1320     . $locale->text('Delete Dataset') . qq|">
 
1329     'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
 
1333 <br>$msg{$form->{dbdriver}}
 
1344   &{ $form->{nextsub} };
 
1348 sub update_dataset {
 
1350   %needsupdate = User->dbneedsupdate(\%$form);
 
1354     . $locale->text('Database Administration') . " / "
 
1355     . $locale->text('Update Dataset');
 
1364 <h2>$form->{title}</h2>
 
1367   foreach $key (sort keys %needsupdate) {
 
1368     if ($needsupdate{$key} ne $form->{dbversion}) {
 
1369       $upd .= qq|<input id="$field_id" name="db$key" type="checkbox" value="1" checked> $key\n|;
 
1370       $form->{dbupdate} .= "db$key ";
 
1375   chop $form->{dbupdate};
 
1377   if ($form->{dbupdate}) {
 
1381 <form method=post action=$form->{script}>
 
1383 <input type=hidden name="dbdriver"  value="$form->{dbdriver}">
 
1384 <input type=hidden name="dbhost"    value="$form->{dbhost}">
 
1385 <input type=hidden name="dbport"    value="$form->{dbport}">
 
1386 <input type=hidden name="dbuser"    value="$form->{dbuser}">
 
1387 <input type=hidden name="dbpasswd"  value="$form->{dbpasswd}">
 
1388 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
 
1390 <tr class=listheading>
 
1391   <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
 
1403 <input name=dbupdate type=hidden value="$form->{dbupdate}">
 
1405 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
 
1407 <input type=hidden name=path value=$form->{path}>
 
1408 <input type=hidden name=rpw value=$form->{rpw}>
 
1410 <input type=hidden name=nextsub value=dbupdate>
 
1415 <input type=submit class=submit name=action value="|
 
1416       . $locale->text('Continue') . qq|">
 
1425     print $locale->text('All Datasets up to date!');
 
1438   $form->{"stylesheet"} = "lx-office-erp.css";
 
1439   $form->{"title"} = $main::locale->text("Dataset upgrade");
 
1443          map({ s/\s//g; s/^db//; $_; }
 
1444              grep({ $form->{$_} }
 
1445                   split(/\s+/, $form->{"dbupdate"}))));
 
1446   print($form->parse_html_template("dbupgrade/header",
 
1447                                    { "dbname" => $dbname }));
 
1449   User->dbupdate(\%$form);
 
1454 | . $locale->text('Dataset updated!') . qq|
 
1458 <a id="enddatasetupdate" href="admin.pl?action=login&| .
 
1459 join("&", map({ "$_=" . $form->escape($form->{$_}); } qw(path rpw))) .
 
1460 qq|">| . $locale->text("Continue") . qq|</a>|;
 
1464 sub create_dataset {
 
1466   foreach $item (sort User->dbsources(\%$form)) {
 
1467     $dbsources .= "[$item] ";
 
1470   opendir SQLDIR, "sql/." or $form - error($!);
 
1471   foreach $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
 
1472     next if ($item eq 'Default-chart.sql');
 
1473     $item =~ s/-chart\.sql//;
 
1475       qq| <input name=chart class=radio type=radio value="$item"> $item|;
 
1479   $selectencoding = qq|<option>
 
1480   <option value="SQL_ASCII">ASCII
 
1481   <option value="EUC_JP">Japanese Extended UNIX Code
 
1482   <option value="EUC_CN">Chinese Extended UNIX Code
 
1483   <option value="EUC_KR">Korean Extended UNIX Code
 
1484   <option value="EUC_TW">Taiwan Extended UNIX Code
 
1485   <option value="UNICODE">UTF-8 Unicode
 
1486   <option value="MULE_INTERNAL">Mule internal type
 
1487   <option selected="selected"  value="LATIN1">ISO 8859-1 
 
1488   <option value="LATIN2">ISO 8859-2
 
1489   <option value="LATIN3">ISO 8859-3
 
1490   <option value="LATIN4">ISO 8859-4
 
1491   <option value="LATIN5">ISO 8859-5
 
1492   <option value="LATIN9">ISO 8859-15
 
1493   <option value="KOI8">KOI8-R
 
1494   <option value="WIN">Windows CP1251
 
1495   <option value="ALT">Windows CP866
 
1500     . $locale->text('Database Administration') . " / "
 
1501     . $locale->text('Create Dataset');
 
1510 <h2>$form->{title}</h2>
 
1512 <form method=post action=$form->{script}>
 
1515   <tr class=listheading>
 
1516     <th colspan=2> </th>
 
1521     <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
 
1528     <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
 
1529     <td><input name=db></td>
 
1535     <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
 
1536     <td><select name=encoding>$selectencoding</select></td>
 
1542     <th align=right nowrap>|
 
1543     . $locale->text('Create Chart of Accounts') . qq|</th>
 
1550 <input type=hidden name="dbdriver"  value="$form->{dbdriver}">
 
1551 <input type=hidden name="dbuser"    value="$form->{dbuser}">
 
1552 <input type=hidden name="dbhost"    value="$form->{dbhost}">
 
1553 <input type=hidden name="dbport"    value="$form->{dbport}">
 
1554 <input type=hidden name="dbpasswd"  value="$form->{dbpasswd}">
 
1555 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
 
1557 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
 
1559 <input type=hidden name=path value=$form->{path}>
 
1560 <input type=hidden name=rpw value=$form->{rpw}>
 
1562 <input type=hidden name=nextsub value=dbcreate>
 
1567 <input type=submit class=submit name=action value="|
 
1568     . $locale->text('Continue') . qq|">
 
1584   $form->isblank("db", $locale->text('Dataset missing!'));
 
1586   User->dbcreate(\%$form);
 
1590     . $locale->text('Database Administration') . " / "
 
1591     . $locale->text('Create Dataset');
 
1600 <h2>$form->{title}</h2>
 
1602 <form method=post action=$form->{script}>|
 
1604     . $locale->text('Dataset')
 
1606     . $locale->text('successfully created!')
 
1610 <input type=hidden name=path value="$form->{path}">
 
1611 <input type=hidden name=rpw value="$form->{rpw}">
 
1613 <input type=hidden name=nextsub value=list_users>
 
1615 <p><input type=submit class=submit name=action value="|
 
1616     . $locale->text('Continue') . qq|">
 
1626 sub delete_dataset {
 
1628   if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
 
1629     foreach $item (sort @dbsources) {
 
1631         qq|<input name=db class=radio type=radio value=$item> $item |;
 
1634     $form->error($locale->text('Nothing to delete!'));
 
1639     . $locale->text('Database Administration') . " / "
 
1640     . $locale->text('Delete Dataset');
 
1647 <h2>$form->{title}</h2>
 
1649 <form method=post action=$form->{script}>
 
1652   <tr class=listheading>
 
1654     . $locale->text('The following Datasets are not in use and can be deleted')
 
1666 <input type=hidden name="dbdriver"  value="$form->{dbdriver}">
 
1667 <input type=hidden name="dbuser"    value="$form->{dbuser}">
 
1668 <input type=hidden name="dbhost"    value="$form->{dbhost}">
 
1669 <input type=hidden name="dbport"    value="$form->{dbport}">
 
1670 <input type=hidden name="dbpasswd"  value="$form->{dbpasswd}">
 
1671 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
 
1673 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
 
1675 <input type=hidden name=path value="$form->{path}">
 
1676 <input type=hidden name=rpw value="$form->{rpw}">
 
1678 <input type=hidden name=nextsub value=dbdelete>
 
1683 <input type=submit class=submit name=action value="|
 
1684     . $locale->text('Continue') . qq|">
 
1700     $form->error($locale->text('No Dataset selected!'));
 
1703   User->dbdelete(\%$form);
 
1707     . $locale->text('Database Administration') . " / "
 
1708     . $locale->text('Delete Dataset');
 
1717 <h2>$form->{title}</h2>
 
1719 <form method=post action=$form->{script}>
 
1721 $form->{db} | . $locale->text('successfully deleted!')
 
1725 <input type=hidden name=path value="$form->{path}">
 
1726 <input type=hidden name=rpw value="$form->{rpw}">
 
1728 <input type=hidden name=nextsub value=list_users>
 
1730 <p><input type=submit class=submit name=action value="|
 
1731     . $locale->text('Continue') . qq|">
 
1743   unlink "$userspath/nologin";
 
1746     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
 
1748   $form->redirect($locale->text('Lockfile removed!'));
 
1754   open(FH, ">$userspath/nologin")
 
1755     or $form->error($locale->text('Cannot create Lock!'));
 
1759     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
 
1761   $form->redirect($locale->text('Lockfile created!'));