Created
March 13, 2015 14:07
-
-
Save christianseel/ab6efa9c69cb34f66472 to your computer and use it in GitHub Desktop.
fix file and folder permissions for MODX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On what event is this plugin listening?