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