Quote from: OpenGeek at Jan 09, 2010, 11:08 AM
All you need do is have the plugin listen on both OnDocPublished and OnDocFormSave to handle cases where someone is directly calling the publishing action, with it’s own event vs. editing a document and changing the published status (potentially along with a great many other things).
I do not agree that this is a bug; it may not be totally intuitive to have to handle both events, but this is the way the event model is currently implemented and used.
I tried messing with this and I’m not sure the logic makes sense. It looks like OnDocPublished is only invoked in the publish processor, and I can’t find any places where it’s being called. Neither the publish processor not OnDocPublished are fired by the resource create and update processors, which both publish documents. If OnDocPublished *is* called somewhere, it seems that a plugin listening to both events might execute the code twice unless there’s some system for deciding when OnDocPublished is and isn’t invoked. And that raises the question: why have an OnDocPublished event if it isn’t invoked every time a document is published. I have the same question with OnActivateUser.
It seems to me that it would make more sense to invoke OnDocPublished in the resource object’s save() method and nowhere else (and OnActivateUser invoked in the user object’s save method).
I was also surprised to find that there’s no OnResourceBeforeSave event to match all the other OnObjectBeforeSave events. That would be a logical place to check for publication if OnDocPublished is unreliable.
I couldn’t see any method that would work when when a resource is set to published in code or bulk action (e.g. Batcher).