Chris@1494: # Redmine - project management software Chris@1494: # Copyright (C) 2006-2014 Jean-Philippe Lang Chris@1494: # Chris@1494: # This program is free software; you can redistribute it and/or Chris@1494: # modify it under the terms of the GNU General Public License Chris@1494: # as published by the Free Software Foundation; either version 2 Chris@1494: # of the License, or (at your option) any later version. Chris@1494: # Chris@1494: # This program is distributed in the hope that it will be useful, Chris@1494: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1494: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1494: # GNU General Public License for more details. Chris@1494: # Chris@1494: # You should have received a copy of the GNU General Public License Chris@1494: # along with this program; if not, write to the Free Software Chris@1494: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@1494: Chris@1494: class AdminController < ApplicationController Chris@1494: layout 'admin' Chris@1494: menu_item :projects, :only => :projects Chris@1494: menu_item :plugins, :only => :plugins Chris@1494: menu_item :info, :only => :info Chris@1494: Chris@1494: before_filter :require_admin Chris@1494: helper :sort Chris@1494: include SortHelper Chris@1494: Chris@1494: def index Chris@1494: @no_configuration_data = Redmine::DefaultData::Loader::no_data? Chris@1494: end Chris@1494: Chris@1494: def projects Chris@1494: @status = params[:status] || 1 Chris@1494: Chris@1494: scope = Project.status(@status).order('lft') Chris@1494: scope = scope.like(params[:name]) if params[:name].present? Chris@1494: @projects = scope.all Chris@1494: Chris@1494: render :action => "projects", :layout => false if request.xhr? Chris@1494: end Chris@1494: Chris@1494: def plugins Chris@1494: @plugins = Redmine::Plugin.all Chris@1494: end Chris@1494: Chris@1494: # Loads the default configuration Chris@1494: # (roles, trackers, statuses, workflow, enumerations) Chris@1494: def default_configuration Chris@1494: if request.post? Chris@1494: begin Chris@1494: Redmine::DefaultData::Loader::load(params[:lang]) Chris@1494: flash[:notice] = l(:notice_default_data_loaded) Chris@1494: rescue Exception => e Chris@1494: flash[:error] = l(:error_can_t_load_default_data, e.message) Chris@1494: end Chris@1494: end Chris@1494: redirect_to admin_path Chris@1494: end Chris@1494: Chris@1494: def test_email Chris@1494: raise_delivery_errors = ActionMailer::Base.raise_delivery_errors Chris@1494: # Force ActionMailer to raise delivery errors so we can catch it Chris@1494: ActionMailer::Base.raise_delivery_errors = true Chris@1494: begin Chris@1494: @test = Mailer.test_email(User.current).deliver Chris@1494: flash[:notice] = l(:notice_email_sent, User.current.mail) Chris@1494: rescue Exception => e Chris@1494: flash[:error] = l(:notice_email_error, Redmine::CodesetUtil.replace_invalid_utf8(e.message)) Chris@1494: end Chris@1494: ActionMailer::Base.raise_delivery_errors = raise_delivery_errors Chris@1494: redirect_to settings_path(:tab => 'notifications') Chris@1494: end Chris@1494: Chris@1494: def info Chris@1494: @db_adapter_name = ActiveRecord::Base.connection.adapter_name Chris@1494: @checklist = [ Chris@1494: [:text_default_administrator_account_changed, User.default_admin_account_changed?], Chris@1494: [:text_file_repository_writable, File.writable?(Attachment.storage_path)], Chris@1494: [:text_plugin_assets_writable, File.writable?(Redmine::Plugin.public_directory)], Chris@1494: [:text_rmagick_available, Object.const_defined?(:Magick)], Chris@1494: [:text_convert_available, Redmine::Thumbnail.convert_available?] Chris@1494: ] Chris@1494: end Chris@1494: end