Is there a "current folder" function?

Permalink
Hi,

I am trying to fix the file importing php in my Concrete5 (v8.3.2), because it does not consider the current folder permissions but the global permissions in order to allow the replacing of files.

To get the current folder, I have found this piece of code:

$folder = null;
if (isset($_REQUEST['currentFolder'])) {
    $node = Concrete\Core\Tree\Node\Node::getByID($_REQUEST['currentFolder']);
    if ($node instanceof \Concrete\Core\Tree\Node\Type\FileFolder) {
        $folder = $node;
    }
}


But $_REQUEST['currentFolder'] is empty. In fact, $_REQUEST is empty. Is there any function that returns the current folder or any other way to get it?

Thanks,

Juan Ramón

jrsanche
 
jrsanche replied on at Permalink Reply
jrsanche
Hi,

Finally, I've found a way. Luckily, there is a variable called $result of type Result available in the page that I am working on, so this is the way:

if ($result) {
    if (count($result->getItems()) > 0) {
        $fin = false;
        $i = 0;
        while (!$fin && (count($result->getItems()) >= $i)) {
            if ($result->getItems()[$i]->isFolder != 1) {
                $node = Concrete\Core\Tree\Node\Node::getByID($result->getItems()[$i]->treeNodeID);
                if ($node instanceof \Concrete\Core\Tree\Node\Type\FileFolder) {
                    $folder = $node;
                }
                $fin = true;
            } 
            $i++;
        }
    }


Hope it helps someone else.

Regards,

Juan Ramón