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

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



Revision: 2748
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2748&view=rev
Author:   einhverfr
Date:     2009-08-07 15:41:41 +0000 (Fri, 07 Aug 2009)

Log Message:
-----------
Initiate.pl now mostly works-- still needs role/admin user creation

Modified Paths:
--------------
    trunk/LedgerSMB/Initiate.pm
    trunk/bin/initiate.pl

Modified: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm	2009-08-07 15:41:03 UTC (rev 2747)
+++ trunk/LedgerSMB/Initiate.pm	2009-08-07 15:41:41 UTC (rev 2748)
@@ -4,7 +4,7 @@
 
 package LedgerSMB::Initiate;
 use LedgerSMB::Sysconfig;
-use LedgerSMB::Auth::DB;
+use LedgerSMB::Auth;
 use LedgerSMB::Locale;
 use Data::Dumper;
 use DBI;
@@ -73,26 +73,27 @@
 
  if($form->{initiateon}==1)
  {
-   $database = $form->{company};
-   $host=$form->{host};
-   $port=$form->{port};
+   $ENV{PGDATABASE} = $form->{company};
+   $ENV{PGHOST}=$form->{host};
+   $ENV{PGPORT}=$form->{port};
    $username=$form->{username};
    $password=$form->{password};
+   $ENV{PGUSER} = $form->{username};
+   $ENV{PGPASSWORD} = $form->{password};
  }
  else
  {
 
-    $database=$form->{database};
-    $host=$form->{dbhost};
-    $port=$form->{dbport};
+    $ENV{PGDATABASE}=$form->{database};
+    $ENV{PGHOST}=$form->{dbhost};
+    $ENV{PGPORT}=$form->{dbport};
     $username=$form->{username};
     $password=$form->{password};
 
  }
   
 
-   my $dbconnect = "dbi:Pg:dbname=$database host=$host
-		port=$port user=$username password=$password";    # for easier debugging
+   my $dbconnect = "dbi:Pg:user=$username password=$password";    # for easier debugging
 
    my $dbh = DBI->connect($dbconnect) or return "no999";
 
@@ -137,7 +138,7 @@
        $dir =~s/\/[\w\d\.]*$/\/sql\/coa\//;   # 2nd way is store path of coa in sysconfig file
 
 
-	my @dir=LedgerSMB::Initiate->read_directory($form,$dir);
+	my @dir= sort LedgerSMB::Initiate->read_directory($form,$dir);
 
         my @allcodes = grep !/\.+/,@dir;
 
@@ -185,27 +186,6 @@
 
    
 
-    $form->error( __FILE__ . ':' . __LINE__ . ': '
-          . $locale->text('Database Host Missing!') )
-
-      unless $form->{dbhost};
-
-    $form->{dbport}=~s/ //g;
-    $form->error( __FILE__ . ':' . __LINE__ . ': '
-          . $locale->text('Database Port Number Missing!') )
-      unless $form->{dbport};
-   
-
-   
-    $invalid=($form->{dbport}=~m/^\d{4}$/);
-
-   
-    $form->error( __FILE__ . ':' . __LINE__ . ': '
-          . $locale->text('Invalid Database Port Number!') )
-      unless $invalid;
-
-
-
     $form->{contribpath}=~s/ //g;
 
     $form->error( __FILE__ . ':' . __LINE__ . ': '
@@ -276,7 +256,6 @@
 
 		# Now all the files are found now start execution process(Stages)
 
-
 		#Stage 1 -   Create the databse $form->{database}
 
 		LedgerSMB::Initiate->create_database($form,$form->{dbh},$form->{database},$form->{username}); 
@@ -291,11 +270,7 @@
 
 		#Stage -  Wind up completed the task
 
-		$form->error( __FILE__ . ':' . __LINE__ . ': '
-				  . $locale->text("under construction database/language created successfully"));
 
-		exit;
-
 						
 
 }
@@ -324,7 +299,7 @@
 	
 	my $newdbh=$form->{newdbh};
 
-         system("");
+         system("psql < $dbfile");
 }
 
 
@@ -410,6 +385,9 @@
 	#Check contrib files exist at particular directory else through an error
 
 	$dir = $form->{contribpath};
+        if ($dir !~ /\/$/){
+		$dir = "$dir/";
+	}
 
         $locale=$form->{locale};
  
@@ -499,7 +477,7 @@
 	open(ORD, '<', $dir . "LOADORDER");
 	while (my $line = <ORD>){
 		$line =~ s/\#.*$//; # ignore comments
-		next if $line ~= /^\s*$/;
+		next if $line =~ /^\s*$/;
 		$line =~ s/^\s*//;
 		$line =~ s/\s*$//;
 		push @dest, $dir.$line;

Modified: trunk/bin/initiate.pl
===================================================================
--- trunk/bin/initiate.pl	2009-08-07 15:41:03 UTC (rev 2747)
+++ trunk/bin/initiate.pl	2009-08-07 15:41:41 UTC (rev 2748)
@@ -3,7 +3,7 @@
 use LedgerSMB::Locale;
 use LedgerSMB::User;
 use LedgerSMB::Initiate;
-use LedgerSMB::Auth::DB;
+use LedgerSMB::Auth;
 
 #use LedgerSMB::Session;
 
@@ -70,9 +70,9 @@
 sub check_password {
 
 
-	my $auth_temp=LedgerSMB::Auth::DB->get_credentials();
+	my $auth_temp=LedgerSMB::Auth->get_credentials();
 
-        LedgerSMB::Auth::DB->credential_prompt unless($auth_temp);
+        LedgerSMB::Auth->credential_prompt unless($auth_temp);
 
         $form->{'login'}=$auth_temp->{'login'};
 
@@ -87,7 +87,7 @@
 	$form->{dbh}=$root->getdbh($form);   # get the connection if user exist as superuser
 
 	if ( lc($form->{dbh}) eq "no999" or !$root->checksuperuser($form)) {
-            LedgerSMB::Auth::DB->credential_prompt;
+            LedgerSMB::Auth->credential_prompt;
             exit;
         }
     
@@ -166,7 +166,7 @@
    
    #$form->redirect( $locale->text('successfully logged Out') );
    
-   LedgerSMB::Auth::DB->credential_prompt;
+   LedgerSMB::Auth->credential_prompt;
 
 }
 


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