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 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2016 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. helper :sort
  25. include SortHelper
  26. def index
  27. @no_configuration_data = Redmine::DefaultData::Loader::no_data?
  28. end
  29. def projects
  30. @status = params[:status] || 1
  31. scope = Project.status(@status).sorted
  32. scope = scope.like(params[:name]) if params[:name].present?
  33. @project_count = scope.count
  34. @project_pages = Paginator.new @project_count, per_page_option, params['page']
  35. @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a
  36. render :action => "projects", :layout => false if request.xhr?
  37. end
  38. def plugins
  39. @plugins = Redmine::Plugin.all
  40. end
  41. # Loads the default configuration
  42. # (roles, trackers, statuses, workflow, enumerations)
  43. def default_configuration
  44. if request.post?
  45. begin
  46. Redmine::DefaultData::Loader::load(params[:lang])
  47. flash[:notice] = l(:notice_default_data_loaded)
  48. rescue Exception => e
  49. flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
  50. end
  51. end
  52. redirect_to admin_path
  53. end
  54. def test_email
  55. raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
  56. # Force ActionMailer to raise delivery errors so we can catch it
  57. ActionMailer::Base.raise_delivery_errors = true
  58. begin
  59. @test = Mailer.test_email(User.current).deliver
  60. flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail))
  61. rescue Exception => e
  62. flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup)))
  63. end
  64. ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
  65. redirect_to settings_path(:tab => 'notifications')
  66. end
  67. def info
  68. @checklist = [
  69. [:text_default_administrator_account_changed, User.default_admin_account_changed?],
  70. [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
  71. ["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)],
  72. [:text_rmagick_available, Object.const_defined?(:Magick)],
  73. [:text_convert_available, Redmine::Thumbnail.convert_available?]
  74. ]
  75. end
  76. end