Skip to content

Instantly share code, notes, and snippets.

@crazylion
Created September 21, 2011 16:19
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save crazylion/1232512 to your computer and use it in GitHub Desktop.
change author
# location lib/plugins/assign_author/hook.rb
#如果使用者想要透過webservice指定作者的話,http 參數給予author_login即可。
# 此欄位為user table的 login欄位
module AssignAuthor
class Hooks < Redmine::Hook::ViewListener
def controller_issues_new_before_save(context={})
if context[:params]["author_login"]
u=User.find_by_login(context[:params]["author_login"])
context[:issue].author = u
end
return ''
end
end
end
#location: config/initializers/init.rb
require 'redmine'
require_dependency 'plugins/assign_author/hook'
@zx1986
Copy link

zx1986 commented Sep 22, 2011

收到!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment