/**
  * lookup size
  */
 function _lookupFileSize($a_id)
 {
     global $ilDB;
     $q = "SELECT * FROM file_data WHERE file_id = " . $ilDB->quote($a_id);
     $r = $ilDB->query($q);
     $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
     include_once 'Services/Migration/DBUpdate_904/classes/class.ilFSStorageFile.php';
     $fss = new ilFSStorageFile($a_id);
     $file = $fss->getAbsolutePath() . '/' . $row->file_name;
     if (@(!is_file($file))) {
         $version_subdir = "/" . sprintf("%03d", ilObjFileAccess::_lookupVersion($a_id));
         $file = $fss->getAbsolutePath() . '/' . $version_subdir . '/' . $row->file_name;
     }
     if (is_file($file)) {
         $size = filesize($file);
     } else {
         $size = 0;
     }
     return $size;
 }
Beispiel #2
0
         $new_ops[] = 4;
     }
     if (in_array($copy_id, $operations)) {
         $new_ops[] = $copy_id;
     }
     if (in_array(6, $operations)) {
         $new_ops[] = 6;
     }
     $query = "INSERT INTO rbac_pa SET " . "rol_id = " . $ilDB->quote($pa_row->rol_id) . ", " . "ops_id = " . $ilDB->quote(serialize($new_ops)) . ", " . "ref_id = " . $ilDB->quote($file_ref_id) . " ";
     $ilDB->query($query);
 }
 // INSERT file_data
 $query = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) " . "VALUES (" . $ilDB->quote($file_obj_id) . ", " . $ilDB->quote($row->file_name) . ", " . $ilDB->quote($row->file_type) . ", " . $ilDB->quote($row->file_size) . ", " . $ilDB->quote(1) . ", " . $ilDB->quote('object') . ")";
 $ilDB->query($query);
 // Move File
 $fss = new ilFSStorageFile($file_obj_id);
 ilUpdateUtils::makeDirParents($fss->getAbsolutePath() . '/001');
 $ess = new ilFSStorageEvent($row->event_id);
 if ($fss->rename($ess->getAbsolutePath() . '/' . $row->file_id, $fss->getAbsolutePath() . '/001/' . $row->file_name)) {
     $ilLog->write('Success renaming file: ' . $ess->getAbsolutePath() . '/' . $row->file_id . " to " . $fss->getAbsolutePath() . '/001/' . $row->file_name);
 } else {
     $ilLog->write('Error renaming file: ' . $ess->getAbsolutePath() . '/' . $row->file_id . " to " . $fss->getAbsolutePath() . '/001/' . $row->file_name);
 }
 // Meta data
 $next_id = $ilDB->nextId("il_meta_general");
 $query = "INSERT INTO il_meta_general (meta_general_id,rbac_id,obj_id,obj_type, " . "general_structure,title,title_language,coverage,coverage_language) " . "VALUES( " . $ilDB->quote($next_id, 'integer') . ", " . $ilDB->quote($file_obj_id, 'integer') . ", " . $ilDB->quote($file_obj_id, 'integer') . ", " . $ilDB->quote('file', 'text') . ", " . $ilDB->quote('Hierarchical', 'text') . ", " . $ilDB->quote($row->file_name, 'text') . ", " . $ilDB->quote('en', 'text') . ", " . $ilDB->quote('', 'text') . ", " . $ilDB->quote('en', 'text') . " " . ")";
 $ilDB->query($query);
 // MD technical
 $next_id = $ilDB->nextId('il_meta_technical');
 $query = "INSERT INTO il_meta_technical (meta_technical_id,rbac_id,obj_id,obj_type, " . "t_size,ir,ir_language,opr,opr_language,duration) " . "VALUES( " . $ilDB->quote($next_id, 'integer') . ", " . $ilDB->quote($file_obj_id, 'integer') . ", " . $ilDB->quote($file_obj_id, 'integer') . ", " . $ilDB->quote('file', 'text') . ", " . $ilDB->quote($row->file_size, 'text') . ", " . $ilDB->quote('', 'text') . ", " . $ilDB->quote('en', 'text') . ", " . $ilDB->quote('', 'text') . ", " . $ilDB->quote('en', 'text') . ", " . $ilDB->quote('', 'text') . " " . ")";
 $ilDB->query($query);
 /**
  * Returns the number of bytes used on the harddisk by the file object
  * with the specified object id.
  * @param int object id of a file object.
  */
 function _lookupDiskUsage($a_id)
 {
     include_once 'Modules/File/classes/class.ilFSStorageFile.php';
     $fileStorage = new ilFSStorageFile($a_id);
     $dir = $fileStorage->getAbsolutePath();
     return ilUtil::dirsize($dir);
 }
 /**
  *  Add a content from ILIAS to the Adobe Connect server
  *
  * @return string cmd
  */
 public function addContentFromILIAS()
 {
     require_once 'Modules/File/classes/class.ilFSStorageFile.php';
     require_once 'Modules/File/classes/class.ilObjFileAccess.php';
     if (!(int) $_POST['file_id']) {
         ilUtil::sendInfo($this->txt('content_select_one'));
         return $this->showFileSearchResult($_SESSION['contents']['search_result']);
     }
     /** @noinspection PhpUndefinedClassInspection */
     $fss = new ilFSStorageFile((int) $_POST['file_id']);
     /** @noinspection PhpUndefinedClassInspection */
     $version_subdir = '/' . sprintf("%03d", ilObjFileAccess::_lookupVersion($_POST['file_id']));
     include_once './Modules/File/classes/class.ilObjFile.php';
     $file_name = ilObjFile::_lookupFileName((int) $_POST['file_id']);
     $object_title = ilObject::_lookupTitle((int) $_POST['file_id']);
     $file = $fss->getAbsolutePath() . $version_subdir . '/' . $file_name;
     $this->pluginObj->includeClass('class.ilAdobeConnectDuplicateContentException.php');
     try {
         $curl = curl_init($this->object->addContent($object_title, ''));
         curl_setopt($curl, CURLOPT_VERBOSE, true);
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         #curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($curl, CURL_UPLOAD, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, array('name' => $object_title, 'file' => '@' . $file));
         $postResult = curl_exec($curl);
         curl_close($curl);
         unset($_SESSION['contents']['search_result']);
         ilUtil::sendSuccess($this->txt('virtualClassroom_content_added'));
         return $this->showContent();
     } catch (ilAdobeConnectDuplicateContentException $e) {
         ilUtil::sendFailure($this->txt($e->getMessage()));
         return $this->showFileSearchResult($_SESSION['contents']['search_result']);
     }
 }
Beispiel #5
0
 /**
  * return absolute path for version
  *
  */
 public static function _lookupAbsolutePath($obj_id, $a_version = null)
 {
     $file_storage = new ilFSStorageFile($obj_id);
     $filename = ilObjFile::_lookupFileName($obj_id);
     $version_subdir = "";
     if (!is_numeric($a_version)) {
         $a_version = ilObjFile::_lookupVersion($obj_id);
     }
     $version_subdir = DIRECTORY_SEPARATOR . sprintf("%03d", $a_version);
     return $file_storage->getAbsolutePath() . $version_subdir . DIRECTORY_SEPARATOR . $filename;
 }