Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up reimplementing the <code>enabled_module_names=</code> method of projects, including a file in vendor/plugins/my_plugin/lib/my_plugin/patches/project_patch.rb and alias.</p> <pre><code>module MyPlugin module Patches module ProjectPatch def self.included(base) base.send(:include, InstanceMethods) base.extend(ClassMethods) base.class_eval do unloadable # Send unloadable so it will not be unloaded in development # This replaces the existing version of enabled_module_names with a new one # It is needed because we need the "destroy" callbacks to be fired, # and only on the erased modules (not all of them - the default # implementation starts by wiping them out in v0.8'ish) alias_method :enabled_module_names=, :sympa_enabled_module_names= end end module ClassMethods end module InstanceMethods # Redefine enabled_module_names so it invokes # mod.destroy on disconnected modules def sympa_enabled_module_names=(module_names) module_names = [] unless module_names and module_names.is_a?(Array) module_names = module_names.collect(&amp;:to_s) # remove disabled modules enabled_modules.each {|mod| mod.destroy unless module_names.include?(mod.name)} # detect the modules that are new, and create those only module_names.reject {|name| module_enabled?(name)}.each {|name| enabled_modules &lt;&lt; EnabledModule.new(:name =&gt; name) } end end end end end </code></pre> <p>I had to include some code on my vendor/plugins/my_plugin/init.rb file, too:</p> <pre><code>require 'redmine' require 'dispatcher' # you can add additional lines here for patching users, memberships, etc... Dispatcher.to_prepare :redmine_sympa do require_dependency 'project' require_dependency 'enabled_module' Project.send(:include, RedmineSympa::Patches::ProjectPatch) EnabledModule.send(:include, RedmineSympa::Patches::EnabledModulePatch) end Redmine::Plugin.register :redmine_sympa do # ... usual redmine plugin init stuff end </code></pre> <p>After this, I was able to detect deletions on enabled modules (via <code>before_delete</code>) on my patcher.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload