Пример #1
0
 /**
  * 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;
 }
 /**
  * Append object properties
  * @param ilObject $obj
  */
 public function __appendObjectProperties(ilObject $obj)
 {
     switch ($obj->getType()) {
         case 'file':
             include_once './Modules/File/classes/class.ilObjFileAccess.php';
             $size = ilObjFileAccess::_lookupFileSize($obj->getId());
             $extension = ilObjFileAccess::_lookupSuffix($obj->getId());
             $this->xmlStartTag('Properties');
             $this->xmlElement("Property", array('name' => 'fileSize'), (int) $size);
             $this->xmlElement("Property", array('name' => 'fileExtension'), (string) $extension);
             // begin-patch fm
             $this->xmlElement('Property', array('name' => 'fileVersion'), (string) ilObjFileAccess::_lookupVersion($obj->getId()));
             // end-patch fm
             $this->xmlEndTag('Properties');
             break;
     }
 }
 /**
  * Looks up the file size by retrieving it from the filesystem.
  * This function runs much slower than _lookupFileSize()! Use this
  * function only, to update the data in the database. For example, if
  * the file size in the database has become inconsistent for some reason.
  */
 public static function _lookupFileSizeFromFilesystem($a_id)
 {
     global $ilDB;
     $q = "SELECT * FROM file_data WHERE file_id = " . $ilDB->quote($a_id, 'integer');
     $r = $ilDB->query($q);
     $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
     require_once 'Modules/File/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;
 }
 /**
  *  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']);
     }
 }
Пример #5
0
 /**
  * lookup version
  */
 function _lookupVersion($a_id)
 {
     require_once "./Modules/File/classes/class.ilObjFileAccess.php";
     return ilObjFileAccess::_lookupVersion($a_id);
 }