/
config_controller.rb
69 lines (54 loc) · 2.06 KB
/
config_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
=begin
RailsCollab
-----------
Copyright (C) 2007 James S Urquhart (jamesu at gmail.com)This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
=end
class ConfigController < ApplicationController
layout 'administration'
before_filter :login_required
before_filter :process_session
def update_category
begin
@category = ConfigCategory.find(params[:id])
rescue ActiveRecord::RecordNotFound
error_status(true, :invalid_category)
redirect_to :controller => 'administration', :action => 'configuration'
return false
end
if @category.options.empty?
error_status(true, :config_category_empty)
redirect_to :controller => 'administration', :action => 'configuration'
end
@content_for_sidebar = 'update_category_sidebar'
@options = @category.options
@categories = ConfigCategory.find(:all, :order => 'category_order DESC')
case request.method
when :post
option_values = params[:options]
@options.each do |option|
if option_values.has_key? option.name
option.value = option_values[option.name]
option.save
end
end
# Force reload of configuration
ConfigOption.reload_all
error_status(false, :success_updated_config_category)
redirect_to :controller => 'administration', :action => 'configuration'
end
end
def authorize?(user)
return user.is_admin
end
end