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";
44 require "bin/mozilla/common.pl";
46 our $cgi = new CGI('');
49 $form->{"root"} = "root login";
51 $locale = new Locale $language, "admin";
54 if (-f "bin/mozilla/custom_$form->{script}") {
55 eval { require "bin/mozilla/custom_$form->{script}"; };
56 $form->error($@) if ($@);
59 $form->{stylesheet} = "lx-office-erp.css";
60 $form->{favicon} = "favicon.ico";
62 if ($form->{action}) {
65 $subroutine = $locale->findsub($form->{action});
67 if ($subroutine eq 'login') {
69 $form->{rpw} = crypt $form->{rpw}, "ro";
75 call_sub($subroutine);
79 # if there are no drivers bail out
80 $form->error($locale->text('No Database Drivers available!'))
81 unless (User->dbdrivers);
84 if (!-f $memberfile) {
85 open(FH, ">$memberfile") or $form->error("$memberfile : $!");
86 print FH qq|# SQL-Ledger Accounting members
106 qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
116 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
118 . $locale->text('Version')
119 . qq| $form->{version}<p>|
120 . $locale->text('Administration')
123 <form method=post action="$form->{script}">
127 <th>| . $locale->text('Password') . qq|</th>
128 <td><input type=password name=rpw></td>
129 <td><input type=submit class=submit name=action value="|
130 . $locale->text('Login') . qq|"></td>
132 <input type=hidden name=action value=login>
138 <a href=http://www.lx-office.org>Lx-Office |
139 . $locale->text('website') . qq|</a>
159 . $locale->text('Administration') . " / "
160 . $locale->text('Add User');
162 $form->{Oracle_sid} = $sid;
163 $form->{Oracle_dbport} = '1521';
164 $form->{Oracle_dbhost} = `hostname`;
166 if (-f "css/lx-office-erp.css") {
167 $myconfig->{stylesheet} = "lx-office-erp.css";
169 $myconfig->{vclimit} = 200;
171 $myconfig->{"countrycode"} = "de";
172 $myconfig->{"numberformat"} = "1000,00";
173 $myconfig->{"dateformat"} = "dd.mm.yy";
184 . $locale->text('Administration') . " / "
185 . $locale->text('Edit User');
197 qq|<input type=submit class=submit name=action value="|
198 . $locale->text('Delete') . qq|">
199 <input type=hidden name=edit value=1>|;
204 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
205 <input type=hidden name=rpw value=$form->{rpw}>
207 <input type=submit class=submit name=action value="|
208 . $locale->text('Save') . qq|">
221 $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
223 open(FH, "$memberfile") or $form->error("$memberfile : $!");
226 <input type=submit class=submit name=action value="|
227 . $locale->text('Lock System') . qq|">|;
229 if (-e "$userspath/nologin") {
231 <input type=submit class=submit name=action value="|
232 . $locale->text('Unlock System') . qq|">|;
240 $login =~ s/(\[|\])//g;
243 if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
245 ($null, $member{$login}{$var}) = split(/=/, $_, 2);
251 # type=submit $locale->text('Pg Database Administration')
252 # type=submit $locale->text('Oracle Database Administration')
254 foreach $item (User->dbdrivers) {
256 qq|<input name=action type=submit class=submit value="|
257 . $locale->text("$item Database Administration") . qq|">|;
260 $column_header{login} = qq|<th>| . $locale->text('Login') . qq|</th>|;
261 $column_header{name} = qq|<th>| . $locale->text('Name') . qq|</th>|;
262 $column_header{company} = qq|<th>| . $locale->text('Company') . qq|</th>|;
263 $column_header{dbdriver} = qq|<th>| . $locale->text('Driver') . qq|</th>|;
264 $column_header{dbhost} = qq|<th>| . $locale->text('Host') . qq|</th>|;
265 $column_header{dataset} = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
266 $column_header{templates} =
267 qq|<th>| . $locale->text('Templates') . qq|</th>|;
269 @column_index = qw(login name company dbdriver dbhost dataset templates);
271 $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
278 <form method=post action=$form->{script}>
282 <tr class=listheading>
283 <th>$form->{title}</th>
289 <tr class=listheading>|;
291 map { print "$column_header{$_}\n" } @column_index;
297 foreach $key (sort keys %member) {
299 "$script?action=edit&login=$key&rpw=$form->{rpw}";
302 $member{$key}{templates} =~ s/^$templates\///;
303 $member{$key}{dbhost} = $locale->text('localhost')
304 unless $member{$key}{dbhost};
305 $member{$key}{dbname} = $member{$key}{dbuser}
306 if ($member{$key}{dbdriver} eq 'Oracle');
308 $column_data{login} = qq|<td><a id="$key" href="$href">$key</a></td>|;
309 $column_data{name} = qq|<td>$member{$key}{name}</td>|;
310 $column_data{company} = qq|<td>$member{$key}{company}</td>|;
311 $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
312 $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
313 $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
314 $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
319 <tr class="listrow$i">|;
321 map { print "$column_data{$_}\n" } @column_index;
332 <td><hr size=3 noshade></td>
336 <input type=hidden name=rpw value=$form->{rpw}>
338 <br><input type=submit class=submit name=action value="|
339 . $locale->text('Add User') . qq|">
340 <input type=submit class=submit name=action value="|
341 . $locale->text('Change Admin Password') . qq|">
348 | . $locale->text('Click on login name to edit!') . qq|
352 '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.'
358 <form method=post action=login.pl>
360 <table border=0 width=100%>
361 <tr class=listheading>
362 <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
368 <th align=right>| . $locale->text('Name') . qq|</th>
369 <td><input class=login name=login></td>
373 <th align=right>| . $locale->text('Password') . qq|</th>
374 <td><input class=login type=password name=password></td>
375 <td><input type=submit name=action value="|
376 . $locale->text('Login') . qq|"></td>
395 # if there is a login, get user
396 if ($form->{login}) {
399 $myconfig = new User "$memberfile", "$form->{login}";
401 $myconfig->{signature} =~ s/\\n/\r\n/g;
402 $myconfig->{address} =~ s/\\n/\r\n/g;
404 # strip basedir from templates directory
405 $myconfig->{templates} =~ s/^$templates\///;
407 # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
410 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
412 ($item eq $myconfig->{dateformat})
413 ? "<option selected>$item\n"
417 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
419 ($item eq $myconfig->{numberformat})
420 ? "<option selected>$item\n"
424 %countrycodes = User->country_codes;
426 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
430 ($myconfig->{countrycode} eq $key)
431 ? "<option selected value=$key>$countrycodes{$key}"
432 : "<option value=$key>$countrycodes{$key}";
434 $countrycodes = qq|<option value="">American English\n$countrycodes|;
436 # is there a templates basedir
437 if (!-d "$templates") {
438 $form->error( $locale->text('Directory')
440 . $locale->text('does not exist'));
443 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
444 my @all = readdir(TEMPLATEDIR);
445 my @alldir = sort(grep({ -d "$templates/$_" && !/^\.\.?$/ } @all));
446 my @allhtml = sort(grep({ -f "$templates/$_" && /\.html$/ } @all));
447 closedir TEMPLATEDIR;
449 @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
450 @alldir = grep !/^(webpages|\.svn)$/, @alldir;
452 @allhtml = reverse grep !/Default/, @allhtml;
453 push @allhtml, 'Default';
454 @allhtml = reverse @allhtml;
456 foreach $item (@alldir) {
457 if ($item eq $myconfig->{templates}) {
458 $usetemplates .= qq|<option selected>$item\n|;
460 $usetemplates .= qq|<option>$item\n|;
464 $lastitem = $allhtml[0];
465 $lastitem =~ s/-.*//g;
466 $mastertemplates = qq|<option>$lastitem\n|;
467 foreach $item (@allhtml) {
470 if ($item ne $lastitem) {
471 my $selected = $item eq "German" ? " selected" : "";
472 $mastertemplates .= qq|<option$selected>$item\n|;
477 # opendir CSS, "css/.";
478 # @all = grep /.*\.css$/, readdir CSS;
481 # css dir has styles that are not intended as general layouts.
482 # reverting to hardcoded list
483 @all = qw(lx-office-erp.css Win2000.css);
485 foreach $item (@all) {
486 if ($item eq $myconfig->{stylesheet}) {
487 $selectstylesheet .= qq|<option selected>$item\n|;
489 $selectstylesheet .= qq|<option>$item\n|;
495 if ($myconfig->{menustyle} eq "v3") {
496 $menustyle_v3 = "checked";
497 } elsif ($myconfig->{menustyle} eq "neu") {
498 $menustyle_neu = "checked";
500 $menustyle_old = "checked";
506 <form method=post action=$form->{script}>
509 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
515 <th align=right>| . $locale->text('Login') . qq|</th>
516 <td><input name="login" value="$myconfig->{login}"></td>
519 <th align=right>| . $locale->text('Password') . qq|</th>
520 <td><input type="password" name="password" size="8" value="$myconfig->{password}"></td>
521 <input type="hidden" name="old_password" value="$myconfig->{password}">
524 <th align=right>| . $locale->text('Name') . qq|</th>
525 <td><input name="name" size="15" value="$myconfig->{name}"></td>
528 <th align=right>| . $locale->text('E-mail') . qq|</th>
529 <td><input name=email size=30 value="$myconfig->{email}"></td>
532 <th align=right>| . $locale->text('Signature') . qq|</th>
533 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
536 <th align=right>| . $locale->text('Phone') . qq|</th>
537 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
540 <th align=right>| . $locale->text('Fax') . qq|</th>
541 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
544 <th align=right>| . $locale->text('Company') . qq|</th>
545 <td><input name=company size=35 value="$myconfig->{company}"></td>
548 <th align=right>| . $locale->text('Address') . qq|</th>
549 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
552 <th align=right>| . $locale->text('Tax number') . qq|</th>
553 <td><input name=taxnumber size=14 value="$myconfig->{taxnumber}"></td>
556 <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
557 <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
560 <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
561 <td><input name=duns size=14 value="$myconfig->{duns}"></td>
568 <th align=right>| . $locale->text('Date Format') . qq|</th>
569 <td><select name=dateformat>$dateformat</select></td>
572 <th align=right>| . $locale->text('Number Format') . qq|</th>
573 <td><select name=numberformat>$numberformat</select></td>
576 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
577 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
580 <th align=right>| . $locale->text('Language') . qq|</th>
581 <td><select name=countrycode>$countrycodes</select></td>
584 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
585 <td><select name=userstylesheet>$selectstylesheet</select></td>
588 <th align=right>| . $locale->text('Printer') . qq|</th>
589 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
592 <th align=right>| . $locale->text('Use Templates') . qq|</th>
593 <td><select name=usetemplates>$usetemplates</select></td>
596 <th align=right>| . $locale->text('New Templates') . qq|</th>
597 <td><input name=newtemplates></td>
600 <th align=right>| . $locale->text('Setup Templates') . qq|</th>
601 <td><select name=mastertemplates>$mastertemplates</select></td>
604 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
605 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
606 $locale->text("Top (CSS)") . qq|
607 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
608 $locale->text("Top (Javascript)") . qq|
609 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
610 $locale->text("Old (on the side)") . qq|
613 <input type=hidden name=templates value=$myconfig->{templates}>
617 <tr class=listheading>
618 <th colspan=2>| . $locale->text('Database') . qq|</th>
621 # list section for database drivers
622 foreach $item (User->dbdrivers) {
631 if ($myconfig->{dbdriver} eq $item) {
632 map { $form->{"${item}_$_"} = $myconfig->{$_} }
633 qw(dbhost dbport dbuser dbpasswd dbname sid);
634 $checked = "checked";
638 <th align=right>| . $locale->text('Driver') . qq|</th>
639 <td><input name="dbdriver" type="radio" class="radio" value="$item" $checked> $item</td>
640 <th align=right>| . $locale->text('Host') . qq|</th>
641 <td><input name="${item}_dbhost" size=30 value="$form->{"${item}_dbhost"}"></td>
648 <th align=right>| . $locale->text('Dataset') . qq|</th>
649 <td><input name="Pg_dbname" size="15" value="$form->{Pg_dbname}"></td>
650 <th align=right>| . $locale->text('Port') . qq|</th>
651 <td><input name="Pg_dbport" size="4" value="$form->{Pg_dbport}"></td>
654 <th align=right>| . $locale->text('User') . qq|</th>
655 <td><input name="${item}_dbuser" size=15 value="$form->{"${item}_dbuser"}"></td>
656 <th align=right>| . $locale->text('Password') . qq|</th>
657 <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
662 if ($item eq 'Oracle') {
664 <th align=right>SID</th>
665 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
666 <th align=right>| . $locale->text('Port') . qq|</th>
667 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
670 <th align=right>| . $locale->text('Dataset') . qq|</th>
671 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
672 <th align=right>| . $locale->text('Password') . qq|</th>
673 <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
679 <input type="hidden" name="old_dbpasswd" value="$myconfig->{dbpasswd}">
684 <td colspan=2><hr size=2 noshade></td>
691 open(FH, $menufile) or $form->error("$menufile : $!");
693 # scan for first menu level
697 if (open(FH, "custom_$menufile")) {
703 next unless $item =~ /\[/;
704 next if $item =~ /\#/;
706 $item =~ s/(\[|\])//g;
710 ($level, $menuitem) = split /--/, $item, 2;
714 push @acsorder, $item;
717 push @{ $acs{$level} }, $menuitem;
721 %role = ('admin' => $locale->text('Administrator'),
722 'user' => $locale->text('User'),
723 'manager' => $locale->text('Manager'),
724 'supervisor' => $locale->text('Supervisor'));
727 foreach $item (qw(user supervisor manager admin)) {
729 ($myconfig->{role} eq $item)
730 ? "<option selected value=$item>$role{$item}\n"
731 : "<option value=$item>$role{$item}\n";
735 <tr class=listheading>
736 <th colspan=2>| . $locale->text('Access Control') . qq|</th>
739 <td><select name=role>$selectrole</select></td>
743 foreach $item (split(/;/, $myconfig->{acs})) {
744 ($key, $value) = split /--/, $item, 2;
745 $excl{$key}{$value} = 1;
748 foreach $key (@acsorder) {
750 $checked = "checked";
751 if ($form->{login}) {
752 $checked = ($excl{$key}{$key}) ? "" : "checked";
755 # can't have variable names with spaces
756 # the 1 is for apache 2
757 $item = $form->escape("${key}--$key", 1);
760 $acsheading =~ s/ / /g;
763 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
764 $menuitems .= "$item;";
768 foreach $item (@{ $acs{$key} }) {
769 next if ($key eq $item);
771 $checked = "checked";
772 if ($form->{login}) {
773 $checked = ($excl{$key}{$item}) ? "" : "checked";
776 $acsitem = $form->escape("${key}--$item", 1);
779 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
780 $menuitems .= "$acsitem;";
787 <tr valign=top>$acsheading $acsdata
792 print qq|<input type=hidden name=acs value="$menuitems">
796 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
797 foreach $directory (@webdavdirs) {
798 if ($myconfig->{$directory}) {
799 $webdav{"${directory}c"} = "checked";
801 $webdav{"${directory}c"} = "";
806 <td colspan=2><hr size=3 noshade></td>
808 <tr class=listheading>
809 <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
813 <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
814 <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
815 <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
818 <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
819 <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
820 <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
824 <td colspan=2><hr size=3 noshade></td>
838 $form->error($locale->text('Database Driver not checked!'))
839 unless $form->{dbdriver};
841 # no spaces allowed in login name
842 ($form->{login}) = split / /, $form->{login};
844 $form->isblank("login", $locale->text('Login name missing!'));
846 # check for duplicates
847 if (!$form->{edit}) {
848 $temp = new User "$memberfile", "$form->{login}";
850 if ($temp->{login}) {
851 $form->error("$form->{login} " . $locale->text('is already a member!'));
855 # no spaces allowed in directories
856 ($form->{newtemplates}) = split / /, $form->{newtemplates};
858 if ($form->{newtemplates}) {
859 $form->{templates} = $form->{newtemplates};
862 ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
866 if (!-d "$templates") {
867 $form->error( $locale->text('Directory')
869 . $locale->text('does not exist'));
872 # add base directory to $form->{templates}
873 $form->{templates} = "$templates/$form->{templates}";
875 $myconfig = new User "$memberfile", "$form->{login}";
877 # redo acs variable and delete all the acs codes
878 @acs = split(/;/, $form->{acs});
881 foreach $item (@acs) {
882 $item = $form->escape($item, 1);
884 if (!$form->{$item}) {
885 $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
887 delete $form->{$item};
890 # check which database was filled in
891 if ($form->{dbdriver} eq 'Oracle') {
892 $form->{sid} = $form->{Oracle_sid},;
893 $form->{dbhost} = $form->{Oracle_dbhost},;
894 $form->{dbport} = $form->{Oracle_dbport};
895 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
896 $form->{dbuser} = $form->{Oracle_dbuser};
897 $form->{dbname} = $form->{Oracle_dbuser};
899 $form->isblank("dbhost", $locale->text('Hostname missing!'));
900 $form->isblank("dbport", $locale->text('Port missing!'));
901 $form->isblank("dbuser", $locale->text('Dataset missing!'));
903 if ($form->{dbdriver} eq 'Pg') {
904 $form->{dbhost} = $form->{Pg_dbhost};
905 $form->{dbport} = $form->{Pg_dbport};
906 $form->{dbpasswd} = $form->{Pg_dbpasswd};
907 $form->{dbuser} = $form->{Pg_dbuser};
908 $form->{dbname} = $form->{Pg_dbname};
910 $form->isblank("dbname", $locale->text('Dataset missing!'));
911 $form->isblank("dbuser", $locale->text('Database User missing!'));
916 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
917 foreach $directory (@webdavdirs) {
918 if ($form->{$directory}) {
919 $form->{$directory} = $form->{$directory};
921 $form->{$directory} = 0;
926 foreach $item (keys %{$form}) {
927 $myconfig->{$item} = $form->{$item};
930 delete $myconfig->{stylesheet};
931 if ($form->{userstylesheet}) {
932 $myconfig->{stylesheet} = $form->{userstylesheet};
935 $myconfig->save_member($memberfile, $userspath);
939 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
940 foreach $directory (@webdavdirs) {
941 $file = "webdav/" . $directory . "/webdav-user";
942 if ($form->{$directory}) {
943 if (open(HTACCESS, "$file")) {
945 ($login, $password) = split(/:/, $_);
946 if ($login ne $form->{login}) {
952 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
953 $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
954 print(HTACCESS $newfile);
957 $form->{$directory} = 0;
958 if (open(HTACCESS, "$file")) {
960 ($login, $password) = split(/:/, $_);
961 if ($login ne $form->{login}) {
967 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
968 print(HTACCESS $newfile);
974 # create user template directory and copy master files
975 if (!-d "$form->{templates}") {
978 if (mkdir "$form->{templates}", oct("771")) {
982 # copy templates to the directory
983 opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
984 @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|xml|txb)$/,
986 closedir TEMPLATEDIR;
988 foreach $file (@templates) {
989 open(TEMP, "$templates/$file")
990 or $form->error("$templates/$file : $!");
992 $file =~ s/$form->{mastertemplates}-//;
993 open(NEW, ">$form->{templates}/$file")
994 or $form->error("$form->{templates}/$file : $!");
996 while ($line = <TEMP>) {
1003 $form->error("$!: $form->{templates}");
1007 $form->redirect($locale->text('User saved!'));
1013 $form->{templates} =
1014 ($form->{templates})
1015 ? "$templates/$form->{templates}"
1016 : "$templates/$form->{login}";
1018 $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
1019 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
1022 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
1029 while ($line = shift @config) {
1031 if ($line =~ /^\[/) {
1032 last if ($line =~ /\[$form->{login}\]/);
1033 $login = &login_name($line);
1036 if ($line =~ /^templates=/) {
1037 $user{$login} = &get_value($line);
1043 # remove everything up to next login or EOF
1044 # and save template variable
1045 while ($line = shift @config) {
1046 if ($line =~ /^templates=/) {
1047 $templatedir = &get_value($line);
1049 last if ($line =~ /^\[/);
1052 # this one is either the next login or EOF
1055 $login = &login_name($line);
1057 while ($line = shift @config) {
1058 if ($line =~ /^\[/) {
1059 $login = &login_name($line);
1062 if ($line =~ /^templates=/) {
1063 $user{$login} = &get_value($line);
1070 unlink "${memberfile}.LCK";
1072 # scan %user for $templatedir
1073 foreach $login (keys %user) {
1074 last if ($found = ($templatedir eq $user{$login}));
1077 # if found keep directory otherwise delete
1080 # delete it if there is a template directory
1081 $dir = "$form->{templates}";
1083 unlink <$dir/*.html>;
1084 unlink <$dir/*.tex>;
1085 unlink <$dir/*.sty>;
1090 # delete config file for user
1091 unlink "$userspath/$form->{login}.conf";
1093 $form->redirect($locale->text('User deleted!'));
1100 $login =~ s/\[\]//g;
1101 return ($login) ? $login : undef;
1108 my ($null, $value) = split(/=/, $line, 2);
1111 $value =~ s/\s#.*//g;
1113 # remove any trailing whitespace
1114 $value =~ s/^\s*(.*?)\s*$/$1/;
1119 sub change_admin_password {
1123 . $locale->text('Administration') . " / "
1124 . $locale->text('Change Admin Password');
1132 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1134 <form method=post action=$form->{script}>
1138 <td><b>| . $locale->text('Password') . qq|</b></td>
1139 <td><input type=password name=password size=8></td>
1142 <td><b>| . $locale->text('Repeat the password') . qq|</b></td>
1143 <td><input type=password name=password_again size=8></b></td>
1147 <input type=hidden name=rpw value=$form->{rpw}>
1150 <input type=submit class=submit name=action value="|
1151 . $locale->text('Change Password') . qq|">
1161 sub change_password {
1162 if ($form->{"password"} ne $form->{"password_again"}) {
1165 . $locale->text('Administration') . " / "
1166 . $locale->text('Change Admin Password');
1174 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1176 <p>| . $locale->text("The passwords do not match.") . qq|<br>
1177 <input type="button" onclick="history.back()" value="| . $locale->text("Back") . qq|">|;
1181 $root->{password} = $form->{password};
1183 $root->{'root login'} = 1;
1184 $root->save_member($memberfile);
1187 "$form->{script}?action=list_users&rpw=$root->{password}";
1189 $form->redirect($locale->text('Password changed!'));
1193 sub check_password {
1194 $root = new User "$memberfile", $form->{root};
1196 if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
1197 $form->error($locale->text('Incorrect Password!'));
1202 sub pg_database_administration {
1204 $form->{dbdriver} = 'Pg';
1209 sub oracle_database_administration {
1211 $form->{dbdriver} = 'Oracle';
1216 sub dbdriver_defaults {
1218 # load some defaults for the selected driver
1220 'Pg' => { dbport => '5432',
1221 dbuser => 'postgres',
1222 dbdefault => 'template1',
1223 dbhost => 'localhost',
1224 connectstring => $locale->text('Connect to')
1226 'Oracle' => { dbport => '1521',
1229 dbhost => `hostname`,
1230 connectstring => 'SID'
1233 map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1234 keys %{ $driverdefaults{Pg} };
1238 sub dbselect_source {
1244 'Leave host and port field empty unless you want to make a remote connection.'
1248 'You must enter a host and port for local and remote connections!');
1251 "Lx-Office ERP / " . $locale->text('Database Administration');
1260 <h2>$form->{title}</h2>
1262 <form method=post action=$form->{script}>
1269 <tr class=listheading>
1270 <th colspan=4>| . $locale->text('Database') . qq|</th>
1273 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1280 <th align=right>| . $locale->text('Host') . qq|</th>
1281 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1282 <th align=right>| . $locale->text('Port') . qq|</th>
1283 <td><input name=dbport size=5 value=$form->{dbport}></td>
1289 <th align=right>| . $locale->text('User') . qq|</th>
1290 <td><input name="dbuser" size="10" value="$form->{dbuser}"></td>
1291 <th align=right>| . $locale->text('Password') . qq|</th>
1292 <td><input type="password" name="dbpasswd" size="10"></td>
1298 <th align=right>$form->{connectstring}</th>
1299 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1308 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1309 <input type=hidden name=rpw value=$form->{rpw}>
1313 <input type=submit class=submit name=action value="|
1314 . $locale->text('Create Dataset') . qq|">|;
1315 # Vorübergehend Deaktiviert
1316 # <input type=submit class=submit name=action value="|
1317 # . $locale->text('Update Dataset') . qq|">
1318 print qq| <input type=submit class=submit name=action value="|
1319 . $locale->text('Delete Dataset') . qq|">
1328 'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1332 <br>$msg{$form->{dbdriver}}
1342 call_sub($form->{"nextsub"});
1345 sub update_dataset {
1347 %needsupdate = User->dbneedsupdate(\%$form);
1351 . $locale->text('Database Administration') . " / "
1352 . $locale->text('Update Dataset');
1361 <h2>$form->{title}</h2>
1364 foreach $key (sort keys %needsupdate) {
1365 if ($needsupdate{$key} ne $form->{dbversion}) {
1366 $upd .= qq|<input id="$field_id" name="db$key" type="checkbox" value="1" checked> $key\n|;
1367 $form->{dbupdate} .= "db$key ";
1372 chop $form->{dbupdate};
1374 if ($form->{dbupdate}) {
1378 <form method=post action=$form->{script}>
1380 <input type=hidden name="dbdriver" value="$form->{dbdriver}">
1381 <input type=hidden name="dbhost" value="$form->{dbhost}">
1382 <input type=hidden name="dbport" value="$form->{dbport}">
1383 <input type=hidden name="dbuser" value="$form->{dbuser}">
1384 <input type=hidden name="dbpasswd" value="$form->{dbpasswd}">
1385 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
1387 <tr class=listheading>
1388 <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1400 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1402 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1404 <input type=hidden name=rpw value=$form->{rpw}>
1406 <input type=hidden name=nextsub value=dbupdate>
1411 <input type=submit class=submit name=action value="|
1412 . $locale->text('Continue') . qq|">
1421 print $locale->text('All Datasets up to date!');
1434 $form->{"stylesheet"} = "lx-office-erp.css";
1435 $form->{"title"} = $main::locale->text("Dataset upgrade");
1439 map({ s/\s//g; s/^db//; $_; }
1440 grep({ $form->{$_} }
1441 split(/\s+/, $form->{"dbupdate"}))));
1442 print($form->parse_html_template("dbupgrade/header",
1443 { "dbname" => $dbname }));
1445 User->dbupdate(\%$form);
1450 | . $locale->text('Dataset updated!') . qq|
1454 <a id="enddatasetupdate" href="admin.pl?action=login&| .
1455 join("&", map({ "$_=" . $form->escape($form->{$_}); } qw(rpw))) .
1456 qq|">| . $locale->text("Continue") . qq|</a>|;
1460 sub create_dataset {
1462 foreach $item (sort User->dbsources(\%$form)) {
1463 $dbsources .= "[$item] ";
1466 opendir SQLDIR, "sql/." or $form - error($!);
1467 foreach $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
1468 next if ($item eq 'Default-chart.sql');
1469 $item =~ s/-chart\.sql//;
1471 qq| <input name=chart class=radio type=radio value="$item"> $item|;
1475 my (@values, %labels);
1477 my $default_charset = $dbcharset;
1478 $default_charset ||= Common::DEFAULT_CHARSET;
1479 my $default_encoding;
1481 foreach my $encoding (@Common::db_encodings) {
1482 push @values, $encoding->{dbencoding};
1483 $labels{$encoding->{dbencoding}} = $encoding->{label};
1485 $default_encoding = $encoding->{dbencoding} if $encoding->{charset} eq $default_charset;
1489 NTI($cgi->popup_menu('-name' => 'encoding',
1490 '-values' => \@values,
1491 '-labels' => \%labels,
1492 '-default' => $default_encoding));
1496 . $locale->text('Database Administration') . " / "
1497 . $locale->text('Create Dataset');
1506 <h2>$form->{title}</h2>
1508 <form method=post action=$form->{script}>
1511 <tr class=listheading>
1512 <th colspan=2> </th>
1517 <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1524 <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1525 <td><input name=db></td>
1531 <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1532 <td>$selectencoding</td>
1538 <th align=right nowrap>|
1539 . $locale->text('Create Chart of Accounts') . qq|</th>
1546 <input type=hidden name="dbdriver" value="$form->{dbdriver}">
1547 <input type=hidden name="dbuser" value="$form->{dbuser}">
1548 <input type=hidden name="dbhost" value="$form->{dbhost}">
1549 <input type=hidden name="dbport" value="$form->{dbport}">
1550 <input type=hidden name="dbpasswd" value="$form->{dbpasswd}">
1551 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
1553 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1555 <input type=hidden name=rpw value=$form->{rpw}>
1557 <input type=hidden name=nextsub value=dbcreate>
1562 <input type=submit class=submit name=action value="|
1563 . $locale->text('Continue') . qq|">
1579 $form->isblank("db", $locale->text('Dataset missing!'));
1581 User->dbcreate(\%$form);
1585 . $locale->text('Database Administration') . " / "
1586 . $locale->text('Create Dataset');
1595 <h2>$form->{title}</h2>
1597 <form method=post action=$form->{script}>|
1599 . $locale->text('Dataset')
1601 . $locale->text('successfully created!')
1605 <input type=hidden name=rpw value="$form->{rpw}">
1607 <input type=hidden name=nextsub value=list_users>
1609 <p><input type=submit class=submit name=action value="|
1610 . $locale->text('Continue') . qq|">
1620 sub delete_dataset {
1622 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1623 foreach $item (sort @dbsources) {
1625 qq|<input name=db class=radio type=radio value=$item> $item |;
1628 $form->error($locale->text('Nothing to delete!'));
1633 . $locale->text('Database Administration') . " / "
1634 . $locale->text('Delete Dataset');
1641 <h2>$form->{title}</h2>
1643 <form method=post action=$form->{script}>
1646 <tr class=listheading>
1648 . $locale->text('The following Datasets are not in use and can be deleted')
1660 <input type=hidden name="dbdriver" value="$form->{dbdriver}">
1661 <input type=hidden name="dbuser" value="$form->{dbuser}">
1662 <input type=hidden name="dbhost" value="$form->{dbhost}">
1663 <input type=hidden name="dbport" value="$form->{dbport}">
1664 <input type=hidden name="dbpasswd" value="$form->{dbpasswd}">
1665 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
1667 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1669 <input type=hidden name=rpw value="$form->{rpw}">
1671 <input type=hidden name=nextsub value=dbdelete>
1676 <input type=submit class=submit name=action value="|
1677 . $locale->text('Continue') . qq|">
1693 $form->error($locale->text('No Dataset selected!'));
1696 User->dbdelete(\%$form);
1700 . $locale->text('Database Administration') . " / "
1701 . $locale->text('Delete Dataset');
1710 <h2>$form->{title}</h2>
1712 <form method=post action=$form->{script}>
1714 $form->{db} | . $locale->text('successfully deleted!')
1718 <input type=hidden name=rpw value="$form->{rpw}">
1720 <input type=hidden name=nextsub value=list_users>
1722 <p><input type=submit class=submit name=action value="|
1723 . $locale->text('Continue') . qq|">
1735 unlink "$userspath/nologin";
1738 "$form->{script}?action=list_users&rpw=$root->{password}";
1740 $form->redirect($locale->text('Lockfile removed!'));
1746 open(FH, ">$userspath/nologin")
1747 or $form->error($locale->text('Cannot create Lock!'));
1751 "$form->{script}?action=list_users&rpw=$root->{password}";
1753 $form->redirect($locale->text('Lockfile created!'));