diff --git a/README.md b/README.md index 10feda3fa502..8c24fa29d7e8 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,12 @@ module OpenProject::RepositoryAuthentication register 'openproject-repository_authentication', :author_url => 'http://finn.de', - :requires_openproject => '>= 3.0.0pre6' + :requires_openproject => '>= 3.0.0pre6' do + menu :project_menu, + :repo_auth, + {:controller => '/repo_auth_controller', :action => :index}, + :caption => "Repo Auth!" + end patches [:SysController] end diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 9a6d88877279..ae2523de2f68 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -15,6 +15,8 @@ See doc/COPYRIGHT.md for more details. # Changelog +* Allows plugin register to receive a block so plugins don't have to register with this plugin AND Redmine::Plugin + ## 1.0.5 * Readme: Add note about db:create and db:migrate in same rake process diff --git a/lib/open_project/plugins/acts_as_op_engine.rb b/lib/open_project/plugins/acts_as_op_engine.rb index ea4a9d6edda3..b2f34124127e 100644 --- a/lib/open_project/plugins/acts_as_op_engine.rb +++ b/lib/open_project/plugins/acts_as_op_engine.rb @@ -70,11 +70,12 @@ def self.included(base) # options: An options Hash, at least :requires_openproject is recommended to # define the minimal version of OpenProject the plugin is compatible with # Another common option is :author_url. - base.send(:define_method, :register) do |gem_name, options| + # block: Pass a block to the plugin (for defining permissions, menu items and the like) + base.send(:define_method, :register) do |gem_name, options, &block| base.initializer "#{engine_name}.register_plugin" do spec = Bundler.environment.specs[gem_name][0] - Redmine::Plugin.register engine_name.to_sym do + p = Redmine::Plugin.register engine_name.to_sym do name spec.summary author spec.authors.kind_of?(Array) ? spec.authors[0] : spec.authors description spec.description @@ -85,6 +86,7 @@ def self.included(base) send(name, value) end end + p.instance_eval(&block) if (p && block) end # Workaround to ensure settings are available after unloading in development mode