Chris@0: # redMine - project management software Chris@0: # Copyright (C) 2006-2007 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@0: 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@0: return Chris@0: end Chris@0: @options = {} Chris@0: @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] } Chris@0: @deliveries = ActionMailer::Base.perform_deliveries Chris@0: Chris@0: @guessed_host_and_path = request.host_with_port.dup Chris@0: @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank? Chris@117: Chris@117: Redmine::Themes.rescan Chris@0: end Chris@0: Chris@0: def plugin Chris@0: @plugin = Redmine::Plugin.find(params[:id]) Chris@0: if request.post? Chris@0: Setting["plugin_#{@plugin.id}"] = params[:settings] Chris@0: flash[:notice] = l(:notice_successful_update) Chris@0: redirect_to :action => 'plugin', :id => @plugin.id Chris@0: end Chris@0: @partial = @plugin.settings[:partial] Chris@0: @settings = Setting["plugin_#{@plugin.id}"] Chris@0: rescue Redmine::PluginNotFound Chris@0: render_404 Chris@0: end Chris@0: end