To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / settings_controller.rb @ 441:cbce1fd3b1b7
History | View | Annotate | Download (2.23 KB)
| 1 | 441:cbce1fd3b1b7 | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang
|
||
| 3 | 0:513646585e45 | Chris | #
|
| 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 | 441:cbce1fd3b1b7 | Chris | |
| 21 | 0:513646585e45 | Chris | before_filter :require_admin
|
| 22 | |||
| 23 | def index |
||
| 24 | edit |
||
| 25 | render :action => 'edit' |
||
| 26 | end
|
||
| 27 | |||
| 28 | def edit |
||
| 29 | 37:94944d00e43c | chris | @notifiables = Redmine::Notifiable.all |
| 30 | 0:513646585e45 | Chris | if request.post? && params[:settings] && params[:settings].is_a?(Hash) |
| 31 | settings = (params[:settings] || {}).dup.symbolize_keys
|
||
| 32 | settings.each do |name, value|
|
||
| 33 | # remove blank values in array settings
|
||
| 34 | value.delete_if {|v| v.blank? } if value.is_a?(Array)
|
||
| 35 | Setting[name] = value
|
||
| 36 | end
|
||
| 37 | flash[:notice] = l(:notice_successful_update) |
||
| 38 | redirect_to :action => 'edit', :tab => params[:tab] |
||
| 39 | 441:cbce1fd3b1b7 | Chris | else
|
| 40 | @options = {}
|
||
| 41 | @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] } |
||
| 42 | @deliveries = ActionMailer::Base.perform_deliveries |
||
| 43 | |||
| 44 | @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? |
||
| 46 | |||
| 47 | Redmine::Themes.rescan |
||
| 48 | 0:513646585e45 | Chris | end
|
| 49 | end
|
||
| 50 | |||
| 51 | def plugin |
||
| 52 | @plugin = Redmine::Plugin.find(params[:id]) |
||
| 53 | if request.post?
|
||
| 54 | Setting["plugin_#{@plugin.id}"] = params[:settings] |
||
| 55 | flash[:notice] = l(:notice_successful_update) |
||
| 56 | redirect_to :action => 'plugin', :id => @plugin.id |
||
| 57 | 441:cbce1fd3b1b7 | Chris | else
|
| 58 | @partial = @plugin.settings[:partial] |
||
| 59 | @settings = Setting["plugin_#{@plugin.id}"] |
||
| 60 | 0:513646585e45 | Chris | end
|
| 61 | rescue Redmine::PluginNotFound |
||
| 62 | render_404 |
||
| 63 | end
|
||
| 64 | end |