comparison app/controllers/settings_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
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'
34 # remove blank values in array settings 36 # remove blank values in array settings
35 value.delete_if {|v| v.blank? } if value.is_a?(Array) 37 value.delete_if {|v| v.blank? } if value.is_a?(Array)
36 Setting[name] = value 38 Setting[name] = value
37 end 39 end
38 flash[:notice] = l(:notice_successful_update) 40 flash[:notice] = l(:notice_successful_update)
39 redirect_to :action => 'edit', :tab => params[:tab] 41 redirect_to settings_path(:tab => params[:tab])
40 else 42 else
41 @options = {} 43 @options = {}
42 user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} 44 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]} 45 @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
44 @deliveries = ActionMailer::Base.perform_deliveries 46 @deliveries = ActionMailer::Base.perform_deliveries
50 end 52 end
51 end 53 end
52 54
53 def plugin 55 def plugin
54 @plugin = Redmine::Plugin.find(params[:id]) 56 @plugin = Redmine::Plugin.find(params[:id])
57 unless @plugin.configurable?
58 render_404
59 return
60 end
61
55 if request.post? 62 if request.post?
56 Setting.send "plugin_#{@plugin.id}=", params[:settings] 63 Setting.send "plugin_#{@plugin.id}=", params[:settings]
57 flash[:notice] = l(:notice_successful_update) 64 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'plugin', :id => @plugin.id 65 redirect_to plugin_settings_path(@plugin)
59 else 66 else
60 @partial = @plugin.settings[:partial] 67 @partial = @plugin.settings[:partial]
61 @settings = Setting.send "plugin_#{@plugin.id}" 68 @settings = Setting.send "plugin_#{@plugin.id}"
62 end 69 end
63 rescue Redmine::PluginNotFound 70 rescue Redmine::PluginNotFound