Permalink
Browse files

MINOR moved allowed_extensions and friends to the model layer (from r…

…92046) (from r96743)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102369 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 1bb7bfa commit 2ac34ccff04751cd1c18f7ef0c5c92ef82134aac @chillu chillu committed Apr 12, 2010
Showing with 16 additions and 3 deletions.
  1. +16 −3 filesystem/File.php
View
@@ -46,6 +46,19 @@ class File extends DataObject {
static $extensions = array(
"Hierarchy",
);
+
+ /**
+ * @see Upload->allowedExtensions
+ * @var array
+ */
+ public static $allowed_extensions = array();
+
+ /**
+ * If this is true, then restrictions set in $allowed_max_file_size and
+ * $allowed_extensions will be applied to users with admin privileges as
+ * well.
+ */
+ public static $apply_restrictions_to_admin = false;
/**
@@ -619,16 +632,16 @@ function fieldLabels($includerelations = true) {
}
function validate() {
- if(!AssetAdmin::$apply_restrictions_to_admin && Permission::check('ADMIN')) {
- if(!in_array(strtolower(pathinfo($this->Name, PATHINFO_EXTENSION)), AssetAdmin::$allowed_extensions)) {
+ if(!File::$apply_restrictions_to_admin && Permission::check('ADMIN')) {
+ if(!in_array(strtolower(pathinfo($this->Name, PATHINFO_EXTENSION)), self::$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)
+ implode(',',self::$allowed_extensions)
);
return new ValidationResult(false, $message);
}

0 comments on commit 2ac34cc

Please sign in to comment.