You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings_controller.rb 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2012 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. class SettingsController < ApplicationController
  18. layout 'admin'
  19. menu_item :plugins, :only => :plugin
  20. before_filter :require_admin
  21. def index
  22. edit
  23. render :action => 'edit'
  24. end
  25. def edit
  26. @notifiables = Redmine::Notifiable.all
  27. if request.post? && params[:settings] && params[:settings].is_a?(Hash)
  28. settings = (params[:settings] || {}).dup.symbolize_keys
  29. settings.each do |name, value|
  30. # remove blank values in array settings
  31. value.delete_if {|v| v.blank? } if value.is_a?(Array)
  32. Setting[name] = value
  33. end
  34. flash[:notice] = l(:notice_successful_update)
  35. redirect_to :action => 'edit', :tab => params[:tab]
  36. else
  37. @options = {}
  38. @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
  39. @deliveries = ActionMailer::Base.perform_deliveries
  40. @guessed_host_and_path = request.host_with_port.dup
  41. @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
  42. Redmine::Themes.rescan
  43. end
  44. end
  45. def plugin
  46. @plugin = Redmine::Plugin.find(params[:id])
  47. if request.post?
  48. Setting.send "plugin_#{@plugin.id}=", params[:settings]
  49. flash[:notice] = l(:notice_successful_update)
  50. redirect_to :action => 'plugin', :id => @plugin.id
  51. else
  52. @partial = @plugin.settings[:partial]
  53. @settings = Setting.send "plugin_#{@plugin.id}"
  54. end
  55. rescue Redmine::PluginNotFound
  56. render_404
  57. end
  58. end