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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # redMine - project management software
  2. # Copyright (C) 2006-2007 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 'base'
  19. before_filter :require_admin
  20. def index
  21. edit
  22. render :action => 'edit'
  23. end
  24. def edit
  25. @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted)
  26. if request.post? && params[:settings] && params[:settings].is_a?(Hash)
  27. settings = (params[:settings] || {}).dup.symbolize_keys
  28. settings.each do |name, value|
  29. # remove blank values in array settings
  30. value.delete_if {|v| v.blank? } if value.is_a?(Array)
  31. Setting[name] = value
  32. end
  33. flash[:notice] = l(:notice_successful_update)
  34. redirect_to :action => 'edit', :tab => params[:tab]
  35. return
  36. end
  37. @options = {}
  38. @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
  39. end
  40. def plugin
  41. plugin_id = params[:id].to_sym
  42. @plugin = Redmine::Plugin.registered_plugins[plugin_id]
  43. if request.post?
  44. Setting["plugin_#{plugin_id}"] = params[:settings]
  45. flash[:notice] = l(:notice_successful_update)
  46. redirect_to :action => 'plugin', :id => params[:id]
  47. end
  48. @partial = "../../vendor/plugins/#{plugin_id}/app/views/" + @plugin.settings[:partial]
  49. @settings = Setting["plugin_#{plugin_id}"]
  50. end
  51. end