Chris@441: # Redmine - project management software Chris@1115: # Copyright (C) 2006-2012 Jean-Philippe Lang Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or Chris@0: # modify it under the terms of the GNU General Public License Chris@0: # as published by the Free Software Foundation; either version 2 Chris@0: # of the License, or (at your option) any later version. Chris@0: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU General Public License for more details. Chris@0: # Chris@0: # You should have received a copy of the GNU General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@0: Chris@0: class SettingsController < ApplicationController Chris@0: layout 'admin' Chris@1115: menu_item :plugins, :only => :plugin Chris@441: Chris@0: before_filter :require_admin Chris@0: Chris@0: def index Chris@0: edit Chris@0: render :action => 'edit' Chris@0: end Chris@0: Chris@0: def edit chris@37: @notifiables = Redmine::Notifiable.all Chris@0: if request.post? && params[:settings] && params[:settings].is_a?(Hash) Chris@0: settings = (params[:settings] || {}).dup.symbolize_keys Chris@0: settings.each do |name, value| Chris@0: # remove blank values in array settings Chris@0: value.delete_if {|v| v.blank? } if value.is_a?(Array) Chris@0: Setting[name] = value Chris@0: end Chris@0: flash[:notice] = l(:notice_successful_update) Chris@0: redirect_to :action => 'edit', :tab => params[:tab] Chris@441: else Chris@441: @options = {} Chris@1115: user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} Chris@1115: @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]} Chris@441: @deliveries = ActionMailer::Base.perform_deliveries Chris@441: Chris@441: @guessed_host_and_path = request.host_with_port.dup Chris@441: @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank? Chris@441: Chris@441: Redmine::Themes.rescan Chris@0: end Chris@0: end Chris@0: Chris@0: def plugin Chris@0: @plugin = Redmine::Plugin.find(params[:id]) Chris@0: if request.post? Chris@1115: Setting.send "plugin_#{@plugin.id}=", params[:settings] Chris@0: flash[:notice] = l(:notice_successful_update) Chris@0: redirect_to :action => 'plugin', :id => @plugin.id Chris@441: else Chris@441: @partial = @plugin.settings[:partial] Chris@1115: @settings = Setting.send "plugin_#{@plugin.id}" Chris@0: end Chris@0: rescue Redmine::PluginNotFound Chris@0: render_404 Chris@0: end Chris@0: end