mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR moved File validation to the model (from r92044)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96742 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0ce4714fdf
commit
b4dc73e002
@ -614,6 +614,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…
x
Reference in New Issue
Block a user