File: app/controllers/admin_controller.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  class: AdminController#18
includes
  SortHelper   
inherits from
  ApplicationController   
has properties
method: index #28
method: projects #32
method: plugins #43
method: default_configuration #49
method: test_email #61
method: info #75

Class Hierarchy

Code

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