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";
42 $locale = new Locale $language, "admin";
44 eval { require DBI; };
45 $form->error($locale->text('DBI not installed!')) if ($@);
48 if (-f "$form->{path}/custom_$form->{script}") {
49 eval { require "$form->{path}/custom_$form->{script}"; };
50 $form->error($@) if ($@);
53 $form->{stylesheet} = "lx-office-erp.css";
54 $form->{favicon} = "favicon.ico";
56 if ($form->{action}) {
58 $subroutine = $locale->findsub($form->{action});
60 if ($subroutine eq 'login') {
62 $form->{rpw} = crypt $form->{rpw}, "ro";
72 # if there are no drivers bail out
73 $form->error($locale->text('No Database Drivers available!'))
74 unless (User->dbdrivers);
77 if (!-f $memberfile) {
78 open(FH, ">$memberfile") or $form->error("$memberfile : $!");
79 print FH qq|# SQL-Ledger Accounting members
99 qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
109 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
111 . $locale->text('Version')
112 . qq| $form->{version}<p>|
113 . $locale->text('Administration')
116 <form method=post action="$form->{script}">
120 <th>| . $locale->text('Password') . qq|</th>
121 <td><input type=password name=rpw></td>
122 <td><input type=submit class=submit name=action value="|
123 . $locale->text('Login') . qq|"></td>
125 <input type=hidden name=action value=login>
126 <input type=hidden name=root value="root login">
127 <input type=hidden name=path value=$form->{path}>
133 <a href=http://www.lx-office.org>Lx-Office |
134 . $locale->text('website') . qq|</a>
154 . $locale->text('Administration') . " / "
155 . $locale->text('Add User');
157 $form->{Oracle_sid} = $sid;
158 $form->{Oracle_dbport} = '1521';
159 $form->{Oracle_dbhost} = `hostname`;
161 if (-f "css/lx-office-erp.css") {
162 $myconfig->{stylesheet} = "lx-office-erp.css";
164 $myconfig->{vclimit} = 200;
175 . $locale->text('Administration') . " / "
176 . $locale->text('Edit User');
188 qq|<input type=submit class=submit name=action value="|
189 . $locale->text('Delete') . qq|">
190 <input type=hidden name=edit value=1>|;
195 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
196 <input type=hidden name=root value="$form->{root}">
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}&root=$form->{root}&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}>
331 <input type=hidden name=root value="$form->{root}">
333 <br><input type=submit class=submit name=action value="|
334 . $locale->text('Add User') . qq|">
335 <input type=submit class=submit name=action value="|
336 . $locale->text('Change Admin Password') . qq|">
343 | . $locale->text('Click on login name to edit!') . qq|
347 '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.'
353 <form method=post action=login.pl>
355 <table border=0 width=100%>
356 <tr class=listheading>
357 <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
363 <th align=right>| . $locale->text('Name') . qq|</th>
364 <td><input class=login name=login></td>
368 <th align=right>| . $locale->text('Password') . qq|</th>
369 <td><input class=login type=password name=password></td>
370 <td><input type=submit name=action value="|
371 . $locale->text('Login') . qq|"></td>
373 <input type=hidden name=path value=$form->{path}>
391 # if there is a login, get user
392 if ($form->{login}) {
395 $myconfig = new User "$memberfile", "$form->{login}";
397 $myconfig->{signature} =~ s/\\n/\r\n/g;
398 $myconfig->{address} =~ s/\\n/\r\n/g;
400 # strip basedir from templates directory
401 $myconfig->{templates} =~ s/^$templates\///;
403 # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
406 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
408 ($item eq $myconfig->{dateformat})
409 ? "<option selected>$item\n"
413 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
415 ($item eq $myconfig->{numberformat})
416 ? "<option selected>$item\n"
420 %countrycodes = User->country_codes;
422 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
426 ($myconfig->{countrycode} eq $key)
427 ? "<option selected value=$key>$countrycodes{$key}"
428 : "<option value=$key>$countrycodes{$key}";
430 $countrycodes = qq|<option value="">American English\n$countrycodes|;
432 # is there a templates basedir
433 if (!-d "$templates") {
434 $form->error( $locale->text('Directory')
436 . $locale->text('does not exist'));
439 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
440 @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
441 closedir TEMPLATEDIR;
443 @allhtml = sort grep /\.html/, @all;
444 @alldir = grep !/\.(html|tex)$/, @all;
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=ustid size=14 value="$myconfig->{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=root value="$form->{root}">
1123 <input type=hidden name=path value=$form->{path}>
1124 <input type=hidden name=rpw value=$form->{rpw}>
1127 <input type=submit class=submit name=action value="|
1128 . $locale->text('Change Password') . qq|">
1138 sub change_password {
1140 $root->{password} = $form->{password};
1142 $root->{'root login'} = 1;
1143 $root->save_member($memberfile);
1146 "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1148 $form->redirect($locale->text('Password changed!'));
1152 sub check_password {
1154 $root = new User "$memberfile", $form->{root};
1156 if ($root->{password}) {
1157 if ($root->{password} ne $form->{rpw}) {
1158 $form->error($locale->text('Incorrect Password!'));
1164 sub pg_database_administration {
1166 $form->{dbdriver} = 'Pg';
1171 sub oracle_database_administration {
1173 $form->{dbdriver} = 'Oracle';
1178 sub dbdriver_defaults {
1180 # load some defaults for the selected driver
1182 'Pg' => { dbport => '5432',
1183 dbuser => 'postgres',
1184 dbdefault => 'template1',
1185 dbhost => 'localhost',
1186 connectstring => $locale->text('Connect to')
1188 'Oracle' => { dbport => '1521',
1191 dbhost => `hostname`,
1192 connectstring => 'SID'
1195 map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1196 keys %{ $driverdefaults{Pg} };
1200 sub dbselect_source {
1206 'Leave host and port field empty unless you want to make a remote connection.'
1210 'You must enter a host and port for local and remote connections!');
1213 "Lx-Office ERP / " . $locale->text('Database Administration');
1222 <h2>$form->{title}</h2>
1224 <form method=post action=$form->{script}>
1231 <tr class=listheading>
1232 <th colspan=4>| . $locale->text('Database') . qq|</th>
1235 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1242 <th align=right>| . $locale->text('Host') . qq|</th>
1243 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1244 <th align=right>| . $locale->text('Port') . qq|</th>
1245 <td><input name=dbport size=5 value=$form->{dbport}></td>
1251 <th align=right>| . $locale->text('User') . qq|</th>
1252 <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1253 <th align=right>| . $locale->text('Password') . qq|</th>
1254 <td><input type=password name=dbpasswd size=10></td>
1260 <th align=right>$form->{connectstring}</th>
1261 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1270 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1271 <input type=hidden name=root value="$form->{root}">
1272 <input type=hidden name=path value=$form->{path}>
1273 <input type=hidden name=rpw value=$form->{rpw}>
1277 <input type=submit class=submit name=action value="|
1278 . $locale->text('Create Dataset') . qq|">
1279 <input type=submit class=submit name=action value="|
1280 . $locale->text('Update Dataset') . qq|">
1281 <input type=submit class=submit name=action value="|
1282 . $locale->text('Delete Dataset') . qq|">
1291 'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1295 <br>$msg{$form->{dbdriver}}
1306 &{ $form->{nextsub} };
1310 sub update_dataset {
1312 %needsupdate = User->dbneedsupdate(\%$form);
1316 . $locale->text('Database Administration') . " / "
1317 . $locale->text('Update Dataset');
1326 <h2>$form->{title}</h2>
1329 foreach $key (sort keys %needsupdate) {
1330 if ($needsupdate{$key} ne $form->{dbversion}) {
1331 $upd .= qq|<input name="db$key" type=checkbox value=1 checked> $key\n|;
1332 $form->{dbupdate} .= "db$key ";
1336 chop $form->{dbupdate};
1338 if ($form->{dbupdate}) {
1342 <form method=post action=$form->{script}>
1344 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1345 <input type=hidden name=dbhost value=$form->{dbhost}>
1346 <input type=hidden name=dbport value=$form->{dbport}>
1347 <input type=hidden name=dbuser value=$form->{dbuser}>
1348 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1349 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1351 <tr class=listheading>
1352 <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1364 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1366 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1368 <input type=hidden name=root value="$form->{root}">
1369 <input type=hidden name=path value=$form->{path}>
1370 <input type=hidden name=rpw value=$form->{rpw}>
1372 <input type=hidden name=nextsub value=dbupdate>
1377 <input type=submit class=submit name=action value="|
1378 . $locale->text('Continue') . qq|">
1387 print $locale->text('All Datasets up to date!');
1401 User->dbupdate(\%$form);
1403 $form->redirect($locale->text('Dataset updated!'));
1407 sub create_dataset {
1409 foreach $item (sort User->dbsources(\%$form)) {
1410 $dbsources .= "[$item] ";
1413 opendir SQLDIR, "sql/." or $form - error($!);
1414 foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1415 next if ($item eq 'Default-chart.sql');
1416 $item =~ s/-chart\.sql//;
1418 qq| <input name=chart class=radio type=radio value="$item"> $item|;
1422 $selectencoding = qq|<option>
1423 <option value=SQL_ASCII>ASCII
1424 <option value=EUC_JP>Japanese Extended UNIX Code
1425 <option value=EUC_CN>Chinese Extended UNIX Code
1426 <option value=EUC_KR>Korean Extended UNIX Code
1427 <option value=EUC_TW>Taiwan Extended UNIX Code
1428 <option value=UNICODE>UTF-8 Unicode
1429 <option value=MULE_INTERNAL>Mule internal type
1430 <option value=LATIN1>ISO 8859-1
1431 <option value=LATIN2>ISO 8859-2
1432 <option value=LATIN3>ISO 8859-3
1433 <option value=LATIN4>ISO 8859-4
1434 <option value=LATIN5>ISO 8859-5
1435 <option value=KOI8>KOI8-R
1436 <option value=WIN>Windows CP1251
1437 <option value=ALT>Windows CP866
1442 . $locale->text('Database Administration') . " / "
1443 . $locale->text('Create Dataset');
1452 <h2>$form->{title}</h2>
1454 <form method=post action=$form->{script}>
1457 <tr class=listheading>
1458 <th colspan=2> </th>
1463 <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1470 <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1471 <td><input name=db></td>
1477 <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1478 <td><select name=encoding>$selectencoding</select></td>
1484 <th align=right nowrap>|
1485 . $locale->text('Create Chart of Accounts') . qq|</th>
1492 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1493 <input type=hidden name=dbuser value=$form->{dbuser}>
1494 <input type=hidden name=dbhost value=$form->{dbhost}>
1495 <input type=hidden name=dbport value=$form->{dbport}>
1496 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1497 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1499 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1501 <input type=hidden name=root value="$form->{root}">
1502 <input type=hidden name=path value=$form->{path}>
1503 <input type=hidden name=rpw value=$form->{rpw}>
1505 <input type=hidden name=nextsub value=dbcreate>
1510 <input type=submit class=submit name=action value="|
1511 . $locale->text('Continue') . qq|">
1527 $form->isblank("db", $locale->text('Dataset missing!'));
1529 User->dbcreate(\%$form);
1533 . $locale->text('Database Administration') . " / "
1534 . $locale->text('Create Dataset');
1543 <h2>$form->{title}</h2>
1545 <form method=post action=$form->{script}>|
1547 . $locale->text('Dataset')
1549 . $locale->text('successfully created!')
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}">
1557 <input type=hidden name=nextsub value=list_users>
1559 <p><input type=submit class=submit name=action value="|
1560 . $locale->text('Continue') . qq|">
1570 sub delete_dataset {
1572 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1573 foreach $item (sort @dbsources) {
1575 qq|<input name=db class=radio type=radio value=$item> $item |;
1578 $form->error($locale->text('Nothing to delete!'));
1583 . $locale->text('Database Administration') . " / "
1584 . $locale->text('Delete Dataset');
1591 <h2>$form->{title}</h2>
1593 <form method=post action=$form->{script}>
1596 <tr class=listheading>
1598 . $locale->text('The following Datasets are not in use and can be deleted')
1610 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1611 <input type=hidden name=dbuser value=$form->{dbuser}>
1612 <input type=hidden name=dbhost value=$form->{dbhost}>
1613 <input type=hidden name=dbport value=$form->{dbport}>
1614 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1615 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1617 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1619 <input type=hidden name=root value="$form->{root}">
1620 <input type=hidden name=path value="$form->{path}">
1621 <input type=hidden name=rpw value="$form->{rpw}">
1623 <input type=hidden name=nextsub value=dbdelete>
1628 <input type=submit class=submit name=action value="|
1629 . $locale->text('Continue') . qq|">
1645 $form->error($locale->text('No Dataset selected!'));
1648 User->dbdelete(\%$form);
1652 . $locale->text('Database Administration') . " / "
1653 . $locale->text('Delete Dataset');
1662 <h2>$form->{title}</h2>
1664 <form method=post action=$form->{script}>
1666 $form->{db} | . $locale->text('successfully deleted!')
1670 <input type=hidden name=root value="$form->{root}">
1671 <input type=hidden name=path value="$form->{path}">
1672 <input type=hidden name=rpw value="$form->{rpw}">
1674 <input type=hidden name=nextsub value=list_users>
1676 <p><input type=submit class=submit name=action value="|
1677 . $locale->text('Continue') . qq|">
1689 unlink "$userspath/nologin";
1692 "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1694 $form->redirect($locale->text('Lockfile removed!'));
1700 open(FH, ">$userspath/nologin")
1701 or $form->error($locale->text('Cannot create Lock!'));
1705 "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
1707 $form->redirect($locale->text('Lockfile created!'));