diff --git a/src/Chamilo/CoreBundle/Component/Editor/Connector.php b/src/Chamilo/CoreBundle/Component/Editor/Connector.php index aca3c9bd43..746bd36c65 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Connector.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Connector.php @@ -275,15 +275,15 @@ class Connector public function getOperations() { //https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1 - $opts = array( + $opts = [ //'debug' => true, - 'bind' => array( - 'upload rm' => array($this, 'manageCommands') - ) - ); + 'bind' => [ + 'upload rm mkdir' => array($this, 'manageCommands') + ], + 'sessionCloseEarlier' => false + ]; $this->setDrivers(); - $opts['roots'] = $this->getRoots(); return $opts; @@ -340,6 +340,7 @@ class Connector public function manageCommands($cmd, $result, $args, $elFinder) { $cmd = ucfirst($cmd); + $cmd = 'after'.$cmd; /* if (isset($args['target'])) { diff --git a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php index 53bfb7856d..ffebd4d36d 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php @@ -166,7 +166,7 @@ class CourseDriver extends Driver implements DriverInterface return $config; } - return array(); + return []; } /** @@ -229,6 +229,7 @@ class CourseDriver extends Driver implements DriverInterface */ public function upload($fp, $dst, $name, $tmpname, $hashes = array()) { + // Needed to load course information in elfinder $this->setConnectorFromPlugin(); if ($this->allowToEdit()) { @@ -331,23 +332,25 @@ class CourseDriver extends Driver implements DriverInterface /** * @inheritdoc */ - protected function _mkdir($path, $name) + public function mkdir($path, $name) { + // Needed to load course information in elfinder + $this->setConnectorFromPlugin(); + if ($this->allowToEdit() == false) { return false; } - $path = $this->_joinPath($path, $name); + $result = parent::mkdir($path, $name); - if (mkdir($path)) { - $this->setConnectorFromPlugin(); - chmod($path, $this->options['dirMode']); - clearstatcache(); + if ($result && isset($result['hash'])) { $_course = $this->connector->course; $realPathRoot = $this->getCourseDocumentSysPath(); + $realPath = $this->realpath($result['hash']); // Removing course path - $newPath = str_replace($realPathRoot, '/', $path); + $newPath = str_replace($realPathRoot, '/', $realPath); + $documentId = add_document( $_course, $newPath, @@ -363,12 +366,12 @@ class CourseDriver extends Driver implements DriverInterface ); if (empty($documentId)) { - unlink($path); + $this->rm($result['hash']); return false; } - return $path; + return $result; } return false;