comparison plugins/redmine_checkout/lib/checkout/settings_controller_patch.rb @ 1117:b4b72f1eb644 redmine-2.2-integration

Moved all the plugins from the vendor folder to the application root folder.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 08 Jan 2013 12:32:05 +0000
parents vendor/plugins/redmine_checkout/lib/checkout/settings_controller_patch.rb@020926a36823
children
comparison
equal deleted inserted replaced
1116:bb32da3bea34 1117:b4b72f1eb644
1 require_dependency 'settings_controller'
2
3 module Checkout
4 module SettingsControllerPatch
5 def self.included(base) # :nodoc:
6 base.send(:include, InstanceMethods)
7
8 base.class_eval do
9 unloadable
10
11 alias_method_chain :edit, :checkout
12 end
13 end
14
15 module InstanceMethods
16 def edit_with_checkout
17 if request.post? && params['tab'] == 'checkout'
18 if params[:settings] && params[:settings].is_a?(Hash)
19 settings = HashWithIndifferentAccess.new
20 (params[:settings] || {}).each do |name, value|
21 if name = name.to_s.slice(/checkout_(.+)/, 1)
22 case value
23 when Array
24 # remove blank values in array settings
25 value.delete_if {|v| v.blank? }
26 when Hash
27 # change protocols hash to array.
28 value = value.sort{|(ak,av),(bk,bv)|ak<=>bk}.collect{|id,protocol| protocol} if name.start_with? "protocols_"
29 end
30 settings[name.to_sym] = value
31 end
32 end
33
34 Setting.plugin_redmine_checkout = settings
35 params[:settings] = {}
36 end
37 end
38 edit_without_checkout
39 end
40 end
41 end
42 end
43
44 SettingsController.send(:include, Checkout::SettingsControllerPatch)