@@ -50,7 +50,7 class AdminController < ApplicationController | |||||
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def plugins |
|
52 | def plugins | |
53 |
@plugins = Redmine::Plugin. |
|
53 | @plugins = Redmine::Plugin.all | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | # Loads the default configuration |
|
56 | # Loads the default configuration |
@@ -45,14 +45,15 class SettingsController < ApplicationController | |||||
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def plugin |
|
47 | def plugin | |
48 | plugin_id = params[:id].to_sym |
|
48 | @plugin = Redmine::Plugin.find(params[:id]) | |
49 | @plugin = Redmine::Plugin.registered_plugins[plugin_id] |
|
|||
50 | if request.post? |
|
49 | if request.post? | |
51 |
Setting["plugin_#{plugin |
|
50 | Setting["plugin_#{@plugin.id}"] = params[:settings] | |
52 | flash[:notice] = l(:notice_successful_update) |
|
51 | flash[:notice] = l(:notice_successful_update) | |
53 |
redirect_to :action => 'plugin', :id => |
|
52 | redirect_to :action => 'plugin', :id => @plugin.id | |
54 | end |
|
53 | end | |
55 | @partial = @plugin.settings[:partial] |
|
54 | @partial = @plugin.settings[:partial] | |
56 |
@settings = Setting["plugin_#{plugin |
|
55 | @settings = Setting["plugin_#{@plugin.id}"] | |
|
56 | rescue Redmine::PluginNotFound | |||
|
57 | render_404 | |||
57 | end |
|
58 | end | |
58 | end |
|
59 | end |
@@ -75,9 +75,9 class Setting < ActiveRecord::Base | |||||
75 |
|
75 | |||
76 | cattr_accessor :available_settings |
|
76 | cattr_accessor :available_settings | |
77 | @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) |
|
77 | @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) | |
78 |
Redmine::Plugin. |
|
78 | Redmine::Plugin.all.each do |plugin| | |
79 | next unless plugin.settings |
|
79 | next unless plugin.settings | |
80 | @@available_settings["plugin_#{id}"] = {'default' => plugin.settings[:default], 'serialized' => true} |
|
80 | @@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true} | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | validates_uniqueness_of :name |
|
83 | validates_uniqueness_of :name |
@@ -17,6 +17,8 | |||||
17 |
|
17 | |||
18 | module Redmine #:nodoc: |
|
18 | module Redmine #:nodoc: | |
19 |
|
19 | |||
|
20 | class PluginNotFound < StandardError; end | |||
|
21 | ||||
20 | # Base class for Redmine plugins. |
|
22 | # Base class for Redmine plugins. | |
21 | # Plugins are registered using the <tt>register</tt> class method that acts as the public constructor. |
|
23 | # Plugins are registered using the <tt>register</tt> class method that acts as the public constructor. | |
22 | # |
|
24 | # | |
@@ -62,7 +64,17 module Redmine #:nodoc: | |||||
62 | def self.register(id, &block) |
|
64 | def self.register(id, &block) | |
63 | p = new(id) |
|
65 | p = new(id) | |
64 | p.instance_eval(&block) |
|
66 | p.instance_eval(&block) | |
65 |
|
|
67 | registered_plugins[id] = p | |
|
68 | end | |||
|
69 | ||||
|
70 | # Returns an array off all registered plugins | |||
|
71 | def self.all | |||
|
72 | registered_plugins.values.sort | |||
|
73 | end | |||
|
74 | ||||
|
75 | # Finds a plugin by its id | |||
|
76 | def self.find(id) | |||
|
77 | registered_plugins[id.to_sym] || raise(PluginNotFound) | |||
66 | end |
|
78 | end | |
67 |
|
79 | |||
68 | def initialize(id) |
|
80 | def initialize(id) |
General Comments 0
You need to be logged in to leave comments.
Login now