Redmine Customization Using Plugins
Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.
Redmine is open source and released under the terms of the GNU General Public License v2 (GPL).
Creating a new Plugin
Creating a new plugin can be done using the Redmine plugin generator.
Syntax for this generator is:
Edit plugins/polls/init.rb to adjust plugin information (name, author, description, and version):
Generating a model
For now, plugin doesn't store anything. Let's create a simple Poll model for our plugin. Syntax is:
Generating a controller
For now, the plugin doesn't do anything. So let's create a controller for our plugin.
We can use the plugin controller generator for that. Syntax is:
Our controller works fine but users have to know the url to see the polls. Using the Redmine plugin API, you can extend standard menus.
So let's add a new item to the application menu.
Extending the application menu
Edit plugins/polls/init.rb at the root of your plugin directory to add the following line at the end of the plugin registration block:
Adding new permissions
For now, anyone can vote for polls. Let's make it more configurable by changing the permission declaration.
We're going to declare 2 project based permissions, one for viewing the polls and another one for voting. These permissions are no longer public (:public => true option is removed).
Edit plugins/polls/init.rb to replace the previous permission declaration with these 2 lines:
Hooks in views
To use one or more hooks in views, you need to create a class that inherits from Redmine::Hook::ViewListener and implement methods named with the hook(s) you want to use. To append some content to the project overview, add a class to your plugin and require it in your init.rb, then implement methods whose name match the hook names.
For our plugin create a file plugins/polls/lib/polls_hook_listener.rb with this content:
Prepend this line to plugins/<plugin name>/init.rb: