No parents
1:be45f1 »
0
0
7
| 1 |
require 'redmine' |
|
| 2 |
require 'redmine_default_group/patch' |
|
| 3 |
|
|
| 4 |
|
|
| 5 |
Redmine::Plugin.register :redmine_default_group do |
|
| 6 |
name 'Redmine Default Group plugin' |
|
| 7 |
author 'Arthur Zalevsky' |
|
| 8 |
description 'This plugin allows to set default group for new users.' |
|
| 9 |
version '0.0.1' |
|
| 10 |
url 'https://github.com/yourcelf/redmine_etherpad' |
|
| 11 |
author_url 'https://github.com/yourcelf' |
|
| 12 |
settings :partial => 'settings/default_group', |
|
| 13 |
:default => {
|
|
| 14 |
'group' => false, |
|
| 15 |
} |
|
| 16 |
|
|
| 17 |
Rails.configuration.to_prepare do |
|
| 18 |
# This tells the Redmine version's controller to include the module from the file above. |
|
| 19 |
AccountController.send(:include, RedmineDefaultGroup::AccountControllerPatch) |
|
| 20 |
end |
|
| 21 |
|
|
| 22 |
# settings = Setting.plugin_redmine_etherpad |
|
| 23 |
# unless settings['host'] and settings['key'] |
|
| 24 |
# raise "Please define etherpad parameters in configuration.yml." |
|
| 25 |
# end |
|
| 26 |
|
|
| 27 |
# Set current user name. |
|
| 28 |
if User.current |
|
| 29 |
settings['userName'] = User.current.name |
|
| 30 |
#elsif conf.fetch('loginRequired', true)
|
|
| 31 |
# return "TODO: embed read-only." |
|
| 32 |
end |
|
| 33 |
|
|
| 34 |
end |
| 1 |
module RedmineDefaultGroup |
|
| 2 |
module AccountControllerPatch |
|
| 3 |
def self.included(base) |
|
| 4 |
base.class_eval do |
|
| 5 |
# Insert overrides here, for example: |
|
| 6 |
def register_automatically_with_default_group(user, &block) |
|
| 7 |
register_automatically_without_default_group(user, &block) |
|
| 8 |
@group = Group.find(:first, :conditions => ["LOWER(lastname) = ?", Setting.plugin_redmine_default_group['group'].downcase]) |
|
| 9 |
@group.users << user |
|
| 10 |
end |
|
| 11 |
|
|
| 12 |
alias_method_chain :register_automatically, :default_group # This tells Redmine to allow me to extend show by letting me call it via "show_without_plugin" above. |
|
| 13 |
# I can outright override it by just calling it "def show", at which case the original controller's method will be overridden instead of extended. |
|
| 14 |
end |
|
| 15 |
end |
|
| 16 |
end |
|
| 17 |
end |
0 comments (0 inline)