comparison app/controllers/settings_controller.rb @ 1464:261b3d9a4903 redmine-2.4

Update to Redmine 2.4 branch rev 12663
author Chris Cannam
date Tue, 14 Jan 2014 14:37:42 +0000
parents 433d4f72a19b
children e248c7af89ec
comparison
equal deleted inserted replaced
1296:038ba2d95de8 1464:261b3d9a4903
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
17 17
18 class SettingsController < ApplicationController 18 class SettingsController < ApplicationController
19 layout 'admin' 19 layout 'admin'
20 menu_item :plugins, :only => :plugin 20 menu_item :plugins, :only => :plugin
21 21
22 helper :queries
23
22 before_filter :require_admin 24 before_filter :require_admin
23 25
24 def index 26 def index
25 edit 27 edit
26 render :action => 'edit' 28 render :action => 'edit'
29 def edit 31 def edit
30 @notifiables = Redmine::Notifiable.all 32 @notifiables = Redmine::Notifiable.all
31 if request.post? && params[:settings] && params[:settings].is_a?(Hash) 33 if request.post? && params[:settings] && params[:settings].is_a?(Hash)
32 settings = (params[:settings] || {}).dup.symbolize_keys 34 settings = (params[:settings] || {}).dup.symbolize_keys
33 settings.each do |name, value| 35 settings.each do |name, value|
34 # remove blank values in array settings 36 Setting.set_from_params name, value
35 value.delete_if {|v| v.blank? } if value.is_a?(Array)
36 Setting[name] = value
37 end 37 end
38 flash[:notice] = l(:notice_successful_update) 38 flash[:notice] = l(:notice_successful_update)
39 redirect_to :action => 'edit', :tab => params[:tab] 39 redirect_to settings_path(:tab => params[:tab])
40 else 40 else
41 @options = {} 41 @options = {}
42 user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} 42 user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]}
43 @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]} 43 @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
44 @deliveries = ActionMailer::Base.perform_deliveries 44 @deliveries = ActionMailer::Base.perform_deliveries
45 45
46 @guessed_host_and_path = request.host_with_port.dup 46 @guessed_host_and_path = request.host_with_port.dup
47 @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank? 47 @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
48 48
49 @commit_update_keywords = Setting.commit_update_keywords.dup
50 @commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any?
51
49 Redmine::Themes.rescan 52 Redmine::Themes.rescan
50 end 53 end
51 end 54 end
52 55
53 def plugin 56 def plugin
54 @plugin = Redmine::Plugin.find(params[:id]) 57 @plugin = Redmine::Plugin.find(params[:id])
58 unless @plugin.configurable?
59 render_404
60 return
61 end
62
55 if request.post? 63 if request.post?
56 Setting.send "plugin_#{@plugin.id}=", params[:settings] 64 Setting.send "plugin_#{@plugin.id}=", params[:settings]
57 flash[:notice] = l(:notice_successful_update) 65 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'plugin', :id => @plugin.id 66 redirect_to plugin_settings_path(@plugin)
59 else 67 else
60 @partial = @plugin.settings[:partial] 68 @partial = @plugin.settings[:partial]
61 @settings = Setting.send "plugin_#{@plugin.id}" 69 @settings = Setting.send "plugin_#{@plugin.id}"
62 end 70 end
63 rescue Redmine::PluginNotFound 71 rescue Redmine::PluginNotFound