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

settings_controller.rb 3.9 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 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. helper :queries
  21. before_filter :require_admin
  22. def index
  23. edit
  24. render :action => 'edit'
  25. end
  26. def edit
  27. hidden_non_project = Setting.find_by_name("hidden_non_project")
  28. @text = (hidden_non_project && hidden_non_project.value == "0") ? l(:label_show_non_project) : l(:label_hidden_non_project)
  29. #1隐藏了课程信息 0显示了课程信息
  30. hidden_courses = Setting.find_by_name("hidden_courses")
  31. @text_1 = (hidden_courses && hidden_courses.value == "1") ? l(:label_show_courses) : l(:label_hidden_courses)
  32. @notifiables = Redmine::Notifiable.all
  33. if request.post? && params[:settings] && params[:settings].is_a?(Hash)
  34. settings = (params[:settings] || {}).dup.symbolize_keys
  35. settings.each do |name, value|
  36. # remove blank values in array settings
  37. value.delete_if {|v| v.blank? } if value.is_a?(Array)
  38. Setting[name] = value
  39. end
  40. flash[:notice] = l(:notice_successful_update)
  41. redirect_to settings_url(:tab => params[:tab])
  42. else
  43. @options = {}
  44. user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]}
  45. @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
  46. @deliveries = ActionMailer::Base.perform_deliveries
  47. @guessed_host_and_path = request.host_with_port.dup
  48. @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
  49. Redmine::Themes.rescan
  50. end
  51. end
  52. def plugin
  53. @plugin = Redmine::Plugin.find(params[:id])
  54. unless @plugin.configurable?
  55. render_404
  56. return
  57. end
  58. if request.post?
  59. Setting.send "plugin_#{@plugin.id}=", params[:settings]
  60. flash[:notice] = l(:notice_successful_update)
  61. redirect_to plugin_settings_url(@plugin)
  62. else
  63. @partial = @plugin.settings[:partial]
  64. @settings = Setting.send "plugin_#{@plugin.id}"
  65. end
  66. rescue Redmine::PluginNotFound
  67. render_404
  68. end
  69. #隐藏/显示非项目信息
  70. def hidden_non_project
  71. @notifiable = Setting.find_by_name("hidden_non_project")
  72. if @notifiable
  73. @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1
  74. @notifiable.save
  75. else
  76. @notifiable = Setting.new()
  77. @notifiable.name = "hidden_non_project"
  78. @notifiable.value = 0
  79. @notifiable.save
  80. end
  81. redirect_to settings_url
  82. end
  83. #隐藏/显示课程信息
  84. def hidden_courses
  85. @notifiable = Setting.find_by_name("hidden_courses")
  86. if @notifiable
  87. @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1
  88. @notifiable.save
  89. else
  90. @notifiable = Setting.new()
  91. @notifiable.name = "hidden_courses"
  92. @notifiable.value = 1
  93. @notifiable.save
  94. end
  95. redirect_to settings_url
  96. end
  97. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...