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 @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
444 closedir TEMPLATEDIR;
446 @allhtml = sort grep /\.html/, @all;
447 @alldir = grep !/\.(html|tex|sty|odt)$/, @all;
448 @alldir = grep !/^(webpages|\.svn)$/, @alldir;
450 @allhtml = reverse grep !/Default/, @allhtml;
451 push @allhtml, 'Default';
452 @allhtml = reverse @allhtml;
454 foreach $item (@alldir) {
455 if ($item eq $myconfig->{templates}) {
456 $usetemplates .= qq|<option selected>$item\n|;
458 $usetemplates .= qq|<option>$item\n|;
462 $lastitem = $allhtml[0];
463 $lastitem =~ s/-.*//g;
464 $mastertemplates = qq|<option>$lastitem\n|;
465 foreach $item (@allhtml) {
468 if ($item ne $lastitem) {
469 my $selected = $item eq "German" ? " selected" : "";
470 $mastertemplates .= qq|<option$selected>$item\n|;
475 opendir CSS, "css/.";
476 @all = grep /.*\.css$/, readdir CSS;
479 foreach $item (@all) {
480 if ($item eq $myconfig->{stylesheet}) {
481 $selectstylesheet .= qq|<option selected>$item\n|;
483 $selectstylesheet .= qq|<option>$item\n|;
486 $selectstylesheet .= "<option>\n";
490 if ($myconfig->{menustyle} eq "neu") { $neu = "checked"; }
491 else { $old = "checked"; }
496 <form method=post action=$form->{script}>
499 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
505 <th align=right>| . $locale->text('Login') . qq|</th>
506 <td><input name=login value="$myconfig->{login}"></td>
509 <th align=right>| . $locale->text('Password') . qq|</th>
510 <td><input type=password name=password size=8 value=$myconfig->{password}></td>
511 <input type=hidden name=old_password value=$myconfig->{password}>
514 <th align=right>| . $locale->text('Name') . qq|</th>
515 <td><input name=name size=15 value="$myconfig->{name}"></td>
518 <th align=right>| . $locale->text('E-mail') . qq|</th>
519 <td><input name=email size=30 value="$myconfig->{email}"></td>
522 <th align=right>| . $locale->text('Signature') . qq|</th>
523 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
526 <th align=right>| . $locale->text('Phone') . qq|</th>
527 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
530 <th align=right>| . $locale->text('Fax') . qq|</th>
531 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
534 <th align=right>| . $locale->text('Company') . qq|</th>
535 <td><input name=company size=35 value="$myconfig->{company}"></td>
538 <th align=right>| . $locale->text('Address') . qq|</th>
539 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
542 <th align=right>| . $locale->text('Steuernummer') . qq|</th>
543 <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
546 <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
547 <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
550 <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
551 <td><input name=duns size=14 value="$myconfig->{duns}"></td>
558 <th align=right>| . $locale->text('Date Format') . qq|</th>
559 <td><select name=dateformat>$dateformat</select></td>
562 <th align=right>| . $locale->text('Number Format') . qq|</th>
563 <td><select name=numberformat>$numberformat</select></td>
566 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
567 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
570 <th align=right>| . $locale->text('Language') . qq|</th>
571 <td><select name=countrycode>$countrycodes</select></td>
574 <th align=right>| . $locale->text('Character Set') . qq|</th>
575 <td><input name=charset value="$myconfig->{charset}"></td>
578 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
579 <td><select name=userstylesheet>$selectstylesheet</select></td>
582 <th align=right>| . $locale->text('Printer') . qq|</th>
583 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
586 <th align=right>| . $locale->text('Use Templates') . qq|</th>
587 <td><select name=usetemplates>$usetemplates</select></td>
590 <th align=right>| . $locale->text('New Templates') . qq|</th>
591 <td><input name=newtemplates></td>
594 <th align=right>| . $locale->text('Setup Templates') . qq|</th>
595 <td><select name=mastertemplates>$mastertemplates</select></td>
598 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
599 <td><input name=menustyle type=radio class=radio value=neu $neu> New
600 <input name=menustyle type=radio class=radio value=old $old> Old</td>
602 <input type=hidden name=templates value=$myconfig->{templates}>
606 <tr class=listheading>
607 <th colspan=2>| . $locale->text('Database') . qq|</th>
610 # list section for database drivers
611 foreach $item (User->dbdrivers) {
620 if ($myconfig->{dbdriver} eq $item) {
621 map { $form->{"${item}_$_"} = $myconfig->{$_} }
622 qw(dbhost dbport dbuser dbpasswd dbname sid);
623 $checked = "checked";
627 <th align=right>| . $locale->text('Driver') . qq|</th>
628 <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
629 <th align=right>| . $locale->text('Host') . qq|</th>
630 <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
636 <th align=right>| . $locale->text('Dataset') . qq|</th>
637 <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
638 <th align=right>| . $locale->text('Port') . qq|</th>
639 <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
642 <th align=right>| . $locale->text('User') . qq|</th>
643 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
644 <th align=right>| . $locale->text('Password') . qq|</th>
645 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
650 if ($item eq 'Oracle') {
652 <th align=right>SID</th>
653 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
654 <th align=right>| . $locale->text('Port') . qq|</th>
655 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
658 <th align=right>| . $locale->text('Dataset') . qq|</th>
659 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
660 <th align=right>| . $locale->text('Password') . qq|</th>
661 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
667 <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
672 <td colspan=2><hr size=2 noshade></td>
679 open(FH, $menufile) or $form->error("$menufile : $!");
681 # scan for first menu level
685 if (open(FH, "custom_$menufile")) {
691 next unless $item =~ /\[/;
692 next if $item =~ /\#/;
694 $item =~ s/(\[|\])//g;
698 ($level, $menuitem) = split /--/, $item, 2;
702 push @acsorder, $item;
705 push @{ $acs{$level} }, $menuitem;
709 %role = ('admin' => $locale->text('Administrator'),
710 'user' => $locale->text('User'),
711 'manager' => $locale->text('Manager'),
712 'supervisor' => $locale->text('Supervisor'));
715 foreach $item (qw(user supervisor manager admin)) {
717 ($myconfig->{role} eq $item)
718 ? "<option selected value=$item>$role{$item}\n"
719 : "<option value=$item>$role{$item}\n";
723 <tr class=listheading>
724 <th colspan=2>| . $locale->text('Access Control') . qq|</th>
727 <td><select name=role>$selectrole</select></td>
731 foreach $item (split(/;/, $myconfig->{acs})) {
732 ($key, $value) = split /--/, $item, 2;
733 $excl{$key}{$value} = 1;
736 foreach $key (@acsorder) {
738 $checked = "checked";
739 if ($form->{login}) {
740 $checked = ($excl{$key}{$key}) ? "" : "checked";
743 # can't have variable names with spaces
744 # the 1 is for apache 2
745 $item = $form->escape("${key}--$key", 1);
748 $acsheading =~ s/ / /g;
751 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
752 $menuitems .= "$item;";
756 foreach $item (@{ $acs{$key} }) {
757 next if ($key eq $item);
759 $checked = "checked";
760 if ($form->{login}) {
761 $checked = ($excl{$key}{$item}) ? "" : "checked";
764 $acsitem = $form->escape("${key}--$item", 1);
767 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
768 $menuitems .= "$acsitem;";
775 <tr valign=top>$acsheading $acsdata
780 print qq|<input type=hidden name=acs value="$menuitems">
784 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
785 foreach $directory (@webdavdirs) {
786 if ($myconfig->{$directory}) {
787 $webdav{"${directory}c"} = "checked";
789 $webdav{"${directory}c"} = "";
794 <td colspan=2><hr size=3 noshade></td>
796 <tr class=listheading>
797 <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
801 <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
802 <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
803 <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
806 <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
807 <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
808 <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
812 <td colspan=2><hr size=3 noshade></td>
826 $form->error($locale->text('Database Driver not checked!'))
827 unless $form->{dbdriver};
829 # no spaces allowed in login name
830 ($form->{login}) = split / /, $form->{login};
832 $form->isblank("login", $locale->text('Login name missing!'));
834 # check for duplicates
835 if (!$form->{edit}) {
836 $temp = new User "$memberfile", "$form->{login}";
838 if ($temp->{login}) {
839 $form->error("$form->{login} " . $locale->text('is already a member!'));
843 # no spaces allowed in directories
844 ($form->{newtemplates}) = split / /, $form->{newtemplates};
846 if ($form->{newtemplates}) {
847 $form->{templates} = $form->{newtemplates};
850 ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
854 if (!-d "$templates") {
855 $form->error( $locale->text('Directory')
857 . $locale->text('does not exist'));
860 # add base directory to $form->{templates}
861 $form->{templates} = "$templates/$form->{templates}";
863 $myconfig = new User "$memberfile", "$form->{login}";
865 # redo acs variable and delete all the acs codes
866 @acs = split(/;/, $form->{acs});
869 foreach $item (@acs) {
870 $item = $form->escape($item, 1);
872 if (!$form->{$item}) {
873 $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
875 delete $form->{$item};
878 # check which database was filled in
879 if ($form->{dbdriver} eq 'Oracle') {
880 $form->{sid} = $form->{Oracle_sid},;
881 $form->{dbhost} = $form->{Oracle_dbhost},;
882 $form->{dbport} = $form->{Oracle_dbport};
883 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
884 $form->{dbuser} = $form->{Oracle_dbuser};
885 $form->{dbname} = $form->{Oracle_dbuser};
887 $form->isblank("dbhost", $locale->text('Hostname missing!'));
888 $form->isblank("dbport", $locale->text('Port missing!'));
889 $form->isblank("dbuser", $locale->text('Dataset missing!'));
891 if ($form->{dbdriver} eq 'Pg') {
892 $form->{dbhost} = $form->{Pg_dbhost};
893 $form->{dbport} = $form->{Pg_dbport};
894 $form->{dbpasswd} = $form->{Pg_dbpasswd};
895 $form->{dbuser} = $form->{Pg_dbuser};
896 $form->{dbname} = $form->{Pg_dbname};
898 $form->isblank("dbname", $locale->text('Dataset missing!'));
899 $form->isblank("dbuser", $locale->text('Database User missing!'));
904 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
905 foreach $directory (@webdavdirs) {
906 if ($form->{$directory}) {
907 $form->{$directory} = $form->{$directory};
909 $form->{$directory} = 0;
914 foreach $item (keys %{$form}) {
915 $myconfig->{$item} = $form->{$item};
918 delete $myconfig->{stylesheet};
919 if ($form->{userstylesheet}) {
920 $myconfig->{stylesheet} = $form->{userstylesheet};
923 $myconfig->save_member($memberfile, $userspath);
927 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
928 foreach $directory (@webdavdirs) {
929 $file = "webdav/" . $directory . "/webdav-user";
930 if ($form->{$directory}) {
931 if (open(HTACCESS, "$file")) {
933 ($login, $password) = split(/:/, $_);
934 if ($login ne $form->{login}) {
940 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
941 $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
942 print(HTACCESS $newfile);
945 $form->{$directory} = 0;
946 if (open(HTACCESS, "$file")) {
948 ($login, $password) = split(/:/, $_);
949 if ($login ne $form->{login}) {
955 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
956 print(HTACCESS $newfile);
962 # create user template directory and copy master files
963 if (!-d "$form->{templates}") {
966 if (mkdir "$form->{templates}", oct("771")) {
970 # copy templates to the directory
971 opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
972 @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|xml|txb)$/,
974 closedir TEMPLATEDIR;
976 foreach $file (@templates) {
977 open(TEMP, "$templates/$file")
978 or $form->error("$templates/$file : $!");
980 $file =~ s/$form->{mastertemplates}-//;
981 open(NEW, ">$form->{templates}/$file")
982 or $form->error("$form->{templates}/$file : $!");
984 while ($line = <TEMP>) {
991 $form->error("$!: $form->{templates}");
995 $form->redirect($locale->text('User saved!'));
1001 $form->{templates} =
1002 ($form->{templates})
1003 ? "$templates/$form->{templates}"
1004 : "$templates/$form->{login}";
1006 $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
1007 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
1010 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
1017 while ($line = shift @config) {
1019 if ($line =~ /^\[/) {
1020 last if ($line =~ /\[$form->{login}\]/);
1021 $login = &login_name($line);
1024 if ($line =~ /^templates=/) {
1025 $user{$login} = &get_value($line);
1031 # remove everything up to next login or EOF
1032 # and save template variable
1033 while ($line = shift @config) {
1034 if ($line =~ /^templates=/) {
1035 $templatedir = &get_value($line);
1037 last if ($line =~ /^\[/);
1040 # this one is either the next login or EOF
1043 $login = &login_name($line);
1045 while ($line = shift @config) {
1046 if ($line =~ /^\[/) {
1047 $login = &login_name($line);
1050 if ($line =~ /^templates=/) {
1051 $user{$login} = &get_value($line);
1058 unlink "${memberfile}.LCK";
1060 # scan %user for $templatedir
1061 foreach $login (keys %user) {
1062 last if ($found = ($templatedir eq $user{$login}));
1065 # if found keep directory otherwise delete
1068 # delete it if there is a template directory
1069 $dir = "$form->{templates}";
1071 unlink <$dir/*.html>;
1072 unlink <$dir/*.tex>;
1073 unlink <$dir/*.sty>;
1078 # delete config file for user
1079 unlink "$userspath/$form->{login}.conf";
1081 $form->redirect($locale->text('User deleted!'));
1088 $login =~ s/\[\]//g;
1089 return ($login) ? $login : undef;
1096 my ($null, $value) = split(/=/, $line, 2);
1099 $value =~ s/\s#.*//g;
1101 # remove any trailing whitespace
1102 $value =~ s/^\s*(.*?)\s*$/$1/;
1107 sub change_admin_password {
1111 . $locale->text('Administration') . " / "
1112 . $locale->text('Change Admin Password');
1120 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1122 <form method=post action=$form->{script}>
1126 <td><b>| . $locale->text('Password') . qq|</b></td>
1127 <td><input type=password name=password size=8></td>
1130 <td><b>| . $locale->text('Repeat the password') . qq|</b></td>
1131 <td><input type=password name=password_again size=8></b></td>
1135 <input type=hidden name=path value=$form->{path}>
1136 <input type=hidden name=rpw value=$form->{rpw}>
1139 <input type=submit class=submit name=action value="|
1140 . $locale->text('Change Password') . qq|">
1150 sub change_password {
1151 if ($form->{"password"} ne $form->{"password_again"}) {
1154 . $locale->text('Administration') . " / "
1155 . $locale->text('Change Admin Password');
1163 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1165 <p>| . $locale->text("The passwords do not match.") . qq|<br>
1166 <input type="button" onclick="history.back()" value="| . $locale->text("Back") . qq|">|;
1170 $root->{password} = $form->{password};
1172 $root->{'root login'} = 1;
1173 $root->save_member($memberfile);
1176 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1178 $form->redirect($locale->text('Password changed!'));
1182 sub check_password {
1183 $root = new User "$memberfile", $form->{root};
1185 if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
1186 $form->error($locale->text('Incorrect Password!'));
1191 sub pg_database_administration {
1193 $form->{dbdriver} = 'Pg';
1198 sub oracle_database_administration {
1200 $form->{dbdriver} = 'Oracle';
1205 sub dbdriver_defaults {
1207 # load some defaults for the selected driver
1209 'Pg' => { dbport => '5432',
1210 dbuser => 'postgres',
1211 dbdefault => 'template1',
1212 dbhost => 'localhost',
1213 connectstring => $locale->text('Connect to')
1215 'Oracle' => { dbport => '1521',
1218 dbhost => `hostname`,
1219 connectstring => 'SID'
1222 map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1223 keys %{ $driverdefaults{Pg} };
1227 sub dbselect_source {
1233 'Leave host and port field empty unless you want to make a remote connection.'
1237 'You must enter a host and port for local and remote connections!');
1240 "Lx-Office ERP / " . $locale->text('Database Administration');
1249 <h2>$form->{title}</h2>
1251 <form method=post action=$form->{script}>
1258 <tr class=listheading>
1259 <th colspan=4>| . $locale->text('Database') . qq|</th>
1262 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1269 <th align=right>| . $locale->text('Host') . qq|</th>
1270 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1271 <th align=right>| . $locale->text('Port') . qq|</th>
1272 <td><input name=dbport size=5 value=$form->{dbport}></td>
1278 <th align=right>| . $locale->text('User') . qq|</th>
1279 <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1280 <th align=right>| . $locale->text('Password') . qq|</th>
1281 <td><input type=password name=dbpasswd size=10></td>
1287 <th align=right>$form->{connectstring}</th>
1288 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1297 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1298 <input type=hidden name=path value=$form->{path}>
1299 <input type=hidden name=rpw value=$form->{rpw}>
1303 <input type=submit class=submit name=action value="|
1304 . $locale->text('Create Dataset') . qq|">|;
1305 # Vorübergehend Deaktiviert
1306 # <input type=submit class=submit name=action value="|
1307 # . $locale->text('Update Dataset') . qq|">
1308 print qq| <input type=submit class=submit name=action value="|
1309 . $locale->text('Delete Dataset') . qq|">
1318 'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1322 <br>$msg{$form->{dbdriver}}
1333 &{ $form->{nextsub} };
1337 sub update_dataset {
1339 %needsupdate = User->dbneedsupdate(\%$form);
1343 . $locale->text('Database Administration') . " / "
1344 . $locale->text('Update Dataset');
1353 <h2>$form->{title}</h2>
1356 foreach $key (sort keys %needsupdate) {
1357 if ($needsupdate{$key} ne $form->{dbversion}) {
1358 $upd .= qq|<input id="$field_id" name="db$key" type="checkbox" value="1" checked> $key\n|;
1359 $form->{dbupdate} .= "db$key ";
1364 chop $form->{dbupdate};
1366 if ($form->{dbupdate}) {
1370 <form method=post action=$form->{script}>
1372 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1373 <input type=hidden name=dbhost value=$form->{dbhost}>
1374 <input type=hidden name=dbport value=$form->{dbport}>
1375 <input type=hidden name=dbuser value=$form->{dbuser}>
1376 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1377 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1379 <tr class=listheading>
1380 <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1392 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1394 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1396 <input type=hidden name=path value=$form->{path}>
1397 <input type=hidden name=rpw value=$form->{rpw}>
1399 <input type=hidden name=nextsub value=dbupdate>
1404 <input type=submit class=submit name=action value="|
1405 . $locale->text('Continue') . qq|">
1414 print $locale->text('All Datasets up to date!');
1427 $form->{"stylesheet"} = "lx-office-erp.css";
1428 $form->{"title"} = $main::locale->text("Dataset upgrade");
1432 map({ s/\s//g; s/^db//; $_; }
1433 grep({ $form->{$_} }
1434 split(/\s+/, $form->{"dbupdate"}))));
1435 print($form->parse_html_template("dbupgrade/header",
1436 { "dbname" => $dbname }));
1438 User->dbupdate(\%$form);
1443 | . $locale->text('Dataset updated!') . qq|
1447 <a id="enddatasetupdate" href="admin.pl?action=login&| .
1448 join("&", map({ "$_=" . $form->escape($form->{$_}); } qw(path rpw))) .
1449 qq|">| . $locale->text("Continue") . qq|</a>|;
1453 sub create_dataset {
1455 foreach $item (sort User->dbsources(\%$form)) {
1456 $dbsources .= "[$item] ";
1459 opendir SQLDIR, "sql/." or $form - error($!);
1460 foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1461 next if ($item eq 'Default-chart.sql');
1462 $item =~ s/-chart\.sql//;
1464 qq| <input name=chart class=radio type=radio value="$item"> $item|;
1468 $selectencoding = qq|<option>
1469 <option value=SQL_ASCII>ASCII
1470 <option value=EUC_JP>Japanese Extended UNIX Code
1471 <option value=EUC_CN>Chinese Extended UNIX Code
1472 <option value=EUC_KR>Korean Extended UNIX Code
1473 <option value=EUC_TW>Taiwan Extended UNIX Code
1474 <option value=UNICODE>UTF-8 Unicode
1475 <option value=MULE_INTERNAL>Mule internal type
1476 <option value=LATIN1>ISO 8859-1
1477 <option value=LATIN2>ISO 8859-2
1478 <option value=LATIN3>ISO 8859-3
1479 <option value=LATIN4>ISO 8859-4
1480 <option value=LATIN5>ISO 8859-5
1481 <option value=KOI8>KOI8-R
1482 <option value=WIN>Windows CP1251
1483 <option value=ALT>Windows CP866
1488 . $locale->text('Database Administration') . " / "
1489 . $locale->text('Create Dataset');
1498 <h2>$form->{title}</h2>
1500 <form method=post action=$form->{script}>
1503 <tr class=listheading>
1504 <th colspan=2> </th>
1509 <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1516 <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1517 <td><input name=db></td>
1523 <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1524 <td><select name=encoding>$selectencoding</select></td>
1530 <th align=right nowrap>|
1531 . $locale->text('Create Chart of Accounts') . qq|</th>
1538 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1539 <input type=hidden name=dbuser value=$form->{dbuser}>
1540 <input type=hidden name=dbhost value=$form->{dbhost}>
1541 <input type=hidden name=dbport value=$form->{dbport}>
1542 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1543 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1545 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1547 <input type=hidden name=path value=$form->{path}>
1548 <input type=hidden name=rpw value=$form->{rpw}>
1550 <input type=hidden name=nextsub value=dbcreate>
1555 <input type=submit class=submit name=action value="|
1556 . $locale->text('Continue') . qq|">
1572 $form->isblank("db", $locale->text('Dataset missing!'));
1574 User->dbcreate(\%$form);
1578 . $locale->text('Database Administration') . " / "
1579 . $locale->text('Create Dataset');
1588 <h2>$form->{title}</h2>
1590 <form method=post action=$form->{script}>|
1592 . $locale->text('Dataset')
1594 . $locale->text('successfully created!')
1598 <input type=hidden name=path value="$form->{path}">
1599 <input type=hidden name=rpw value="$form->{rpw}">
1601 <input type=hidden name=nextsub value=list_users>
1603 <p><input type=submit class=submit name=action value="|
1604 . $locale->text('Continue') . qq|">
1614 sub delete_dataset {
1616 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1617 foreach $item (sort @dbsources) {
1619 qq|<input name=db class=radio type=radio value=$item> $item |;
1622 $form->error($locale->text('Nothing to delete!'));
1627 . $locale->text('Database Administration') . " / "
1628 . $locale->text('Delete Dataset');
1635 <h2>$form->{title}</h2>
1637 <form method=post action=$form->{script}>
1640 <tr class=listheading>
1642 . $locale->text('The following Datasets are not in use and can be deleted')
1654 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1655 <input type=hidden name=dbuser value=$form->{dbuser}>
1656 <input type=hidden name=dbhost value=$form->{dbhost}>
1657 <input type=hidden name=dbport value=$form->{dbport}>
1658 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1659 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1661 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1663 <input type=hidden name=path value="$form->{path}">
1664 <input type=hidden name=rpw value="$form->{rpw}">
1666 <input type=hidden name=nextsub value=dbdelete>
1671 <input type=submit class=submit name=action value="|
1672 . $locale->text('Continue') . qq|">
1688 $form->error($locale->text('No Dataset selected!'));
1691 User->dbdelete(\%$form);
1695 . $locale->text('Database Administration') . " / "
1696 . $locale->text('Delete Dataset');
1705 <h2>$form->{title}</h2>
1707 <form method=post action=$form->{script}>
1709 $form->{db} | . $locale->text('successfully deleted!')
1713 <input type=hidden name=path value="$form->{path}">
1714 <input type=hidden name=rpw value="$form->{rpw}">
1716 <input type=hidden name=nextsub value=list_users>
1718 <p><input type=submit class=submit name=action value="|
1719 . $locale->text('Continue') . qq|">
1731 unlink "$userspath/nologin";
1734 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1736 $form->redirect($locale->text('Lockfile removed!'));
1742 open(FH, ">$userspath/nologin")
1743 or $form->error($locale->text('Cannot create Lock!'));
1747 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1749 $form->redirect($locale->text('Lockfile created!'));