Skip to content

Instantly share code, notes, and snippets.

@Fi1osof
Created April 8, 2015 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fi1osof/f385c27df60c306d8a27 to your computer and use it in GitHub Desktop.
Save Fi1osof/f385c27df60c306d8a27 to your computer and use it in GitHub Desktop.
<?php
switch($modx->event->name){
case 'OnFileManagerUpload':
$source = & $scriptProperties['source'];
if(!$source->hasErrors()){
/*
Запрещаем загрузку в корень, точнее удаляем новый файл,
так как в MODX нет нормальной обработки событий на загрузку файлов,
чтобы запретить загрузку
*/
if($directory == '/' && $files){
foreach($files as $file){
$path = $directory . $source->fileHandler->sanitizePath($file['name']);
$source->removeObject($path);
}
$source->addError('path', "Нельзя загружать файлы в корневой раздел.");
}
}
break;
default:;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment