Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Image_Uploader $allowed_actions


Go to End


3 Posts   2202 Views

Avatar
micahsheets

Community Member, 165 Posts

14 May 2009 at 11:56am

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.

Avatar
Sean

Forum Moderator, 922 Posts

29 May 2009 at 10:30am

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

Avatar
micahsheets

Community Member, 165 Posts

29 May 2009 at 11:37am

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')