git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2039 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.8.0-RC1
@@ -50,7 +50,7 @@ class AdminController < ApplicationController | |||
end | |||
def plugins | |||
@plugins = Redmine::Plugin.registered_plugins.values.sort | |||
@plugins = Redmine::Plugin.all | |||
end | |||
# Loads the default configuration |
@@ -45,14 +45,15 @@ class SettingsController < ApplicationController | |||
end | |||
def plugin | |||
plugin_id = params[:id].to_sym | |||
@plugin = Redmine::Plugin.registered_plugins[plugin_id] | |||
@plugin = Redmine::Plugin.find(params[:id]) | |||
if request.post? | |||
Setting["plugin_#{plugin_id}"] = params[:settings] | |||
Setting["plugin_#{@plugin.id}"] = params[:settings] | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to :action => 'plugin', :id => params[:id] | |||
redirect_to :action => 'plugin', :id => @plugin.id | |||
end | |||
@partial = @plugin.settings[:partial] | |||
@settings = Setting["plugin_#{plugin_id}"] | |||
@settings = Setting["plugin_#{@plugin.id}"] | |||
rescue Redmine::PluginNotFound | |||
render_404 | |||
end | |||
end |
@@ -75,9 +75,9 @@ class Setting < ActiveRecord::Base | |||
cattr_accessor :available_settings | |||
@@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) | |||
Redmine::Plugin.registered_plugins.each do |id, plugin| | |||
Redmine::Plugin.all.each do |plugin| | |||
next unless plugin.settings | |||
@@available_settings["plugin_#{id}"] = {'default' => plugin.settings[:default], 'serialized' => true} | |||
@@available_settings["plugin_#{plugin.id}"] = {'default' => plugin.settings[:default], 'serialized' => true} | |||
end | |||
validates_uniqueness_of :name |
@@ -17,6 +17,8 @@ | |||
module Redmine #:nodoc: | |||
class PluginNotFound < StandardError; end | |||
# Base class for Redmine plugins. | |||
# Plugins are registered using the <tt>register</tt> class method that acts as the public constructor. | |||
# | |||
@@ -62,7 +64,17 @@ module Redmine #:nodoc: | |||
def self.register(id, &block) | |||
p = new(id) | |||
p.instance_eval(&block) | |||
Plugin.registered_plugins[id] = p | |||
registered_plugins[id] = p | |||
end | |||
# Returns an array off all registered plugins | |||
def self.all | |||
registered_plugins.values.sort | |||
end | |||
# Finds a plugin by its id | |||
def self.find(id) | |||
registered_plugins[id.to_sym] || raise(PluginNotFound) | |||
end | |||
def initialize(id) |