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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class AdminController < ApplicationController
  19. layout 'admin'
  20. self.main_menu = false
  21. menu_item :projects, :only => :projects
  22. menu_item :plugins, :only => :plugins
  23. menu_item :info, :only => :info
  24. before_action :require_admin
  25. def index
  26. @no_configuration_data = Redmine::DefaultData::Loader::no_data?
  27. end
  28. def projects
  29. @status = params[:status] || 1
  30. scope = Project.status(@status).sorted
  31. scope = scope.like(params[:name]) if params[:name].present?
  32. @project_count = scope.count
  33. @project_pages = Paginator.new @project_count, per_page_option, params['page']
  34. @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a
  35. render :action => "projects", :layout => false if request.xhr?
  36. end
  37. def plugins
  38. @plugins = Redmine::Plugin.all
  39. end
  40. # Loads the default configuration
  41. # (roles, trackers, statuses, workflow, enumerations)
  42. def default_configuration
  43. if request.post?
  44. begin
  45. Redmine::DefaultData::Loader::load(params[:lang])
  46. flash[:notice] = l(:notice_default_data_loaded)
  47. rescue => e
  48. flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
  49. end
  50. end
  51. redirect_to admin_path
  52. end
  53. def test_email
  54. begin
  55. Mailer.deliver_test_email(User.current)
  56. flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail))
  57. rescue => e
  58. flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup)))
  59. end
  60. redirect_to settings_path(:tab => 'notifications')
  61. end
  62. def info
  63. @checklist = [
  64. [:text_default_administrator_account_changed, User.default_admin_account_changed?],
  65. [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
  66. ["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)],
  67. [:text_minimagick_available, Object.const_defined?(:MiniMagick)],
  68. [:text_convert_available, Redmine::Thumbnail.convert_available?],
  69. [:text_gs_available, Redmine::Thumbnail.gs_available?]
  70. ]
  71. end
  72. end