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