Permalink
Browse files

MINOR moved File validation to the model (from r92044) (from r96742)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102368 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent c672061 commit 1bb7bfa71f7b48341138b8539bba9a46538b1031 @chillu chillu committed Apr 12, 2010
Showing with 18 additions and 0 deletions.
  1. +18 −0 filesystem/File.php
View
@@ -618,6 +618,24 @@ function fieldLabels($includerelations = true) {
return $labels;
}
+ function validate() {
+ if(!AssetAdmin::$apply_restrictions_to_admin && Permission::check('ADMIN')) {
+ if(!in_array(strtolower(pathinfo($this->Name, PATHINFO_EXTENSION)), AssetAdmin::$allowed_extensions)) {
+ $message = sprintf(
+ _t(
+ 'File.INVALIDEXTENSION',
+ 'Extension is not allowed (valid: %s)',
+ PR_MEDIUM,
+ 'Argument 1: Comma-separated list of valid extensions'
+ ),
+ implode(',',AssetAdmin::$allowed_extensions)
+ );
+ return new ValidationResult(false, $message);
+ }
+ }
+ return new ValidationResult(true);
+ }
+
}
?>

0 comments on commit 1bb7bfa

Please sign in to comment.