Jump to:

23461 Posts in 18908 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Image_Uploader $allowed_actions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1605 Views
  • micahsheets
    Avatar
    Community Member
    164 Posts

    Image_Uploader $allowed_actions Link to this post

    Is there a way to add more $allowed_actions to the Image_Uploader class without editing any core files? Also does $allowed_actions allow multiple entries per action? For example the $allowed_actions for Image_Uploader is:

       static $allowed_actions = array(
          'iframe' => 'CMS_ACCESS_CMSMain',
          'flush' => 'CMS_ACCESS_CMSMain',
          'save' => 'CMS_ACCESS_CMSMain',
          'delete' => 'CMS_ACCESS_CMSMain',
          'EditImageForm' => 'CMS_ACCESS_CMSMain',
          'DeleteImageForm' => 'CMS_ACCESS_CMSMain'
       );

    So 'iframe' is only allowed if the memeber has CMS_ACCESS_CMSMain. I want to add my own permissions to that.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Image_Uploader $allowed_actions Link to this post

    $allowed_actions is a public static, so you could overload it by setting Image_Uploader::$allowed_actions from your mysite/_config.php file.

  • micahsheets
    Avatar
    Community Member
    164 Posts

    Re: Image_Uploader $allowed_actions Link to this post

    Thank you, it is good to know that public static vars can be set that way in the _config.php. I didn't know that. That will help me a lot. So in this case:

    static $allowed_actions = array(
    'iframe' => 'CMS_ACCESS_CMSMain',
    'flush' => 'CMS_ACCESS_CMSMain',
    'save' => 'CMS_ACCESS_CMSMain',
    'delete' => 'CMS_ACCESS_CMSMain',
    'EditImageForm' => 'CMS_ACCESS_CMSMain',
    'DeleteImageForm' => 'CMS_ACCESS_CMSMain'
    );

    can I set more than one permission per item in the array?

    For example 'iframe' => 'CMS_ACCESS_CMSMain',
    'iframe' => 'CMS_ACCESS_CUSTOM',

    or 'iframe' =? array('CMS_ACCESS_CMSMain','CMS_ACCESS_CUSTOM')

    1605 Views
Page: 1
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.