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