We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30524
    • 22 Posts
    Hey,

    Situation

    I have two different Usergroups. In One group are SuperUser in the another one are the normal Content-Editors.
    They both have access to the Mgr and they can both create Content. I want that all content created by the user of the Content-Editors have a speciel default ResourceGroup maybe like "notyetpublic".The SuperUser is able to choose the RG.

    Idea:
    I tried to do this with the Form Customization Rules but I cant find any hint how I can address ResourceGroup with the Default Value Rule.

    Is this somehow possible?

    matic

      • 3749
      • 24,544 Posts
      I think you’d need a plugin to do that. The easiest way is to have all the docs created under parent containers that belong to the protected resource group and have the children inherit the resource groups of their parents. IIRC, the NewsPublisher snippet will create docs that inherit their doc group membership from their immediate parent.

        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
        • 30524
        • 22 Posts
        Hey BobRay,

        thank you for that answer.

        For this situation it is not possible do create a Parent with a special ResourceGroup. So, I will go for the Plugin solution.
        Modx made it pretty easy to develop plugins and snippets wink But at first I take a look at the NewsPublisher, but i that a Evo - Snippet
          • 3749
          • 24,544 Posts
          I’m working on a Revo version of NewsPublisher. It’s not quite ready for use, but I hope to have something up in the next week or so.
            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
            • 30524
            • 22 Posts
            hey bobray,

            for now i just did it like that:

             $eventName = $this->modxInstance->event->name;
                    switch($eventName) {
                        case 'OnDocFormSave':
                                
                                
                              if($this->properties['mode'] == 'new') {
                                
                                $resourceGroupId = $this->modxInstance->getOption('editorialgroup',$this->properties,'0'); 
                                
                                $resource =&  $this->properties['resource'];
                                $resourceId = $resource->get('id');
                                
                                $newResourceGroupAccess = $this->modxInstance->newObject('modResourceGroupResource');
                                $newResourceGroupAccess->set('document_group',$resourceGroupId);
                                $newResourceGroupAccess->set('document',$resourceId);
                                $newResourceGroupAccess->save();
                              }
                                
                                
                            break;


            It works perfectly.
              • 3749
              • 24,544 Posts
              Looks good, although the first three lines are unnecessary if you’re only linking it to one event.
                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
                • 12262
                • 40 Posts
                Hello traedamatic,

                nice script... but it does not work on my website. What do I have to change (which is the resource group name (editorialgroup?). I'm running on Revo 2.2.6


                Thomas
                • I may be mistaken, but doesn't this line cause problems with some versions of PHP?
                  $resource =&  $this->properties['resource'];


                  http://php.net/manual/en/language.references.whatdo.php
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 38290
                    • 712 Posts
                    This is awesome. What about removing a resource from a resource group?
                      jpdevries
                      • 38290
                      • 712 Posts
                      Bob answered this in this post. Thanks!
                      Quote from: BobRay at Jun 14, 2013, 08:13 PM
                      This will remove a resource from a resource group:

                      $resource->leaveGroup($group);
                      http://forums.modx.com/index.php?topic=60107.0;wap2
                        jpdevries