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.

admin_controller.rb 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 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 AdminController < ApplicationController
  18. layout 'admin'
  19. self.main_menu = false
  20. menu_item :projects, :only => :projects
  21. menu_item :plugins, :only => :plugins
  22. menu_item :info, :only => :info
  23. before_action :require_admin
  24. def index
  25. @no_configuration_data = Redmine::DefaultData::Loader::no_data?
  26. end
  27. def projects
  28. @status = params[:status] || 1
  29. scope = Project.status(@status).sorted
  30. scope = scope.like(params[:name]) if params[:name].present?
  31. @project_count = scope.count
  32. @project_pages = Paginator.new @project_count, per_page_option, params['page']
  33. @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a
  34. render :action => "projects", :layout => false if request.xhr?
  35. end
  36. def plugins
  37. @plugins = Redmine::Plugin.all
  38. end
  39. # Loads the default configuration
  40. # (roles, trackers, statuses, workflow, enumerations)
  41. def default_configuration
  42. if request.post?
  43. begin
  44. Redmine::DefaultData::Loader::load(params[:lang])
  45. flash[:notice] = l(:notice_default_data_loaded)
  46. rescue Exception => e
  47. flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
  48. end
  49. end
  50. redirect_to admin_path
  51. end
  52. def test_email
  53. begin
  54. Mailer.deliver_test_email(User.current)
  55. flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail))
  56. rescue Exception => e
  57. flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup)))
  58. end
  59. redirect_to settings_path(:tab => 'notifications')
  60. end
  61. def info
  62. @checklist = [
  63. [:text_default_administrator_account_changed, User.default_admin_account_changed?],
  64. [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
  65. ["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)],
  66. [:text_rmagick_available, Object.const_defined?(:Magick)],
  67. [:text_convert_available, Redmine::Thumbnail.convert_available?]
  68. ]
  69. end
  70. end