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

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



Revision: 3813
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3813&view=rev
Author:   einhverfr
Date:     2011-10-07 23:50:23 +0000 (Fri, 07 Oct 2011)
Log Message:
-----------
Merging from branches/1.3

Modified Paths:
--------------
    trunk/LedgerSMB/Template/TXT.pm
    trunk/LedgerSMB/Template.pm
    trunk/UI/setup/new_user.html
    trunk/scripts/setup.pl

Property Changed:
----------------
    trunk/


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-3809
   + /branches/1.3:3711-3812

Modified: trunk/LedgerSMB/Template/TXT.pm
===================================================================
--- trunk/LedgerSMB/Template/TXT.pm	2011-10-07 23:46:20 UTC (rev 3812)
+++ trunk/LedgerSMB/Template/TXT.pm	2011-10-07 23:50:23 UTC (rev 3813)
@@ -45,9 +45,19 @@
 use Template;
 use LedgerSMB::Template::TTI18N;
 
+sub get_extension {
+    my ($parent) = shift;
+    if ($parent->{format_args}->{extension}){
+        return $parent->{format_args}->{extension};
+    } else {
+        return 'txt';
+    }
+}
+
 sub get_template {
-    my $name = shift;
-    return "${name}.txt";
+    my ($name, $parent) = @_;
+    my $extension;
+    return "${name}.". get_extension($parent);
 }
 
 sub preprocess {
@@ -61,9 +71,8 @@
 	my $template;
 	my $source;
 	my $output;
-
 	if ($parent->{outputfile}) {
-		$output = "$parent->{outputfile}.txt";
+		$output = "$parent->{outputfile}.". get_extension($parent);
 	} else {
 		$output = \$parent->{output};
 	}
@@ -72,7 +81,7 @@
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};
 	} else {
-		$source = get_template($parent->{template});
+		$source = get_template($parent->{template}, $parent);
 	}
 	$template = Template->new({
 		INCLUDE_PATH => $parent->{include_path},
@@ -95,7 +104,7 @@
 
 sub postprocess {
     my $parent = shift;
-    $parent->{rendered} = "$parent->{outputfile}.txt" if $parent->{outputfile};
+    $parent->{rendered} = "$parent->{outputfile}.". get_extension($parent) if $parent->{outputfile};
     return $parent->{rendered};
 }
 

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2011-10-07 23:46:20 UTC (rev 3812)
+++ trunk/LedgerSMB/Template.pm	2011-10-07 23:50:23 UTC (rev 3813)
@@ -302,6 +302,7 @@
         for ( keys %args ) { $self->{output_args}->{$_} = $args{$_}; };
 
 	my $method = $self->{method} || $args{method} || $args{media};
+        $method = '' if !defined $method;
 	if ('email' eq lc $method) {
 		$self->_email_output;
 	} elsif ('print' eq lc $method) {

Modified: trunk/UI/setup/new_user.html
===================================================================
--- trunk/UI/setup/new_user.html	2011-10-07 23:46:20 UTC (rev 3812)
+++ trunk/UI/setup/new_user.html	2011-10-07 23:50:23 UTC (rev 3813)
@@ -11,6 +11,9 @@
    value = database
 } ?>
 <div class="form">
+<?lsmb- IF notice -?>
+<div class="notice"><?lsmb notice ?></div>
+<?lsmb- END # IF notice -?>
 <div class="input_row">
 <?lsmb INCLUDE input element_data = {
                             name  = 'username'

Modified: trunk/scripts/setup.pl
===================================================================
--- trunk/scripts/setup.pl	2011-10-07 23:46:20 UTC (rev 3812)
+++ trunk/scripts/setup.pl	2011-10-07 23:50:23 UTC (rev 3813)
@@ -480,7 +480,32 @@
                                    $creds->{password});
     $request->{dbh}->{AutoCommit} = 0;
     my $user = LedgerSMB::DBObject::Admin->new({base => $request});
-    $user->save_user;
+    if (8 == $user->save_user){ # Told not to import but user exists in db
+        $request->{notice} = $request->{_locale}->text(
+                       'User already exists. Import?'
+        );
+
+
+       @{$request->{salutations}} 
+        = $request->call_procedure(procname => 'person__list_salutations' ); 
+          
+       @{$request->{countries}} 
+        = $request->call_procedure(procname => 'location_list_country' ); 
+
+       my $locale = $request->{_locale};
+
+       @{$request->{perm_sets}} = (
+           {id => '0', label => $locale->text('Manage Users')},
+           {id => '1', label => $locale->text('Full Permissions')},
+       );
+        my $template = LedgerSMB::Template->new(
+                path => 'UI/setup',
+                template => 'new_user',
+         format => 'HTML',
+        );
+        $template->render($request);
+        exit;        
+    }
     if ($request->{perms} == 1){
          for my $role (
                 $request->call_procedure(procname => 'admin__get_roles')
@@ -537,14 +562,33 @@
     $dbh->do('CREATE SCHEMA PUBLIC');
 
     $database->load_modules('LOADORDER');
+    $database->process_roles('Roles.sql');
     my $dbtemplate = LedgerSMB::Template->new(
         user => {}, 
-        template => 'sql/upgrade/1.2-1.3.sql',
+        path => 'sql/upgrade',
+        template => '1.2-1.3',
         no_auto_output => 1,
-        format => 'text' );
+        format_options => {extension => 'sql'},
+        output_file => '1.2-1.3-upgrade',
+        format => 'TXT' );
     $dbtemplate->render($request);
-    $rc2 = system("psql -f $dbtemplate->{rendered} >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
+    $rc2 = system("psql -f $temp/1.2-1.3-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
     $rc ||= $rc2;
+
+    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+
+   @{$request->{salutations}} 
+    = $request->call_procedure(procname => 'person__list_salutations' ); 
+          
+   @{$request->{countries}} 
+    = $request->call_procedure(procname => 'location_list_country' ); 
+
+   my $locale = $request->{_locale};
+
+   @{$request->{perm_sets}} = (
+       {id => '0', label => $locale->text('Manage Users')},
+       {id => '1', label => $locale->text('Full Permissions')},
+   );
     my $template = LedgerSMB::Template->new(
                    path => 'UI/setup',
                    template => 'new_user',

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