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

    Is there any way to extend the permission verification in MODExt (understand being able to check more permissions than the ones already provided : http://rtfm.modx.com/display/revolution20/MODExt+MODx+Object#MODExtMODxObject-MODx.perm )?

    Since there are numerous ways of doing things in/with MODX, i might have chosen an "improper" one. Basically, here’s what i’m trying to achieve:

    In a CMP grid, i’d like to check if a user have some permission (in my case edit_locked). If so, some options will be available in the contextual menu. Some code might be more "talkative":
    …
        ,getMenu: function() {
            var m = [];
            if (this.menu.record.locked != 1 || MODx.perm.new_chunk == 1 ) {
                m.push({
                    text: _('asides.aside_update')
                    ,handler: this.updateAside
                });
                m.push('-');
                m.push({
                    text: _('asides.aside_remove')
                    ,handler: this.removeAside
                });
            }
            this.addContextMenuItem(m);
        }
    …
    


    So if you have any idea on how i could do (either via "extending" MODx.perm or via another way), any reading recommendation would be welcome (/me loves reading MODX source code laugh).
    Thanks
      • 28215
      • 4,149 Posts
      Just set a JS var in your CMP’s controller:

      $hasPerm = $modx->hasPermission('my_permission');
      $modx->regClientStartupHTMLBlock('<script type="text/javascript">var myPermToCheck = '.($hasPerm ? 1 : 0).';</script>');
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • The more i work with MODX, the more i see how you made things so simple for us (and i’m loving MODX more & more everyday!).

        Thanks splittingred for your anwser