annotate .svn/pristine/e7/e76e8f98c28f6f04d88e216206ea726d39535175.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents e248c7af89ec
children
rev   line source
Chris@1494 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1494 3 #
Chris@1494 4 # This program is free software; you can redistribute it and/or
Chris@1494 5 # modify it under the terms of the GNU General Public License
Chris@1494 6 # as published by the Free Software Foundation; either version 2
Chris@1494 7 # of the License, or (at your option) any later version.
Chris@1494 8 #
Chris@1494 9 # This program is distributed in the hope that it will be useful,
Chris@1494 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1494 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1494 12 # GNU General Public License for more details.
Chris@1494 13 #
Chris@1494 14 # You should have received a copy of the GNU General Public License
Chris@1494 15 # along with this program; if not, write to the Free Software
Chris@1494 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1494 17
Chris@1494 18 module Redmine
Chris@1494 19 module Configuration
Chris@1494 20
Chris@1494 21 # Configuration default values
Chris@1494 22 @defaults = {
Chris@1494 23 'email_delivery' => nil,
Chris@1494 24 'max_concurrent_ajax_uploads' => 2
Chris@1494 25 }
Chris@1494 26
Chris@1494 27 @config = nil
Chris@1494 28
Chris@1494 29 class << self
Chris@1494 30 # Loads the Redmine configuration file
Chris@1494 31 # Valid options:
Chris@1494 32 # * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml)
Chris@1494 33 # * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env)
Chris@1494 34 def load(options={})
Chris@1494 35 filename = options[:file] || File.join(Rails.root, 'config', 'configuration.yml')
Chris@1494 36 env = options[:env] || Rails.env
Chris@1494 37
Chris@1494 38 @config = @defaults.dup
Chris@1494 39
Chris@1494 40 load_deprecated_email_configuration(env)
Chris@1494 41 if File.file?(filename)
Chris@1494 42 @config.merge!(load_from_yaml(filename, env))
Chris@1494 43 end
Chris@1494 44
Chris@1494 45 # Compatibility mode for those who copy email.yml over configuration.yml
Chris@1494 46 %w(delivery_method smtp_settings sendmail_settings).each do |key|
Chris@1494 47 if value = @config.delete(key)
Chris@1494 48 @config['email_delivery'] ||= {}
Chris@1494 49 @config['email_delivery'][key] = value
Chris@1494 50 end
Chris@1494 51 end
Chris@1494 52
Chris@1494 53 if @config['email_delivery']
Chris@1494 54 ActionMailer::Base.perform_deliveries = true
Chris@1494 55 @config['email_delivery'].each do |k, v|
Chris@1494 56 v.symbolize_keys! if v.respond_to?(:symbolize_keys!)
Chris@1494 57 ActionMailer::Base.send("#{k}=", v)
Chris@1494 58 end
Chris@1494 59 end
Chris@1494 60
Chris@1494 61 @config
Chris@1494 62 end
Chris@1494 63
Chris@1494 64 # Returns a configuration setting
Chris@1494 65 def [](name)
Chris@1494 66 load unless @config
Chris@1494 67 @config[name]
Chris@1494 68 end
Chris@1494 69
Chris@1494 70 # Yields a block with the specified hash configuration settings
Chris@1494 71 def with(settings)
Chris@1494 72 settings.stringify_keys!
Chris@1494 73 load unless @config
Chris@1494 74 was = settings.keys.inject({}) {|h,v| h[v] = @config[v]; h}
Chris@1494 75 @config.merge! settings
Chris@1494 76 yield if block_given?
Chris@1494 77 @config.merge! was
Chris@1494 78 end
Chris@1494 79
Chris@1494 80 private
Chris@1494 81
Chris@1494 82 def load_from_yaml(filename, env)
Chris@1494 83 yaml = nil
Chris@1494 84 begin
Chris@1494 85 yaml = YAML::load_file(filename)
Chris@1494 86 rescue ArgumentError
Chris@1494 87 $stderr.puts "Your Redmine configuration file located at #{filename} is not a valid YAML file and could not be loaded."
Chris@1494 88 exit 1
Chris@1494 89 end
Chris@1494 90 conf = {}
Chris@1494 91 if yaml.is_a?(Hash)
Chris@1494 92 if yaml['default']
Chris@1494 93 conf.merge!(yaml['default'])
Chris@1494 94 end
Chris@1494 95 if yaml[env]
Chris@1494 96 conf.merge!(yaml[env])
Chris@1494 97 end
Chris@1494 98 else
Chris@1494 99 $stderr.puts "Your Redmine configuration file located at #{filename} is not a valid Redmine configuration file."
Chris@1494 100 exit 1
Chris@1494 101 end
Chris@1494 102 conf
Chris@1494 103 end
Chris@1494 104
Chris@1494 105 def load_deprecated_email_configuration(env)
Chris@1494 106 deprecated_email_conf = File.join(Rails.root, 'config', 'email.yml')
Chris@1494 107 if File.file?(deprecated_email_conf)
Chris@1494 108 warn "Storing outgoing emails configuration in config/email.yml is deprecated. You should now store it in config/configuration.yml using the email_delivery setting."
Chris@1494 109 @config.merge!({'email_delivery' => load_from_yaml(deprecated_email_conf, env)})
Chris@1494 110 end
Chris@1494 111 end
Chris@1494 112 end
Chris@1494 113 end
Chris@1494 114 end