Tuesday, December 7, 2010

Modx 2 file manager + upload image on 2.0.4-pl2 or lower

File manager works well when you plan to use only "web" context for your manager users.
But when it comes to using other context, you will realise that there are some permission issue related to context.

To fix it temporary, until modx 2.0.5 is release, here is a fix.
path:
model/modx/processors/browser:

*/directory/getlist.php , */directory/getfiles.php , */file/upload.php , */file/remove.php:
Adding this somewhere at the top:
$context = !isset($scriptProperties['ctx']) ? "web": $scriptProperties['ctx'];

Change from:
$root = $modx->fileHandler->getBasePath();
To:
$root = $modx->fileHandler->getBasePath(false, $context);
---------------
Change from:
$fileManagerUrl = $modx->fileHandler->getBaseUrl();
To:
$fileManagerUrl = $modx->fileHandler->getBaseUrl($context);
----------------

No comments: