Umbraco - how to add a special notification?

I am using Umbraco 4.6.2 and you need to extend the default notifications that it provides. For the sake of this question, let's say I'm trying to add a "Unpublish" message.

In \umbraco\presentation\umbraco\dialogs\notifications.aspx.csit creates a list of checkbx elements that are displayed to the user when the "Notifications" dialog is opened from the context menu.

I see that everyone Actionhas the ShowInNotifier property - how can I set this value to truefor the UnPublish action? Is it necessary to modify the basic codebase, or is there a good way that I can gracefully extend Umbraco?

So, after I added this, users can sign up for the UnPublish notification (I don’t see any steps here?). Will it automatically send notifications now?

I suppose not, so the next thing I did is to hook up the UnPublish event:

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);
        }
    }
}

So, bits of this code that are not real / I need some pointers to:

  • Is this the right way to check if a user is subscribed to a particular notification?

  • How can I send a notification using umbraco's default settings? (e.g. generate email like other notifications)

If this is not possible, and I must create my own email address:

  • How to get the email address stored in umbracoSettings.config file, which

  • , Umbraco ? ().

( ) : >

+3
2

.

, , . /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!

public char Letter. , . , .

public bool ShowInNotifier true.

!

0

Umbraco 4.7, UmbracoSettings:

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);
0

All Articles