To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / settings_controller.rb @ 1535:e2c122809c5c
History | View | Annotate | Download (2.54 KB)
| 1 | 441:cbce1fd3b1b7 | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | 1494:e248c7af89ec | Chris | # Copyright (C) 2006-2014 Jean-Philippe Lang
|
| 3 | 0:513646585e45 | Chris | #
|
| 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 | 1115:433d4f72a19b | Chris | menu_item :plugins, :only => :plugin |
| 21 | 441:cbce1fd3b1b7 | Chris | |
| 22 | 1464:261b3d9a4903 | Chris | helper :queries
|
| 23 | |||
| 24 | 0:513646585e45 | Chris | before_filter :require_admin
|
| 25 | |||
| 26 | def index |
||
| 27 | edit |
||
| 28 | render :action => 'edit' |
||
| 29 | end
|
||
| 30 | |||
| 31 | def edit |
||
| 32 | 37:94944d00e43c | chris | @notifiables = Redmine::Notifiable.all |
| 33 | 0:513646585e45 | Chris | if request.post? && params[:settings] && params[:settings].is_a?(Hash) |
| 34 | settings = (params[:settings] || {}).dup.symbolize_keys
|
||
| 35 | settings.each do |name, value|
|
||
| 36 | 1464:261b3d9a4903 | Chris | Setting.set_from_params name, value
|
| 37 | 0:513646585e45 | Chris | end
|
| 38 | flash[:notice] = l(:notice_successful_update) |
||
| 39 | 1464:261b3d9a4903 | Chris | redirect_to settings_path(:tab => params[:tab]) |
| 40 | 441:cbce1fd3b1b7 | Chris | else
|
| 41 | @options = {}
|
||
| 42 | 1115:433d4f72a19b | Chris | 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 | 441:cbce1fd3b1b7 | Chris | @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 | 1464:261b3d9a4903 | Chris | @commit_update_keywords = Setting.commit_update_keywords.dup |
| 50 | @commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any? |
||
| 51 | |||
| 52 | 441:cbce1fd3b1b7 | Chris | Redmine::Themes.rescan |
| 53 | 0:513646585e45 | Chris | end
|
| 54 | end
|
||
| 55 | |||
| 56 | def plugin |
||
| 57 | @plugin = Redmine::Plugin.find(params[:id]) |
||
| 58 | 1464:261b3d9a4903 | Chris | unless @plugin.configurable? |
| 59 | render_404 |
||
| 60 | return
|
||
| 61 | end
|
||
| 62 | |||
| 63 | 0:513646585e45 | Chris | if request.post?
|
| 64 | 1115:433d4f72a19b | Chris | Setting.send "plugin_#{@plugin.id}=", params[:settings] |
| 65 | 0:513646585e45 | Chris | flash[:notice] = l(:notice_successful_update) |
| 66 | 1464:261b3d9a4903 | Chris | redirect_to plugin_settings_path(@plugin)
|
| 67 | 441:cbce1fd3b1b7 | Chris | else
|
| 68 | @partial = @plugin.settings[:partial] |
||
| 69 | 1115:433d4f72a19b | Chris | @settings = Setting.send "plugin_#{@plugin.id}" |
| 70 | 0:513646585e45 | Chris | end
|
| 71 | rescue Redmine::PluginNotFound |
||
| 72 | render_404 |
||
| 73 | end
|
||
| 74 | end |