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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2012 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. menu_item :projects, :only => :projects
  20. menu_item :plugins, :only => :plugins
  21. menu_item :info, :only => :info
  22. before_filter :require_admin
  23. helper :sort
  24. include SortHelper
  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)
  31. scope = scope.like(params[:name]) if params[:name].present?
  32. @projects = scope.all(:order => 'lft')
  33. render :action => "projects", :layout => false if request.xhr?
  34. end
  35. def plugins
  36. @plugins = Redmine::Plugin.all
  37. end
  38. # Loads the default configuration
  39. # (roles, trackers, statuses, workflow, enumerations)
  40. def default_configuration
  41. if request.post?
  42. begin
  43. Redmine::DefaultData::Loader::load(params[:lang])
  44. flash[:notice] = l(:notice_default_data_loaded)
  45. rescue Exception => e
  46. flash[:error] = l(:error_can_t_load_default_data, e.message)
  47. end
  48. end
  49. redirect_to :action => 'index'
  50. end
  51. def test_email
  52. raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
  53. # Force ActionMailer to raise delivery errors so we can catch it
  54. ActionMailer::Base.raise_delivery_errors = true
  55. begin
  56. @test = Mailer.deliver_test_email(User.current)
  57. flash[:notice] = l(:notice_email_sent, User.current.mail)
  58. rescue Exception => e
  59. flash[:error] = l(:notice_email_error, e.message)
  60. end
  61. ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
  62. redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
  63. end
  64. def info
  65. @db_adapter_name = ActiveRecord::Base.connection.adapter_name
  66. @checklist = [
  67. [:text_default_administrator_account_changed, User.default_admin_account_changed?],
  68. [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
  69. [:text_plugin_assets_writable, File.writable?(Redmine::Plugin.public_directory)],
  70. [:text_rmagick_available, Object.const_defined?(:Magick)]
  71. ]
  72. end
  73. end