comparison app/controllers/settings_controller.rb @ 1338:25603efa57b5

Merge from live branch
author Chris Cannam
date Thu, 20 Jun 2013 13:14:14 +0100
parents 433d4f72a19b
children 622f24f53b42 261b3d9a4903
comparison
equal deleted inserted replaced
1209:1b1138f6f55e 1338:25603efa57b5
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 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.
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 class SettingsController < ApplicationController 18 class SettingsController < ApplicationController
19 layout 'admin' 19 layout 'admin'
20 menu_item :plugins, :only => :plugin
20 21
21 before_filter :require_admin 22 before_filter :require_admin
22 23
23 def index 24 def index
24 edit 25 edit
36 end 37 end
37 flash[:notice] = l(:notice_successful_update) 38 flash[:notice] = l(:notice_successful_update)
38 redirect_to :action => 'edit', :tab => params[:tab] 39 redirect_to :action => 'edit', :tab => params[:tab]
39 else 40 else
40 @options = {} 41 @options = {}
41 @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] } 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]}
42 @deliveries = ActionMailer::Base.perform_deliveries 44 @deliveries = ActionMailer::Base.perform_deliveries
43 45
44 @guessed_host_and_path = request.host_with_port.dup 46 @guessed_host_and_path = request.host_with_port.dup
45 @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?
46 48
49 end 51 end
50 52
51 def plugin 53 def plugin
52 @plugin = Redmine::Plugin.find(params[:id]) 54 @plugin = Redmine::Plugin.find(params[:id])
53 if request.post? 55 if request.post?
54 Setting["plugin_#{@plugin.id}"] = params[:settings] 56 Setting.send "plugin_#{@plugin.id}=", params[:settings]
55 flash[:notice] = l(:notice_successful_update) 57 flash[:notice] = l(:notice_successful_update)
56 redirect_to :action => 'plugin', :id => @plugin.id 58 redirect_to :action => 'plugin', :id => @plugin.id
57 else 59 else
58 @partial = @plugin.settings[:partial] 60 @partial = @plugin.settings[:partial]
59 @settings = Setting["plugin_#{@plugin.id}"] 61 @settings = Setting.send "plugin_#{@plugin.id}"
60 end 62 end
61 rescue Redmine::PluginNotFound 63 rescue Redmine::PluginNotFound
62 render_404 64 render_404
63 end 65 end
64 end 66 end