To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / controllers / settings_controller.rb @ 1334:9397280c138c

History | View | Annotate | Download (2.38 KB)

1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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
      user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]}
43
      @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
44
      @deliveries = ActionMailer::Base.perform_deliveries
45

    
46
      @guessed_host_and_path = request.host_with_port.dup
47
      @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
48

    
49
      Redmine::Themes.rescan
50
    end
51
  end
52

    
53
  def plugin
54
    @plugin = Redmine::Plugin.find(params[:id])
55
    if request.post?
56
      Setting.send "plugin_#{@plugin.id}=", params[:settings]
57
      flash[:notice] = l(:notice_successful_update)
58
      redirect_to :action => 'plugin', :id => @plugin.id
59
    else
60
      @partial = @plugin.settings[:partial]
61
      @settings = Setting.send "plugin_#{@plugin.id}"
62
    end
63
  rescue Redmine::PluginNotFound
64
    render_404
65
  end
66
end