Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

CMS Workflow - Email alerts


Go to End


13 Posts   4617 Views

Avatar
Andrew Houle

Community Member, 140 Posts

8 May 2010 at 5:41am

I have the CMS workflow installed and running ok. Upon an administrator hitting 'Save and Publish' an email is sent to the other administrators for the site. I would like to disable this feature. I see in the readme file that you can customize the email alerts, but I haven't been able to get this to work successfully. I'm assuming I should put my code in mysite/_config.php I've tried a bunch of combinations like this WorkflowRequest::set_alert('WorkflowPublicationRequest', 'publish', 'publisher', 'false'); with no success. Am I doing this right? Any suggestions?

Thanks in advance,
Andrew

Avatar
mark_s

Community Member, 78 Posts

12 May 2010 at 11:41am

Hi Andrew.

Try:

WorkflowRequest::set_alert('WorkflowPublicationRequest', 'approve', 'publisher', 'false');

The docs were a little out of date. 'publish' event became 'approve' in 2-step workflow, so I've corrected the docs to reflect what's in the code.

Regards
Mark

Avatar
Andrew Houle

Community Member, 140 Posts

13 May 2010 at 1:24am

Hi Mark, thanks for your response. I've tried these...

WorkflowRequest::set_alert('WorkflowPublicationRequest', 'approve', 'publisher', 'false');
WorkflowRequest::set_alert('WorkflowPublicationRequest', 'approve', 'approver', 'false');

but it's still sending emails to administrators on approval. Any ideas?

Thanks,
Andrew

Avatar
mark_s

Community Member, 78 Posts

13 May 2010 at 3:01pm

Hi Andrew.

A couple of questions:
* What revision of cmsworkflow are you using?
* Are you using 2 or 3 step?

Also, can you print_r the value of WorkflowTwoStepRequest::$default_alerts before and after setting the alert. (or WorkflowThreeStepRequest::$default_alerts if you're using 3-step).

Thanks
Mark

Avatar
Andrew Houle

Community Member, 140 Posts

14 May 2010 at 1:35am

Hi Mark, thanks for your support. I'm using rev #104799 on SS 2.4rc1. It's a two step workflow, and I have the following in mysite/_config.php

WorkflowRequest::set_alert('WorkflowPublicationRequest', 'approve', 'publisher', 'false');
WorkflowRequest::set_alert('WorkflowPublicationRequest', 'approve', 'approver', 'false');
WorkflowRequest::set_alert('WorkflowPublicationRequest', 'publish', 'publisher', 'false');
WorkflowRequest::set_alert('WorkflowPublicationRequest', 'publish', 'approver', 'false');

(Trying every option). Any suggestions? Have you gotten this to work in your setup? I'm not sure what you mean by the print_r bit?

Thanks,
Andy

Avatar
mark_s

Community Member, 78 Posts

14 May 2010 at 9:03am

Hi Andrew.

Thanks for the details.

The alert logic (for 2-step) uses the static WorkflowTwoStepRequest::$default_alerts as the defaults for what is loaded into a static variable WorkflowRequest::alerts. set_alert overrides values in this static. There are a couple of avenues to pursue:

* determine if set_alert is having the effect you think it should be having, by calling print_r(WorkflowRequest::alerts) before and after calling set_alert.
* rather than call set_alert, assign WorkflowTwoStepRequest::$default_alerts in mysite config. It's not pretty, but you could try something like this:
if (class_exists('WorkflowTwoStepRequest')) {
WorkflowTwoStepRequest::$default_alerts = array(
'WorkflowPublicationRequest' => array(
'request' => array(
'author' => true,
'publisher' => true
),
'approve' => array(
'author' => true,
'publisher' => true
),
'deny' => array(
'author' => true,
'publisher' => true
),
'cancel' => array(
'author' => true,
'publisher' => true
),
'comment' => array(
'author' => true,
'publisher' => true
),
'requestedit' => array(
'author' => true,
'publisher' => true,
'approver' => true
)
),
'WorkflowDeletionRequest' => array(
'request' => array(
'author' => false,
'publisher' => false
),
'approve' => array(
'author' => true,
'publisher' => true
),
'deny' => array(
'author' => true,
'publisher' => true
),
'cancel' => array(
'author' => true,
'publisher' => true
),
'comment' => array(
'author' => false,
'publisher' => false
)
)
);
}

in mysite/_config.php, with the settings you want, and see if that gives you the behaviour you're after. Is it only admin you gets the unwanted email? If you have a non-admin with publishing priveleges, do you get the same behaviour?

Mark

Avatar
Andrew Houle

Community Member, 140 Posts

15 May 2010 at 7:04am

Only admins have publishing rights. The other publishers that don't approve the change are the one's that see the email. I tried adding: print_r(WorkflowRequest::alerts); to mysite/_config.php but it just gave my a white screen. I tried the long permissions in config and that had no effect. I tried hacking the core and changing things to false in WorkflowTwoStepRequest.php and that didn't work. Finally, I removed:

if (WorkflowRequest::should_send_alert(get_class($this->owner), 'approve', 'publisher')) {
$publishers = $this->owner->Page()->PublisherMembers();
foreach($publishers as $publisher) $emailsToSend[] = array($userWhoApproved, $publisher);
}

in notifyApproved($comment) function. That worked, but of course I'd rather not hack the core of this module. Lost for ideas. Thanks again for working with me.

Andrew

Avatar
mandrew

Community Member, 37 Posts

17 May 2010 at 1:13pm

Hi.

Sorry, my mistake, try print_r(WorkflowRequest::$alerts) to get the alert settings. Odd that the explicit settings didn't make a difference. Did you play with the values in there to see if you could affect it's behaviour? I just realised that in:

'WorkflowPublicationRequest' => array(
'request' => array(
'author' => true,
'publisher' => true
),
'approve' => array(
'author' => true,
'publisher' => true
),

you need to alter:
'publisher' => true

to
'publisher' => false

and any other changes you want. I should have pointed that out before.

Mark

Go to Top