Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 0.5.0: Compatibility with Redmine 2.0.3

  • Loading branch information...
commit 46fb75b003d76e6243a88e626c83906a4ed409dd 1 parent 4b39b73
@teleological authored
View
2  COPYRIGHT
@@ -1,4 +1,4 @@
-Copyright (C) 2010 Riley Lynch
+Copyright (C) 2010-2012 Riley Lynch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
View
11 README.textile
@@ -4,8 +4,8 @@ This is a plugin for the "Redmine project management application":http://www.red
h2. Installation
-# Install the redmine-stealth-plugin into your redmine application directory: ./script/plugin install http://github.com/teleological/redmine-stealth-plugin.git
-# Restart any running Redmine application servers
+# Install the redmine-stealth-plugin into your redmine application directory. For Redmine 2, git clone http://github.com/teleological/redmine-stealth-plugin.git plugins/redmine-stealth-plugin or for Redmine 1: ./script/plugin install http://github.com/teleological/redmine-stealth-plugin.git
+# Restart any running Redmine application servers or touch tmp/restart.txt for Passenger
# Configure the per-role permissions for "Toggle stealth mode" as desired
h2. Usage
@@ -14,9 +14,12 @@ h2. Usage
# Do whatever it is that needs doing. Redmine will not send emails as a result of your actions while stealth mode is enabled. Other users's actions will continue to send email unless they have also activated stealth mode.
# Click "Disable stealth mode" in the account menu. Don't worry. You got away with it.
-h2. To-do
+h2. Compatibility
-* Determine compatibility with different versions of redmine. This plugin was initially developed this with Redmine 0.9.1.stable, and version 0.4.0 was developed against Redmine 1.4.3. Please let me know if you find incompatibilities with older or newer versions.
+* Version 0.5.0 was written for Redmine 2.0.3 and tested for backwards-compatibility with Redmine 1.4.3.
+* Version 0.4.0 was written for Redmine 1.4.3 and added support for Ruby 1.9.
+* Previous verions were written for Redmine 0.9.1.stable and reported to work with Redmine 1.1.2 and 1.3-stable.
+* Compatibility with Chiliproject is unknown, but patches are welcome.
h2. License
View
17 config/routes.rb
@@ -1,3 +1,16 @@
-ActionController::Routing::Routes.draw do |map|
- map.connect '/stealth/toggle', :controller => 'stealth', :action => 'toggle'
+
+if Rails::VERSION::MAJOR >= 3
+
+ RedmineApp::Application.routes.draw do
+ match '/stealth/toggle', :to => 'stealth#toggle'
+ end
+
+else
+
+ ActionController::Routing::Routes.draw do |map|
+ map.connect '/stealth/toggle',
+ :controller => 'stealth', :action => 'toggle'
+ end
+
end
+
View
27 init.rb
@@ -1,9 +1,16 @@
+
require 'redmine'
require 'redmine/i18n'
require 'redmine_stealth'
require 'redmine_menu_manager_extensions'
-require 'action_mailer_base_extensions'
+
+if Rails::VERSION::MAJOR >= 3
+ require 'stealth_mail_interceptor'
+else
+ require 'action_mailer_base_extensions'
+end
+
require 'stealth_hooks'
Redmine::Plugin.register :redmine_stealth do
@@ -14,7 +21,7 @@
author 'Riley Lynch'
description 'Enables users to disable Redmine email notifications ' +
'for their actions'
- version '0.4.0'
+ version '0.5.0'
if respond_to?(:url)
url 'http://teleological.github.com/redmine-stealth-plugin'
@@ -53,9 +60,19 @@
}
end
-require 'dispatcher'
+require 'application_helper'
require 'stealth_css_helper'
-Dispatcher.to_prepare do
- ApplicationHelper.send(:include, StealthCssHelper)
+stealth_css_helper_mixin = lambda do |*_|
+ unless ApplicationHelper.included_modules.include?(StealthCssHelper)
+ ApplicationHelper.send(:include, StealthCssHelper)
+ end
+end
+
+if Rails::VERSION::MAJOR >= 3
+ ActionDispatch::Callbacks.to_prepare(&stealth_css_helper_mixin)
+else
+ require 'dispatcher'
+ Dispatcher.to_prepare(&stealth_css_helper_mixin)
end
+
View
2  lib/action_mailer_base_extensions.rb
@@ -1,4 +1,6 @@
+# Rails < 3
+
module ActionMailerBaseExtensions
def deliver_with_stealth!(mail=nil)
mail ||= instance_variable_get(:@mail)
View
2  lib/stealth_css_helper.rb
@@ -1,4 +1,3 @@
-require_dependency 'application_helper'
module StealthCssHelper
def self.included(base) # :nodoc:
@@ -21,3 +20,4 @@ def body_css_classes_with_stealth
end
end
end
+
View
16 lib/stealth_mail_interceptor.rb
@@ -0,0 +1,16 @@
+
+# Rails >= 3
+
+class StealthMailInterceptor
+ def self.delivering_email(msg)
+ if ::RedmineStealth.cloaked?
+ msg.perform_deliveries = false
+ if logger = ActionMailer::Base.logger
+ logger.info("Squelching notification: #{msg.subject}")
+ end
+ end
+ end
+end
+
+ActionMailer::Base.register_interceptor(StealthMailInterceptor)
+
Please sign in to comment.
Something went wrong with that request. Please try again.