File: app/controllers/settings_controller.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  class: SettingsController#18
inherits from
  ApplicationController   
has properties
method: index #24
method: edit #29
method: plugin #52

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 SettingsController < ApplicationController
  19    layout 'admin'
  20    menu_item :plugins, :only => :plugin
  21 
  22    before_filter :require_admin
  23 
  24    def index
  25      edit
  26      render :action => 'edit'
  27    end
  28 
  29    def edit
  30      @notifiables = Redmine::Notifiable.all
  31      if request.post? && params[:settings] && params[:settings].is_a?(Hash)
  32        settings = (params[:settings] || {}).dup.symbolize_keys
  33        settings.each do |name, value|
  34          # remove blank values in array settings
  35          value.delete_if {|v| v.blank? } if value.is_a?(Array)
  36          Setting[name] = value
  37        end
  38        flash[:notice] = l(:notice_successful_update)
  39        redirect_to :action => 'edit', :tab => params[:tab]
  40      else
  41        @options = {}
  42        @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
  43        @deliveries = ActionMailer::Base.perform_deliveries
  44 
  45        @guessed_host_and_path = request.host_with_port.dup
  46        @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
  47 
  48        Redmine::Themes.rescan
  49      end
  50    end
  51 
  52    def plugin
  53      @plugin = Redmine::Plugin.find(params[:id])
  54      if request.post?
  55        Setting.send "plugin_#{@plugin.id}=", params[:settings]
  56        flash[:notice] = l(:notice_successful_update)
  57        redirect_to :action => 'plugin', :id => @plugin.id
  58      else
  59        @partial = @plugin.settings[:partial]
  60        @settings = Setting.send "plugin_#{@plugin.id}"
  61      end
  62    rescue Redmine::PluginNotFound
  63      render_404
  64    end
  65  end