We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi guys, I love Revo - but was wondering if anyone had any ideas on the possibly introduction of tiered manager user roles which would involve email notification of actions. So the idea would be, the CMS has an editor role and a publisher role, the editor can create new resources but not publish them live - they instead can submit the resource for approval, which would then ping the publisher (who can create resources and also publish / unpublish) an email to login and review and edit/publish.

    I know using ACLs you can create the editor role not to allow them to publish articles - but there is no way (that I am aware of) to include the email notification to publisher(s) when a new resource has been created by an editor ready for approval to go live...?

    Does this workflow exist in any addon? Or could it be added to the core in some way?

    Appreciate peoples thoughts - I think this would be a great addition to the manager / roles section...

    Thoughts?

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      I think that would best be done in a plugin attached to OnDocFormSave. At that point, you can tell the difference between new and existing documents, so the plugin could fire off the email if a new resource is being saved by a member of the Editors user group.

      This would work, but would notify the admin of *all* new resources unless you create a hook to check the usergroup and/or role of the user:
      http://rtfm.modx.com/display/ADDON/ResourceWatcher

      Here's a possible solution using ResourceWatcher: http://www.bdcreative-design.com/blog/my-solution-for-a-resource-approval-workflow-using-modx.html [ed. note: BobRay last edited this post 13 years, 4 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 8168
        • 1,118 Posts
        Quote from: BobRay at Jun 20, 2013, 02:02 PM
        I think that would best be done in a plugin attached to OnDocFormSave. At that point, you can tell the difference between new and existing documents, so the plugin could fire off the email if a new resource is being saved by a member of the Editors user group.

        There may already be an extra that does this. If not, it should be relatively simple to create.

        Thanks Bob - Sounds interesting - I am not sure sending an email notification everytime the editor saved a resource would be required though - I would more see it as an additional button / checkbox for the editors where they can select to say, this resource is now ready for approval - this then informs the CMS to send the email notification... Possible?

        Anyone developed anything like this already?
          • 3749
          • 24,544 Posts
          That should be easy enough to do with a checkbox TV ("Submit for Review"). The hook for ResourceWatcher could check the TV value and the user group of the creator.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 8168
            • 1,118 Posts
            Quote from: BobRay at Jun 20, 2013, 02:17 PM
            That should be easy enough to do with a checkbox TV ("Submit for Review"). The hook for ResourceWatcher could check the TV value and the user group of the creator.

            Thanks Bob. You make this all sound very simple to implement - is it an easy job then?
            • discuss.answer
              • 3749
              • 24,544 Posts
              I think the method in this link would do just what you want: http://www.bdcreative-design.com/blog/my-solution-for-a-resource-approval-workflow-using-modx.html

              The checkbox TV would be called approvalSwitch with a default value of 0. You can use anything you like for the Caption. The user would just check it when they want to submit the resource for review and save the resource. If the user is a member of the Editor user group, you should get an email.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 8168
                • 1,118 Posts
                Thanks Bob - that looks like a great solution. I will give it a go... Thanks for your expertise and insight on this.

                Cheers.
                  • 3749
                  • 24,544 Posts
                  Don't thank me until it works. wink
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 8168
                    • 1,118 Posts
                    Hi Bob,

                    I implemented things as per that tutorial but can't seem to get it to work... It now seems when the editor tries to save a resource it sits on a never ending Please Wait - Saving pop-up which never goes away... I assume something is not right with the hook in the ResourceWatcher - this must be what is causing the issue on resource save...

                    Any ideas? Have you ever implemented this theory?

                    Update - yep, if I remove the custom snippet as mentioned in that tutorial the saving works and the default email notifications work from ResourceWatcher. Any ideas what is wrong with the snippet code below?

                    /** * * * A hook to send approval request. Only triggered upon resource update */
                    $usergroup='Editor';
                    $resource = $modx->getObject('modResource', $scriptProperties['id']);
                    $editor = $resource->get('editedby');
                    $user=$modx->getObject('modUser',array('id'=>$editor));
                    $checkMembership = $user->isMember($usergroup);
                    $state = $resource->getTVValue('approvalSwitch');
                    if ($state=='yes' && $checkMembership==true) {
                    // resource is not from editor, we don't want notifications
                    return true; }
                    return false;
                    
                    [ed. note: dubbs last edited this post 13 years, 3 months ago.]
                      • 3749
                      • 24,544 Posts
                      Try this version and look in the error log:

                      <?php
                      /** * * * A hook to send approval request. Only triggered upon resource update */
                      $usergroup='Editor';
                      
                      if (! isset($scriptProperties['id'])) {
                          $modx->log(MODX::LOG_LEVEL_ERROR, 'scriptProperties ID not set');
                          return;
                      }
                      
                      $resource = $modx->getObject('modResource', $scriptProperties['id']);
                      
                      if (! $resource) {
                          $modx->log(MODX::LOG_LEVEL_ERROR, 'Could not get Resource. ID: ' . $scriptProperties['id']);
                          return;
                      }
                      
                      $editor = $resource->get('editedby');
                      
                      if (! $editor) {
                          $modx->log(MODX::LOG_LEVEL_ERROR, 'editedby is empty');
                          return;
                      }
                      $user=$modx->getObject('modUser',array('id'=>$editor));
                      
                      if (!$user) {
                          $modx->log(MODX::LOG_LEVEL_ERROR, 'user is empty');
                          return;
                      }
                      
                      
                      $checkMembership = $user->isMember($usergroup);
                      $state = $resource->getTVValue('approvalSwitch');
                      if ($state=='yes' && $checkMembership==true) {
                          return true;
                      }
                      return false;
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting