2019-03-16 09:37:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# frozen_string_literal: true  
						 
					
						
							
								
									
										
										
										
											2019-03-15 01:32:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Redmine - project management software  
						 
					
						
							
								
									
										
										
										
											2023-01-01 06:19:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Copyright (C) 2006-2023  Jean-Philippe Lang  
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# This program is free software; you can redistribute it and/or  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# modify it under the terms of the GNU General Public License  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# as published by the Free Software Foundation; either version 2  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# of the License, or (at your option) any later version.  
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# This program is distributed in the hope that it will be useful,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# but WITHOUT ANY WARRANTY; without even the implied warranty of  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# GNU General Public License for more details.  
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# You should have received a copy of the GNU General Public License  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# along with this program; if not, write to the Free Software  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-17 20:45:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								require  'redmine'  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								module  Redmine  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  module  Configuration 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    # Configuration default values 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    @defaults  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-04 15:59:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      'avatar_server_url'  = >  'https://www.gravatar.com' , 
							 
						 
					
						
							
								
									
										
										
										
											2012-12-10 20:09:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      'email_delivery'  = >  nil , 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 05:17:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      'max_concurrent_ajax_uploads'  = >  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      'common_mark_enable_hardbreaks'  = >  true 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    @config  =  nil 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    class  <<  self 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      # Loads the Redmine configuration file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      # Valid options: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      # * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml) 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      # * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env) 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      def  load ( options = { } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        filename  =  options [ :file ]  ||  File . join ( Rails . root ,  'config' ,  'configuration.yml' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        env  =  options [ :env ]  ||  Rails . env 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        @config  =  @defaults . dup 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        load_deprecated_email_configuration ( env ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  File . file? ( filename ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          @config . merge! ( load_from_yaml ( filename ,  env ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        # Compatibility mode for those who copy email.yml over configuration.yml 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        %w( delivery_method smtp_settings sendmail_settings ) . each  do  | key | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          if  value  =  @config . delete ( key ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            @config [ 'email_delivery' ]  || =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            @config [ 'email_delivery' ] [ key ]  =  value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        if  @config [ 'email_delivery' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          ActionMailer :: Base . perform_deliveries  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          @config [ 'email_delivery' ] . each  do  | k ,  v | 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-10 17:13:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            # Comprehensive error message for those who used async_smtp and async_sendmail 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            # delivery methods that are removed in Redmine 4.0. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  k  ==  'delivery_method'  &&  v . to_s  =~  / \ Aasync_(.+) / 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-01 06:45:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              abort  " Redmine now uses ActiveJob to send emails asynchronously and the : #{ v }  delivery method is no longer available. \n "  + 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-10 17:13:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Please update your config/configuration.yml to use : # $1 delivery method instead. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            end 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            v . symbolize_keys!  if  v . respond_to? ( :symbolize_keys! ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ActionMailer :: Base . send ( " #{ k } = " ,  v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 10:52:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        check_regular_expressions 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        @config 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      # Returns a configuration setting 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      def  [] ( name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        load  unless  @config 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        @config [ name ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-02-25 14:30:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      # Yields a block with the specified hash configuration settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      def  with ( settings ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        settings . stringify_keys! 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        load  unless  @config 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        was  =  settings . keys . inject ( { } )  { | h , v |  h [ v ]  =  @config [ v ] ;  h } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        @config . merge!  settings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        yield  if  block_given? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        @config . merge!  was 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      private 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      def  load_from_yaml ( filename ,  env ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-12-07 18:54:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        yaml  =  nil 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        begin 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-24 10:51:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          yaml  =  YAML :: load ( ERB . new ( File . read ( filename ) ) . result ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-01 09:17:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        rescue  ArgumentError ,  Psych :: SyntaxError  = >  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          abort  " Your Redmine configuration file located at  #{ filename }  is not a valid YAML file and could not be loaded: \n #{ e . message } " 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-24 10:53:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        rescue  SyntaxError  = >  e 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 19:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          abort  " A syntax error occurred when parsing your Redmine configuration file located at  #{ filename }  with ERB: \n #{ e . message } " 
							 
						 
					
						
							
								
									
										
										
										
											2011-12-07 18:54:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        conf  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  yaml . is_a? ( Hash ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          if  yaml [ 'default' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            conf . merge! ( yaml [ 'default' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          if  yaml [ env ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            conf . merge! ( yaml [ env ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 19:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          abort  " Your Redmine configuration file located at  #{ filename }  is not a valid Redmine configuration file. " 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-01 00:48:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      def  load_deprecated_email_configuration ( env ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        deprecated_email_conf  =  File . join ( Rails . root ,  'config' ,  'email.yml' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  File . file? ( deprecated_email_conf ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          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. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          @config . merge! ( { 'email_delivery'  = >  load_from_yaml ( deprecated_email_conf ,  env ) } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 10:52:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      # Checks the validness of regular expressions set for repository paths at startup 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      def  check_regular_expressions 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        @config . each  do  | name ,  value | 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-27 02:15:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          if  value . present?  &&  / ^scm_.+_path_regexp$ / . match? ( name ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 10:52:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            begin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              Regexp . new  value . to_s . strip 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            rescue  = >  e 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 19:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              abort  " Invalid regular expression set as  #{ name }  setting in your Redmine configuration file: \n #{ e . message } " 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-08 10:52:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      end 
							 
						 
					
						
							
								
									
										
										
										
											2011-01-23 10:22:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  end 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								end