magento-lts
magento-lts copied to clipboard
Customization for _getUploadRoot and _getAllowedExtensions in Mage_Adminhtml_Model_System_Config_Backend_File
…lowedExtensions
Description (*)
Here we have the implementation of 2 functionalities:
1 - Add validation for allowed extensions when uploading files.
today:
<upload_dir config="system/filesystem/media" scope_info="1">sales/store/logo</upload_dir>
new:
<upload_dir allowed_extensions="png,jpg,jpeg,gif" config="system/filesystem/media" scope_info="1">sales/store/logo</upload_dir>
2 - Add validation to the config's attribute in upload_dir's tag (not used today). Also the possibility of customizing it. Example:
today:
<upload_dir config="system/filesystem/media" scope_info="1">docs/pdf</upload_dir>
new:
<upload_dir allowed_extensions="pdf" config="system/filesystem/var" scope_info="1">docs/pdf</upload_dir>
Related Pull Requests
Fixed Issues (if relevant)
- Fixes OpenMage/magento-lts#<issue_number>
Manual testing scenarios (*)
- ...
- ...
Questions or comments
Contribution checklist (*)
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All automated tests passed successfully (all builds are green)
- [ ] Add yourself to contributors list
@eneiasramos could you please write a real title and description? thanks!
@eneiasramos could you please write a real title and description? thanks!
Sorry I forgot that my dear :smile_cat:
@fballiano done my dear!
@Flyingmana can you help me here? I'm not sure I understand how to test this
will have a look on the weekend
Images can use the backend_model Mage_Adminhtml_Model_System_Config_Backend_Image, this will allow uploading of 'jpg', 'jpeg', 'gif', 'png' already. No need to have that in the base class.
As for the path I don't follow the changes here. Can you explain some more of what you are trying to do?
If you only want to allow a specific file extension I would provide a class that extends Mage_Adminhtml_Model_System_Config_Backend_File and override protected function _getAllowedExtensions.
(see Mage_Adminhtml_Model_System_Config_Backend_Image as an example)
Ok, for the how to Test part.
have a config which overwrites the system.xml for
There by adding the new allowed_extensions attribute it should be able to control which ones are allowed to upload.
Although, its probably more for the logo in app/code/core/Mage/Sales/etc/system.xml not the placeholder one in my screenshot.
What Iam not sure about is, what the exact use case or benefit should be.
Also as this part is a bit complex, I would would like to require a phpunit test for this parts
@Flyingmana here:
https://github.com/OpenMage/magento-lts/pull/4078
https://github.com/OpenMage/magento-lts/pull/4079
replaced by https://github.com/OpenMage/magento-lts/pull/4079 and https://github.com/OpenMage/magento-lts/pull/4078