Skip to content
Browse files

MINOR implement the allowedExtensions functionality of AssetAdmin whe…

…n you rename a file (from r92037) (from r96814)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102676 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 99eb135 commit caed94d9f55e5cc0dcbdbdd38cd3d1b6bf6dc5e9 @chillu chillu committed Apr 13, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 code/AssetTableField.php
View
24 code/AssetTableField.php
@@ -343,6 +343,30 @@ public function movemarked($request) {
);
}
}
+ function handleItem($request) {
+ return new AssetTableField_ItemRequest($this, $request->param('ID'));
+ }
}
+class AssetTableField_ItemRequest extends ComplexTableField_ItemRequest {
+ function saveComplexTableField($data, $form, $request) {
+
+ if(!AssetAdmin::$apply_restrictions_to_admin && Permission::check('ADMIN')) {
+ if(!in_array(strtolower(pathinfo($data['Name'], PATHINFO_EXTENSION)), AssetAdmin::$allowed_extensions)) {
+ $form->sessionMessage(sprintf(
+ _t(
+ 'File.INVALIDEXTENSION',
+ 'Extension is not allowed (valid: %s)',
+ PR_MEDIUM,
+ 'Argument 1: Comma-separated list of valid extensions'
+ ),
+ implode(',',AssetAdmin::$allowed_extensions)
+ ), 'bad');
+ Director::redirectBack();
+ return;
+ }
+ }
+ return parent::saveComplexTableField($data, $form, $request);
+ }
+}
?>

0 comments on commit caed94d

Please sign in to comment.
Something went wrong with that request. Please try again.