Skip to main content
edited tags to clarify context of the question
Link
Nickoli Roussakov
  • 18.4k
  • 4
  • 31
  • 62
Tweeted twitter.com/#!/StackTridion/status/426795027487285249
Source Link
Quirijn
  • 6.8k
  • 1
  • 14
  • 33

Which event is fired when I click the Publish button?

I'm trying to catch the moment when a user hits the Publish button in the publish popup screen in the GUI. This is a GUI-driven event, which is important for me because I have some logic that is tied to the group memberships of the user who clicks the button. For this reason, I cannot use any of the events that are fired by the publisher service. For those events, the session user is always 'NT Authority\System'.

The following code does not seem to work, or rather, I cannot get it to start debugging. I have attached to the dllhost, dllhst3g and TcmServiceHost processes, but although the breakpoints become active, they are never hit.

[TcmExtension("PreventPublishing")]
public class PreventPublishing : TcmExtension
{
    public PreventPublishing()
    {
        EventSystem.Subscribe<RepositoryLocalObject, PublishingEventArgs>(OnItemPublish, EventPhases.Initiated);
    }

    private void OnItemPublish(RepositoryLocalObject item, PublishingEventArgs args, EventPhases phase)
    {
        User user = item.Session.User;
        if (user.IsSystemAdministrator)
            return;
        throw new PublisherException(new LocalizableMessage("Only system administrators are allowed to publish"));
    }
}

Any clues?