unstable-Zweig als Kopie des "alten" trunks erstellt.
[kivitendo-erp.git] / bin / mozilla / admin.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #
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.
20 #
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 #======================================================================
29 #
30 # setup module
31 # add/edit/delete users
32 #
33 #======================================================================
34
35 $menufile = "menu.ini";
36
37 use SL::Form;
38 use SL::User;
39
40
41 $form = new Form;
42
43 $locale = new Locale $language, "admin";
44   
45 eval { require DBI; };
46 $form->error($locale->text('DBI not installed!')) if ($@);
47
48
49 # customization
50 if (-f "$form->{path}/custom_$form->{script}") {
51   eval { require "$form->{path}/custom_$form->{script}"; };
52   $form->error($@) if ($@);
53 }
54
55
56 $form->{stylesheet} = "lx-office-erp.css";
57 $form->{favicon} = "favicon.ico";
58
59 if ($form->{action}) {
60
61   $subroutine = $locale->findsub($form->{action});
62   
63   if ($subroutine eq 'login') {
64     if ($form->{rpw}) {
65       $form->{rpw} = crypt $form->{rpw}, "ro";
66     }
67   }
68   
69   &check_password;
70   
71   &$subroutine;
72     
73 } else {
74
75   # if there are no drivers bail out
76   $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
77
78   # create memberfile
79   if (! -f $memberfile) {
80     open(FH, ">$memberfile") or $form->error("$memberfile : $!");
81     print FH qq|# SQL-Ledger Accounting members
82
83 [root login]
84 password=
85
86 |;
87     close FH;
88   }
89
90   &adminlogin;
91
92 }
93
94 1;
95 # end
96
97
98 sub adminlogin {
99
100   $form->{title} = qq|Lx-Office ERP $form->{version} |.$locale->text('Administration');
101
102   $form->header;
103   
104   print qq|
105 <body class=admin>
106
107
108 <div align=center>
109
110 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
111 <h1 class=login>|.$locale->text('Version').qq| $form->{version}<p>|.$locale->text('Administration').qq|</h1>
112
113 <form method=post action="$form->{script}">
114
115 <table>
116   <tr>
117     <th>|.$locale->text('Password').qq|</th>
118     <td><input type=password name=rpw></td>
119     <td><input type=submit class=submit name=action value="|.$locale->text('Login').qq|"></td>
120   </tr>
121 <input type=hidden name=action value=login>
122 <input type=hidden name=root value="root login">
123 <input type=hidden name=path value=$form->{path}>
124 </table>
125
126
127 </form>
128
129 <a href=http://www.lx-office.org>Lx-Office |.$locale->text('website').qq|</a>
130
131 </div>
132
133 </body>
134 </html>
135 |;
136
137 }
138
139
140
141
142 sub login {
143
144   &list_users;
145
146 }
147
148
149
150 sub add_user {
151   
152   $form->{title} = "Lx-Office ERP ".$locale->text('Administration')." / ".$locale->text('Add User');
153
154   $form->{Oracle_sid} = $sid;
155   $form->{Oracle_dbport} = '1521';
156   $form->{Oracle_dbhost} = `hostname`;
157
158   if (-f "css/lx-office-erp.css") {
159     $myconfig->{stylesheet} = "lx-office-erp.css";
160   }
161   $myconfig->{vclimit} = 200;
162   
163   &form_header;
164   &form_footer;
165   
166 }
167
168
169
170 sub edit {
171
172   $form->{title} = "Lx-Office ERP ".$locale->text('Administration')." / ".$locale->text('Edit User');
173   $form->{edit} = 1;
174
175   &form_header;
176   &form_footer;
177
178 }
179
180
181 sub form_footer {
182
183   if ($form->{edit}) {
184     $delete = qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">
185 <input type=hidden name=edit value=1>|;
186   }
187
188   print qq|
189
190 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
191 <input type=hidden name=root value="$form->{root}">
192 <input type=hidden name=path value=$form->{path}>
193 <input type=hidden name=rpw value=$form->{rpw}>
194
195 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
196 $delete
197
198 </form>
199
200 </body>
201 </html>
202 |;
203
204 }
205
206
207 sub list_users {
208
209   $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
210
211   open(FH, "$memberfile") or $form->error("$memberfile : $!");
212
213   $nologin = qq|
214 <input type=submit class=submit name=action value="|.$locale->text('Lock System').qq|">|;
215
216   if (-e "$userspath/nologin") {
217     $nologin = qq|
218 <input type=submit class=submit name=action value="|.$locale->text('Unlock System').qq|">|;
219   }
220
221
222   while (<FH>) {
223     chop;
224     
225     if (/^\[.*\]/) {
226       $login = $_;
227       $login =~ s/(\[|\])//g;
228     }
229
230     if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
231       chop ($var = $&);
232       ($null, $member{$login}{$var}) = split /=/, $_, 2;
233     }
234   }
235   
236   close(FH);
237
238 # type=submit $locale->text('Pg Database Administration')
239 # type=submit $locale->text('Oracle Database Administration')
240
241   foreach $item (User->dbdrivers) {
242     $dbdrivers .= qq|<input name=action type=submit class=submit value="|.$locale->text("$item Database Administration").qq|">|;
243   }
244
245
246   $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
247   $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
248   $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
249   $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
250   $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
251   $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
252   $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
253
254   @column_index = qw(login name company dbdriver dbhost dataset templates);
255
256   $form->{title} = "Lx-Office ERP ".$locale->text('Administration');
257
258   $form->header;
259
260   print qq|
261 <body class=admin>
262
263 <form method=post action=$form->{script}>
264
265 <table width=100%>
266   <tr>
267   <tr class=listheading>
268     <th>$form->{title}</th>
269   </tr>
270   <tr size=5></tr>
271   <tr>
272     <td>
273       <table width=100%>
274         <tr class=listheading>|;
275
276   map { print "$column_header{$_}\n" } @column_index;
277   
278   print qq|
279         </tr>
280 |;
281
282 foreach $key (sort keys %member) {
283   $href = "$script?action=edit&login=$key&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}";
284   $href =~ s/ /%20/g;
285   
286   $member{$key}{templates} =~ s/^$templates\///;
287   $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
288   $member{$key}{dbname} = $member{$key}{dbuser} if ($member{$key}{dbdriver} eq 'Oracle');
289
290   $column_data{login} = qq|<td><a href=$href>$key</a></td>|;
291   $column_data{name} = qq|<td>$member{$key}{name}</td>|;
292   $column_data{company} = qq|<td>$member{$key}{company}</td>|;
293   $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
294   $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
295   $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
296   $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
297   
298   $i++; $i %= 2;
299   print qq|
300         <tr class=listrow$i>|;
301
302   map { print "$column_data{$_}\n" } @column_index;
303
304   print qq|
305         </tr>|;
306 }
307
308
309 print qq|
310       </table>
311     </td>
312   </tr>
313   <tr>
314     <td><hr size=3 noshade></td>
315   </tr>
316 </table>
317
318 <input type=hidden name=path value=$form->{path}>
319 <input type=hidden name=rpw value=$form->{rpw}>
320 <input type=hidden name=root value="$form->{root}">
321
322 <br><input type=submit class=submit name=action value="|.$locale->text('Add User').qq|">
323 <input type=submit class=submit name=action value="|.$locale->text('Change Admin Password').qq|">
324
325 $dbdrivers
326 $nologin
327
328 </form>
329
330 |.$locale->text('Click on login name to edit!').qq|
331 <br>
332 |.$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|
333
334 <p>
335
336 <form method=post action=login.pl>
337
338 <table border=0 width=100%>
339   <tr class=listheading>
340     <th>Lx-Office ERP |.$locale->text('Login').qq|</th>
341   </tr>
342   <tr>
343     <td>
344       <table>
345         <tr>
346           <th align=right>|.$locale->text('Name').qq|</th>
347           <td><input class=login name=login></td>
348           <td>&nbsp;</td>
349         </tr>
350         <tr>
351           <th align=right>|.$locale->text('Password').qq|</th>
352           <td><input class=login type=password name=password></td>
353           <td><input type=submit name=action value="|.$locale->text('Login').qq|"></td>
354         </tr>
355 <input type=hidden name=path value=$form->{path}>
356       </table>
357     </td>
358   </tr>
359 </table>
360
361 </form>
362
363 <hr size=3 noshade>
364
365 </body>
366 </html>
367 |;
368
369 }
370
371
372
373 sub form_header {
374
375   # if there is a login, get user
376   if ($form->{login}) {
377     # get user
378     $myconfig = new User "$memberfile", "$form->{login}";
379
380     $myconfig->{signature} =~ s/\\n/\r\n/g;
381     $myconfig->{address} =~ s/\\n/\r\n/g;
382
383     # strip basedir from templates directory
384     $myconfig->{templates} =~ s/^$templates\///;
385
386     # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
387   }
388
389
390   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
391     $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
392   }
393
394   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
395     $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
396   }
397
398
399   %countrycodes = User->country_codes;
400   $countrycodes = "";
401   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
402     $countrycodes .= ($myconfig->{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}" : "<option value=$key>$countrycodes{$key}";
403   }
404   $countrycodes = qq|<option value="">American English\n$countrycodes|;
405
406   # is there a templates basedir
407   if (! -d "$templates") {
408     $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
409   }
410
411   opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
412   @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
413   closedir TEMPLATEDIR;
414
415   @allhtml = sort grep /\.html/, @all;
416   @alldir = grep !/\.(html|tex)$/, @all;
417   
418   @allhtml = reverse grep !/Default/, @allhtml;
419   push @allhtml, 'Default';
420   @allhtml = reverse @allhtml;
421   
422   foreach $item (@alldir) {
423     if ($item eq $myconfig->{templates}) {
424       $usetemplates .= qq|<option selected>$item\n|;
425     } else {
426       $usetemplates .= qq|<option>$item\n|;
427     }
428   }
429   
430   $lastitem = $allhtml[0];
431   $lastitem =~ s/-.*//g;
432   $mastertemplates = qq|<option>$lastitem\n|;
433   foreach $item (@allhtml) {
434     $item =~ s/-.*//g;
435     
436     if ($item ne $lastitem) {
437       $mastertemplates .= qq|<option>$item\n|;
438       $lastitem = $item;
439     }
440   }
441
442   opendir CSS, "css/.";
443   @all = grep /.*\.css$/, readdir CSS;
444   closedir CSS;
445   
446   foreach $item (@all) {
447     if ($item eq $myconfig->{stylesheet}) {
448       $selectstylesheet .= qq|<option selected>$item\n|;
449     } else {
450       $selectstylesheet .= qq|<option>$item\n|;
451     }
452   }
453   $selectstylesheet .= "<option>\n";
454   
455   
456   $form->header;
457  
458   print qq|
459 <body class=admin>
460
461 <form method=post action=$form->{script}>
462
463 <table width=100%>
464   <tr class=listheading><th colspan=2>$form->{title}</th></tr>
465   <tr size=5></tr>
466   <tr valign=top>
467     <td>
468       <table>
469         <tr>
470           <th align=right>|.$locale->text('Login').qq|</th>
471           <td><input name=login value="$myconfig->{login}"></td>
472         </tr>
473         <tr>
474           <th align=right>|.$locale->text('Password').qq|</th>
475           <td><input type=password name=password size=8 value=$myconfig->{password}></td>
476           <input type=hidden name=old_password value=$myconfig->{password}>
477         </tr>
478         <tr>
479           <th align=right>|.$locale->text('Name').qq|</th>
480           <td><input name=name size=15 value="$myconfig->{name}"></td>
481         </tr>
482         <tr>
483           <th align=right>|.$locale->text('E-mail').qq|</th>
484           <td><input name=email size=30 value="$myconfig->{email}"></td>
485         </tr>
486         <tr valign=top>
487           <th align=right>|.$locale->text('Signature').qq|</th>
488           <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
489         </tr>
490         <tr>
491           <th align=right>|.$locale->text('Phone').qq|</th>
492           <td><input name=tel size=14 value="$myconfig->{tel}"></td>
493         </tr>
494         <tr>
495           <th align=right>|.$locale->text('Fax').qq|</th>
496           <td><input name=fax size=14 value="$myconfig->{fax}"></td>
497         </tr>
498         <tr>
499           <th align=right>|.$locale->text('Company').qq|</th>
500           <td><input name=company size=35 value="$myconfig->{company}"></td>
501         </tr>
502         <tr valign=top>
503           <th align=right>|.$locale->text('Address').qq|</th>
504           <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
505         </tr>
506         <tr valign=top>
507           <th align=right>|.$locale->text('Steuernummer').qq|</th>
508           <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
509         </tr>
510         <tr valign=top>
511           <th align=right>|.$locale->text('Ust-IDNr').qq|</th>
512           <td><input name=ustid size=14 value="$myconfig->{ustid}"></td>
513         </tr>
514         <tr valign=top>
515           <th align=right>|.$locale->text('DUNS-Nr').qq|</th>
516           <td><input name=duns size=14 value="$myconfig->{duns}"></td>
517         </tr>
518       </table>
519     </td>
520     <td>
521       <table>
522         <tr>
523           <th align=right>|.$locale->text('Date Format').qq|</th>
524           <td><select name=dateformat>$dateformat</select></td>
525         </tr>
526         <tr>
527           <th align=right>|.$locale->text('Number Format').qq|</th>
528           <td><select name=numberformat>$numberformat</select></td>
529         </tr>
530         <tr>
531           <th align=right>|.$locale->text('Dropdown Limit').qq|</th>
532           <td><input name=vclimit value="$myconfig->{vclimit}"></td>
533         </tr>
534         <tr>
535           <th align=right>|.$locale->text('Language').qq|</th>
536           <td><select name=countrycode>$countrycodes</select></td>
537         </tr>
538         <tr>
539           <th align=right>|.$locale->text('Character Set').qq|</th>
540           <td><input name=charset value="$myconfig->{charset}"></td>
541         </tr>
542         <tr>
543           <th align=right>|.$locale->text('Stylesheet').qq|</th>
544           <td><select name=userstylesheet>$selectstylesheet</select></td>
545         </tr>
546         <tr>
547           <th align=right>|.$locale->text('Printer').qq|</th>
548           <td><input name=printer size=20 value="$myconfig->{printer}"></td>
549         </tr>
550         <tr>
551           <th align=right>|.$locale->text('Use Templates').qq|</th>
552           <td><select name=usetemplates>$usetemplates</select></td>
553         </tr>
554         <tr>
555           <th align=right>|.$locale->text('New Templates').qq|</th>
556           <td><input name=newtemplates></td>
557         </tr>
558         <tr>
559           <th align=right>|.$locale->text('Setup Templates').qq|</th>
560           <td><select name=mastertemplates>$mastertemplates</select></td>
561         </tr>
562         <input type=hidden name=templates value=$myconfig->{templates}>
563       </table>
564     </td>
565   </tr>
566   <tr class=listheading>
567     <th colspan=2>|.$locale->text('Database').qq|</th>
568   </tr>|;
569
570     # list section for database drivers
571     foreach $item (User->dbdrivers) {
572       
573     print qq|
574   <tr>
575     <td colspan=2>
576       <table>
577         <tr>|;
578
579     $checked = "";
580     if ($myconfig->{dbdriver} eq $item) {
581       map { $form->{"${item}_$_"} = $myconfig->{$_} } qw(dbhost dbport dbuser dbpasswd dbname sid);
582       $checked = "checked";
583     }
584
585     print qq|
586           <th align=right>|.$locale->text('Driver').qq|</th>
587           <td><input name=dbdriver type=radio class=radio value=$item $checked>&nbsp;$item</td>
588           <th align=right>|.$locale->text('Host').qq|</th>
589           <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
590         </tr>
591         <tr>|;
592
593     if ($item eq 'Pg') {
594       print qq|
595           <th align=right>|.$locale->text('Dataset').qq|</th>
596           <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
597           <th align=right>|.$locale->text('Port').qq|</th>
598           <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
599         </tr>
600         <tr>
601           <th align=right>|.$locale->text('User').qq|</th>
602           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
603           <th align=right>|.$locale->text('Password').qq|</th>
604           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
605         </tr>|;
606
607     }
608
609     if ($item eq 'Oracle') {
610       print qq|
611           <th align=right>SID</th>
612           <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
613           <th align=right>|.$locale->text('Port').qq|</th>
614           <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
615         </tr>
616         <tr>
617           <th align=right>|.$locale->text('Dataset').qq|</th>
618           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
619           <th align=right>|.$locale->text('Password').qq|</th>
620           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
621           
622         </tr>|;
623     }
624     
625       
626     print qq|
627         <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
628       </table>
629     </td>
630   </tr>
631   <tr>
632     <td colspan=2><hr size=2 noshade></td>
633   </tr>
634 |;
635
636   }
637
638
639   # access control
640   open(FH, $menufile) or $form->error("$menufile : $!");
641   # scan for first menu level
642   @a = <FH>;
643   close(FH);
644   
645   if (open(FH, "custom_$menufile")) {
646     push @a, <FH>;
647   }
648   close(FH);
649
650   foreach $item (@a) {
651     next unless $item =~ /\[/;
652     next if $item =~ /\#/;
653
654     $item =~ s/(\[|\])//g;
655     chop $item;
656
657     if ($item =~ /--/) {
658       ($level, $menuitem) = split /--/, $item, 2;
659     } else {
660       $level = $item;
661       $menuitem = $item;
662       push @acsorder, $item;
663     }
664
665     push @{ $acs{$level} }, $menuitem;
666
667   }
668   
669   %role = ( 'admin' => $locale->text('Administrator'),
670             'user' => $locale->text('User'),
671             'manager' => $locale->text('Manager'),
672             'supervisor' => $locale->text('Supervisor')
673            );
674             
675   $selectrole = "";
676   foreach $item (qw(user supervisor manager admin)) {
677     $selectrole .= ($myconfig->{role} eq $item) ? "<option selected value=$item>$role{$item}\n" : "<option value=$item>$role{$item}\n";
678   }
679   
680   print qq|
681   <tr class=listheading>
682     <th colspan=2>|.$locale->text('Access Control').qq|</th>
683   </tr>
684   <tr>
685     <td><select name=role>$selectrole</select></td>
686   </tr>
687 |;
688   
689   foreach $item (split /;/, $myconfig->{acs}) {
690     ($key, $value) = split /--/, $item, 2;
691     $excl{$key}{$value} = 1;
692   }
693   
694   foreach $key (@acsorder) {
695
696     $checked = "checked";
697     if ($form->{login}) {
698       $checked = ($excl{$key}{$key}) ? "" : "checked";
699     }
700     
701     # can't have variable names with spaces
702     # the 1 is for apache 2
703     $item = $form->escape("${key}--$key", 1);
704     
705     $acsheading = $key;
706     $acsheading =~ s/ /&nbsp;/g;
707     
708     $acsheading = qq|
709     <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked>&nbsp;$acsheading</th>\n|;
710     $menuitems .= "$item;";
711     $acsdata = "
712     <td>";
713
714     foreach $item (@{ $acs{$key} }) {
715       next if ($key eq $item);
716
717       $checked = "checked";
718       if ($form->{login}) {
719         $checked = ($excl{$key}{$item}) ? "" : "checked";
720       }
721
722       $acsitem = $form->escape("${key}--$item", 1);
723       
724       $acsdata .= qq|
725     <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked>&nbsp;$item|;
726       $menuitems .= "$acsitem;";
727     }
728
729     $acsdata .= "
730     </td>";
731
732     print qq|
733   <tr valign=top>$acsheading $acsdata
734   </tr>
735 |;
736   }
737   
738   print qq|<input type=hidden name=acs value="$menuitems">
739 |;
740    if ($webdav) {
741    @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
742    foreach $directory (@webdavdirs) {
743      if ($myconfig->{$directory}) {
744         $webdav{"${directory}c"} = "checked";
745      } else {
746         $webdav{"${directory}c"} = "";
747         }
748    }
749    print qq|  
750    <tr>
751     <td colspan=2><hr size=3 noshade></td>
752   </tr>
753   <tr class=listheading>
754     <th colspan=2>|.$locale->text('WEBDAV-Zugriff').qq|</th>
755   </tr>
756   <table width=100%>
757         <tr>
758         <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}>&nbsp;Angebot</td>
759         <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}>&nbsp;Bestellung</td> 
760         <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}>&nbsp;Rechnung</td>
761         </tr>
762         <tr>
763         <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}>&nbsp;Angebot</td>
764         <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}>&nbsp;Lieferantenbestellung</td> 
765         <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}>&nbsp;Einkaufsrechnung</td>
766         </tr>
767   </table>    
768   <tr>
769     <td colspan=2><hr size=3 noshade></td>
770   </tr>
771 |;
772 }
773 print qq|
774 </table>
775 </div>
776 |;
777
778 }
779
780
781 sub save {
782
783   # no driver checked
784   $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
785
786   # no spaces allowed in login name
787   ($form->{login}) = split / /, $form->{login};
788
789   $form->isblank("login", $locale->text('Login name missing!'));
790   
791   # check for duplicates
792   if (!$form->{edit}) {
793     $temp = new User "$memberfile", "$form->{login}";
794    
795     if ($temp->{login}) {
796       $form->error("$form->{login} ".$locale->text('is already a member!'));
797     }
798   }
799   
800   # no spaces allowed in directories
801   ($form->{newtemplates}) = split / /, $form->{newtemplates};
802   
803   if ($form->{newtemplates}) {
804     $form->{templates} = $form->{newtemplates};
805   } else {
806     $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
807   }
808   
809   # is there a basedir
810   if (! -d "$templates") {
811     $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
812   }
813
814   # add base directory to $form->{templates}
815   $form->{templates} = "$templates/$form->{templates}";
816
817
818   $myconfig = new User "$memberfile", "$form->{login}";
819
820   # redo acs variable and delete all the acs codes
821   @acs = split /;/, $form->{acs};
822
823   $form->{acs} = "";
824   foreach $item (@acs) {
825     $item = $form->escape($item, 1);
826
827     if (!$form->{$item}) {
828       $form->{acs} .= $form->unescape($form->unescape($item)).";";
829     }
830     delete $form->{$item};
831   }
832
833   # check which database was filled in
834   if ($form->{dbdriver} eq 'Oracle') {
835     $form->{sid} = $form->{Oracle_sid}, ;
836     $form->{dbhost} = $form->{Oracle_dbhost}, ;
837     $form->{dbport} = $form->{Oracle_dbport};
838     $form->{dbpasswd} = $form->{Oracle_dbpasswd};
839     $form->{dbuser} = $form->{Oracle_dbuser};
840     $form->{dbname} = $form->{Oracle_dbuser};
841
842     $form->isblank("dbhost", $locale->text('Hostname missing!'));
843     $form->isblank("dbport", $locale->text('Port missing!'));
844     $form->isblank("dbuser", $locale->text('Dataset missing!'));
845   }
846   if ($form->{dbdriver} eq 'Pg') {
847     $form->{dbhost} = $form->{Pg_dbhost};
848     $form->{dbport} = $form->{Pg_dbport};
849     $form->{dbpasswd} = $form->{Pg_dbpasswd};
850     $form->{dbuser} = $form->{Pg_dbuser};
851     $form->{dbname} = $form->{Pg_dbname};
852     
853     $form->isblank("dbname", $locale->text('Dataset missing!'));
854     $form->isblank("dbuser", $locale->text('Database User missing!'));
855   }
856
857   if ($webdav) {
858     @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
859     foreach $directory (@webdavdirs) {
860         if ($form->{$directory}) {
861                 $form->{$directory} = $form->{$directory};
862         } else {
863                 $form->{$directory} = 0;
864         }
865     }
866   }
867   
868   foreach $item (keys %{$form}) {
869     $myconfig->{$item} = $form->{$item};
870   }
871
872   delete $myconfig->{stylesheet};
873   if ($form->{userstylesheet}) {
874     $myconfig->{stylesheet} = $form->{userstylesheet};
875   }
876   
877   $myconfig->save_member($memberfile, $userspath);
878   
879   if ($webdav) {
880     @webdavdirs = qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
881     foreach $directory (@webdavdirs) {
882       $file = "webdav/".$directory."/webdav-user";
883       if ($form->{$directory}) {
884         if (open (HTACCESS, "$file")) {
885           while (<HTACCESS>) {
886             ($login,$password) = split(/:/, $_);
887             if ($login ne $form->{login}) {
888               $newfile .= $_;
889             }
890           }
891           close (HTACCESS);
892         }
893         open (HTACCESS, "> $file") or die "cannot open $file $!\n";
894         $newfile .= $myconfig->{login}.":".$myconfig->{password}."\n";
895         print (HTACCESS $newfile);
896         close (HTACCESS);
897       } else {
898         $form->{$directory} = 0;
899         if (open (HTACCESS, "$file")) {
900           while (<HTACCESS>) {
901             ($login,$password) = split(/:/, $_);
902             if ($login ne $form->{login}) {
903               $newfile .= $_;
904             }
905           }
906           close (HTACCESS);
907         }
908         open (HTACCESS, "> $file") or die "cannot open $file $!\n";
909         print (HTACCESS $newfile);
910         close (HTACCESS);
911       }
912     }
913   }    
914
915   # create user template directory and copy master files
916   if (! -d "$form->{templates}") {
917     umask(002);
918     
919     if (mkdir "$form->{templates}", oct("771")) {
920       
921       umask(007);
922       
923       # copy templates to the directory
924       opendir TEMPLATEDIR, "$templates/." or $form-error("$templates : $!");
925       @templates = grep /$form->{mastertemplates}.*?\.(html|tex)$/, readdir TEMPLATEDIR;
926       closedir TEMPLATEDIR;
927
928       foreach $file (@templates) {
929         open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
930         
931         $file =~ s/$form->{mastertemplates}-//;
932         open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
933           
934         while ($line = <TEMP>) {
935           print NEW $line;
936         }
937         close(TEMP);
938         close(NEW);
939       }
940     } else {
941       $form->error("$!: $form->{templates}");
942     }
943   }
944   
945
946
947   $form->redirect($locale->text('User saved!'));
948   
949 }
950
951
952 sub delete {
953
954   $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
955   
956   $form->error($locale->text('File locked!')) if (-f ${memberfile}.LCK);
957   open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
958   close(FH);
959   
960   open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
961
962   @config = <CONF>;
963
964   seek(CONF, 0, 0);
965   truncate(CONF, 0);
966   
967   while ($line = shift @config) {
968
969     if ($line =~ /^\[/) {
970       last if ($line =~ /\[$form->{login}\]/);
971       $login = &login_name($line);
972     }
973     
974     if ($line =~ /^templates=/) {
975       $user{$login} = &get_value($line);
976     }
977
978     print CONF $line;
979   }
980
981   # remove everything up to next login or EOF
982   # and save template variable
983   while ($line = shift @config) {
984     if ($line =~ /^templates=/) {
985       $templatedir = &get_value($line);
986     }
987     last if ($line =~ /^\[/);
988   }
989
990   # this one is either the next login or EOF
991   print CONF $line;
992
993   $login = &login_name($line);
994   
995
996   while ($line = shift @config) {
997     if ($line =~ /^\[/) {
998       $login = &login_name($line);
999     }
1000     
1001     if ($line =~ /^templates=/) {
1002       $user{$login} = &get_value($line);
1003     }
1004     
1005     print CONF $line;
1006   }
1007
1008   close(CONF);
1009   unlink "${memberfile}.LCK";
1010
1011   # scan %user for $templatedir
1012   foreach $login (keys %user) {
1013     last if ($found = ($templatedir eq $user{$login}));
1014   }
1015
1016   # if found keep directory otherwise delete
1017   if (!$found) {
1018     # delete it if there is a template directory
1019     $dir = "$form->{templates}";
1020     if (-d "$dir") {
1021       unlink <$dir/*.html>;
1022       unlink <$dir/*.tex>;
1023       rmdir "$dir";
1024     }
1025   }
1026   
1027   # delete config file for user
1028   unlink "$userspath/$form->{login}.conf";
1029     
1030   $form->redirect($locale->text('User deleted!'));
1031   
1032 }
1033
1034
1035 sub login_name {
1036   my $login = shift;
1037   
1038   $login =~ s/\[\]//g;
1039   return ($login) ? $login : undef;
1040   
1041 }
1042
1043
1044
1045 sub get_value {
1046   my $line = shift;
1047   
1048   my ($null, $value) = split(/=/, $line, 2);
1049
1050   # remove comments
1051   $value =~ s/\s#.*//g;
1052       
1053   # remove any trailing whitespace
1054   $value =~ s/^\s*(.*?)\s*$/$1/;
1055
1056   $value;
1057 }
1058
1059
1060
1061 sub change_admin_password {
1062
1063   $form->{title} = qq|Lx-Office ERP |.$locale->text('Administration')." / ".$locale->text('Change Admin Password');
1064   
1065   $form->header;
1066
1067   print qq|
1068 <body class=admin>
1069
1070
1071 <h2>|.$locale->text('Change Admin Password').qq|</h2>
1072
1073 <form method=post action=$form->{script}>
1074
1075 <b>|.$locale->text('Password').qq|</b> <input type=password name=password size=8>
1076
1077 <input type=hidden name=root value="$form->{root}">
1078 <input type=hidden name=path value=$form->{path}>
1079 <input type=hidden name=rpw value=$form->{rpw}>
1080
1081 <p>
1082 <input type=submit class=submit name=action value="|.$locale->text('Change Password').qq|">
1083
1084 </form>
1085
1086 </body>
1087 </html>
1088 |;
1089
1090 }
1091
1092
1093 sub change_password {
1094
1095   $root->{password} = $form->{password};
1096   
1097   $root->{'root login'} = 1;
1098   $root->save_member($memberfile);
1099
1100   $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1101
1102   $form->redirect($locale->text('Password changed!'));
1103
1104 }
1105
1106
1107 sub check_password {
1108
1109   $root = new User "$memberfile", $form->{root};
1110
1111   if ($root->{password}) {
1112     if ($root->{password} ne $form->{rpw}) {
1113       $form->error($locale->text('Incorrect Password!'));
1114     }
1115   }
1116
1117 }
1118
1119
1120 sub pg_database_administration {
1121
1122   $form->{dbdriver} = 'Pg';
1123   &dbselect_source;
1124
1125 }
1126
1127
1128 sub oracle_database_administration {
1129   
1130   $form->{dbdriver} = 'Oracle';
1131   &dbselect_source;
1132
1133 }
1134
1135
1136 sub dbdriver_defaults {
1137
1138   # load some defaults for the selected driver
1139   %driverdefaults = ( 'Pg' => { dbport => '5432',
1140                                 dbuser => 'postgres',
1141                              dbdefault => 'template1',
1142                                 dbhost => 'localhost',
1143                          connectstring => $locale->text('Connect to')
1144                               },
1145                   'Oracle' => { dbport => '1521',
1146                                 dbuser => 'oralin',
1147                              dbdefault => $sid,
1148                                 dbhost => `hostname`,
1149                          connectstring => 'SID'
1150                               }
1151                     );
1152
1153   map { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} } keys %{ $driverdefaults{Pg} };
1154   
1155 }
1156   
1157
1158 sub dbselect_source {
1159
1160   &dbdriver_defaults;
1161
1162   $msg{Pg} = $locale->text('Leave host and port field empty unless you want to make a remote connection.');
1163   $msg{Oracle} = $locale->text('You must enter a host and port for local and remote connections!');
1164   
1165
1166  $form->{title} = "Lx-Office ERP / ".$locale->text('Database Administration');
1167   
1168
1169   $form->header;
1170
1171   print qq|
1172 <body class=admin>
1173
1174
1175 <center>
1176 <h2>$form->{title}</h2>
1177
1178 <form method=post action=$form->{script}>
1179
1180 <table>
1181 <tr><td>
1182
1183 <table>
1184
1185   <tr class=listheading>
1186     <th colspan=4>|.$locale->text('Database').qq|</th>
1187   </tr>
1188
1189 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1190
1191   <tr><td>
1192    <table>
1193
1194   <tr>
1195
1196     <th align=right>|.$locale->text('Host').qq|</th>
1197     <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1198     <th align=right>|.$locale->text('Port').qq|</th>
1199     <td><input name=dbport size=5 value=$form->{dbport}></td>
1200
1201   </tr>
1202
1203   <tr>
1204
1205     <th align=right>|.$locale->text('User').qq|</th>
1206     <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1207     <th align=right>|.$locale->text('Password').qq|</th>
1208     <td><input type=password name=dbpasswd size=10></td>
1209
1210   </tr>
1211   
1212   <tr>
1213
1214     <th align=right>$form->{connectstring}</th>
1215     <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1216
1217   </tr>
1218
1219 </table>
1220
1221 </td></tr>
1222 </table>
1223
1224 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1225 <input type=hidden name=root value="$form->{root}">
1226 <input type=hidden name=path value=$form->{path}>
1227 <input type=hidden name=rpw value=$form->{rpw}>
1228
1229 <br>
1230
1231 <input type=submit class=submit name=action value="|.$locale->text('Create Dataset').qq|">
1232 <input type=submit class=submit name=action value="|.$locale->text('Update Dataset').qq|">
1233 <input type=submit class=submit name=action value="|.$locale->text('Delete Dataset').qq|">
1234
1235 </form>
1236
1237 </td></tr>
1238 </table>
1239
1240 <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
1241
1242 .qq|
1243 <br>$msg{$form->{dbdriver}}
1244
1245
1246 </body>
1247 </html>
1248 |;
1249
1250 }
1251
1252
1253 sub continue {
1254
1255   &{ $form->{nextsub} };
1256
1257 }
1258
1259
1260 sub update_dataset {
1261
1262   %needsupdate = User->dbneedsupdate(\%$form);
1263
1264   $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset');
1265   
1266   $form->header;
1267
1268   print qq|
1269 <body class=admin>
1270
1271
1272 <center>
1273 <h2>$form->{title}</h2>
1274 |;
1275
1276
1277   foreach $key (sort keys %needsupdate) {
1278     if ($needsupdate{$key} ne $form->{dbversion}) {
1279       $upd .= qq|<input name="db$key" type=checkbox value=1 checked> $key\n|;
1280       $form->{dbupdate} .= "db$key ";
1281     }
1282   }
1283
1284   chop $form->{dbupdate};
1285
1286
1287   if ($form->{dbupdate}) {
1288
1289     print qq|
1290 <table width=100%>
1291 <form method=post action=$form->{script}>
1292
1293 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1294 <input type=hidden name=dbhost value=$form->{dbhost}>
1295 <input type=hidden name=dbport value=$form->{dbport}>
1296 <input type=hidden name=dbuser value=$form->{dbuser}>
1297 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1298 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1299
1300 <tr class=listheading>
1301   <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
1302 </tr>
1303 <tr>
1304 <td>
1305
1306 $upd
1307
1308 </td>
1309 </tr>
1310 <tr>
1311 <td>
1312
1313 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1314
1315 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1316
1317 <input type=hidden name=root value="$form->{root}">
1318 <input type=hidden name=path value=$form->{path}>
1319 <input type=hidden name=rpw value=$form->{rpw}>
1320
1321 <input type=hidden name=nextsub value=dbupdate>
1322
1323 <hr size=3 noshade>
1324
1325 <br>
1326 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1327
1328 </td></tr>
1329 </table>
1330 </form>
1331 |;
1332
1333   } else {
1334
1335     print $locale->text('All Datasets up to date!');
1336
1337   }
1338   
1339   print qq|
1340
1341 </body>
1342 </html>
1343 |;
1344
1345 }
1346
1347
1348 sub dbupdate {
1349
1350   User->dbupdate(\%$form);
1351
1352   $form->redirect($locale->text('Dataset updated!'));
1353   
1354 }
1355
1356
1357 sub create_dataset {
1358
1359   foreach $item (sort User->dbsources(\%$form)) {
1360     $dbsources .= "[$item] ";
1361   }
1362
1363   opendir SQLDIR, "sql/." or $form-error($!);
1364   foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1365     next if ($item eq 'Default-chart.sql');
1366     $item =~ s/-chart\.sql//;
1367     push @charts, qq| <input name=chart class=radio type=radio value="$item">&nbsp;$item|;
1368   }
1369   closedir SQLDIR;
1370
1371   $selectencoding = qq|<option>
1372   <option value=SQL_ASCII>ASCII
1373   <option value=EUC_JP>Japanese Extended UNIX Code
1374   <option value=EUC_CN>Chinese Extended UNIX Code
1375   <option value=EUC_KR>Korean Extended UNIX Code
1376   <option value=EUC_TW>Taiwan Extended UNIX Code
1377   <option value=UNICODE>UTF-8 Unicode
1378   <option value=MULE_INTERNAL>Mule internal type
1379   <option value=LATIN1>ISO 8859-1
1380   <option value=LATIN2>ISO 8859-2
1381   <option value=LATIN3>ISO 8859-3
1382   <option value=LATIN4>ISO 8859-4
1383   <option value=LATIN5>ISO 8859-5
1384   <option value=KOI8>KOI8-R
1385   <option value=WIN>Windows CP1251
1386   <option value=ALT>Windows CP866
1387   |;
1388   
1389   $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1390   
1391   $form->header;
1392
1393   print qq|
1394 <body class=admin>
1395
1396
1397 <center>
1398 <h2>$form->{title}</h2>
1399
1400 <form method=post action=$form->{script}>
1401
1402 <table width=100%>
1403   <tr class=listheading>
1404     <th colspan=2>&nbsp;</th>
1405   </tr>
1406
1407   <tr>
1408
1409     <th align=right nowrap>|.$locale->text('Existing Datasets').qq|</th>
1410     <td>$dbsources</td>
1411
1412   </tr>
1413   
1414   <tr>
1415
1416     <th align=right nowrap>|.$locale->text('Create Dataset').qq|</th>
1417     <td><input name=db></td>
1418
1419   </tr>
1420
1421   <tr>
1422
1423     <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th>
1424     <td><select name=encoding>$selectencoding</select></td>
1425
1426   </tr>
1427  
1428   <tr>
1429
1430     <th align=right nowrap>|.$locale->text('Create Chart of Accounts').qq|</th>
1431     <td>@charts</td>
1432
1433   </tr>
1434  
1435   <tr><td colspan=2>
1436 <p>
1437 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1438 <input type=hidden name=dbuser value=$form->{dbuser}>
1439 <input type=hidden name=dbhost value=$form->{dbhost}>
1440 <input type=hidden name=dbport value=$form->{dbport}>
1441 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1442 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1443
1444 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1445
1446 <input type=hidden name=root value="$form->{root}">
1447 <input type=hidden name=path value=$form->{path}>
1448 <input type=hidden name=rpw value=$form->{rpw}>
1449
1450 <input type=hidden name=nextsub value=dbcreate>
1451
1452 <hr size=3 noshade>
1453
1454 <br>
1455 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1456
1457   </td></tr>
1458 </table>
1459
1460 </form>
1461
1462
1463 </body>
1464 </html>
1465 |;
1466
1467 }
1468
1469
1470 sub dbcreate {
1471
1472   $form->isblank("db", $locale->text('Dataset missing!'));
1473
1474   User->dbcreate(\%$form);
1475   
1476   $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1477
1478   $form->header;
1479
1480   print qq|
1481 <body class=admin>
1482
1483
1484 <center>
1485 <h2>$form->{title}</h2>
1486
1487 <form method=post action=$form->{script}>|
1488
1489 .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
1490
1491 .qq|
1492
1493 <input type=hidden name=root value="$form->{root}">
1494 <input type=hidden name=path value="$form->{path}">
1495 <input type=hidden name=rpw value="$form->{rpw}">
1496
1497 <input type=hidden name=nextsub value=list_users>
1498
1499 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1500 </form>
1501
1502
1503 </body>
1504 </html>
1505 |;
1506
1507 }
1508
1509
1510 sub delete_dataset {
1511
1512   if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1513     foreach $item (sort @dbsources) {
1514       $dbsources .= qq|<input name=db class=radio type=radio value=$item>&nbsp;$item |;
1515     }
1516   } else {
1517     $form->error($locale->text('Nothing to delete!'));
1518   }
1519
1520   $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1521
1522   $form->header;
1523
1524   print qq|
1525 <body class=admin>
1526
1527 <h2>$form->{title}</h2>
1528
1529 <form method=post action=$form->{script}>
1530
1531 <table width=100%>
1532   <tr class=listheading>
1533     <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
1534   </tr>
1535
1536   <tr>
1537     <td>
1538     $dbsources
1539     </td>
1540   </tr>
1541   
1542   <tr><td>
1543 <p>
1544 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1545 <input type=hidden name=dbuser value=$form->{dbuser}>
1546 <input type=hidden name=dbhost value=$form->{dbhost}>
1547 <input type=hidden name=dbport value=$form->{dbport}>
1548 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1549 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1550
1551 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1552
1553 <input type=hidden name=root value="$form->{root}">
1554 <input type=hidden name=path value="$form->{path}">
1555 <input type=hidden name=rpw value="$form->{rpw}">
1556
1557 <input type=hidden name=nextsub value=dbdelete>
1558
1559 <hr size=3 noshade>
1560
1561 <br>
1562 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1563
1564   </td></tr>
1565 </table>
1566
1567 </form>
1568
1569 </body>
1570 </html>
1571 |;
1572
1573 }
1574
1575
1576 sub dbdelete {
1577
1578   if (!$form->{db}) {
1579     $form->error($locale->text('No Dataset selected!'));
1580   }
1581
1582   User->dbdelete(\%$form);
1583
1584   $form->{title} = "Lx-Office ERP ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1585
1586   $form->header;
1587
1588   print qq|
1589 <body class=admin>
1590
1591
1592 <center>
1593 <h2>$form->{title}</h2>
1594
1595 <form method=post action=$form->{script}>
1596
1597 $form->{db} |.$locale->text('successfully deleted!')
1598
1599 .qq|
1600
1601 <input type=hidden name=root value="$form->{root}">
1602 <input type=hidden name=path value="$form->{path}">
1603 <input type=hidden name=rpw value="$form->{rpw}">
1604
1605 <input type=hidden name=nextsub value=list_users>
1606
1607 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1608 </form>
1609
1610
1611 </body>
1612 </html>
1613 |;
1614
1615 }
1616
1617
1618 sub unlock_system {
1619
1620   unlink "$userspath/nologin";
1621   
1622   $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1623
1624   $form->redirect($locale->text('Lockfile removed!'));
1625
1626 }
1627
1628
1629 sub lock_system {
1630
1631   open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
1632   close(FH);
1633   
1634   $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1635
1636   $form->redirect($locale->text('Lockfile created!'));
1637
1638 }
1639
1640