hi all,
I am trying to do something like the following in a snippet that is called from a document accessed in a web context.
return $modx->request->handleRequest(array(’location’ => ’browser/directory’));
What I get is a JSON indicating lack of permission.
Can someone point me to what permissions have to be changed?
splittingred: I get a blank response page.
-
MODX Staff
- 10,725 Posts
You have to apply a Context policy for your User to the web Context with appropriate permissions to be able to execute specific processors from the web Context. The user will also have to be logged into the web Context. Otherwise, the scripts could be open for anonymous users to manage your content for you via Resources that execute these processors in the web Context.
Opengeek - For the sake of testing.
1. I have added the Administrator policy to a new user grop for the web context.
2. And I have logged in as that user and still get a blank page when I open the document that calls a snippet with the following code.
global $modx;
$response = $modx->runProcessor(’browser/directory’);
return $response;
I get 1 if I were instead to return
print_r($respone).
-
MODX Staff
- 10,725 Posts
Hmm works in my tests. Did you clear cache and flush sessions after making the permission changes? And are you using the Login package to login to the web Context?
OpenGeek:
Yes, I have cleared Cache and Flushed Permissions. Yes I am using the Login Package to login to the web context.
I am using 2.0.8-pl(traditional).
I wonder why I get an empty response. I am sure it is no longer an authorization issue because it does return a JSON with a access denied message.
I went thorough the code of runProcessor. And I think it is trying to execute browser/directory.php when such a file does not exist.
So I tried the following:
1. $response = $modx->runProcessor(’browser/directory/getlist’); - shows a memory exhausted error.No matter how much I increase it to.
2. $response = $modx->runProcessor(’browser/directory/getfiles’); - "Fatal error: Call to undefined method modX::outputArray()"
Error Log
[2011-03-16 14:24:34] (ERROR @ /cl/index.php) Processor /Applications/MAMP/htdocs/cl/core/model/modx/processors/browser/directory.php does not exist; Array
(
)
I have found the solution.
It had to do with runProcessor returning an Object.
Converting the object to a string exhausts the memory. As the object has more than just the response.
But accessing ->{"response"} of the object works.
So the code for getlist has to be...
$response = $modx->runProcessor(’browser/directory/getlist’ );
return $response->{"response"};
for getfiles, there seems to be a bug and the last file in getfiles.php has to be changed to
return $this->toJSON($files);