annotate app/controllers/admin_controller.rb @ 853:969bb872d4bf feature_142

Close obsolete branch feature_142
author Chris Cannam
date Thu, 14 Jul 2011 14:26:44 +0100
parents cbce1fd3b1b7
children cbb26bc654de
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2006 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 class AdminController < ApplicationController
Chris@0 19 layout 'admin'
Chris@0 20 before_filter :require_admin
Chris@0 21 helper :sort
Chris@0 22 include SortHelper
Chris@0 23
Chris@0 24 def index
Chris@0 25 @no_configuration_data = Redmine::DefaultData::Loader::no_data?
Chris@0 26 end
Chris@0 27
Chris@0 28 def projects
Chris@0 29 @status = params[:status] ? params[:status].to_i : 1
Chris@0 30 c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
Chris@0 31 unless params[:name].blank?
Chris@0 32 name = "%#{params[:name].strip.downcase}%"
Chris@0 33 c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
Chris@0 34 end
Chris@0 35 @projects = Project.find :all, :order => 'lft',
Chris@0 36 :conditions => c.conditions
Chris@0 37
Chris@0 38 render :action => "projects", :layout => false if request.xhr?
Chris@0 39 end
Chris@441 40
Chris@0 41 def plugins
Chris@0 42 @plugins = Redmine::Plugin.all
Chris@0 43 end
Chris@441 44
Chris@0 45 # Loads the default configuration
Chris@0 46 # (roles, trackers, statuses, workflow, enumerations)
Chris@0 47 def default_configuration
Chris@0 48 if request.post?
Chris@0 49 begin
Chris@0 50 Redmine::DefaultData::Loader::load(params[:lang])
Chris@0 51 flash[:notice] = l(:notice_default_data_loaded)
Chris@0 52 rescue Exception => e
Chris@0 53 flash[:error] = l(:error_can_t_load_default_data, e.message)
Chris@0 54 end
Chris@0 55 end
Chris@0 56 redirect_to :action => 'index'
Chris@0 57 end
Chris@441 58
Chris@0 59 def test_email
Chris@0 60 raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
Chris@0 61 # Force ActionMailer to raise delivery errors so we can catch it
Chris@0 62 ActionMailer::Base.raise_delivery_errors = true
Chris@0 63 begin
Chris@0 64 @test = Mailer.deliver_test(User.current)
Chris@0 65 flash[:notice] = l(:notice_email_sent, User.current.mail)
Chris@0 66 rescue Exception => e
Chris@0 67 flash[:error] = l(:notice_email_error, e.message)
Chris@0 68 end
Chris@0 69 ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
Chris@0 70 redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
Chris@0 71 end
Chris@441 72
Chris@0 73 def info
Chris@0 74 @db_adapter_name = ActiveRecord::Base.connection.adapter_name
Chris@0 75 @checklist = [
Chris@441 76 [:text_default_administrator_account_changed,
Chris@441 77 User.find(:first,
Chris@441 78 :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
Chris@0 79 [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
Chris@441 80 [:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
Chris@441 81 [:text_rmagick_available, Object.const_defined?(:Magick)]
Chris@0 82 ]
Chris@441 83 end
Chris@0 84 end