Example #1
0
 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     if ($this->connector->security->isGranted('ROLE_ADMIN')) {
         return parent::upload($fp, $dst, $name, $tmpname);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     if ($this->connector->security->isGranted('IS_AUTHENTICATED_FULLY')) {
         return parent::upload($fp, $dst, $name, $tmpname);
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     if ($this->allow()) {
         return parent::upload($fp, $dst, $name, $tmpname);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     // upload file by elfinder.
     $result = parent::upload($fp, $dst, $name, $tmpname);
     $name = $result['name'];
     $filtered = \URLify::filter($result['name'], 80);
     if (strcmp($name, $filtered) != 0) {
         /*$arg = array('target' => $file['hash'], 'name' => $filtered);
           $elFinder->exec('rename', $arg);*/
         $this->rename($result['hash'], $filtered);
     }
     $realPath = $this->realpath($result['hash']);
     if (!empty($realPath)) {
         // Getting file info
         //$info = $elFinder->exec('file', array('target' => $file['hash']));
         /** @var elFinderVolumeLocalFileSystem $volume */
         //$volume = $info['volume'];
         //$root = $volume->root();
         //var/www/chamilogits/data/courses/NEWONE/document
         $realPathRoot = $this->getCourseDocumentSysPath();
         // Removing course path
         $realPath = str_replace($realPathRoot, '/', $realPath);
         \FileManager::add_document($this->connector->course, $realPath, 'file', intval($result['size']), $result['name']);
     }
     return $result;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function upload($fp, $dst, $name, $tmpname)
 {
     $this->setConnectorFromPlugin();
     $sessionId = api_get_session_id();
     if ($this->allow()) {
         // upload file by elfinder.
         $result = parent::upload($fp, $dst, $name, $tmpname);
         $name = $result['name'];
         $filtered = \URLify::filter($result['name'], 80, '', true);
         if (strcmp($name, $filtered) != 0) {
             $result = $this->customRename($result['hash'], $filtered);
         }
         $realPath = $this->realpath($result['hash']);
         if (!empty($realPath)) {
             // Getting file info
             //$info = $elFinder->exec('file', array('target' => $file['hash']));
             /** @var elFinderVolumeLocalFileSystem $volume */
             //$volume = $info['volume'];
             //$root = $volume->root();
             //var/www/chamilogits/data/courses/NEWONE/document
             $realPathRoot = $this->getCourseDocumentSysPath();
             // Removing course path
             $realPath = str_replace($realPathRoot, '/', $realPath);
             $documentId = add_document($this->connector->course, $realPath, 'file', intval($result['size']), $result['name']);
             api_item_property_update($this->connector->course, TOOL_DOCUMENT, $documentId, 'DocumentAdded', api_get_user_id(), null, null, null, null, $sessionId);
         }
         //error_log(print_r($this->error(),1));
         return $result;
     }
     return false;
 }