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

    It would be so nice if one could merely do something like
    $modx->addPermission("content", "Image upload", 0);
    to add a new "Image upload" permission to the "Content Management" group with a default of 0 (no).

    Then you could check it in the code:
    if ($modx->hasPermission("content", "Image upload")) { ... };

    Using a system similiar to this, a snippet could register a new permission right during install, along with a default state, and it would autoregister in all roles.

    Does this make sense to anyone other than me? smiley

    Sounds great!

    So I think it should be $modx->addPermission($category,$permCode,$description,$default);

    e.g.
    $modx->addPermission("Content Roles","image_upload","Image Upload",0);

    if ($modx->hasPermission("image_upload")) {
    /// do stuff
    }

    or maybe

    if ($modx->hasPermission(array("image_upload","file_upload"))) {
    // do stuff
    }
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 6661
      • 119 Posts



      Something I did several months ago was to abstract the permissions to the point where even the WYSIWYG editor could control who could select font colors, tables, image uploads, bold/italics, etc based on security profiles.

      Wow! I'm thinking do we need to go that far? smiley

      Actually this is very useful. Specifically for the WYSIWYG editor, what is even more useful is to be able to set the options on a per TV basis. For example, you might have an HTMLarea TV that should only allow bold, italics and underline and nothing else. Because maybe it is a section of the page you don't want any images or tables. Another TV might use the full HTMLarea (or whatever editor). Looking this over, this is a not a permission thing but a TV feature request. A little popup or something with checkboxes for the WYSIWYG options to be passed to the editor would be perfect.