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