MINOR moved allowed_extensions and friends to the model layer (from r92046) (from r96743)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102369 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 02:35:12 +00:00
parent 1bb7bfa71f
commit 2ac34ccff0

View File

@ -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,8 +632,8 @@ class File extends DataObject {
}
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',
@ -628,7 +641,7 @@ class File extends DataObject {
PR_MEDIUM,
'Argument 1: Comma-separated list of valid extensions'
),
implode(',',AssetAdmin::$allowed_extensions)
implode(',',self::$allowed_extensions)
);
return new ValidationResult(false, $message);
}