mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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
This commit is contained in:
parent
c672061024
commit
1bb7bfa71f
@ -618,6 +618,24 @@ class File extends DataObject {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user