Plugin modifying other plugin
Added by Daniel Vandersluis almost 15 years ago
Is it possible to have one plugin check for the existence of another plugin? I want to have one plugin add a permission into another plugin's project module, but only if the first is enabled.
I've considered checking if Redmine::Plugin.registered_plugins.keys
includes the plugin name, but at plugin initiation it will only contain plugins that are earlier alphabetically, which isn't the greatest thing to rely on. Any suggestions?
Replies (3)
RE: Plugin modifying other plugin - Added by Eric Davis almost 15 years ago
Yes, I added an API method that will check that another plugin is installed. It still loads alphabetically so you might need to change how the plugins are named if the load order isn't correct.
Redmine::Plugin.register :timesheet_plugin do
...
requires_redmine_plugin :another_plugin, :version_or_higher => '0.1.0'
end
Eric Davis
RE: Plugin modifying other plugin - Added by Daniel Vandersluis almost 15 years ago
Thanks, Eric, but that's not exactly what I was looking for -- I want to add functionality to my plugin based on if another plugin is available, but my plugin is not dependent on the other one. Is that possible?
RE: Plugin modifying other plugin - Added by Eric Davis almost 15 years ago
Oh ok. There are two ways I've done this. (Assume PluginAdder will add functionality to PluginClient.)
- Add Redmine hooks into PluginClient and then call the hooks from PluginAdder. That way both will work alone. My Timesheet and Billing plugin work like that, Billing adds a context menu to Timesheet
- Have PluginAdder patch PluginClient's models or classes at runtime to change the behavior. This is the same as any Redmine core patch except it's from plugin to plugin. I've done this too but I can't remember which plugins.
Eric Davis