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

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



Revision: 4945
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4945&view=rev
Author:   einhverfr
Date:     2012-06-22 08:09:40 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
Resolving auth conflict between setup.pl and main app

Modified Paths:
--------------
    trunk/LedgerSMB/Auth/DB.pm
    trunk/LedgerSMB/Auth.pm
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/UI/setup/complete.html
    trunk/sql/modules/trial_balance.sql

Modified: trunk/LedgerSMB/Auth/DB.pm
===================================================================
--- trunk/LedgerSMB/Auth/DB.pm	2012-06-22 07:35:32 UTC (rev 4944)
+++ trunk/LedgerSMB/Auth/DB.pm	2012-06-22 08:09:40 UTC (rev 4945)
@@ -62,7 +62,8 @@
 =cut
 
 sub credential_prompt{
-    http_error(401);
+    my ($suffix) = @_;
+    http_error(401, $suffix);
 }
 
 sub password_check { # Old routine, leaving in at the moment

Modified: trunk/LedgerSMB/Auth.pm
===================================================================
--- trunk/LedgerSMB/Auth.pm	2012-06-22 07:35:32 UTC (rev 4944)
+++ trunk/LedgerSMB/Auth.pm	2012-06-22 08:09:40 UTC (rev 4945)
@@ -93,6 +93,12 @@
     # but this doesn't seem to be working.  Although it is generally desirable
     # to create the headers using the package, I think we should print them
     # manually.  -CT
+    if ($errcode eq '401'){
+        if ($msg_plus eq 'setup'){
+           $err->{'401'}->{others}->{'WWW-Authenticate'}
+                = "Basic realm=\"LedgerSMB-$msg_plus\"";
+        }
+    }
     my $status;
     if ($err->{$errcode}->{status}){
         $status = $err->{$errcode}->{status};

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2012-06-22 07:35:32 UTC (rev 4944)
+++ trunk/LedgerSMB/Scripts/setup.pm	2012-06-22 08:09:40 UTC (rev 4945)
@@ -50,7 +50,7 @@
     use LedgerSMB::Locale;
     my ($request) = @_;
     $logger->trace("\$request=$request \$request->{dbh}=$request->{dbh} request=".Data::Dumper::Dumper(\$request));
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     if (!$request->{database}){
         $request->error($request->{_locale}->text('No database specified'));
     }
@@ -180,7 +180,7 @@
 sub run_backup {
     use LedgerSMB::Company_Config;
 
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $request = shift @_;
 
     my $database = LedgerSMB::Database->new(
@@ -255,7 +255,7 @@
 
 sub migrate_sl{
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $database = LedgerSMB::Database->new(
                {username => $creds->{login},
             company_name => $request->{database},
@@ -331,7 +331,7 @@
 
 sub upgrade{
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $database = LedgerSMB::Database->new(
                {username => $creds->{login},
             company_name => $request->{database},
@@ -475,7 +475,7 @@
 
 sub fix_tests{
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     # ENVIRONMENT NECESSARY
     $ENV{PGUSER} = $creds->{login};
     $ENV{PGPASSWORD} = $creds->{password};
@@ -510,7 +510,7 @@
 sub create_db{
     use LedgerSMB::Sysconfig;
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $rc=0;
 
 
@@ -633,7 +633,7 @@
     # here in order to avoid creating objects just to get argument
     # mapping going. --CT
 
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     
     # ENVIRONMENT NECESSARY
     $ENV{PGUSER} = $creds->{login};
@@ -685,7 +685,7 @@
     use LedgerSMB::DBObject::Entity::Person::Employee;
     use LedgerSMB::DBObject::Entity::User;
     use LedgerSMB::PGDate;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",
                                    $creds->{login},
                                    $creds->{password});
@@ -760,7 +760,7 @@
 
 sub run_upgrade {
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $database = LedgerSMB::Database->new(
                {username => $creds->{login},
             company_name => $request->{database},
@@ -836,7 +836,7 @@
 
 sub rebuild_modules {
     my ($request) = @_;
-    my $creds = LedgerSMB::Auth::get_credentials();
+    my $creds = LedgerSMB::Auth::get_credentials('setup');
     my $database = LedgerSMB::Database->new(
                {username => $creds->{login},
             company_name => $request->{database},

Modified: trunk/UI/setup/complete.html
===================================================================
--- trunk/UI/setup/complete.html	2012-06-22 07:35:32 UTC (rev 4944)
+++ trunk/UI/setup/complete.html	2012-06-22 08:09:40 UTC (rev 4945)
@@ -1,7 +1,10 @@
 <?lsmb INCLUDE "ui-header.html" 
 stylesheet="ledgersmb.css"
 include_stylesheet=["UI/setup/stylesheet.css"]
-include_script = ['UI/setup/login.js', 'UI/util.js'] ?>
+include_script = ['UI/setup/login.js', 'UI/util.js', 'UI/logout/epiphany.js',   
+                  'UI/setup/iexplore.js',   'UI/setup/opera.js',
+                  'UI/setup/firefox.js',    'UI/setup/konqueror.js',  
+                  'UI/setup/safari.js' ] ?>
 <?lsmb PROCESS elements.html ?>
 <body>
 <h2><?lsmb text('Database Management Console') ?></h2>

Modified: trunk/sql/modules/trial_balance.sql
===================================================================
--- trunk/sql/modules/trial_balance.sql	2012-06-22 07:35:32 UTC (rev 4944)
+++ trunk/sql/modules/trial_balance.sql	2012-06-22 08:09:40 UTC (rev 4945)
@@ -22,7 +22,7 @@
 
 CREATE OR REPLACE FUNCTION trial_balance__generate 
 (in_date_from DATE, in_date_to DATE, in_heading INT, in_accounts INT[],
- in_ignore_yearend TEXT, in_department INT) 
+ in_ignore_yearend TEXT, in_department INT, in_business_units int[]) 
 returns setof tb_row AS
 $$
 DECLARE
@@ -80,17 +80,33 @@
 
     RETURN QUERY
        WITH ac (transdate, amount, chart_id) AS (
+           WITH RECURSIVE bu_tree (id, path) AS (
+            SELECT id, id::text AS path
+              FROM business_unit
+             WHERE parent_id = any(in_business_units)
+                   OR (parent_id = IS NULL 
+                       AND (in_business_units = '{}' 
+                             OR in_business_units IS NULL))
+            UNION
+            SELECT bu.id, bu_tree.path || ',' || bu.id
+              FROM business_unit bu
+              JOIN bu_tree ON bu_tree.id = bu.parent_id
+            )
        SELECT ac.transdate, ac.amount, ac.chart_id
          FROM acc_trans ac
          JOIN (SELECT id, approved, department_id FROM ar UNION ALL
                SELECT id, approved, department_id FROM ap UNION ALL
                SELECT id, approved, department_id FROM gl) gl
                    ON ac.approved and gl.approved and ac.trans_id = gl.id
+    LEFT JOIN business_unit_ac buac ON ac.entry_id = buac.entry_id
+    LEFT JOIN bu_tree ON buac.bu_id = bu_tree.id
         WHERE ac.transdate BETWEEN t_roll_forward + '1 day'::interval 
                                     AND t_end_date
               AND ac.trans_id <> ALL(ignore_trans)
               AND (in_department is null 
                  or gl.department_id = in_department)
+              ((in_business_units = '{}' OR in_business_units IS NULL)
+                OR bu_tree.id IS NOT NULL)
        )
        SELECT a.id, a.accno, a.description, a.gifi_accno,
          case when in_date_from is null then 0 else

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