Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fix file and folder permissions for MODX
<?php
switch($modx->event->name) {
case 'OnFileManagerDirCreate':
$modx->log(modX::LOG_LEVEL_ERROR, 'fix folder permissions for: '.$directory.'/');
chmod($directory.'/', octdec($modx->getOption('new_folder_permissions')));
break;
case 'OnFileManagerFileCreate':
$modx->log(modX::LOG_LEVEL_ERROR, 'fix file permissions for: '.$path);
chmod($path, octdec($modx->getOption('new_file_permissions')));
break;
case 'OnFileManagerUpload':
$full_path = $modx->getOption('assets_path') .'uploads/'. $directory;
if (file_exists($full_path.$files['file']['name'])) {
$modx->log(modX::LOG_LEVEL_ERROR, 'fix file permissions for uploaded file: '.$full_path.$files['file']['name']);
chmod($full_path.$files['file']['name'], octdec($modx->getOption('new_file_permissions')));
} else {
$modx->log(modX::LOG_LEVEL_ERROR, 'Can\'t file permissions because: File not found! Full path: '. $full_path.$files['file']['name'] .' Directory: '.$directory. ' File data: '.json_encode($files));
}
break;
}
return;
@thijsvandamme
Copy link

thijsvandamme commented Jun 6, 2015

On what event is this plugin listening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment