Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » CMS Workflow - Email alerts

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 2859 Views
  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    CMS Workflow - Email alerts Link to this post

    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

  • mark_s
    Avatar
    Community Member
    78 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • mark_s
    Avatar
    Community Member
    78 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • mark_s
    Avatar
    Community Member
    78 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

  • mandrew
    Avatar
    Core Development Team
    32 Posts

    Re: CMS Workflow - Email alerts Link to this post

    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

    2859 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.