[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3653] trunk



Revision: 3653
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3653&view=rev
Author:   einhverfr
Date:     2011-08-15 22:23:21 +0000 (Mon, 15 Aug 2011)

Log Message:
-----------

Database management console now creates databases, but does not yet load charts of accounts, or create admin users
Removed obsolete code from LedgerSMB/Sysconfig.pm
Added language handler for screens with no attached user

Modified Paths:
--------------
    trunk/LedgerSMB/Database.pm
    trunk/LedgerSMB/Sysconfig.pm
    trunk/UI/setup/confirm_operation.html
    trunk/UI/setup/credentials.html
    trunk/ledgersmb.conf.default
    trunk/lsmb-request.pl
    trunk/scripts/setup.pl

Added Paths:
-----------
    trunk/UI/setup/login.js
    trunk/UI/setup/stylesheet.css

Modified: trunk/LedgerSMB/Database.pm
===================================================================
--- trunk/LedgerSMB/Database.pm	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/LedgerSMB/Database.pm	2011-08-15 22:23:21 UTC (rev 3653)
@@ -205,6 +205,7 @@
        my $sth;
        # Legacy SL and LSMB
        $sth = $dbh->prepare('SELECT version FROM defaults');
+       $sth->execute();
        if (my ($ref) = $sth->fetchrow_hashref('NAME_lc')){
            $retval->{appname} = 'ledgersmb';
            $retval->{version} = 'legacy';

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/LedgerSMB/Sysconfig.pm	2011-08-15 22:23:21 UTC (rev 3653)
@@ -135,27 +135,6 @@
     ${$var} = $config{mail}{$var} if $config{mail}{$var};
 }
 
-# We used to have a global dbconnect but have moved to single entries
-for my $var (qw(DBhost DBport DBname DBUserName DBPassword)) {
-    ${ "global" . $var } = $config{globaldb}{$var} if $config{globaldb}{$var};
-}
-
-#putting this in an if clause for now so not to break other devel users
-#if ( $config{globaldb}{DBname} ) {
-#    my $dbconnect = "dbi:Pg:dbname=$globalDBname host=$globalDBhost
-#		port=$globalDBport user=$globalDBUserName
-#		password=$globalDBPassword";    # for easier debugging
-#    $GLOBALDBH = DBI->connect($dbconnect);
-#    if ( !$GLOBALDBH ) {
-#        $form = new Form;
-#        $form->error("No GlobalDBH Configured or Could not Connect");
-#    }
-#    $GLOBALDBH->{pg_enable_utf8} = 1;
-#}
-
-# These lines prevent other apps in mod_perl from seeing the global db
-# connection info
-
 # Log4perl configuration
 our $log4perl_config = qq(
     log4perl.rootlogger = $log_level, Screen, Basic
@@ -190,4 +169,6 @@
 our $default_db = $config{database}{default_db};
 our $db_namespace = $config{database}{db_namespace} || 'public';
 $ENV{PGSSLMODE} = $config{database}{sslmode} if $config{database}{sslmode};
+$ENV{PG_CONTRIB_DIR} = $config{database}{contrib_dir};
+
 1;

Modified: trunk/UI/setup/confirm_operation.html
===================================================================
--- trunk/UI/setup/confirm_operation.html	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/UI/setup/confirm_operation.html	2011-08-15 22:23:21 UTC (rev 3653)
@@ -1,8 +1,11 @@
-<?lsmb INCLUDE "ui-header.html" stylesheet="UI/setup/stylesheet.css" ?>
+<?lsmb INCLUDE "ui-header.html" 
+stylesheet="ledgersmb.css"
+include_stylesheet=["UI/setup/stylesheet.css"] ?>
 <?lsmb PROCESS elements.html ?>
 <body>
 <div class="listtop"><?lsmb text('Confirm Operation') ?></div>
 <div id="notice"><?lsmb notice ?></div>
+<div id="message"><?lsmb message ?></div>
 <div id="operation"><?lsmb operation ?></div>
 <form action="setup.pl" method="POST" name="confirm_operation">
 <?lsmb INCLUDE input element_data = {
@@ -10,7 +13,7 @@
     type = 'hidden'
    value = database
 } ?>
-<div class="inputrow">
+<div class="inputrow" id="yesno">
 <?lsmb 
 INCLUDE input element_data = {
     name = 'confirm'

Modified: trunk/UI/setup/credentials.html
===================================================================
--- trunk/UI/setup/credentials.html	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/UI/setup/credentials.html	2011-08-15 22:23:21 UTC (rev 3653)
@@ -1,10 +1,14 @@
-<?lsmb INCLUDE "ui-header.html" stylesheet="UI/setup/stylesheet.css" ?>
+<?lsmb INCLUDE "ui-header.html" 
+stylesheet="ledgersmb.css"
+include_stylesheet=["UI/setup/stylesheet.css"]
+include_script = ['UI/setup/login.js', 'UI/util.js'] ?>
 <?lsmb PROCESS elements.html ?>
-<body>
+<body onLoad="init()">
+<h2><?lsmb text('Database Management Console') ?></h2>
 <div class="listtop"><?lsmb text('Superuser Credentials') ?></div>
-<form action="setup.pl" method="POST" name="credentials">
+<form action="setup.pl" id="loginform" method="POST" name="credentials">
 <div class="login_form">
-<div class="userpass">
+<div id="userpass">
 <div class="inputrow">
 <?lsmb IF !s_user; s_user = 'postgres'; END;
 INCLUDE input element_data = {

Added: trunk/UI/setup/login.js
===================================================================
--- trunk/UI/setup/login.js	                        (rev 0)
+++ trunk/UI/setup/login.js	2011-08-15 22:23:21 UTC (rev 3653)
@@ -0,0 +1,24 @@
+function submit_form() {
+	var http = get_http_request_object();
+        var username = document.getElementById('s-user').value;
+	var password = document.getElementById('s-password').value;
+	http.open("get", 'login.pl?action=authenticate&company=template1',
+		false, username, password);
+	http.send("");
+        if (http.status != 200){
+                if (http.status != '454'){
+  		     alert("Access Denied:  Bad username/Password");
+                } else {
+                     alert('Company does not exist.');
+                }
+		return false;
+	}
+	document.location = "setup.pl?action=login&company="+
+		document.credentials.database.value;
+}
+
+function init() {
+    document.getElementById('userpass').style.display = 'block';
+    document.getElementById('loginform').addEventListener('submit', 
+           function () {submit_form()}, false);
+}

Added: trunk/UI/setup/stylesheet.css
===================================================================
--- trunk/UI/setup/stylesheet.css	                        (rev 0)
+++ trunk/UI/setup/stylesheet.css	2011-08-15 22:23:21 UTC (rev 3653)
@@ -0,0 +1,56 @@
+div.login {
+    background-color: white;
+    margin-right: auto;
+    margin-left: auto;
+    width: 25em;
+    padding: 2em;
+    padding-bottom: 2em;
+    border-style: outset;
+}
+
+div {
+    overflow: auto;
+}
+
+#yesno label {
+    width: 2em
+}
+
+#userpass {
+    display: none
+}
+
+
+label {
+    width: 10em;
+    text-align: right;
+    float: left;
+    border-width: 1px;
+    margin: 0em;
+    padding-right: 0.5em;
+    margin-top: 0.5em;
+}
+input {
+    width: 14em;
+    margin: 0px;
+    text-align: left;
+    float: left;
+    border-width: 3px;
+    margin: 0em;
+    margin-top: 0.5em;
+}
+
+#yesno input {
+    width: 1em;
+    margin-right: 3em;
+}
+
+img.logo {
+    border-style: none;
+    width: 16em;
+    height: 8em;
+}
+
+button {
+    margin-top: 10px;
+}

Modified: trunk/ledgersmb.conf.default
===================================================================
--- trunk/ledgersmb.conf.default	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/ledgersmb.conf.default	2011-08-15 22:23:21 UTC (rev 3653)
@@ -76,5 +76,6 @@
 default_db = lsmb13
 host = localhost
 db_namespace = public
+contrib_dir = /usr/share/pgsql/contrib/
 # sslmode can be require, allow, prefer, or disable.  Defaults to prefer.
 sslmode = prefer

Modified: trunk/lsmb-request.pl
===================================================================
--- trunk/lsmb-request.pl	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/lsmb-request.pl	2011-08-15 22:23:21 UTC (rev 3653)
@@ -58,6 +58,8 @@
 	$request->error($locale->text('No workflow script specified'));
 }
 
+$request->{_locale} = $locale;
+
 $logger->debug("calling $script");
 
 &call_script( $script, $request );

Modified: trunk/scripts/setup.pl
===================================================================
--- trunk/scripts/setup.pl	2011-08-10 04:44:17 UTC (rev 3652)
+++ trunk/scripts/setup.pl	2011-08-15 22:23:21 UTC (rev 3653)
@@ -41,11 +41,13 @@
 =cut
 
 sub login {
+    use LedgerSMB::Locale;
     my ($request) = @_;
+    $request->{_locale}->new('en');
     my $creds = LedgerSMB::Auth::get_credentials();
     my $database = LedgerSMB::Database->new(
-               {username => $creds->{username}
-            company_name => $request->{company_name}
+               {username => $creds->{username},
+            company_name => $request->{database},
                 password => $creds->{password}}
     );
     my $version_info = $database->get_info();
@@ -93,7 +95,7 @@
          }
     } elsif (!$version_info->{exists}){
         $request->{message} = $request->{_locale}->text(
-             'Database does not exist.'
+             'Database does not exist.');
         $request->{operation} = $request->{_locale}->text('Create Database?');
         $request->{next_action} = 'create_db';
     } else {
@@ -122,8 +124,8 @@
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials();
     my $database = LedgerSMB::Database->new(
-               {username => $creds->{username}
-            company_name => $request->{company_name}
+               {username => $creds->{username},
+            company_name => $request->{database},
                 password => $creds->{password}}
     );
 }
@@ -138,8 +140,8 @@
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials();
     my $database = LedgerSMB::Database->new(
-               {username => $creds->{username}
-            company_name => $request->{company_name}
+               {username => $creds->{username},
+            company_name => $request->{database},
                 password => $creds->{password}}
     );
 }
@@ -151,11 +153,15 @@
 =cut
 
 sub create_db{
+    use LedgerSMB::Sysconfig;
     my ($request) = @_;
     my $creds = LedgerSMB::Auth::get_credentials();
+    $ENV{PGUSER} = $creds->{login};
+    $ENV{PGPASSWORD} = $creds->{password};
+    $ENV{PGDATABASE} = $request->{database};
     my $database = LedgerSMB::Database->new(
-               {username => $creds->{username}
-            company_name => $request->{company_name}
+               {username => $creds->{login},
+            company_name => $request->{database},
                 password => $creds->{password}}
     );
     $database->create_and_load();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.