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

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



Revision: 3149
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3149&view=rev
Author:   einhverfr
Date:     2011-05-22 19:15:33 +0000 (Sun, 22 May 2011)

Log Message:
-----------
Default email addresses etc tied into templates

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/Template.pm
    trunk/LedgerSMB.pm

Added Paths:
-----------
    trunk/LedgerSMB/Company_Config.pm

Added: trunk/LedgerSMB/Company_Config.pm
===================================================================
--- trunk/LedgerSMB/Company_Config.pm	                        (rev 0)
+++ trunk/LedgerSMB/Company_Config.pm	2011-05-22 19:15:33 UTC (rev 3149)
@@ -0,0 +1,57 @@
+=head1 NAME
+
+LedgerSMB::Company_Config    Company-specific Configuration for LedgerSMB
+
+=head1 SYNOPSIS
+
+This module stores the various company-specific configuration details for
+LedgerSMB
+
+=head1 METHODS
+
+=over 
+
+=item initialize()
+
+Initializes the $settings hashref.
+
+=back
+
+=head1 DATA
+
+All data is contained in the LedgerSMB::Company_Config::settings hashref.  
+These are defined by looking at the @company_settings list in the current 
+namespace (scope of which is 'my') and setting keys as expected.
+
+=head1 Copyright (C) 2006, The LedgerSMB core team.
+
+=cut
+
+package LedgerSMB::Company_Config;
+use strict;
+use base qw(LedgerSMB);
+use LedgerSMB::Setting;
+
+my @company_settings = qw(templates businessnumber weightunit curr
+                          default_email_from default_email_to
+                          default_email_bcc  default_email_cc
+                          separate_duties);
+
+our $VERSION = 0.1;
+our $settings = {};
+
+sub initialize{
+   my ($self) = @_;
+   for my $k (keys %$settings){
+       delete $settings->{$k};
+   }
+   for my $setting (@company_settings){
+       my ($ref) = LedgerSMB::call_procedure($self, procname => 'setting_get', 
+                  args => [$setting]);
+       if ($ref->{setting_key} eq 'curr'){
+          $settings->{$setting} = split /:/, $ref->{value};
+       } else {
+          $settings->{$setting} = $ref->{value};
+       }
+   }
+}

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2011-05-21 21:10:09 UTC (rev 3148)
+++ trunk/LedgerSMB/Form.pm	2011-05-22 19:15:33 UTC (rev 3149)
@@ -65,6 +65,7 @@
 use Time::Local;
 use Cwd;
 use File::Copy;
+use LedgerSMB::Company_Config;
 
 use charnames qw(:full);
 use open ':utf8';
@@ -1325,7 +1326,7 @@
         $sth->execute;
         ($self->{pw_expires})  = $sth->fetchrow_array;
     }
-
+    LedgerSMB::Company_Config::initialize($self);
     $sth->finish();
 }
 

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2011-05-21 21:10:09 UTC (rev 3148)
+++ trunk/LedgerSMB/Template.pm	2011-05-22 19:15:33 UTC (rev 3149)
@@ -131,6 +131,7 @@
 use Error qw(:try);
 use LedgerSMB::Sysconfig;
 use LedgerSMB::Mailer;
+use LedgerSMB::Company_Config;
 
 sub new {
 	my $class = shift;
@@ -363,6 +364,14 @@
 		@mailmime = ('contenttype', $self->{mimeytype});
 	}
 
+        # Default addresses
+        my $csettings = $LedgerSMB::Company_Config::settings;
+        $args->{from} ||= $csettings->{default_email_from};
+        $args->{to} ||= $csettings->{default_email_to};
+        $args->{cc} ||= $csettings->{default_email_cc};
+        $args->{bcc} ||= $csettings->{default_email_bcc};
+
+        # Mailer stuff
 	my $mail = new LedgerSMB::Mailer(
 		from => $args->{from} || $self->{user}->{email},
 		to => $args->{to},

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2011-05-21 21:10:09 UTC (rev 3148)
+++ trunk/LedgerSMB.pm	2011-05-22 19:15:33 UTC (rev 3149)
@@ -196,6 +196,7 @@
 use LedgerSMB::User;
 use LedgerSMB::Setting;
 use LedgerSMB::Log;
+use LedgerSMB::Company_Config;
 use strict;
 
 $CGI::Simple::POST_MAX = -1;
@@ -301,7 +302,9 @@
 
     $self->_db_init;
 
+    LedgerSMB::Company_Config::initialize($self);
 
+
     if ($self->is_run_mode('cgi', 'mod_perl')) {
        #check for valid session unless this is an inital authentication
        #request -- CT


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