Project

General

Profile

Defect #1379 » environment.rb

Lee Taylor, 2008-06-04 22:30

 
1
# Be sure to restart your web server when you modify this file.
2

    
3
# Uncomment below to force Rails into production mode when 
4
# you don't control web/app server and can't set it the proper way
5
 ENV['RAILS_ENV'] ||= 'production'
6

    
7
# Specifies gem version of Rails to use when vendor/rails is not present
8
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
9

    
10
# Bootstrap the Rails environment, frameworks, and default configuration
11
require File.join(File.dirname(__FILE__), 'boot')
12

    
13
# Load Engine plugin if available
14
begin
15
  require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')
16
rescue LoadError
17
  # Not available
18
end
19

    
20
Rails::Initializer.run do |config|
21
  # Settings in config/environments/* take precedence those specified here
22
  
23
  # Skip frameworks you're not going to use
24
  # config.frameworks -= [ :action_web_service, :action_mailer ]
25

    
26
  # Add additional load paths for sweepers
27
  config.load_paths += %W( #{RAILS_ROOT}/app/sweepers )
28

    
29
  # Force all environments to use the same logger level 
30
  # (by default production uses :info, the others :debug)
31
  # config.log_level = :debug
32

    
33
  # Use the database for sessions instead of the file system
34
  # (create the session table with 'rake create_sessions_table')
35
  # config.action_controller.session_store = :active_record_store
36
  config.action_controller.session_store = :PStore
37

    
38
  # Enable page/fragment caching by setting a file-based store
39
  # (remember to create the caching directory and make it readable to the application)
40
  # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
41
  
42
  # Activate observers that should always be running
43
  # config.active_record.observers = :cacher, :garbage_collector
44
  config.active_record.observers = :message_observer
45

    
46
  # Make Active Record use UTC-base instead of local time
47
  # config.active_record.default_timezone = :utc
48
  
49
  # Use Active Record's schema dumper instead of SQL when creating the test database
50
  # (enables use of different database adapters for development and test environments)
51
  # config.active_record.schema_format = :ruby
52

    
53
  # See Rails::Configuration for more options
54
  
55
	# SMTP server configuration
56
	config.action_mailer.smtp_settings = {
57
		:address => '127.0.0.1',
58
		:port => 25,
59
		:domain => 'eliasinteractive.com',
60
		:pop3_auth => { 
61
			:server => 'mail.eliasinteractive.com', 
62
			:user_name => 'redmine@eliasinteractive.com', 
63
			:password => 'OUR_PASSWORD',
64
			:authentication => :login
65
 		   }
66
	}
67
	
68
	config.action_mailer.perform_deliveries = true
69

    
70
	# Tell ActionMailer not to deliver emails to the real world.
71
	# The :test delivery method accumulates sent emails in the
72
	# ActionMailer::Base.deliveries array.
73
	#config.action_mailer.delivery_method = :test
74
	config.action_mailer.delivery_method = :smtp  
75

    
76
end
77

    
78
ActiveRecord::Errors.default_error_messages = {
79
  :inclusion => "activerecord_error_inclusion",
80
  :exclusion => "activerecord_error_exclusion",
81
  :invalid => "activerecord_error_invalid",
82
  :confirmation => "activerecord_error_confirmation",
83
  :accepted  => "activerecord_error_accepted",
84
  :empty => "activerecord_error_empty",
85
  :blank => "activerecord_error_blank",
86
  :too_long => "activerecord_error_too_long",
87
  :too_short => "activerecord_error_too_short",
88
  :wrong_length => "activerecord_error_wrong_length",
89
  :taken => "activerecord_error_taken",
90
  :not_a_number => "activerecord_error_not_a_number"
91
}
92

    
93
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
94

    
95
Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)
96
Mime::Type.register 'application/pdf', :pdf
97

    
98
GLoc.set_config :default_language => :en
99
GLoc.clear_strings
100
GLoc.set_kcode
101
GLoc.load_localized_strings
102
GLoc.set_config(:raise_string_not_found_errors => false)
103

    
104
require 'redmine'
105

    
106

    
107
if ActionMailer::Base.delivery_method == :smtp and ActionMailer::Base.smtp_settings.has_key?(:pop3_auth)
108
    class ActionMailer::Base
109

    
110
      alias_method :base_perform_delivery_smtp, :perform_delivery_smtp
111

    
112
      @@pop3_auth_done = nil
113

    
114
      private
115

    
116
      def perform_delivery_smtp(mail)
117
        do_pop_auth if !@@pop3_auth_done or (Time.now - smtp_settings[:pop3_auth][:expires]) >= @@pop3_auth_done
118
        base_perform_delivery_smtp(mail)
119
      end
120

    
121
      # Implementacion de la autenticacion
122
      def do_pop_auth
123
        require 'net/pop'
124
        pop = Net::POP3.new(smtp_settings[:pop3_auth][:server])
125
        pop.start(smtp_settings[:pop3_auth][:user_name], smtp_settings[:pop3_auth][:password])
126
        @@pop3_auth_done = Time.now
127
        pop.finish
128
      end
129
    end
130
  end
(1-1/2)