首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >红矿插件开发

红矿插件开发
EN

Stack Overflow用户
提问于 2012-04-24 13:29:15
回答 1查看 2.1K关注 0票数 3

我正试图为红矿山创建一个消息插件。我对此有几点怀疑

  1. 我怎样才能用红矿山插件发送电子邮件呢?是否有可能在插件中创建邮件程序?如果是,那么创建mailer的命令是什么?
  2. 我能够看到几乎所有控制器文件的this(call_hook)方法。这种方法有什么用?

提前谢谢

EN

回答 1

Stack Overflow用户

发布于 2012-04-28 08:48:54

如何做到这一点有两种方法:

  1. 创建新邮件并从redmine继承它,只需按需要添加新方法即可。
  2. 修补红地雷邮件程序并添加发送邮件的方法

我在插件RedmineCRM中使用了第二个插件,您可以下载它并在lib/redmine/修补程序/mailerpatch.rb中签入

代码语言:javascript
运行
复制
require 'dispatcher'   

module RedmineContacts
  module Patches    

    module MailerPatch
      module InstanceMethods
        def contacts_note_added(note, parent) 
          redmine_headers 'X-Project' => note.source.project.identifier, 
          'X-Notable-Id' => note.source.id,
          'X-Note-Id' => note.id
          message_id note
          if parent
            recipients (note.source.watcher_recipients + parent.watcher_recipients).uniq
          else
            recipients note.source.watcher_recipients
          end

          subject "[#{note.source.project.name}] - #{parent.name + ' - ' if parent}#{l(:label_note_for)} #{note.source.name}"  

          body :note => note,   
          :note_url => url_for(:controller => 'notes', :action => 'show', :note_id => note.id)
          render_multipart('note_added', body)
        end

        def contacts_issue_connected(issue, contact)
          redmine_headers 'X-Project' => contact.project.identifier, 
          'X-Issue-Id' => issue.id,
          'X-Contact-Id' => contact.id
          message_id contact
          recipients contact.watcher_recipients 
          subject "[#{contact.projects.first.name}] - #{l(:label_issue_for)} #{contact.name}"  

          body :contact => contact,
          :issue => issue,
          :contact_url => url_for(:controller => contact.class.name.pluralize.downcase, :action => 'show', :project_id => contact.project, :id => contact.id),
          :issue_url => url_for(:controller => "issues", :action => "show", :id => issue)
          render_multipart('issue_connected', body)
        end

      end  

      def self.included(receiver)
        receiver.send :include, InstanceMethods
        receiver.class_eval do 
          unloadable   
          self.instance_variable_get("@inheritable_attributes")[:view_paths] << RAILS_ROOT + "/vendor/plugins/redmine_contacts/app/views"
        end  
      end

    end

  end
end

Dispatcher.to_prepare do  

  unless Mailer.included_modules.include?(RedmineContacts::Patches::MailerPatch)
    Mailer.send(:include, RedmineContacts::Patches::MailerPatch)
  end   

end
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10298888

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档