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;
176 . $locale->text('Administration') . " / "
177 . $locale->text('Edit User');
189 qq|<input type=submit class=submit name=action value="|
190 . $locale->text('Delete') . qq|">
191 <input type=hidden name=edit value=1>|;
196 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
197 <input type=hidden name=path value=$form->{path}>
198 <input type=hidden name=rpw value=$form->{rpw}>
200 <input type=submit class=submit name=action value="|
201 . $locale->text('Save') . qq|">
214 $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
216 open(FH, "$memberfile") or $form->error("$memberfile : $!");
219 <input type=submit class=submit name=action value="|
220 . $locale->text('Lock System') . qq|">|;
222 if (-e "$userspath/nologin") {
224 <input type=submit class=submit name=action value="|
225 . $locale->text('Unlock System') . qq|">|;
233 $login =~ s/(\[|\])//g;
236 if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
238 ($null, $member{$login}{$var}) = split /=/, $_, 2;
244 # type=submit $locale->text('Pg Database Administration')
245 # type=submit $locale->text('Oracle Database Administration')
247 foreach $item (User->dbdrivers) {
249 qq|<input name=action type=submit class=submit value="|
250 . $locale->text("$item Database Administration") . qq|">|;
253 $column_header{login} = qq|<th>| . $locale->text('Login') . qq|</th>|;
254 $column_header{name} = qq|<th>| . $locale->text('Name') . qq|</th>|;
255 $column_header{company} = qq|<th>| . $locale->text('Company') . qq|</th>|;
256 $column_header{dbdriver} = qq|<th>| . $locale->text('Driver') . qq|</th>|;
257 $column_header{dbhost} = qq|<th>| . $locale->text('Host') . qq|</th>|;
258 $column_header{dataset} = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
259 $column_header{templates} =
260 qq|<th>| . $locale->text('Templates') . qq|</th>|;
262 @column_index = qw(login name company dbdriver dbhost dataset templates);
264 $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
271 <form method=post action=$form->{script}>
275 <tr class=listheading>
276 <th>$form->{title}</th>
282 <tr class=listheading>|;
284 map { print "$column_header{$_}\n" } @column_index;
290 foreach $key (sort keys %member) {
292 "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}";
295 $member{$key}{templates} =~ s/^$templates\///;
296 $member{$key}{dbhost} = $locale->text('localhost')
297 unless $member{$key}{dbhost};
298 $member{$key}{dbname} = $member{$key}{dbuser}
299 if ($member{$key}{dbdriver} eq 'Oracle');
301 $column_data{login} = qq|<td><a href=$href>$key</a></td>|;
302 $column_data{name} = qq|<td>$member{$key}{name}</td>|;
303 $column_data{company} = qq|<td>$member{$key}{company}</td>|;
304 $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
305 $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
306 $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
307 $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
312 <tr class=listrow$i>|;
314 map { print "$column_data{$_}\n" } @column_index;
325 <td><hr size=3 noshade></td>
329 <input type=hidden name=path value=$form->{path}>
330 <input type=hidden name=rpw value=$form->{rpw}>
332 <br><input type=submit class=submit name=action value="|
333 . $locale->text('Add User') . qq|">
334 <input type=submit class=submit name=action value="|
335 . $locale->text('Change Admin Password') . qq|">
342 | . $locale->text('Click on login name to edit!') . qq|
346 '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.'
352 <form method=post action=login.pl>
354 <table border=0 width=100%>
355 <tr class=listheading>
356 <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
362 <th align=right>| . $locale->text('Name') . qq|</th>
363 <td><input class=login name=login></td>
367 <th align=right>| . $locale->text('Password') . qq|</th>
368 <td><input class=login type=password name=password></td>
369 <td><input type=submit name=action value="|
370 . $locale->text('Login') . qq|"></td>
372 <input type=hidden name=path value=$form->{path}>
390 # if there is a login, get user
391 if ($form->{login}) {
394 $myconfig = new User "$memberfile", "$form->{login}";
396 $myconfig->{signature} =~ s/\\n/\r\n/g;
397 $myconfig->{address} =~ s/\\n/\r\n/g;
399 # strip basedir from templates directory
400 $myconfig->{templates} =~ s/^$templates\///;
402 # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
405 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
407 ($item eq $myconfig->{dateformat})
408 ? "<option selected>$item\n"
412 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
414 ($item eq $myconfig->{numberformat})
415 ? "<option selected>$item\n"
419 %countrycodes = User->country_codes;
421 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
425 ($myconfig->{countrycode} eq $key)
426 ? "<option selected value=$key>$countrycodes{$key}"
427 : "<option value=$key>$countrycodes{$key}";
429 $countrycodes = qq|<option value="">American English\n$countrycodes|;
431 # is there a templates basedir
432 if (!-d "$templates") {
433 $form->error( $locale->text('Directory')
435 . $locale->text('does not exist'));
438 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
439 @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
440 closedir TEMPLATEDIR;
442 @allhtml = sort grep /\.html/, @all;
443 @alldir = grep !/\.(html|tex)$/, @all;
444 @alldir = grep !/^(webpages|\.svn)$/, @alldir;
446 @allhtml = reverse grep !/Default/, @allhtml;
447 push @allhtml, 'Default';
448 @allhtml = reverse @allhtml;
450 foreach $item (@alldir) {
451 if ($item eq $myconfig->{templates}) {
452 $usetemplates .= qq|<option selected>$item\n|;
454 $usetemplates .= qq|<option>$item\n|;
458 $lastitem = $allhtml[0];
459 $lastitem =~ s/-.*//g;
460 $mastertemplates = qq|<option>$lastitem\n|;
461 foreach $item (@allhtml) {
464 if ($item ne $lastitem) {
465 $mastertemplates .= qq|<option>$item\n|;
470 opendir CSS, "css/.";
471 @all = grep /.*\.css$/, readdir CSS;
474 foreach $item (@all) {
475 if ($item eq $myconfig->{stylesheet}) {
476 $selectstylesheet .= qq|<option selected>$item\n|;
478 $selectstylesheet .= qq|<option>$item\n|;
481 $selectstylesheet .= "<option>\n";
485 if ($myconfig->{menustyle} eq "neu") { $neu = "checked"; }
486 else { $old = "checked"; }
491 <form method=post action=$form->{script}>
494 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
500 <th align=right>| . $locale->text('Login') . qq|</th>
501 <td><input name=login value="$myconfig->{login}"></td>
504 <th align=right>| . $locale->text('Password') . qq|</th>
505 <td><input type=password name=password size=8 value=$myconfig->{password}></td>
506 <input type=hidden name=old_password value=$myconfig->{password}>
509 <th align=right>| . $locale->text('Name') . qq|</th>
510 <td><input name=name size=15 value="$myconfig->{name}"></td>
513 <th align=right>| . $locale->text('E-mail') . qq|</th>
514 <td><input name=email size=30 value="$myconfig->{email}"></td>
517 <th align=right>| . $locale->text('Signature') . qq|</th>
518 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
521 <th align=right>| . $locale->text('Phone') . qq|</th>
522 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
525 <th align=right>| . $locale->text('Fax') . qq|</th>
526 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
529 <th align=right>| . $locale->text('Company') . qq|</th>
530 <td><input name=company size=35 value="$myconfig->{company}"></td>
533 <th align=right>| . $locale->text('Address') . qq|</th>
534 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
537 <th align=right>| . $locale->text('Steuernummer') . qq|</th>
538 <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
541 <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
542 <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
545 <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
546 <td><input name=duns size=14 value="$myconfig->{duns}"></td>
553 <th align=right>| . $locale->text('Date Format') . qq|</th>
554 <td><select name=dateformat>$dateformat</select></td>
557 <th align=right>| . $locale->text('Number Format') . qq|</th>
558 <td><select name=numberformat>$numberformat</select></td>
561 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
562 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
565 <th align=right>| . $locale->text('Language') . qq|</th>
566 <td><select name=countrycode>$countrycodes</select></td>
569 <th align=right>| . $locale->text('Character Set') . qq|</th>
570 <td><input name=charset value="$myconfig->{charset}"></td>
573 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
574 <td><select name=userstylesheet>$selectstylesheet</select></td>
577 <th align=right>| . $locale->text('Printer') . qq|</th>
578 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
581 <th align=right>| . $locale->text('Use Templates') . qq|</th>
582 <td><select name=usetemplates>$usetemplates</select></td>
585 <th align=right>| . $locale->text('New Templates') . qq|</th>
586 <td><input name=newtemplates></td>
589 <th align=right>| . $locale->text('Setup Templates') . qq|</th>
590 <td><select name=mastertemplates>$mastertemplates</select></td>
593 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
594 <td><input name=menustyle type=radio class=radio value=neu $neu> New
595 <input name=menustyle type=radio class=radio value=old $old> Old</td>
597 <input type=hidden name=templates value=$myconfig->{templates}>
601 <tr class=listheading>
602 <th colspan=2>| . $locale->text('Database') . qq|</th>
605 # list section for database drivers
606 foreach $item (User->dbdrivers) {
615 if ($myconfig->{dbdriver} eq $item) {
616 map { $form->{"${item}_$_"} = $myconfig->{$_} }
617 qw(dbhost dbport dbuser dbpasswd dbname sid);
618 $checked = "checked";
622 <th align=right>| . $locale->text('Driver') . qq|</th>
623 <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
624 <th align=right>| . $locale->text('Host') . qq|</th>
625 <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
631 <th align=right>| . $locale->text('Dataset') . qq|</th>
632 <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
633 <th align=right>| . $locale->text('Port') . qq|</th>
634 <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
637 <th align=right>| . $locale->text('User') . qq|</th>
638 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
639 <th align=right>| . $locale->text('Password') . qq|</th>
640 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
645 if ($item eq 'Oracle') {
647 <th align=right>SID</th>
648 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
649 <th align=right>| . $locale->text('Port') . qq|</th>
650 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
653 <th align=right>| . $locale->text('Dataset') . 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>
662 <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
667 <td colspan=2><hr size=2 noshade></td>
674 open(FH, $menufile) or $form->error("$menufile : $!");
676 # scan for first menu level
680 if (open(FH, "custom_$menufile")) {
686 next unless $item =~ /\[/;
687 next if $item =~ /\#/;
689 $item =~ s/(\[|\])//g;
693 ($level, $menuitem) = split /--/, $item, 2;
697 push @acsorder, $item;
700 push @{ $acs{$level} }, $menuitem;
704 %role = ('admin' => $locale->text('Administrator'),
705 'user' => $locale->text('User'),
706 'manager' => $locale->text('Manager'),
707 'supervisor' => $locale->text('Supervisor'));
710 foreach $item (qw(user supervisor manager admin)) {
712 ($myconfig->{role} eq $item)
713 ? "<option selected value=$item>$role{$item}\n"
714 : "<option value=$item>$role{$item}\n";
718 <tr class=listheading>
719 <th colspan=2>| . $locale->text('Access Control') . qq|</th>
722 <td><select name=role>$selectrole</select></td>
726 foreach $item (split /;/, $myconfig->{acs}) {
727 ($key, $value) = split /--/, $item, 2;
728 $excl{$key}{$value} = 1;
731 foreach $key (@acsorder) {
733 $checked = "checked";
734 if ($form->{login}) {
735 $checked = ($excl{$key}{$key}) ? "" : "checked";
738 # can't have variable names with spaces
739 # the 1 is for apache 2
740 $item = $form->escape("${key}--$key", 1);
743 $acsheading =~ s/ / /g;
746 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
747 $menuitems .= "$item;";
751 foreach $item (@{ $acs{$key} }) {
752 next if ($key eq $item);
754 $checked = "checked";
755 if ($form->{login}) {
756 $checked = ($excl{$key}{$item}) ? "" : "checked";
759 $acsitem = $form->escape("${key}--$item", 1);
762 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
763 $menuitems .= "$acsitem;";
770 <tr valign=top>$acsheading $acsdata
775 print qq|<input type=hidden name=acs value="$menuitems">
779 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
780 foreach $directory (@webdavdirs) {
781 if ($myconfig->{$directory}) {
782 $webdav{"${directory}c"} = "checked";
784 $webdav{"${directory}c"} = "";
789 <td colspan=2><hr size=3 noshade></td>
791 <tr class=listheading>
792 <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
796 <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
797 <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
798 <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
801 <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
802 <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
803 <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
807 <td colspan=2><hr size=3 noshade></td>
821 $form->error($locale->text('Database Driver not checked!'))
822 unless $form->{dbdriver};
824 # no spaces allowed in login name
825 ($form->{login}) = split / /, $form->{login};
827 $form->isblank("login", $locale->text('Login name missing!'));
829 # check for duplicates
830 if (!$form->{edit}) {
831 $temp = new User "$memberfile", "$form->{login}";
833 if ($temp->{login}) {
834 $form->error("$form->{login} " . $locale->text('is already a member!'));
838 # no spaces allowed in directories
839 ($form->{newtemplates}) = split / /, $form->{newtemplates};
841 if ($form->{newtemplates}) {
842 $form->{templates} = $form->{newtemplates};
845 ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
849 if (!-d "$templates") {
850 $form->error( $locale->text('Directory')
852 . $locale->text('does not exist'));
855 # add base directory to $form->{templates}
856 $form->{templates} = "$templates/$form->{templates}";
858 $myconfig = new User "$memberfile", "$form->{login}";
860 # redo acs variable and delete all the acs codes
861 @acs = split /;/, $form->{acs};
864 foreach $item (@acs) {
865 $item = $form->escape($item, 1);
867 if (!$form->{$item}) {
868 $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
870 delete $form->{$item};
873 # check which database was filled in
874 if ($form->{dbdriver} eq 'Oracle') {
875 $form->{sid} = $form->{Oracle_sid},;
876 $form->{dbhost} = $form->{Oracle_dbhost},;
877 $form->{dbport} = $form->{Oracle_dbport};
878 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
879 $form->{dbuser} = $form->{Oracle_dbuser};
880 $form->{dbname} = $form->{Oracle_dbuser};
882 $form->isblank("dbhost", $locale->text('Hostname missing!'));
883 $form->isblank("dbport", $locale->text('Port missing!'));
884 $form->isblank("dbuser", $locale->text('Dataset missing!'));
886 if ($form->{dbdriver} eq 'Pg') {
887 $form->{dbhost} = $form->{Pg_dbhost};
888 $form->{dbport} = $form->{Pg_dbport};
889 $form->{dbpasswd} = $form->{Pg_dbpasswd};
890 $form->{dbuser} = $form->{Pg_dbuser};
891 $form->{dbname} = $form->{Pg_dbname};
893 $form->isblank("dbname", $locale->text('Dataset missing!'));
894 $form->isblank("dbuser", $locale->text('Database User missing!'));
899 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
900 foreach $directory (@webdavdirs) {
901 if ($form->{$directory}) {
902 $form->{$directory} = $form->{$directory};
904 $form->{$directory} = 0;
909 foreach $item (keys %{$form}) {
910 $myconfig->{$item} = $form->{$item};
913 delete $myconfig->{stylesheet};
914 if ($form->{userstylesheet}) {
915 $myconfig->{stylesheet} = $form->{userstylesheet};
918 $myconfig->save_member($memberfile, $userspath);
922 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
923 foreach $directory (@webdavdirs) {
924 $file = "webdav/" . $directory . "/webdav-user";
925 if ($form->{$directory}) {
926 if (open(HTACCESS, "$file")) {
928 ($login, $password) = split(/:/, $_);
929 if ($login ne $form->{login}) {
935 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
936 $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
937 print(HTACCESS $newfile);
940 $form->{$directory} = 0;
941 if (open(HTACCESS, "$file")) {
943 ($login, $password) = split(/:/, $_);
944 if ($login ne $form->{login}) {
950 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
951 print(HTACCESS $newfile);
957 # create user template directory and copy master files
958 if (!-d "$form->{templates}") {
961 if (mkdir "$form->{templates}", oct("771")) {
965 # copy templates to the directory
966 opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
967 @templates = grep /$form->{mastertemplates}.*?\.(html|tex)$/,
969 closedir TEMPLATEDIR;
971 foreach $file (@templates) {
972 open(TEMP, "$templates/$file")
973 or $form->error("$templates/$file : $!");
975 $file =~ s/$form->{mastertemplates}-//;
976 open(NEW, ">$form->{templates}/$file")
977 or $form->error("$form->{templates}/$file : $!");
979 while ($line = <TEMP>) {
986 $form->error("$!: $form->{templates}");
990 $form->redirect($locale->text('User saved!'));
998 ? "$templates/$form->{templates}"
999 : "$templates/$form->{login}";
1001 $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
1002 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
1005 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
1012 while ($line = shift @config) {
1014 if ($line =~ /^\[/) {
1015 last if ($line =~ /\[$form->{login}\]/);
1016 $login = &login_name($line);
1019 if ($line =~ /^templates=/) {
1020 $user{$login} = &get_value($line);
1026 # remove everything up to next login or EOF
1027 # and save template variable
1028 while ($line = shift @config) {
1029 if ($line =~ /^templates=/) {
1030 $templatedir = &get_value($line);
1032 last if ($line =~ /^\[/);
1035 # this one is either the next login or EOF
1038 $login = &login_name($line);
1040 while ($line = shift @config) {
1041 if ($line =~ /^\[/) {
1042 $login = &login_name($line);
1045 if ($line =~ /^templates=/) {
1046 $user{$login} = &get_value($line);
1053 unlink "${memberfile}.LCK";
1055 # scan %user for $templatedir
1056 foreach $login (keys %user) {
1057 last if ($found = ($templatedir eq $user{$login}));
1060 # if found keep directory otherwise delete
1063 # delete it if there is a template directory
1064 $dir = "$form->{templates}";
1066 unlink <$dir/*.html>;
1067 unlink <$dir/*.tex>;
1072 # delete config file for user
1073 unlink "$userspath/$form->{login}.conf";
1075 $form->redirect($locale->text('User deleted!'));
1082 $login =~ s/\[\]//g;
1083 return ($login) ? $login : undef;
1090 my ($null, $value) = split(/=/, $line, 2);
1093 $value =~ s/\s#.*//g;
1095 # remove any trailing whitespace
1096 $value =~ s/^\s*(.*?)\s*$/$1/;
1101 sub change_admin_password {
1105 . $locale->text('Administration') . " / "
1106 . $locale->text('Change Admin Password');
1114 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1116 <form method=post action=$form->{script}>
1119 . $locale->text('Password')
1120 . qq|</b> <input type=password name=password size=8>
1122 <input type=hidden name=path value=$form->{path}>
1123 <input type=hidden name=rpw value=$form->{rpw}>
1126 <input type=submit class=submit name=action value="|
1127 . $locale->text('Change Password') . qq|">
1137 sub change_password {
1139 $root->{password} = $form->{password};
1141 $root->{'root login'} = 1;
1142 $root->save_member($memberfile);
1145 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1147 $form->redirect($locale->text('Password changed!'));
1151 sub check_password {
1152 $root = new User "$memberfile", $form->{root};
1154 if (!$root->{password} || ($root->{password} ne $form->{rpw})) {
1155 $form->error($locale->text('Incorrect Password!'));
1160 sub pg_database_administration {
1162 $form->{dbdriver} = 'Pg';
1167 sub oracle_database_administration {
1169 $form->{dbdriver} = 'Oracle';
1174 sub dbdriver_defaults {
1176 # load some defaults for the selected driver
1178 'Pg' => { dbport => '5432',
1179 dbuser => 'postgres',
1180 dbdefault => 'template1',
1181 dbhost => 'localhost',
1182 connectstring => $locale->text('Connect to')
1184 'Oracle' => { dbport => '1521',
1187 dbhost => `hostname`,
1188 connectstring => 'SID'
1191 map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1192 keys %{ $driverdefaults{Pg} };
1196 sub dbselect_source {
1202 'Leave host and port field empty unless you want to make a remote connection.'
1206 'You must enter a host and port for local and remote connections!');
1209 "Lx-Office ERP / " . $locale->text('Database Administration');
1218 <h2>$form->{title}</h2>
1220 <form method=post action=$form->{script}>
1227 <tr class=listheading>
1228 <th colspan=4>| . $locale->text('Database') . qq|</th>
1231 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1238 <th align=right>| . $locale->text('Host') . qq|</th>
1239 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1240 <th align=right>| . $locale->text('Port') . qq|</th>
1241 <td><input name=dbport size=5 value=$form->{dbport}></td>
1247 <th align=right>| . $locale->text('User') . qq|</th>
1248 <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1249 <th align=right>| . $locale->text('Password') . qq|</th>
1250 <td><input type=password name=dbpasswd size=10></td>
1256 <th align=right>$form->{connectstring}</th>
1257 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1266 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1267 <input type=hidden name=path value=$form->{path}>
1268 <input type=hidden name=rpw value=$form->{rpw}>
1272 <input type=submit class=submit name=action value="|
1273 . $locale->text('Create Dataset') . qq|">
1274 <input type=submit class=submit name=action value="|
1275 . $locale->text('Update Dataset') . qq|">
1276 <input type=submit class=submit name=action value="|
1277 . $locale->text('Delete Dataset') . qq|">
1286 'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1290 <br>$msg{$form->{dbdriver}}
1301 &{ $form->{nextsub} };
1305 sub update_dataset {
1307 %needsupdate = User->dbneedsupdate(\%$form);
1311 . $locale->text('Database Administration') . " / "
1312 . $locale->text('Update Dataset');
1321 <h2>$form->{title}</h2>
1324 foreach $key (sort keys %needsupdate) {
1325 if ($needsupdate{$key} ne $form->{dbversion}) {
1326 $upd .= qq|<input name="db$key" type=checkbox value=1 checked> $key\n|;
1327 $form->{dbupdate} .= "db$key ";
1331 chop $form->{dbupdate};
1333 if ($form->{dbupdate}) {
1337 <form method=post action=$form->{script}>
1339 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1340 <input type=hidden name=dbhost value=$form->{dbhost}>
1341 <input type=hidden name=dbport value=$form->{dbport}>
1342 <input type=hidden name=dbuser value=$form->{dbuser}>
1343 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1344 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1346 <tr class=listheading>
1347 <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1359 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1361 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1363 <input type=hidden name=path value=$form->{path}>
1364 <input type=hidden name=rpw value=$form->{rpw}>
1366 <input type=hidden name=nextsub value=dbupdate>
1371 <input type=submit class=submit name=action value="|
1372 . $locale->text('Continue') . qq|">
1381 print $locale->text('All Datasets up to date!');
1395 User->dbupdate(\%$form);
1397 $form->redirect($locale->text('Dataset updated!'));
1401 sub create_dataset {
1403 foreach $item (sort User->dbsources(\%$form)) {
1404 $dbsources .= "[$item] ";
1407 opendir SQLDIR, "sql/." or $form - error($!);
1408 foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1409 next if ($item eq 'Default-chart.sql');
1410 $item =~ s/-chart\.sql//;
1412 qq| <input name=chart class=radio type=radio value="$item"> $item|;
1416 $selectencoding = qq|<option>
1417 <option value=SQL_ASCII>ASCII
1418 <option value=EUC_JP>Japanese Extended UNIX Code
1419 <option value=EUC_CN>Chinese Extended UNIX Code
1420 <option value=EUC_KR>Korean Extended UNIX Code
1421 <option value=EUC_TW>Taiwan Extended UNIX Code
1422 <option value=UNICODE>UTF-8 Unicode
1423 <option value=MULE_INTERNAL>Mule internal type
1424 <option value=LATIN1>ISO 8859-1
1425 <option value=LATIN2>ISO 8859-2
1426 <option value=LATIN3>ISO 8859-3
1427 <option value=LATIN4>ISO 8859-4
1428 <option value=LATIN5>ISO 8859-5
1429 <option value=KOI8>KOI8-R
1430 <option value=WIN>Windows CP1251
1431 <option value=ALT>Windows CP866
1436 . $locale->text('Database Administration') . " / "
1437 . $locale->text('Create Dataset');
1446 <h2>$form->{title}</h2>
1448 <form method=post action=$form->{script}>
1451 <tr class=listheading>
1452 <th colspan=2> </th>
1457 <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1464 <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1465 <td><input name=db></td>
1471 <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1472 <td><select name=encoding>$selectencoding</select></td>
1478 <th align=right nowrap>|
1479 . $locale->text('Create Chart of Accounts') . qq|</th>
1486 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1487 <input type=hidden name=dbuser value=$form->{dbuser}>
1488 <input type=hidden name=dbhost value=$form->{dbhost}>
1489 <input type=hidden name=dbport value=$form->{dbport}>
1490 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1491 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1493 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1495 <input type=hidden name=path value=$form->{path}>
1496 <input type=hidden name=rpw value=$form->{rpw}>
1498 <input type=hidden name=nextsub value=dbcreate>
1503 <input type=submit class=submit name=action value="|
1504 . $locale->text('Continue') . qq|">
1520 $form->isblank("db", $locale->text('Dataset missing!'));
1522 User->dbcreate(\%$form);
1526 . $locale->text('Database Administration') . " / "
1527 . $locale->text('Create Dataset');
1536 <h2>$form->{title}</h2>
1538 <form method=post action=$form->{script}>|
1540 . $locale->text('Dataset')
1542 . $locale->text('successfully created!')
1546 <input type=hidden name=path value="$form->{path}">
1547 <input type=hidden name=rpw value="$form->{rpw}">
1549 <input type=hidden name=nextsub value=list_users>
1551 <p><input type=submit class=submit name=action value="|
1552 . $locale->text('Continue') . qq|">
1562 sub delete_dataset {
1564 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1565 foreach $item (sort @dbsources) {
1567 qq|<input name=db class=radio type=radio value=$item> $item |;
1570 $form->error($locale->text('Nothing to delete!'));
1575 . $locale->text('Database Administration') . " / "
1576 . $locale->text('Delete Dataset');
1583 <h2>$form->{title}</h2>
1585 <form method=post action=$form->{script}>
1588 <tr class=listheading>
1590 . $locale->text('The following Datasets are not in use and can be deleted')
1602 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1603 <input type=hidden name=dbuser value=$form->{dbuser}>
1604 <input type=hidden name=dbhost value=$form->{dbhost}>
1605 <input type=hidden name=dbport value=$form->{dbport}>
1606 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1607 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1609 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1611 <input type=hidden name=path value="$form->{path}">
1612 <input type=hidden name=rpw value="$form->{rpw}">
1614 <input type=hidden name=nextsub value=dbdelete>
1619 <input type=submit class=submit name=action value="|
1620 . $locale->text('Continue') . qq|">
1636 $form->error($locale->text('No Dataset selected!'));
1639 User->dbdelete(\%$form);
1643 . $locale->text('Database Administration') . " / "
1644 . $locale->text('Delete Dataset');
1653 <h2>$form->{title}</h2>
1655 <form method=post action=$form->{script}>
1657 $form->{db} | . $locale->text('successfully deleted!')
1661 <input type=hidden name=path value="$form->{path}">
1662 <input type=hidden name=rpw value="$form->{rpw}">
1664 <input type=hidden name=nextsub value=list_users>
1666 <p><input type=submit class=submit name=action value="|
1667 . $locale->text('Continue') . qq|">
1679 unlink "$userspath/nologin";
1682 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1684 $form->redirect($locale->text('Lockfile removed!'));
1690 open(FH, ">$userspath/nologin")
1691 or $form->error($locale->text('Cannot create Lock!'));
1695 "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1697 $form->redirect($locale->text('Lockfile created!'));