Mercurial > hg > soundsoftware-site
comparison .svn/pristine/50/504a75e28140e0b003d557f020f846d8f93e9c79.svn-base @ 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 | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
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. | |
17 | |
18 class SettingsController < ApplicationController | |
19 layout 'admin' | |
20 menu_item :plugins, :only => :plugin | |
21 | |
22 helper :queries | |
23 | |
24 before_filter :require_admin | |
25 | |
26 def index | |
27 edit | |
28 render :action => 'edit' | |
29 end | |
30 | |
31 def edit | |
32 @notifiables = Redmine::Notifiable.all | |
33 if request.post? && params[:settings] && params[:settings].is_a?(Hash) | |
34 settings = (params[:settings] || {}).dup.symbolize_keys | |
35 settings.each do |name, value| | |
36 # remove blank values in array settings | |
37 value.delete_if {|v| v.blank? } if value.is_a?(Array) | |
38 Setting[name] = value | |
39 end | |
40 flash[:notice] = l(:notice_successful_update) | |
41 redirect_to settings_path(:tab => params[:tab]) | |
42 else | |
43 @options = {} | |
44 user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} | |
45 @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]} | |
46 @deliveries = ActionMailer::Base.perform_deliveries | |
47 | |
48 @guessed_host_and_path = request.host_with_port.dup | |
49 @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank? | |
50 | |
51 Redmine::Themes.rescan | |
52 end | |
53 end | |
54 | |
55 def plugin | |
56 @plugin = Redmine::Plugin.find(params[:id]) | |
57 unless @plugin.configurable? | |
58 render_404 | |
59 return | |
60 end | |
61 | |
62 if request.post? | |
63 Setting.send "plugin_#{@plugin.id}=", params[:settings] | |
64 flash[:notice] = l(:notice_successful_update) | |
65 redirect_to plugin_settings_path(@plugin) | |
66 else | |
67 @partial = @plugin.settings[:partial] | |
68 @settings = Setting.send "plugin_#{@plugin.id}" | |
69 end | |
70 rescue Redmine::PluginNotFound | |
71 render_404 | |
72 end | |
73 end |