Umbraco-如何添加自定义通知?

| 我正在使用Umbraco 4.6.2,并且需要扩展它提供的默认通知。为了解决这个问题,假设我正在尝试添加一个“取消发布”通知。 在“ 0”中,它将构造从上下文菜单打开“通知”对话框时显示给用户的checkbx项目列表。 我看到每个ѭ1都有一个ShowInNotifier属性-如何为UnPublish操作将此值设置为
true
? 这是否需要修改核心代码库,还是我可以优雅地扩展Umbraco的一种好方法? 因此,在我添加此内容之后,用户可以订阅UnPublish通知(我是否在这里缺少任何步骤?)。 现在会自动发送通知吗? 我猜不是,所以我接下来要做的就是钩住UnPublish事件:
public class CustomEvents : ApplicationBase
{
    public CustomEvents()
    {
        Document.AfterUnPublish += new Document.UnPublishEventHandler(Document_AfterUnPublish);
    }

    void Document_AfterUnPublish(Document sender, umbraco.cms.businesslogic.UnPublishEventArgs e)
    {
        var user = User.GetCurrent();

        if (!string.IsNullOrEmpty(user.Email) && user.GetNotifications(sender.Path).Contains(\"UnPublish\"))
        {
            //Send a notification here using default Umbraco settings, or, construct email and send manually:
            string umbracoNotificationSenderAddress = \"\";   //How to get the address stored in umbracoSettings.config -> <notifications> -> <email>

            //How to use the same subject/message formats used for other notifications? With the links back to the content?
            string subject = \"Notification of UnPublish performed on \" + MyUtilities.GetFriendlyName(sender.Id);
            string message = MyUtilities.GetFriendlyName(sender.Id) + \" has just been unpublished.\";

            umbraco.library.SendMail(umbracoNotificationSenderAddress, user.Email, subject, message, true);
        }
    }
}
因此,该代码中不真实的位/我需要一些指针: 这是检查用户是否已订阅特定通知的正确方法吗? 如何使用默认的umbraco设置发送通知? (例如,与其他通知一样生成电子邮件) 如果那不可能,那么我必须构造自己的电子邮件: 如何从存储在umbracoSettings.config中的电子邮件地址获取 如何复制默认Umbraco通知使用的格式?我应该手动复制它还是有更好的方法(以编程方式)做到这一点? 任何帮助(甚至只是到相关示例的链接),都表示赞赏:>     
已邀请:
我的同事做了这项工作。 创建一个类,该类将覆盖您希望对其进行通知的操作。 您可以在
/umbraco/cms/Actions
中查看所有动作
public class ActionUnPublishOverride : umbraco.BusinessLogic.Actions.ActionUnPublish, IAction
{
    ... see what the other actions look like to find out what to put in here!
在替代课程中,您将获得a6ѭ。设置它以匹配要挂接到的事件。您可以在数据库中找到每个事件的字母。 将ѭ7设置为true。 而已!     
我已经使用UmbracoSettings类在Umbraco 4.7上进行了此工作: http://www.java2s.com/Open-Source/CSharp/Content-Management-Systems-CMS/umbraco/umbraco/businesslogic/UmbracoSettings.cs.htm
umbraco.library.SendMail(umbraco.UmbracoSettings.NotificationEmailSender, newMember.Email, \"email subject\", \"email body\", false);
    

要回复问题请先登录注册