Start a workflow on page activation without activating the page in CQ5
Asked Answered
M

2

7

I would need to call a workflow whenever a content author clicks activate on a page. The workflow would then send a notification to the administrator, who then proceeds to activate the page.

Let me explain this with some more detail. There are 2 parts to this

i) Whenever a content author is done modifying a page, he would then proceed to click "Activate Page" from either the sidekick or from page properties on the siteadmin. By doing so, he is not activating the page straight away but calling a workflow.

ii) The workflow will send out a notification to the admin, who then decides to activate the page. This bit is fairly ordinary, so no issues here.

All of this is an effort to make sure that there is nothing published/activated unless it has been reviewed by an admin.

I tried setting up a ReplicationEvent listener that would call a workflow. What happens is that the page is already activated before the workflow is called; the occurrence of a ReplicationEvent is only after said Replication Event (i.e Activate) occurs (Obviously!).

As stated, I need to make sure that the page isn't actually activated when the user clicks activate; which means I need to modify what the activate button does exactly.

I have tried looking up online, but found nothing, which leads me to believe that most of CQ5's siteadmin code is hidden from us and cannot be modified (and with good reason).

So is there anything else that anyone can think of which may help me to achieve my requirement? Or should I give this up as a lost cause?

Thanks in advance and apologies for the long post

Manwell answered 18/9, 2013 at 5:10 Comment(0)
V
7

You could put the authors in a user group that does not have replication permissions. When an author tries to activate a page without the permissions, it automatically starts the request for activation workflow. I think the default config has one step for content approval and a separate step for activation. Both steps are mapped to the administrator user group. The workflows are at http://localhost:4502/libs/cq/workflow/content/console.html and you can double click on a model to edit it.

Vevay answered 18/9, 2013 at 15:14 Comment(5)
has this worked for you? because when i try logging in as author and activate any page, it denies the action, but there is no workflow triggered. I haven't found any information about this in their official documentation [link] (dev.day.com/docs/en/cq/current/administering/security.html) on this topic either.Manwell
Which version of cq are you using? From the docs it looks like in 5.6+ the workflow will automatically start when a user fails to activate. You can also set the workflow off manually through the workflow tab in the sidekick.Vevay
i did see that in the docs for ReplicatePageProcess. im using 5.6. my requirements need me to trigger the workflow on clicking activate, though, as stated above, so I guess setting the workflow manually is outManwell
My 5.6 works fine. I started a new instance, created a user without replication permissions, and tried to activate a geometrixx page. It spits out Warn: No rights to replicate. Request for de/activation got issued for /content/dam/geometrixx/packshots/pack_square.jpg and starts a workflow. You should be able to see the message in the admin's inbox (http://localhost:4502/notifications.html)Vevay
Strangely; the workflow gets called when I create a new user from scratch; and not when I change the rights of any preexisting user. Thanks a lot btw :DManwell
C
4

You can use replication preprocessor (example) which is something like replication event listener but is invoked before the activation is done. Throwing exception in the preprocess() method will stop activation process and display exception message.

However, more elegant option is to use ACL to forbid an user to activate the page. After that, clicking Activate button won't publish the page but will rather invoke Request for Activation workflow.

Cowpox answered 18/9, 2013 at 12:22 Comment(3)
just wondering if a replication preprocessor is the best way to go about it. Wouldn't invoking a request for activation workflow in this way set up a never ending loop of sorts when the administrator tries to activate the page?Manwell
The replication preprocessor should disable activation only for selected user/group (not for admin). But I agree that the second way (using ACL rather than preprocessor) is a better option.Gelatinoid
hmm.. is there a way to attach a workflow through ACL on activate? or does it do that automatically? i tried logging in as "author", and activating the page; while it does deny the activation, it does not initiate a Request for activation workflow. Doesn't really say anything about workflows here either :- linkManwell

© 2022 - 2024 — McMap. All rights reserved.