[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [63] trunk/bin/mozilla/admin.pl
- Subject: SF.net SVN: ledger-smb: [63] trunk/bin/mozilla/admin.pl
- From: ..hidden..
- Date: Sun, 10 Sep 2006 17:31:19 -0700
Revision: 63
http://svn.sourceforge.net/ledger-smb/?rev=63&view=rev
Author: christopherm
Date: 2006-09-10 17:31:16 -0700 (Sun, 10 Sep 2006)
Log Message:
-----------
applying HTML fixes patch supplied by David, also doing major whitespace cleanup, fixing more html bugs. Removing all references to Oracle. This has been tested, but it could use more testing
Modified Paths:
--------------
trunk/bin/mozilla/admin.pl
Modified: trunk/bin/mozilla/admin.pl
===================================================================
--- trunk/bin/mozilla/admin.pl 2006-09-11 00:13:32 UTC (rev 62)
+++ trunk/bin/mozilla/admin.pl 2006-09-11 00:31:16 UTC (rev 63)
@@ -23,7 +23,7 @@
#
#======================================================================
#
-# This file has NOT undergone whitespace cleanup.
+# This file has undergone whitespace cleanup.
#
#======================================================================
#
@@ -54,36 +54,34 @@
# customization
if (-f "$form->{path}/custom_$form->{script}") {
- eval { require "$form->{path}/custom_$form->{script}"; };
- $form->error($@) if ($@);
+ eval { require "$form->{path}/custom_$form->{script}"; };
+ $form->error($@) if ($@);
}
if ($form->{action}) {
- &check_password unless $form->{action} eq 'logout';
-
- &{ $locale->findsub($form->{action}) };
-
+ &check_password unless $form->{action} eq 'logout';
+ &{ $locale->findsub($form->{action}) };
+
} else {
- # if there are no drivers bail out
- $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
+ # if there are no drivers bail out
+ $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
- # create memberfile
- if (! -f $memberfile) {
- open(FH, ">$memberfile") or $form->error("$memberfile : $!");
- print FH qq|# LedgerSMB Accounting members
+ # create memberfile
+ if (! -f $memberfile) {
+ open(FH, ">$memberfile") or $form->error("$memberfile : $!");
+ print FH qq|# LedgerSMB Accounting members
-[root login]
-password=
+ [root login]
+ password=
-|;
- close FH;
- }
+ |;
+ close FH;
+ }
- &adminlogin;
-
+ &adminlogin;
}
1;
@@ -92,1564 +90,1408 @@
sub adminlogin {
- $form->{title} = qq|LedgerSMB $form->{version} |.$locale->text('Administration');
+ $form->{title} = qq|LedgerSMB $form->{version} |.$locale->text('Administration');
- $myheaderadd = qq|
-<script language="JavaScript" type="text/javascript">
-<!--
-function sf(){
- document.admin.password.focus();
-}
-// End -->
-</script>
- |;
- $form->header(undef, $headeradd);
+ $myheaderadd = qq|
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ function sf(){
+ document.admin.password.focus();
+ }
+ // End -->
+ </script>
+ |;
+ $form->header(undef, $myheaderadd);
- print qq|
-<body class=admin onload="sf()">
+ print qq|
+ <body class="admin" onload="sf()">
+ <div align="center">
+ <a href="http://sourceforge.net/projects/ledger-smb/"><img src="ledger-smb.png" width="200" height="100" border="0" alt="LedgerSMB Logo" /></a>
+ <h1 class="login">|.$locale->text('Version').qq| $form->{version} <br />|.$locale->text('Administration').qq|</h1>
+ <form method="post" action="$form->{script}" name="admin">
+ <table>
+ <tr>
+ <th>|.$locale->text('Password').qq|</th>
+ <td><input type="password" name="password" /></td>
+ <td><input type="submit" class="submit" name="action" value="|.$locale->text('Login').qq|" /></td>
+ </tr>
+ </table>
+ <input type="hidden" name="action" value="login" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ </form>
-<div align=center>
+ <a href="http://sourceforge.net/projects/ledger-smb/">LedgerSMB |.$locale->text('website').qq|</a>
+ </div>
+ </body>
+ </html>
+ |;
-<a href="http://sourceforge.net/projects/ledger-smb/"><img src="ledger-smb.png" width="200" height="100" border="0" alt="LedgerSMB Logo"></a>
-<h1 class=login>|.$locale->text('Version').qq| $form->{version}<p>|.$locale->text('Administration').qq|</h1>
-
-<form method=post action="$form->{script}" name=admin>
-
-<table>
- <tr>
- <th>|.$locale->text('Password').qq|</th>
- <td><input type=password name=password></td>
- <td><input type=submit class=submit name=action value="|.$locale->text('Login').qq|"></td>
- </tr>
-<input type=hidden name=action value=login>
-<input type=hidden name=path value=$form->{path}>
-</table>
-
-</form>
-
-<a href="http://sourceforge.net/projects/ledger-smb/">LedgerSMB |.$locale->text('website').qq|</a>
-
-</div>
-
-</body>
-</html>
-|;
-
}
sub login {
- &list_users;
-
+ &list_users;
}
sub logout {
- $form->{callback} = "$form->{script}?path=$form->{path}&endsession=1";
- unlink "$userspath/adminhash";
- print qq|Set-Cookie: LedgerSMB=; path=/;\n|;
- $form->redirect($locale->text('You are logged out'));
+ $form->{callback} = "$form->{script}?path=$form->{path}&endsession=1";
+ unlink "$userspath/adminhash";
+ print qq|Set-Cookie: LedgerSMB=; path=/;\n|;
+ $form->redirect($locale->text('You are logged out'));
}
sub add_user {
-
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Add User');
- $form->{Oracle_sid} = $sid;
- $form->{Oracle_dbport} = '1521';
- $form->{Oracle_dbhost} = `hostname`;
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Add User');
- if (-f "css/ledger-smb.css") {
- $myconfig->{stylesheet} = "ledger-smb.css";
- }
- $myconfig->{vclimit} = 1000;
- $myconfig->{menuwidth} = 155;
- $myconfig->{timeout} = 3600;
-
- &form_header;
- &form_footer;
-
-}
+ if (-f "css/ledger-smb.css") {
+ $myconfig->{stylesheet} = "ledger-smb.css";
+ }
+ $myconfig->{vclimit} = 1000;
+ $myconfig->{menuwidth} = 155;
+ $myconfig->{timeout} = 3600;
+ &form_header;
+ &form_footer;
+}
+
sub edit {
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Edit User');
- $form->{edit} = 1;
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Edit User');
+ $form->{edit} = 1;
- &form_header;
- &form_footer;
-
+ &form_header;
+ &form_footer;
}
sub form_footer {
- if ($form->{edit}) {
- $delete = qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">
-<input type=hidden name=edit value=1>|;
- }
+ if ($form->{edit}) {
+ $delete = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Delete').qq|" />
+ <input type="hidden" name="edit" value="1" />|;
+ }
- print qq|
-
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
-
-<input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
-$delete
-
-</form>
-
-</body>
-</html>
-|;
-
+ print qq|
+ <input name="callback" type="hidden" value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Save').qq|" />
+ $delete
+ </form>
+ </body>
+ </html>
+ |;
}
sub list_users {
- open(FH, "$memberfile") or $form->error("$memberfile : $!");
+ open(FH, "$memberfile") or $form->error("$memberfile : $!");
- $nologin = qq|
-<input type=submit class=submit name=action value="|.$locale->text('Lock System').qq|">|;
+ $nologin = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Lock System').qq|" />|;
- if (-e "$userspath/nologin") {
- $nologin = qq|
-<input type=submit class=submit name=action value="|.$locale->text('Unlock System').qq|">|;
- }
+ if (-e "$userspath/nologin") {
+ $nologin = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Unlock System').qq|" />|;
+ }
- while (<FH>) {
- chop;
-
- if (/^\[.*\]/) {
- $login = $_;
- $login =~ s/(\[|\])//g;
- }
+ while (<FH>) {
+ chop;
- if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
- chop ($var = $&);
- ($null, $member{$login}{$var}) = split /=/, $_, 2;
- }
- }
-
- close(FH);
+ if (/^\[.*\]/) {
+ $login = $_;
+ $login =~ s/(\[|\])//g;
+ }
-# type=submit $locale->text('Pg Database Administration')
-# type=submit $locale->text('PgPP Database Administration')
-# type=submit $locale->text('Oracle Database Administration')
+ if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
+ chop ($var = $&);
+ ($null, $member{$login}{$var}) = split /=/, $_, 2;
+ }
+ }
- foreach $item (User->dbdrivers) {
- $dbdrivers .= qq|<input name=action type=submit class=submit value="|.$locale->text("$item Database Administration").qq|">|;
- }
+ close(FH);
+ # type=submit $locale->text('Pg Database Administration')
+ # type=submit $locale->text('PgPP Database Administration')
- $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
- $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
- $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
- $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
- $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
- $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
- $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
+ foreach $item (User->dbdrivers) {
+ $dbdrivers .= qq|<input name="action" type="submit" class="submit" value="|.$locale->text("$item Database Administration").qq|" />|;
+ }
- @column_index = qw(login name company dbdriver dbhost dataset templates);
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration');
+ $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
+ $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
+ $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
+ $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
+ $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
+ $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
+ $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
- $form->{login} = "root login";
- $form->header;
+ @column_index = qw(login name company dbdriver dbhost dataset templates);
- print qq|
-<body class=admin>
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration');
-<form method=post action=$form->{script}>
+ $form->{login} = "root login";
+ $form->header;
-<table width=100%>
- <tr>
- <tr class=listheading>
- <th>$form->{title}</th>
- </tr>
- <tr size=5></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
+ print qq|
+ <body class="admin">
+ <form method="post" action="$form->{script}">
+ <table width="100%">
+ <tr class="listheading">
+ <th>$form->{title}</th>
+ </tr>
+ <tr size="5"></tr>
+ <tr>
+ <td>
+ <table width="100%">
+ <tr class="listheading">|;
- for (@column_index) { print "$column_header{$_}\n" }
-
- print qq|
- </tr>
-|;
+ for (@column_index) { print "$column_header{$_}\n" }
-foreach $key (sort keys %member) {
- $href = "$script?action=edit&login=$key&path=$form->{path}&sessionid=$form->{sessionid}";
- $href =~ s/ /%20/g;
-
- $member{$key}{templates} =~ s/^$templates\///;
- $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
- $member{$key}{dbname} = $member{$key}{dbuser} if ($member{$key}{dbdriver} eq 'Oracle');
+ print qq| </tr>|;
- $column_data{login} = qq|<td><a href=$href>$key</a></td>|;
- $column_data{name} = qq|<td>$member{$key}{name}</td>|;
- $column_data{company} = qq|<td>$member{$key}{company}</td>|;
- $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
- $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
- $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
- $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
-
- $i++; $i %= 2;
- print qq|
- <tr class=listrow$i>|;
+ foreach $key (sort keys %member) {
- for (@column_index) { print "$column_data{$_}\n" }
+ $href = "$script?action=edit&login=$key&path=$form->{path}&sessionid=$form->{sessionid}";
+ $href =~ s/ /%20/g;
- print qq|
- </tr>|;
-}
+ $member{$key}{templates} =~ s/^$templates\///;
+ $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
+ $column_data{login} = qq|<td><a href="$href">$key</a></td>|;
+ $column_data{name} = qq|<td>$member{$key}{name}</td>|;
+ $column_data{company} = qq|<td>$member{$key}{company}</td>|;
+ $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
+ $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
+ $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
+ $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
-print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
+ $i++; $i %= 2;
+ print qq| <tr class="listrow$i">|;
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ for (@column_index) { print "$column_data{$_}\n"; }
-<br><input type=submit class=submit name=action value="|.$locale->text('Add User').qq|">
-<input type=submit class=submit name=action value="|.$locale->text('Change Admin Password').qq|">
+ print qq| </tr>|;
+ }
-$dbdrivers
-$nologin
-<input type=submit class=submit name=action value="|.$locale->text('Logout').qq|">
+ print qq| </table>
+ </td>
+ </tr>
+ <tr>
+ <td><hr size="3" noshade /></td>
+ </tr>
+ </table>
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <br />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Add User').qq|" />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Change Admin Password').qq|" />
-</form>
+ $dbdrivers
+ $nologin
-|.$locale->text('Click on login name to edit!').qq|
-<br>
-|.$locale->text('To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.').qq|
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Logout').qq|" />
+ </form>
-</body>
-</html>
-|;
+ |.$locale->text('Click on login name to edit!').qq|
+ <br />
+ |.$locale->text('To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.').qq|
+ </body>
+ </html>|;
}
sub form_header {
- # if there is a login, get user
- if ($form->{login}) {
- # get user
- $myconfig = new User "$memberfile", "$form->{login}";
+ # if there is a login, get user
+ if ($form->{login}) {
- for (qw(company address signature)) { $myconfig->{$_} = $form->quote($myconfig->{$_}) }
- for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g }
+ # get user
+ $myconfig = new User "$memberfile", "$form->{login}";
- # strip basedir from templates directory
- $myconfig->{templates} =~ s/^$templates\///;
+ for (qw(company address signature)) { $myconfig->{$_} = $form->quote($myconfig->{$_}) }
+ for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g }
- $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
- }
+ # strip basedir from templates directory
+ $myconfig->{templates} =~ s/^$templates\///;
+ $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
+ }
- foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
- $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
- }
+ foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
+ $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item</option>\n" : "<option>$item</option>\n";
+ }
- foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) {
- $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
- }
+ foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) {
+ $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item</option>\n" : "<option>$item</option>\n";
+ }
- %countrycodes = User->country_codes;
- $countrycodes = "";
-
- foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
- $countrycodes .= ($myconfig->{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}" : "<option value=$key>$countrycodes{$key}";
- }
- $countrycodes = qq|<option value="">English\n$countrycodes|;
+ %countrycodes = User->country_codes;
+ $countrycodes = "";
- # is there a templates basedir
- if (! -d "$templates") {
- $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
- }
+ foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
+ $countrycodes .= ($myconfig->{countrycode} eq $key) ? qq|<option selected value="$key">$countrycodes{$key}</option>|
+ : qq|<option value="$key">$countrycodes{$key}</option>|;
+ }
- opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
- @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
- closedir TEMPLATEDIR;
+ $countrycodes = qq|<option value="">English</option>\n$countrycodes|;
- @allhtml = sort grep /\.html/, @all;
+ # is there a templates basedir
+ if (! -d "$templates") {
+ $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
+ }
- @alldir = ();
- for (@all) {
- if (-d "$templates/$_") {
- push @alldir, $_;
- }
- }
-
- @allhtml = reverse grep !/Default/, @allhtml;
- push @allhtml, 'Default';
- @allhtml = reverse @allhtml;
-
- foreach $item (sort @alldir) {
- if ($item eq $myconfig->{templates}) {
- $usetemplates .= qq|<option selected>$item\n|;
- } else {
- $usetemplates .= qq|<option>$item\n|;
- }
- }
-
- $lastitem = $allhtml[0];
- $lastitem =~ s/-.*//g;
- $mastertemplates = qq|<option>$lastitem\n|;
- foreach $item (@allhtml) {
- $item =~ s/-.*//g;
-
- if ($item ne $lastitem) {
- $mastertemplates .= qq|<option>$item\n|;
- $lastitem = $item;
- }
- }
+ opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
+ @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
+ closedir TEMPLATEDIR;
- opendir CSS, "css/.";
- @all = grep /.*\.css$/, readdir CSS;
- closedir CSS;
-
- foreach $item (@all) {
- if ($item eq $myconfig->{stylesheet}) {
- $selectstylesheet .= qq|<option selected>$item\n|;
- } else {
- $selectstylesheet .= qq|<option>$item\n|;
- }
- }
- $selectstylesheet .= "<option>\n";
-
- if (%printer && $latex) {
- $selectprinter = "<option>\n";
- foreach $item (sort keys %printer) {
- if ($myconfig->{printer} eq $item) {
- $selectprinter .= qq|<option value="$item" selected>$item\n|;
- } else {
- $selectprinter .= qq|<option value="$item">$item\n|;
- }
- }
+ @allhtml = sort grep /\.html/, @all;
- $printer = qq|
- <tr>
- <th align=right>|.$locale->text('Printer').qq|</th>
- <td><select name=printer>$selectprinter</select></td>
- </tr>
-|;
+ @alldir = ();
+ for (@all) {
- }
-
- $user = $form->{login};
- $form->{login} = "root login";
- $form->header;
- $form->{login} = $user;
-
- print qq|
-<body class=admin>
+ if (-d "$templates/$_") {
+ push @alldir, $_;
+ }
+ }
-<form method=post action=$form->{script}>
+ @allhtml = reverse grep !/Default/, @allhtml;
+ push @allhtml, 'Default';
+ @allhtml = reverse @allhtml;
-<table width=100%>
- <tr class=listheading><th colspan=2>$form->{title}</th></tr>
- <tr size=5></tr>
- <tr valign=top>
- <td>
- <table>
- <tr>
- <th align=right>|.$locale->text('Login').qq|</th>
- <td><input name=login value="$myconfig->{login}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Password').qq|</th>
- <td><input type=password name=new_password size=8 value=$myconfig->{password}></td>
- <input type=hidden name=old_password value=$myconfig->{password}>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Name').qq|</th>
- <td><input name=name size=15 value="$myconfig->{name}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('E-mail').qq|</th>
- <td><input name=email size=30 value="$myconfig->{email}"></td>
- </tr>
- <tr valign=top>
- <th align=right>|.$locale->text('Signature').qq|</th>
- <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Phone').qq|</th>
- <td><input name=tel size=14 value="$myconfig->{tel}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Fax').qq|</th>
- <td><input name=fax size=14 value="$myconfig->{fax}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Company').qq|</th>
- <td><input name=company size=35 value="$myconfig->{company}"></td>
- </tr>
- <tr valign=top>
- <th align=right>|.$locale->text('Address').qq|</th>
- <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
- </tr>
- </table>
- </td>
- <td>
- <table>
- <tr>
- <th align=right>|.$locale->text('Date Format').qq|</th>
- <td><select name=dateformat>$dateformat</select></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Number Format').qq|</th>
- <td><select name=numberformat>$numberformat</select></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Dropdown Limit').qq|</th>
- <td><input name=vclimit value="$myconfig->{vclimit}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Menu Width').qq|</th>
- <td><input name=menuwidth value="$myconfig->{menuwidth}"></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Language').qq|</th>
- <td><select name=countrycode>$countrycodes</select></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Session Timeout').qq|</th>
- <td><input name=newtimeout value="$myconfig->{timeout}"></td>
- </tr>
+ foreach $item (sort @alldir) {
- <tr>
- <th align=right>|.$locale->text('Stylesheet').qq|</th>
- <td><select name=userstylesheet>$selectstylesheet</select></td>
- </tr>
- $printer
- <tr>
- <th align=right>|.$locale->text('Use Templates').qq|</th>
- <td><select name=usetemplates>$usetemplates</select></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('New Templates').qq|</th>
- <td><input name=newtemplates></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Setup Templates').qq|</th>
- <td><select name=mastertemplates>$mastertemplates</select></td>
- </tr>
- <input type=hidden name=templates value=$myconfig->{templates}>
- </table>
- </td>
- </tr>
- <tr class=listheading>
- <th colspan=2>|.$locale->text('Database').qq|</th>
- </tr>|;
+ if ($item eq $myconfig->{templates}) {
+ $usetemplates .= qq|<option selected value="$item">$item</option>\n|;
+ } else {
+ $usetemplates .= qq|<option value="$item">$item</option>\n|;
+ }
+ }
- # list section for database drivers
- foreach $item (User->dbdrivers) {
-
- print qq|
- <tr>
- <td colspan=2>
- <table>
- <tr>|;
+ $lastitem = $allhtml[0];
+ $lastitem =~ s/-.*//g;
+ $mastertemplates = qq|<option value="$lastitem">$lastitem</option>\n|;
- $checked = "";
- if ($myconfig->{dbdriver} eq $item) {
- for (qw(dbhost dbport dbuser dbpasswd dbname sid)) { $form->{"${item}_$_"} = $myconfig->{$_} }
- $checked = "checked";
- }
+ foreach $item (@allhtml) {
- print qq|
- <th align=right>|.$locale->text('Driver').qq|</th>
- <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
- <th align=right>|.$locale->text('Host').qq|</th>
- <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
- </tr>
- <tr>|;
+ $item =~ s/-.*//g;
- if ($item =~ /Pg/) {
- print qq|
- <th align=right>|.$locale->text('Dataset').qq|</th>
- <td><input name="${item}_dbname" size=15 value=$form->{"${item}_dbname"}></td>
- <th align=right>|.$locale->text('Port').qq|</th>
- <td><input name="${item}_dbport" size=4 value=$form->{"${item}_dbport"}></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('User').qq|</th>
- <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
- <th align=right>|.$locale->text('Password').qq|</th>
- <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
- </tr>|;
+ if ($item ne $lastitem) {
+ $mastertemplates .= qq|<option value="$item">$item</option>\n|;
+ $lastitem = $item;
+ }
+ }
- }
+ opendir CSS, "css/.";
+ @all = grep /.*\.css$/, readdir CSS;
+ closedir CSS;
- if ($item eq 'Oracle') {
- print qq|
- <th align=right>SID</th>
- <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
- <th align=right>|.$locale->text('Port').qq|</th>
- <td><input name="${item}_dbport size=4 value=$form->{"${item}_dbport"}></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Dataset').qq|</th>
- <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
- <th align=right>|.$locale->text('Password').qq|</th>
- <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
-
- </tr>|;
- }
-
-
- print qq|
- <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan=2><hr size=2 noshade></td>
- </tr>
-|;
+ foreach $item (@all) {
- }
+ if ($item eq $myconfig->{stylesheet}) {
+ $selectstylesheet .= qq|<option selected value="$item">$item</option>\n|;
+ } else {
+ $selectstylesheet .= qq|<option value="$item">$item</option>\n|;
+ }
+ }
+ $selectstylesheet .= "<option></option>\n";
- # access control
- open(FH, $menufile) or $form->error("$menufile : $!");
- # scan for first menu level
- @a = <FH>;
- close(FH);
-
- if (open(FH, "custom_$menufile")) {
- push @a, <FH>;
- }
- close(FH);
+ if (%printer && $latex) {
- foreach $item (@a) {
- next unless $item =~ /\[\w+/;
- next if $item =~ /\#/;
+ $selectprinter = "<option></option>\n";
- $item =~ s/(\[|\])//g;
- chop $item;
+ foreach $item (sort keys %printer) {
- if ($item =~ /--/) {
- ($level, $menuitem) = split /--/, $item, 2;
- } else {
- $level = $item;
- $menuitem = $item;
- push @acsorder, $item;
- }
+ if ($myconfig->{printer} eq $item) {
+ $selectprinter .= qq|<option value="$item" selected>$item</option>\n|;
+ } else {
+ $selectprinter .= qq|<option value="$item">$item</option>\n|;
+ }
+ }
- push @{ $acs{$level} }, $menuitem;
+ $printer = qq|
+ <tr>
+ <th align="right">|.$locale->text('Printer').qq|</th>
+ <td><select name="printer">$selectprinter</select></td>
+ </tr>
+ |;
- }
-
- %role = ( 'admin' => $locale->text('Administrator'),
- 'user' => $locale->text('User'),
- 'supervisor' => $locale->text('Supervisor'),
- 'manager' => $locale->text('Manager')
+ }
- );
-
- $selectrole = "";
- foreach $item (qw(user admin supervisor manager)) {
- $selectrole .= ($myconfig->{role} eq $item) ? "<option selected value=$item>$role{$item}\n" : "<option value=$item>$role{$item}\n";
- }
-
- print qq|
- <tr class=listheading>
- <th colspan=2>|.$locale->text('Access Control').qq|</th>
- </tr>
- <tr>
- <td><select name=role>$selectrole</select></td>
- </tr>
-|;
-
- foreach $item (split /;/, $myconfig->{acs}) {
- ($key, $value) = split /--/, $item, 2;
- $excl{$key}{$value} = 1;
- }
-
- foreach $key (@acsorder) {
+ $user = $form->{login};
+ $form->{login} = "root login";
+ $form->header;
+ $form->{login} = $user;
- $checked = "checked";
- if ($form->{login}) {
- $checked = ($excl{$key}{$key}) ? "" : "checked";
- }
-
- # can't have variable names with & and spaces
- $item = $form->escape("${key}--$key",1);
+ print qq|
+ <body class="admin">
+ <form method="post" action="$form->{script}">
+ <table width="100%">
+ <tr class="listheading"><th colspan="2">$form->{title}</th></tr>
+ <tr size="5"></tr>
+ <tr valign="top">
+ <td>
+ <table>
+ <tr>
+ <th align="right">|.$locale->text('Login').qq|</th>
+ <td><input name="login" value="$myconfig->{login}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Password').qq|</th>
+ <td><input type="password" name="new_password" size="8" value="$myconfig->{password}" /></td>
+ <input type="hidden" name="old_password" value="$myconfig->{password}" />
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Name').qq|</th>
+ <td><input name="name" size="15" value="$myconfig->{name}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('E-mail').qq|</th>
+ <td><input name="email" size="30" value="$myconfig->{email}" /></td>
+ </tr>
+ <tr valign="top">
+ <th align="right">|.$locale->text('Signature').qq|</th>
+ <td><textarea name="signature" rows="3" cols="35">$myconfig->{signature}</textarea></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Phone').qq|</th>
+ <td><input name="tel" size="14" value="$myconfig->{tel}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Fax').qq|</th>
+ <td><input name="fax" size="14" value="$myconfig->{fax}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Company').qq|</th>
+ <td><input name="company" size="35" value="$myconfig->{company}" /></td>
+ </tr>
+ <tr valign="top">
+ <th align="right">|.$locale->text('Address').qq|</th>
+ <td><textarea name="address" rows="4" cols="35">$myconfig->{address}</textarea></td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table>
+ <tr>
+ <th align="right">|.$locale->text('Date Format').qq|</th>
+ <td><select name="dateformat">$dateformat</select></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Number Format').qq|</th>
+ <td><select name="numberformat">$numberformat</select></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Dropdown Limit').qq|</th>
+ <td><input name="vclimit" value="$myconfig->{vclimit}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Menu Width').qq|</th>
+ <td><input name="menuwidth" value="$myconfig->{menuwidth}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Language').qq|</th>
+ <td><select name="countrycode">$countrycodes</select></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Session Timeout').qq|</th>
+ <td><input name="newtimeout" value="$myconfig->{timeout}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Stylesheet').qq|</th>
+ <td><select name="userstylesheet">$selectstylesheet</select></td>
+ </tr>
+ $printer
+ <tr>
+ <th align="right">|.$locale->text('Use Templates').qq|</th>
+ <td><select name="usetemplates">$usetemplates</select></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('New Templates').qq|</th>
+ <td><input name="newtemplates" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Setup Templates').qq|</th>
+ <td><select name="mastertemplates">$mastertemplates</select></td>
+ </tr>
+ </table>
+ <input type="hidden" name="templates" value="$myconfig->{templates}" />
+ </td>
+ </tr>
+ <tr class="listheading">
+ <th colspan="2">|.$locale->text('Database').qq|</th>
+ </tr>|;
- $acsheading = $key;
- $acsheading =~ s/ / /g;
+ # list section for database drivers
+ foreach $item (User->dbdrivers) {
- $acsheading = qq|
- <th align=left nowrap><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
- $menuitems .= "$item;";
- $acsdata = "
- <td>";
+ print qq|
+ <tr>
+ <td colspan="2">
+ <table>
+ <tr>|;
- foreach $item (@{ $acs{$key} }) {
+ $checked = "";
- next if ($key eq $item);
+ if ($myconfig->{dbdriver} eq $item) {
- $checked = "checked";
- if ($form->{login}) {
- $checked = ($excl{$key}{$item}) ? "" : "checked";
- }
+ for (qw(dbhost dbport dbuser dbpasswd dbname sid)) { $form->{"${item}_$_"} = $myconfig->{$_} }
+ $checked = "checked";
+ }
- $acsitem = $form->escape("${key}--$item",1);
+ print qq|
+ <th align="right">|.$locale->text('Driver').qq|</th>
+ <td><input name="dbdriver" type="radio" class="radio" value="$item" $checked /> $item</td>
+ <th align="right">|.$locale->text('Host').qq|</th>
+ <td><input name="${item}_dbhost" size="30" value="$form->{"${item}_dbhost"}" /></td>
+ </tr>
+ <tr>|;
- $acsdata .= qq|
- <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
- $menuitems .= "$acsitem;";
- }
+ print qq|
+ <th align="right">|.$locale->text('Dataset').qq|</th>
+ <td><input name="${item}_dbname" size="15" value="$form->{"${item}_dbname"}" /></td>
+ <th align="right">|.$locale->text('Port').qq|</th>
+ <td><input name="${item}_dbport" size="4" value="$form->{"${item}_dbport"}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('User').qq|</th>
+ <td><input name="${item}_dbuser" size="15" value="$form->{"${item}_dbuser"}" /></td>
+ <th align="right">|.$locale->text('Password').qq|</th>
+ <td><input name="${item}_dbpasswd" type="password" size="10" value="$form->{"${item}_dbpasswd"}" /></td>
+ </tr>|;
- $acsdata .= "
- </td>";
+ print qq|
+ </table>
+ <input type="hidden" name="old_dbpasswd" value="$myconfig->{dbpasswd}" />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><hr size="2" noshade /></td>
+ </tr>
+ |;
- print qq|
- <tr valign=top>$acsheading $acsdata
- </tr>
-|;
- }
-
- print qq|<input type=hidden name=acs value="$menuitems">
-
- <tr>
- <td colspan=2><hr size=3 noshade></td>
- </tr>
-</table>
-</div>
-|;
+ }
-}
+ # access control
+ open(FH, $menufile) or $form->error("$menufile : $!");
+ # scan for first menu level
+ @a = <FH>;
+ close(FH);
-sub save {
+ if (open(FH, "custom_$menufile")) {
+ push @a, <FH>;
+ }
- # no driver checked
- $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
+ close(FH);
- # no spaces allowed in login name
- $form->{login} =~ s/ //g;
+ foreach $item (@a) {
- $form->isblank("login", $locale->text('Login name missing!'));
-
- # check for duplicates
- if (!$form->{edit}) {
- $temp = new User "$memberfile", "$form->{login}";
-
- if ($temp->{login}) {
- $form->error("$form->{login} ".$locale->text('is already a member!'));
- }
- }
-
- # no spaces allowed in directories
- $form->{newtemplates} =~ s/( |\.\.|\*)//g;
-
- if ($form->{newtemplates} ne "") {
- $form->{templates} = $form->{newtemplates};
- } else {
- $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
- }
-
- # is there a basedir
- if (! -d "$templates") {
- $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
- }
+ next unless $item =~ /\[\w+/;
+ next if $item =~ /\#/;
- # add base directory to $form->{templates}
- $form->{templates} = "$templates/$form->{templates}";
+ $item =~ s/(\[|\])//g;
+ chop $item;
+ if ($item =~ /--/) {
- $myconfig = new User "$memberfile", "$form->{login}";
+ ($level, $menuitem) = split /--/, $item, 2;
+ } else {
- # redo acs variable and delete all the acs codes
- @acs = split /;/, $form->{acs};
+ $level = $item;
+ $menuitem = $item;
+ push @acsorder, $item;
+ }
- $form->{acs} = "";
- foreach $item (@acs) {
- $item = $form->escape($item,1);
- if (!$form->{$item}) {
- $form->{acs} .= $form->unescape($form->unescape("$item")).";";
- }
- delete $form->{$item};
- }
+ push @{ $acs{$level} }, $menuitem;
- # check which database was filled in
-
- $form->{dbhost} = $form->{"$form->{dbdriver}_dbhost"};
- $form->{dbport} = $form->{"$form->{dbdriver}_dbport"};
- $form->{dbpasswd} = $form->{"$form->{dbdriver}_dbpasswd"};
- $form->{dbuser} = $form->{"$form->{dbdriver}_dbuser"};
- $form->{dbname} = $form->{"$form->{dbdriver}_dbname"};
+ }
- if ($form->{dbdriver} eq 'Oracle') {
- $form->{sid} = $form->{Oracle_sid}, ;
+ %role = ( 'admin' => $locale->text('Administrator'),
+ 'user' => $locale->text('User'),
+ 'supervisor' => $locale->text('Supervisor'),
+ 'manager' => $locale->text('Manager'));
- $form->isblank("dbhost", $locale->text('Hostname missing!'));
- $form->isblank("dbport", $locale->text('Port missing!'));
- $form->isblank("dbuser", $locale->text('Dataset missing!'));
- }
- if ($form->{dbdriver} =~ /Pg/) {
- $form->isblank("dbname", $locale->text('Dataset missing!'));
- $form->isblank("dbuser", $locale->text('Database User missing!'));
- }
-
- foreach $item (keys %{$form}) {
- $myconfig->{$item} = $form->{$item};
- }
+ $selectrole = "";
- $myconfig->{password} = $form->{old_password};
- $myconfig->{password} = $form->{new_password} if $form->{new_password} ne $form->{old_password};
- $myconfig->{timeout} = $form->{newtimeout};
+ foreach $item (qw(user admin supervisor manager)) {
+ $selectrole .= ($myconfig->{role} eq $item) ? "<option selected value=\"$item\">$role{$item}</option>\n"
+ : "<option value=\"$item\">$role{$item}</option>\n";
+ }
- delete $myconfig->{stylesheet};
- if ($form->{userstylesheet}) {
- $myconfig->{stylesheet} = $form->{userstylesheet};
- }
-
- $myconfig->{packpw} = 1;
-
- $myconfig->save_member($memberfile, $userspath);
+ print qq|
+ <tr class="listheading">
+ <th colspan="2">|.$locale->text('Access Control').qq|</th>
+ </tr>
+ <tr>
+ <td><select name="role">$selectrole</select></td>
+ </tr>
+ |;
- # create user template directory and copy master files
- if (! -d "$form->{templates}") {
-
- umask(002);
-
- if (mkdir "$form->{templates}", oct("771")) {
-
- umask(007);
-
- # copy templates to the directory
- opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
- @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR;
- closedir TEMPLATEDIR;
-
- foreach $file (@templates) {
- open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
-
- $file =~ s/$form->{mastertemplates}-//;
- open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
-
- while ($line = <TEMP>) {
- print NEW $line;
+ foreach $item (split /;/, $myconfig->{acs}) {
+ ($key, $value) = split /--/, $item, 2;
+ $excl{$key}{$value} = 1;
}
- close(TEMP);
- close(NEW);
- }
- } else {
- $form->error("$form->{templates} : $!");
- }
- }
- $form->redirect($locale->text('User saved!'));
-
-}
+ foreach $key (@acsorder) {
+ $checked = "checked";
-sub delete {
+ if ($form->{login}) {
+ $checked = ($excl{$key}{$key}) ? "" : "checked";
+ }
- $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
-
- $form->error("$memberfile ".$locale->text('locked!')) if (-f ${memberfile}.LCK);
+ # can't have variable names with & and spaces
+ $item = $form->escape("${key}--$key",1);
- open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
- close(FH);
-
- if (! open(CONF, "+<$memberfile")) {
- unlink "${memberfile}.LCK";
- $form->error("$memberfile : $!");
- }
+ $acsheading = $key;
+ $acsheading =~ s/ / /g;
- @config = <CONF>;
+ $acsheading = qq|
+ <th align="left" nowrap="nowrap"><input name="$item" class="checkbox" type="checkbox" value="1" $checked /> $acsheading</th>\n|;
+ $menuitems .= "$item;";
+ $acsdata = "<td>";
- seek(CONF, 0, 0);
- truncate(CONF, 0);
-
- while ($line = shift @config) {
+ foreach $item (@{ $acs{$key} }) {
- chop $line;
+ next if ($key eq $item);
- if ($line =~ /^\[/) {
- last if ($line eq "[$form->{login}]");
- $login = &login_name($line);
- }
-
- if ($line =~ /^templates=/) {
- ($null, $user{$login}) = split /=/, $line, 2;
- }
+ $checked = "checked";
- print CONF "$line\n";
- }
+ if ($form->{login}) {
+ $checked = ($excl{$key}{$item}) ? "" : "checked";
+ }
- # remove everything up to next login or EOF
- # and save template variable
- while ($line = shift @config) {
+ $acsitem = $form->escape("${key}--$item",1);
- chop $line;
-
- ($key, $value) = split /=/, $line, 2;
- $myconfig{$key} = $value;
-
- last if ($line =~ /^\[/);
- }
+ $acsdata .= qq|<br /><input name="$acsitem" class="checkbox" type="checkbox" value="1" $checked /> $item|;
+ $menuitems .= "$acsitem;";
+ }
- # this one is either the next login or EOF
- print CONF "$line\n";
+ $acsdata .= "
+ </td>";
- $login = &login_name($line);
-
+ print qq|
+ <tr valign="top">$acsheading $acsdata
+ </tr>
+ |;
+ }
- while ($line = shift @config) {
+ print qq|<input type="hidden" name="acs" value="$menuitems" />
+ <tr>
+ <td colspan="2"><hr size="3" noshade /></td>
+ </tr>
+ </table>
+ </div>
+ |;
- chop $line;
+}
- if ($line =~ /^\[/) {
- $login = &login_name($line);
- }
-
- if ($line =~ /^templates=/) {
- ($null, $user{$login}) = split /=/, $line, 2;
- }
-
- print CONF "$line\n";
- }
- close(CONF);
- unlink "${memberfile}.LCK";
+sub save {
- # scan %user for $templatedir
- foreach $login (keys %user) {
- last if ($found = ($form->{templates} eq $user{$login}));
- }
+ # no driver checked
+ $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
- # if found keep directory otherwise delete
- if (!$found) {
- # delete it if there is a template directory
- $dir = "$form->{templates}";
- if (-d "$dir") {
- unlink <$dir/*>;
- rmdir "$dir";
- }
- }
+ # no spaces allowed in login name
+ $form->{login} =~ s/ //g;
- if ($myconfig{dbconnect}) {
- $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
- for (keys %myconfig) { $form->{$_} = $myconfig{$_} }
-
- User->delete_login(\%$form);
-
- # delete config file for user
- unlink "$userspath/$form->{login}.conf";
- }
+ $form->isblank("login", $locale->text('Login name missing!'));
- $form->redirect($locale->text('User deleted!'));
-
-}
+ # check for duplicates
+ if (!$form->{edit}) {
+ $temp = new User "$memberfile", "$form->{login}";
-sub login_name {
- my $login = shift;
-
- $login =~ s/\[\]//g;
- return ($login) ? $login : undef;
-
-}
+ if ($temp->{login}) {
+ $form->error("$form->{login} ".$locale->text('is already a member!'));
+ }
+ }
+ # no spaces allowed in directories
+ $form->{newtemplates} =~ s/( |\.\.|\*)//g;
-sub change_admin_password {
+ if ($form->{newtemplates} ne "") {
+ $form->{templates} = $form->{newtemplates};
+ } else {
+ $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
+ }
- $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password');
+ # is there a basedir
+ if (! -d "$templates") {
+ $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
+ }
- $form->{login} = "root login";
- $form->header;
+ # add base directory to $form->{templates}
+ $form->{templates} = "$templates/$form->{templates}";
- print qq|
-<body class=admin>
-<form method=post action=$form->{script}>
+ $myconfig = new User "$memberfile", "$form->{login}";
-<table>
- <tr>
- <tr class=listheading>
- <th>|.$locale->text('Change Password').qq|</th>
- </tr>
- <tr size=5></tr>
- <tr>
- <td>
- <table width=100%>
- <tr>
- <th align=right>|.$locale->text('Password').qq|</th>
- <td><input type=password name=new_password></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('Confirm').qq|</th>
- <td><input type=password name=confirm_password></td>
- </tr>
- </table>
- </td>
- </tr>
+ # redo acs variable and delete all the acs codes
+ @acs = split /;/, $form->{acs};
-</table>
+ $form->{acs} = "";
-<br>
-<hr size=3 noshade>
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ foreach $item (@acs) {
-<p>
-<input type=submit class=submit name=action value="|.$locale->text('Change Password').qq|">
+ $item = $form->escape($item,1);
-</form>
+ if (!$form->{$item}) {
+ $form->{acs} .= $form->unescape($form->unescape("$item")).";";
+ }
-</body>
-</html>
-|;
+ delete $form->{$item};
+ }
-}
+ # check which database was filled in
+ $form->{dbhost} = $form->{"$form->{dbdriver}_dbhost"};
+ $form->{dbport} = $form->{"$form->{dbdriver}_dbport"};
+ $form->{dbpasswd} = $form->{"$form->{dbdriver}_dbpasswd"};
+ $form->{dbuser} = $form->{"$form->{dbdriver}_dbuser"};
+ $form->{dbname} = $form->{"$form->{dbdriver}_dbname"};
-sub change_password {
+ $form->isblank("dbname", $locale->text('Dataset missing!'));
+ $form->isblank("dbuser", $locale->text('Database User missing!'));
- $form->error($locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password};
-
- $root->{password} = $form->{new_password};
-
- $root->{'root login'} = 1;
- $root->save_member($memberfile);
+ foreach $item (keys %{$form}) {
+ $myconfig->{$item} = $form->{$item};
+ }
- $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
+ $myconfig->{password} = $form->{old_password};
+ $myconfig->{password} = $form->{new_password} if $form->{new_password} ne $form->{old_password};
+ $myconfig->{timeout} = $form->{newtimeout};
- $form->redirect($locale->text('Password changed!'));
+ delete $myconfig->{stylesheet};
-}
+ if ($form->{userstylesheet}) {
+ $myconfig->{stylesheet} = $form->{userstylesheet};
+ }
-sub get_hash {
- use Digest::MD5;
- $form->{hash} = Digest::MD5::md5_hex rand();
-
-}
+ $myconfig->{packpw} = 1;
-sub check_password {
+ $myconfig->save_member($memberfile, $userspath);
+ # create user template directory and copy master files
+ if (! -d "$form->{templates}") {
+ umask(002);
- $root = new User "$memberfile", "root login";
+ if (mkdir "$form->{templates}", oct("771")) {
- if ($root->{password}) {
-
- if ($form->{password}) {
- $form->{callback} .= "&password=$form->{password}" if $form->{callback};
- $form->{sessionid} = time;
- if ($root->{password} ne crypt $form->{password}, 'ro') {
- &getpassword;
- exit;
- }
+ umask(007);
- &get_hash;
-
- open(HASHFILE, "> $userspath/adminhash")
- || $form->error("Can't Open Hashfile: $!");
- print HASHFILE $form->{hash};
+ # copy templates to the directory
+ opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
+ @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR;
+ closedir TEMPLATEDIR;
- print qq|Set-Cookie: LedgerSMB=$form->{hash}; path=/;\n|;
+ foreach $file (@templates) {
- } else {
- if ($ENV{HTTP_USER_AGENT}) {
- $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
- %cookie = split /[=;]/, $ENV{HTTP_COOKIE}; # Changeme to %cookies
- $cookie = ($form->{path} eq 'bin/lynx') ? $cookie{login} : $cookie{"LedgerSMB-root login"};
+ open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
- #fixes problem with first login and such
- if (!(-f "$userspath/adminhash")) {
- &get_hash;
- open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
- print HASHFILE $form->{hash};
- close(HASHFILE);
- }
+ $file =~ s/$form->{mastertemplates}-//;
+ open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
- open (HASHFILE, "< $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
+ while ($line = <TEMP>) {
+ print NEW $line;
+ }
- chomp($form->{hash} = <HASHFILE>);
+ close(TEMP);
+ close(NEW);
+ }
- %cookies = split /[=;]/, $ENV{HTTP_COOKIE};
-
- if (! $cookie || $cookie ne $form->{sessionid} ||
- $form->{hash} ne $cookies{LedgerSMB}) {
- &getpassword;
- exit;
+ } else {
+ $form->error("$form->{templates} : $!");
+ }
}
- }
- }
- }
+ $form->redirect($locale->text('User saved!'));
+
}
-sub pg_database_administration {
+sub delete {
- $form->{dbdriver} = 'Pg';
- &dbselect_source;
+ $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
-}
+ $form->error("$memberfile ".$locale->text('locked!')) if (-f ${memberfile}.LCK);
+ open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
+ close(FH);
-sub pgpp_database_administration {
+ if (! open(CONF, "+<$memberfile")) {
+ unlink "${memberfile}.LCK";
+ $form->error("$memberfile : $!");
+ }
- $form->{dbdriver} = 'PgPP';
- &dbselect_source;
+ @config = <CONF>;
-}
+ seek(CONF, 0, 0);
+ truncate(CONF, 0);
+ while ($line = shift @config) {
-sub oracle_database_administration {
-
- $form->{dbdriver} = 'Oracle';
- &dbselect_source;
+ chop $line;
-}
+ if ($line =~ /^\[/) {
+ last if ($line eq "[$form->{login}]");
+ $login = &login_name($line);
+ }
+ if ($line =~ /^templates=/) {
+ ($null, $user{$login}) = split /=/, $line, 2;
+ }
-sub dbdriver_defaults {
+ print CONF "$line\n";
+ }
- # load some defaults for the selected driver
- %driverdefaults = ( 'Pg' => { dbport => '',
- dbuser => 'ledger-smb',
- dbdefault => 'template1',
- dbhost => '',
- connectstring => $locale->text('Connect to')
- },
- 'Oracle' => { dbport => '1521',
- dbuser => 'oralin',
- dbdefault => $sid,
- dbhost => `hostname`,
- connectstring => 'SID'
- }
- );
+ # remove everything up to next login or EOF
+ # and save template variable
+ while ($line = shift @config) {
- $driverdefaults{PgPP} = $driverdefaults{Pg};
+ chop $line;
- for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} }
-
-}
-
+ ($key, $value) = split /=/, $line, 2;
+ $myconfig{$key} = $value;
-sub dbselect_source {
+ last if ($line =~ /^\[/);
+ }
- &dbdriver_defaults;
+ # this one is either the next login or EOF
+ print CONF "$line\n";
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
-
- $form->{login} = "root login";
- $form->header;
+ $login = &login_name($line);
- print qq|
-<body class=admin>
-<center>
-<h2>$form->{title}</h2>
+ while ($line = shift @config) {
-<form method=post action=$form->{script}>
+ chop $line;
-<table>
- <tr>
- <td>
- <table>
- <tr class=listheading>
- <th colspan=4>|.$locale->text('Database').qq|</th>
- </tr>
- <input type=hidden name=dbdriver value=$form->{dbdriver}>
- <tr>
- <td>
- <table>
- <tr>
- <th align=right>|.$locale->text('Host').qq|</th>
- <td><input name=dbhost size=25 value=$form->{dbhost}></td>
- <th align=right>|.$locale->text('Port').qq|</th>
- <td><input name=dbport size=5 value=$form->{dbport}></td>
- </tr>
- <tr>
- <th align=right>|.$locale->text('User').qq|</th>
- <td><input name=dbuser size=10 value=$form->{dbuser}></td>
- <th align=right>|.$locale->text('Password').qq|</th>
- <td><input type=password name=dbpasswd size=10></td>
- </tr>
- <tr>
+ if ($line =~ /^\[/) {
+ $login = &login_name($line);
+ }
- <th align=right>$form->{connectstring}</th>
- <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
+ if ($line =~ /^templates=/) {
+ ($null, $user{$login}) = split /=/, $line, 2;
+ }
- </tr>
- </table>
- </td>
- </tr>
- </table>
+ print CONF "$line\n";
+ }
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ close(CONF);
+ unlink "${memberfile}.LCK";
-<br>
+ # scan %user for $templatedir
+ foreach $login (keys %user) {
+ last if ($found = ($form->{templates} eq $user{$login}));
+ }
-<input type=submit class=submit name=action value="|.$locale->text('Create Dataset').qq|">
-<input type=submit class=submit name=action value="|.$locale->text('Update Dataset').qq|">
-<input type=submit class=submit name=action value="|.$locale->text('Delete Dataset').qq|">
+ # if found keep directory otherwise delete
+ if (!$found) {
-</form>
+ # delete it if there is a template directory
+ $dir = "$form->{templates}";
+ if (-d "$dir") {
+ unlink <$dir/*>;
+ rmdir "$dir";
+ }
+ }
- </td>
- </tr>
-</table>
+ if ($myconfig{dbconnect}) {
-<p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
+ $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
+ for (keys %myconfig) { $form->{$_} = $myconfig{$_} }
-.qq|
-</body>
-</html>
-|;
+ User->delete_login(\%$form);
+ # delete config file for user
+ unlink "$userspath/$form->{login}.conf";
+ }
+
+ $form->redirect($locale->text('User deleted!'));
}
-sub continue {
+sub login_name {
- &{ $form->{nextsub} };
-
+ my $login = shift;
+ $login =~ s/\[\]//g;
+ return ($login) ? $login : undef;
}
-sub update_dataset {
+sub change_admin_password {
- %needsupdate = User->dbneedsupdate(\%$form);
+ $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password');
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset');
-
- $form->{login} = "root login";
- $form->header;
+ $form->{login} = "root login";
+ $form->header;
- print qq|
-<body class=admin>
+ print qq|
+ <body class="admin">
+ <form method="post" action="$form->{script}">
+ <table>
+ <tr class="listheading">
+ <th>|.$locale->text('Change Password').qq|</th>
+ </tr>
+ <tr size="5"></tr>
+ <tr>
+ <td>
+ <table width="100%">
+ <tr>
+ <th align="right">|.$locale->text('Password').qq|</th>
+ <td><input type="password" name="new_password" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('Confirm').qq|</th>
+ <td><input type="password" name="confirm_password" /></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <br />
+ <hr size="3" noshade />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <p><input type="submit" class="submit" name="action" value="|.$locale->text('Change Password').qq|" /></p>
+ </form>
+ </body>
+ </html>
+ |;
+}
-<center>
-<h2>$form->{title}</h2>
-|;
+sub change_password {
- foreach $key (sort keys %needsupdate) {
- if ($needsupdate{$key} ne $form->{dbversion}) {
- $upd .= qq|<input name="db$key" class=checkbox type=checkbox value=1 checked> $key\n|;
- $form->{dbupdate} .= "db$key ";
- }
- }
+ $form->error($locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password};
+ $root->{password} = $form->{new_password};
+ $root->{'root login'} = 1;
+ $root->save_member($memberfile);
+ $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
+ $form->redirect($locale->text('Password changed!'));
+}
- chop $form->{dbupdate};
+sub get_hash {
+ use Digest::MD5;
+ $form->{hash} = Digest::MD5::md5_hex rand();
+}
- if ($form->{dbupdate}) {
+sub check_password {
- print qq|
-<table width=100%>
-<form method=post action=$form->{script}>
+ $root = new User "$memberfile", "root login";
-<input type=hidden name=dbdriver value=$form->{dbdriver}>
-<input type=hidden name=dbhost value=$form->{dbhost}>
-<input type=hidden name=dbport value=$form->{dbport}>
-<input type=hidden name=dbuser value=$form->{dbuser}>
-<input type=hidden name=dbpasswd value=$form->{dbpasswd}>
-<input type=hidden name=dbdefault value=$form->{dbdefault}>
+ if ($root->{password}) {
-<tr class=listheading>
- <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
-</tr>
-<tr>
-<td>
+ if ($form->{password}) {
-$upd
+ $form->{callback} .= "&password=$form->{password}" if $form->{callback};
+ $form->{sessionid} = time;
-</td>
-</tr>
-<tr>
-<td>
+ if ($root->{password} ne crypt $form->{password}, 'ro') {
+ &getpassword;
+ exit;
+ }
-<input name=dbupdate type=hidden value="$form->{dbupdate}">
+ &get_hash;
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
+ open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
+ print HASHFILE $form->{hash};
+ print qq|Set-Cookie: LedgerSMB=$form->{hash}; path=/;\n|;
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ } else {
-<input type=hidden name=nextsub value=dbupdate>
+ if ($ENV{HTTP_USER_AGENT}) {
-<hr size=3 noshade>
+ $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
+ %cookie = split /[=;]/, $ENV{HTTP_COOKIE}; # Changeme to %cookies
+ $cookie = ($form->{path} eq 'bin/lynx') ? $cookie{login} : $cookie{"LedgerSMB-root login"};
-<br>
-<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
+ #fixes problem with first login and such
+ if (!(-f "$userspath/adminhash")) {
+ &get_hash;
+ open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
+ print HASHFILE $form->{hash};
+ close(HASHFILE);
+ }
-</td></tr>
-</table>
-</form>
-|;
+ open (HASHFILE, "< $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
+ chomp($form->{hash} = <HASHFILE>);
+ %cookies = split /[=;]/, $ENV{HTTP_COOKIE};
- } else {
+ if (! $cookie || $cookie ne $form->{sessionid} || $form->{hash} ne $cookies{LedgerSMB}) {
- print $locale->text('DBA')." : $form->{dbuser} : " .$locale->text('All Datasets up to date!');
+ &getpassword;
+ exit;
+ }
+ }
+ }
+ }
- }
-
- print qq|
+}
-</body>
-</html>
-|;
+sub pg_database_administration {
+
+ $form->{dbdriver} = 'Pg';
+ &dbselect_source;
}
-sub dbupdate {
+sub pgpp_database_administration {
- User->dbupdate(\%$form);
+ $form->{dbdriver} = 'PgPP';
+ &dbselect_source;
- $form->redirect($locale->text('Dataset updated!'));
-
}
-sub create_dataset {
+sub dbdriver_defaults {
- @dbsources = sort User->dbsources(\%$form);
+ # load some defaults for the selected driver
+ %driverdefaults = ( 'Pg' => { dbport => '',
+ dbuser => 'ledger-smb',
+ dbdefault => 'template1',
+ dbhost => '',
+ connectstring => $locale->text('Connect to')
+ } );
- opendir SQLDIR, "sql/." or $form->error($!);
- foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
- next if ($item eq 'Default-chart.sql');
- $item =~ s/-chart\.sql//;
- push @charts, qq|<input name=chart class=radio type=radio value="$item">$item|;
- }
- closedir SQLDIR;
+ $driverdefaults{PgPP} = $driverdefaults{Pg};
- # add Default at beginning
- unshift @charts, qq|<input name=chart class=radio type=radio value="Default" checked>Default|;
+ for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} }
- $selectencoding = qq|<option>
- <option value=SQL_ASCII>ASCII
- <option value=EUC_JP>Japanese EUC
- <option value=EUC_CN>Chinese EUC
- <option value=EUC_KR>Korean EUC
- <option value=JOHAB>Korean EUC (Hangle base)
- <option value=EUC_TW>Taiwan EUC
- <option value=UNICODE>Unicode (UTF-8)
- <option value=MULE_INTERNAL>Mule internal type
- <option value=LATIN1>ISO 8859-1/ECMA 94 (Latin alphabet no. 1)
- <option value=LATIN2>ISO 8859-2/ECMA 94 (Latin alphabet no. 2)
- <option value=LATIN3>ISO 8859-3/ECMA 94 (Latin alphabet no. 3)
- <option value=LATIN4>ISO 8859-4/ECMA 94 (Latin alphabet no. 4)
- <option value=LATIN5>ISO 8859-9/ECMA 128 (Latin alphabet no. 5)
- <option value=LATIN6>ISO 8859-10/ECMA 144 (Latin alphabet no. 6)
- <option value=LATIN7>ISO 8859-13 (Latin alphabet no. 7)
- <option value=LATIN8>ISO 8859-14 (Latin alphabet no. 8)
- <option value=LATIN9>ISO 8859-15 (Latin alphabet no. 9)
- <option value=LATIN10>ISO 8859-16/ASRO SR 14111 (Latin alphabet no. 10)
- <option value=ISO_8859_5>ISO 8859-5/ECMA 113 (Latin/Cyrillic)
- <option value=ISO_8859_6>ISO 8859-6/ECMA 114 (Latin/Arabic)
- <option value=ISO_8859_7>ISO 8859-7/ECMA 118 (Latin/Greek)
- <option value=ISO_8859_8>ISO 8859-8/ECMA 121 (Latin/Hebrew)
- <option value=KOI8>KOI8-R(U)
- <option value=WIN>Windows CP1251
- <option value=ALT>Windows CP866
- <option value=WIN1256>Windows CP1256 (Arabic)
- <option value=TCVN>Windows CP1258 (Vietnamese)
- <option value=WIN874>Windows CP874 (Thai)
- |;
-
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
-
- $form->{login} = "root login";
- $form->header;
+}
- print qq|
-<body class=admin>
+sub dbselect_source {
-<center>
-<h2>$form->{title}</h2>
+ &dbdriver_defaults;
-<form method=post action=$form->{script}>
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
-<table width=100%>
- <tr class=listheading>
- <th colspan=2> </th>
- </tr>
+ $form->{login} = "root login";
+ $form->header;
- <tr>
+ #an insane amount of table nesting here, this should be cleaned up.
+ print qq|
+ <body class="admin">
+ <center>
+ <h2>$form->{title}</h2>
+ <form method="post" action="$form->{script}" />
+ <table>
+ <tr>
+ <td>
+ <table>
+ <tr class="listheading">
+ <th colspan="4">|.$locale->text('Database').qq|</th>
+ </tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right">|.$locale->text('Host').qq|</th>
+ <td><input name="dbhost" size="25" value="$form->{dbhost}" /></td>
+ <th align="right">|.$locale->text('Port').qq|</th>
+ <td><input name="dbport" size="5" value="$form->{dbport}" /></td>
+ </tr>
+ <tr>
+ <th align="right">|.$locale->text('User').qq|</th>
+ <td><input name="dbuser" size="10" value="$form->{dbuser}" /></td>
+ <th align="right">|.$locale->text('Password').qq|</th>
+ <td><input type="password" name="dbpasswd" size="10" /></td>
+ </tr>
+ <tr>
+ <th align="right">$form->{connectstring}</th>
+ <td colspan="3"><input name="dbdefault" size="10" value="$form->{dbdefault}" /></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
+ <input name="callback" type="hidden" value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <br />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Create Dataset').qq|" />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Update Dataset').qq|" />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Delete Dataset').qq|" />
+ </form>
+ <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
+ .qq|</p>
+ </center>
+ </body>
+ </html>
+ |;
+}
- <th align=right nowrap>|.$locale->text('Existing Datasets').qq|</th>
- <td>
-|;
- for (@dbsources) { print "[ $_ ] " }
-
- print qq|
- </td>
- </tr>
-
- <tr>
+sub continue {
- <th align=right nowrap>|.$locale->text('Create Dataset').qq|</th>
- <td><input name=db></td>
+ &{ $form->{nextsub} };
+}
- </tr>
- <tr>
+sub update_dataset {
- <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th>
- <td><select name=encoding>$selectencoding</select></td>
+ %needsupdate = User->dbneedsupdate(\%$form);
- </tr>
-
- <tr>
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')." "
+ .$locale->text('Database Administration')." / "
+ .$locale->text('Update Dataset');
+ $form->{login} = "root login";
+ $form->header;
- <th align=right nowrap>|.$locale->text('Create Chart of Accounts').qq|</th>
- <td>
- <table>
-|;
+ print qq|
+ <body class="admin">
+ <center>
+ <h2>$form->{title}</h2>
+ |;
- while (@charts) {
- print qq|
- <tr>
-|;
+ foreach $key (sort keys %needsupdate) {
- for (0 .. 2) { print "<td>$charts[$_]</td>\n" }
+ if ($needsupdate{$key} ne $form->{dbversion}) {
+ $upd .= qq|<input name="db$key" class="checkbox" type="checkbox" value="1" checked /> $key\n|;
+ $form->{dbupdate} .= "db$key ";
+ }
+ }
- print qq|
- </tr>
-|;
+ chop $form->{dbupdate};
- splice @charts, 0, 3;
- }
+ if ($form->{dbupdate}) {
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <hr size=3 noshade>
- </td>
- </tr>
-</table>
-|;
+ print qq|
+ <form method="post" action="$form->{script}" />
+ <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
+ <input type="hidden" name="dbhost" value="$form->{dbhost}" />
+ <input type="hidden" name="dbport" value="$form->{dbport}" />
+ <input type="hidden" name="dbuser" value="$form->{dbuser}" />
+ <input type="hidden" name="dbpasswd" value="$form->{dbpasswd}" />
+ <input type="hidden" name="dbdefault" value="$form->{dbdefault}" />
+ <input name="dbupdate" type="hidden" value="$form->{dbupdate}" />
+ <input name="callback" type="hidden" value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <input type="hidden" name="nextsub" value="dbupdate" />
+
+ <table width="100%">
+ <tr class="listheading">
+ <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
+ </tr>
+ <tr>
+ <td>
+ $upd
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <hr size="3" noshade />
+ <br />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ |;
- $form->hide_form(qw(dbdriver dbuser dbhost dbport dbpasswd dbdefault path sessionid));
-
- print qq|
-
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
-<input type=hidden name=nextsub value=dbcreate>
-
-<br>
-<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
+ } else {
+ print $locale->text('DBA')." : $form->{dbuser} : " .$locale->text('All Datasets up to date!');
+ }
-</form>
+ print qq|
+ </body>
+ </html>
+ |;
-</body>
-</html>
-|;
-
}
-sub dbcreate {
+sub dbupdate {
- $form->isblank("db", $locale->text('Dataset missing!'));
+ User->dbupdate(\%$form);
+ $form->redirect($locale->text('Dataset updated!'));
+}
- User->dbcreate(\%$form);
-
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
- $form->{login} = "root login";
- $form->header;
+sub create_dataset {
- print qq|
-<body class=admin>
+ @dbsources = sort User->dbsources(\%$form);
+ opendir SQLDIR, "sql/." or $form->error($!);
-<center>
-<h2>$form->{title}</h2>
+ foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
+ next if ($item eq 'Default-chart.sql');
+ $item =~ s/-chart\.sql//;
+ push @charts, qq|<input name="chart" class="radio" type="radio" value="$item" />$item|;
+ }
-<form method=post action=$form->{script}>|
+ closedir SQLDIR;
-.$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
+ # add Default at beginning
+ unshift @charts, qq|<input name="chart" class="radio" type="radio" value="Default" checked />Default|;
-.qq|
+ $selectencoding = qq|<option></option>
+ <option value="SQL_ASCII">ASCII</option>
+ <option value="EUC_JP">Japanese EUC</option>
+ <option value="EUC_CN">Chinese EUC</option>
+ <option value="EUC_KR">Korean EUC</option>
+ <option value="JOHAB">Korean EUC (Hangle base)</option>
+ <option value="EUC_TW">Taiwan EUC</option>
+ <option value="UNICODE">Unicode (UTF-8)</option>
+ <option value="MULE_INTERNAL">Mule internal type</option>
+ <option value="LATIN1">ISO 8859-1/ECMA 94 (Latin alphabet no. 1)</option>
+ <option value="LATIN2">ISO 8859-2/ECMA 94 (Latin alphabet no. 2)</option>
+ <option value="LATIN3">ISO 8859-3/ECMA 94 (Latin alphabet no. 3)</option>
+ <option value="LATIN4">ISO 8859-4/ECMA 94 (Latin alphabet no. 4)</option>
+ <option value="LATIN5">ISO 8859-9/ECMA 128 (Latin alphabet no. 5)</option>
+ <option value="LATIN6">ISO 8859-10/ECMA 144 (Latin alphabet no. 6)</option>
+ <option value="LATIN7">ISO 8859-13 (Latin alphabet no. 7)</option>
+ <option value="LATIN8">ISO 8859-14 (Latin alphabet no. 8)</option>
+ <option value="LATIN9">ISO 8859-15 (Latin alphabet no. 9)</option>
+ <option value="LATIN10">ISO 8859-16/ASRO SR 14111 (Latin alphabet no. 10)</option>
+ <option value="ISO_8859_5">ISO 8859-5/ECMA 113 (Latin/Cyrillic)</option>
+ <option value="ISO_8859_6">ISO 8859-6/ECMA 114 (Latin/Arabic)</option>
+ <option value="ISO_8859_7">ISO 8859-7/ECMA 118 (Latin/Greek)</option>
+ <option value="ISO_8859_8">ISO 8859-8/ECMA 121 (Latin/Hebrew)</option>
+ <option value="KOI8">KOI8-R(U)</option>
+ <option value="WIN">Windows CP1251</option>
+ <option value="ALT">Windows CP866</option>
+ <option value="WIN1256">Windows CP1256 (Arabic)</option>
+ <option value="TCVN">Windows CP1258 (Vietnamese)</option>
+ <option value="WIN874">Windows CP874 (Thai)</option>
+ |;
-<input type=hidden name=path value="$form->{path}">
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')
+ ." ".$locale->text('Database Administration')
+ ." / ".$locale->text('Create Dataset');
+ $form->{login} = "root login";
+ $form->header;
-<input type=hidden name=nextsub value=list_users>
+ print qq|
+ <body class="admin">
+ <center>
+ <h2>$form->{title}</h2>
+ <form method="post" action="$form->{script}" />
+ <table width="100%">
+ <tr class="listheading">
+ <th colspan="2"> </th>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap">|.$locale->text('Existing Datasets').qq|</th>
+ <td>
+ |;
-<p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
-</form>
+ for (@dbsources) { print "[ $_ ] " }
+ print qq|
+ </td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap">|.$locale->text('Create Dataset').qq|</th>
+ <td><input name="db" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap">|.$locale->text('Multibyte Encoding').qq|</th>
+ <td><select name="encoding">$selectencoding</select></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap">|.$locale->text('Create Chart of Accounts').qq|</th>
+ <td>
+ <table>
+ |;
-</body>
-</html>
-|;
+ while (@charts) {
+ print qq| <tr>|;
-}
+ for (0 .. 2) { print "<td>$charts[$_]</td>\n" }
+ print qq| </tr>|;
-sub delete_dataset {
+ splice @charts, 0, 3;
+ }
- if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
- foreach $item (sort @dbsources) {
- $dbsources .= qq|<input name=db class=radio type=radio value=$item> $item |;
- }
- } else {
- $form->error($locale->text('Nothing to delete!'));
- }
+ print qq| </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <hr size="3" noshade />
+ </td>
+ </tr>
+ </table>
+ |;
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
+ $form->hide_form(qw(dbdriver dbuser dbhost dbport dbpasswd dbdefault path sessionid));
- $form->{login} = "root login";
- $form->header;
+ print qq|
+ <input name="callback" type="hidden" value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}" />
+ <input type="hidden" name="nextsub" value="dbcreate" />
+ <br />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
+ </form>
+ </body>
+ </html>
+ |;
- print qq|
-<body class=admin>
+}
-<h2>$form->{title}</h2>
-<form method=post action=$form->{script}>
+sub dbcreate {
-<table width=100%>
- <tr class=listheading>
- <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
- </tr>
+ $form->isblank("db", $locale->text('Dataset missing!'));
- <tr>
- <td>
- $dbsources
- </td>
- </tr>
-
- <tr><td>
-<p>
-<input type=hidden name=dbdriver value=$form->{dbdriver}>
-<input type=hidden name=dbuser value=$form->{dbuser}>
-<input type=hidden name=dbhost value=$form->{dbhost}>
-<input type=hidden name=dbport value=$form->{dbport}>
-<input type=hidden name=dbpasswd value=$form->{dbpasswd}>
-<input type=hidden name=dbdefault value=$form->{dbdefault}>
+ User->dbcreate(\%$form);
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')
+ ." ".$locale->text('Database Administration')
+ ." / ".$locale->text('Create Dataset');
-<input type=hidden name=path value="$form->{path}">
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ $form->{login} = "root login";
+ $form->header;
-<input type=hidden name=nextsub value=dbdelete>
-
-<hr size=3 noshade>
-
-<br>
-<input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
-
- </td></tr>
-</table>
-
-</form>
-
-</body>
-</html>
-|;
-
+ print qq|
+ <body class="admin">
+ <center>
+ <h2>$form->{title}</h2>
+ <form method="post" action="$form->{script}">|
+ .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
+ .qq|
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <input type="hidden" name="nextsub" value="list_users" />
+ <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
+ </form>
+ </center>
+ </body>
+ </html>
+ |;
}
-sub dbdelete {
+sub delete_dataset {
- if (!$form->{db}) {
- $form->error($locale->text('No Dataset selected!'));
- }
+ if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
- User->dbdelete(\%$form);
+ foreach $item (sort @dbsources) {
+ $dbsources .= qq|<input name="db" class="radio" type="radio" value="$item" /> $item |;
+ }
- $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
+ } else {
+ $form->error($locale->text('Nothing to delete!'));
+ }
- $form->{login} = "root login";
- $form->header;
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')
+ ." ".$locale->text('Database Administration')
+ ." / ".$locale->text('Delete Dataset');
- print qq|
-<body class=admin>
+ $form->{login} = "root login";
+ $form->header;
+ print qq|
+ <body class="admin">
+ <h2>$form->{title}</h2>
+ <form method="post" action="$form->{script}" />
+ <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
+ <input type="hidden" name="dbuser" value="$form->{dbuser}" />
+ <input type="hidden" name="dbhost" value="$form->{dbhost}" />
+ <input type="hidden" name="dbport" value="$form->{dbport}" />
+ <input type="hidden" name="dbpasswd" value="$form->{dbpasswd}" />
+ <input type="hidden" name="dbdefault" value="$form->{dbdefault}" />
+ <input name=callback type="hidden" value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <input type="hidden" name="nextsub" value="dbdelete" />
+ <table width="100%">
+ <tr class="listheading">
+ <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
+ </tr>
+ <tr>
+ <td>
+ $dbsources
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <hr size="3" noshade />
+ <br />
+ <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </body>
+ </html>
+ |;
-<center>
-<h2>$form->{title}</h2>
+}
-<form method=post action=$form->{script}>
-$form->{db} |.$locale->text('successfully deleted!')
+sub dbdelete {
-.qq|
+ if (!$form->{db}) {
+ $form->error($locale->text('No Dataset selected!'));
+ }
-<input type=hidden name=path value="$form->{path}">
-<input type=hidden name=sessionid value=$form->{sessionid}>
+ User->dbdelete(\%$form);
-<input type=hidden name=nextsub value=list_users>
+ $form->{title} = "LedgerSMB ".$locale->text('Accounting')
+ ." ".$locale->text('Database Administration')
+ ." / ".$locale->text('Delete Dataset');
-<p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
-</form>
+ $form->{login} = "root login";
+ $form->header;
-
-</body>
-</html>
-|;
-
+ print qq|
+ <body class="admin">
+ <center>
+ <h2>$form->{title}</h2>
+ $form->{db} |.$locale->text('successfully deleted!')
+ .qq|
+ <form method="post" action="$form->{script}" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <input type="hidden" name="sessionid" value="$form->{sessionid}" />
+ <input type="hidden" name="nextsub" value="list_users" />
+ <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
+ </form>
+ </body>
+ </html>
+ |;
}
sub unlock_system {
- unlink "$userspath/nologin";
-
- $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
-
- $form->redirect($locale->text('Lockfile removed!'));
-
+ unlink "$userspath/nologin";
+ $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
+ $form->redirect($locale->text('Lockfile removed!'));
}
sub lock_system {
- open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
- close(FH);
-
- $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
-
- $form->redirect($locale->text('Lockfile created!'));
-
+ open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
+ close(FH);
+ $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
+ $form->redirect($locale->text('Lockfile created!'));
}
-
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.