Mercurial > hg > soundsoftware-site
comparison vendor/plugins/redmine_checkout/lib/checkout/settings_controller_patch.rb @ 16:020926a36823 yuya
* Add redmine-checkout plugin (as of svn rev 179 of the plugin)
author | Chris Cannam |
---|---|
date | Wed, 25 Aug 2010 16:39:01 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:9c6c72729d91 | 16:020926a36823 |
---|---|
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) |