Ejemplo n.º 1
0
 /**
  * New folder
  * @param string $dir The base dir
  * @param string $new_dir The folder to be created
  * @return string $error on failure
  */
 public function folderNew()
 {
     if ($this->checkFeature('create', 'folder') === false) {
         JError::raiseError(403, 'Access to this resource is restricted');
     }
     $args = func_get_args();
     $dir = array_shift($args);
     $new = array_shift($args);
     // decode
     $dir = rawurldecode($dir);
     $new = rawurldecode($new);
     $filesystem = $this->getFileSystem();
     $name = WFUtility::makeSafe($new, $this->get('websafe_mode'), $this->get('websafe_spaces'), $this->get('websafe_textcase'));
     // check for extension in destination name
     if (WFUtility::validateFileName($name) === false) {
         JError::raiseError(403, 'INVALID FOLDER NAME');
     }
     $result = $filesystem->createFolder($dir, $name, $args);
     if ($result instanceof WFFileSystemResult) {
         if (!$result->state) {
             if ($result->message) {
                 $this->setResult($result->message, 'error');
             } else {
                 $this->setResult(JText::sprintf('WF_MANAGER_NEW_FOLDER_ERROR', basename($new)), 'error');
             }
         } else {
             $this->setResult($this->fireEvent('onFolderNew', array($new)));
         }
     }
     return $this->getResult();
 }