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

SF.net SVN: ledger-smb:[6753] branches/1.3/LedgerSMB/Database.pm



Revision: 6753
          http://sourceforge.net/p/ledger-smb/code/6753
Author:   einhverfr
Date:     2014-02-05 09:51:47 +0000 (Wed, 05 Feb 2014)
Log Message:
-----------
Correcting bug 954.  Rebuilding copied db causes permission denied errors.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/Database.pm

Modified: branches/1.3/LedgerSMB/Database.pm
===================================================================
--- branches/1.3/LedgerSMB/Database.pm	2014-02-05 09:37:07 UTC (rev 6752)
+++ branches/1.3/LedgerSMB/Database.pm	2014-02-05 09:51:47 UTC (rev 6753)
@@ -596,12 +596,30 @@
 
 sub process_roles {
     my ($self, $rolefile) = @_;
+    my $company = $self->{company_name};
 
+    # DB connection logic below somewhat obtuse but only used for 1.3
+    # since 1.4 no longer needs special processing for Roles.sql.
+    # This prevents connection leakage though.
+
+    my $dbh = $LedgerSMB::App_State::DBH;
+    $dbh = DBI->connect(
+        qq|dbi:Pg:dbname="$self->{company_name}"|,
+         $self->{username}, $self->{password},
+         { AutoCommit => 0, PrintError => $logger->is_warn(), }
+    ) unless $dbh; 
+    $LedgerSMB::App_State::DBH = $dbh unless $LedgerSMB::App_State::DBH;
+
+    my $prefix = LedgerSMB::Setting->get('role_prefix');
+    $prefix =~ s/^lsmb_//;
+    $prefix =~ s/__$//;
+    $company = $prefix if $prefix;
+
     open (ROLES, '<', "sql/modules/$rolefile");
     open (TROLES, '>', "$temp/lsmb_roles.sql");
 
     for my $line (<ROLES>){
-        $line =~ s/<\?lsmb dbname \?>/$self->{company_name}/;
+        $line =~ s/<\?lsmb dbname \?>/$company/;
         print TROLES $line;
     }
 

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


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits