8require_once(
"Services/Object/classes/class.ilObject2.php");
 
    9require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
 
   80    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
   83        $this->raise_upload_error = 
true;
 
   87        parent::__construct($a_id, $a_call_by_reference);
 
  125        $this->file_storage->create();
 
  137        if ($default_visibility == 
"public") {
 
  142        $this->log->debug(
"ilObjFile::createProperties, ID: " . $this->
getId() . 
", Name: " 
  151        if ($this->
getMode() != self::MODE_FILELIST) {
 
  162        $this->no_meta_data_creation = (bool) $a_status;
 
  168        return !(bool) $this->no_meta_data_creation;
 
  174        return !(bool) $this->no_meta_data_creation;
 
  185        $technical = $md_obj->addTechnical();
 
  188        $format = $technical->addFormat();
 
  191        $technical->update();
 
  199        include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  201        if (!is_object($md_gen = $md->getGeneral())) {
 
  205        $md_gen->setTitle(
$title);
 
  215        include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  217        switch ($a_element) {
 
  222                if (!is_object($md_technical = $md->getTechnical())) {
 
  226                foreach ($md_technical->getFormatIds() as 
$id) {
 
  227                    $md_format = $md_technical->getFormat(
$id);
 
  247        $version_subdir = 
"";
 
  251            $version_subdir = 
sprintf(
"%03d", $a_version);
 
  255        if (!is_object($this->file_storage)) {
 
  259        $str = $this->file_storage->getAbsolutePath() . 
'/' . $version_subdir;
 
  273        $this->raise_upload_error = $a_raise;
 
  286    public function getUploadFile($a_upload_file, $a_filename, $a_prevent_preview = 
false)
 
  290        $upload = 
$DIC->upload();
 
  293        if ($upload->hasUploads()) {
 
  294            if ($upload->hasBeenProcessed() !== 
true) {
 
  295                if (PATH_TO_GHOSTSCRIPT !== 
"") {
 
  303            $result = $upload->getResults()[$a_upload_file];
 
  304            if (
$result->getStatus()->getCode() === \
ILIAS\FileUpload\DTO\ProcessingStatus::OK) {
 
  320                $relative_path_to_file = LegacyPathHelper::createRelativePath($target_directory);
 
  322                $upload->moveOneFileTo(
$result, $relative_path_to_file, Location::STORAGE);
 
  327                if (!$a_prevent_preview) {
 
  348        if (
$result = $this->getUploadFile($a_upload_file, $a_filename, 
true)) {
 
  362        if (
$result = $this->getUploadFile($a_upload_file, $a_filename, 
true)) {
 
  377    public function copy($a_source, $a_destination)
 
  403        if ($a_hist_entry_ids == 
null || count($a_hist_entry_ids) < 1) {
 
  404            $ilDB->manipulate(
"UPDATE file_data SET version = 1 WHERE file_id = " 
  405                . 
$ilDB->quote($this->getId(), 
'integer'));
 
  413            $actualVersionDeleted = 
false;
 
  419            foreach ($a_hist_entry_ids as $hist_id) {
 
  424                    if (
$version[
"hist_entry_id"] == $hist_id) {
 
  434                            $actualVersionDeleted = 
true;
 
  445            if ($actualVersionDeleted) {
 
  461        $q = 
"SELECT * FROM file_data WHERE file_id = %s";
 
  462        $r = 
$DIC->database()->queryF($q, [
'integer'], [$this->
getId()]);
 
  480        if ($this->
getMode() != self::MODE_FILELIST) {
 
  493        $DIC->database()->update(
'file_data', $a_columns, [
 
  513        if (!is_object($technical = $md_obj->getTechnical())) {
 
  514            $technical = $md_obj->addTechnical();
 
  519        $format_ids = $technical->getFormatIds();
 
  520        if (count($format_ids) > 0) {
 
  521            $format = $technical->getFormat($format_ids[0]);
 
  525            $format = $technical->addFormat();
 
  529        $technical->update();
 
  538        $this->filename = $a_name;
 
  574        $this->filesize = $a_size;
 
  592        require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  599    public function getFile($a_hist_entry_id = 
null)
 
  601        if (is_null($a_hist_entry_id)) {
 
  604            require_once(
"./Services/History/classes/class.ilHistory.php");
 
  607            if ($entry === 
false) {
 
  623        $this->version = $a_version;
 
  640        $this->mode = $a_mode;
 
  660        $q = 
"UPDATE file_data SET " . 
" file_type = " . 
$ilDB->quote($a_format, 
'text')
 
  661            . 
" WHERE file_id = " . 
$ilDB->quote($a_id, 
'integer');
 
  677        $q = 
"SELECT * FROM file_data WHERE file_id = " . 
$ilDB->quote($a_id, 
'integer');
 
  683        return $strip_slashes;
 
  690        require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  701        require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  712        if (is_null($a_hist_entry_id)) {
 
  715            require_once(
"./Services/History/classes/class.ilHistory.php");
 
  718            if ($entry === 
false) {
 
  725        if (is_file(
$file)) {
 
  736    public function sendFile($a_hist_entry_id = 
null)
 
  739        $s->sanitizeIfNeeded();
 
  741        if (is_null($a_hist_entry_id)) {
 
  751        if ($this->file_storage->fileExists(
$file)) {
 
  753            $ilClientIniFile = 
$DIC[
'ilClientIniFile'];
 
  761            $ilFileDelivery->setConvertFileNameToAsci((
bool) !$ilClientIniFile->readVariable(
'file_access', 
'disable_ascii'));
 
  764            if ($ilClientIniFile->readVariable(
'file_access', 
'download_with_uploaded_filename')
 
  766                && is_null($a_hist_entry_id)
 
  775                $parts = explode(DIRECTORY_SEPARATOR, 
$file);
 
  776                $download_file_name = end($parts);
 
  778                $ilFileDelivery->setDownloadFileName($download_file_name);
 
  780            $ilFileDelivery->deliver();
 
  785        throw new \ILIAS\Filesystem\Exception\FileNotFoundException(
"This file cannot be found in ILIAS or has been blocked due to security reasons.");
 
  795        require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  808        require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  819        require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  834        $path = pathinfo($a_file);
 
  835        if (
$path[
"extension"] != 
"") {
 
  840        include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  862        $a_new_obj->createDirectory();
 
  869        $query = 
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,rating,f_mode) VALUES (" 
  870            . 
$ilDB->quote($a_new_obj->getId(), 
'integer') . 
"," 
  880        require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
  884        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  888        include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
 
  890        $obj_settings->cloneSettings($a_new_obj->getId());
 
  891        unset($obj_settings);
 
  894        $a_new_obj->addNewsNotification(
"file_created");
 
  907        if (count($usages) == 0) {
 
  921        $q = 
"DELETE FROM file_data WHERE file_id = " . 
$ilDB->quote($this->
getId(), 
'integer');
 
  922        $this->
ilias->db->query($q);
 
  925        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  936        if ($this->
getMode() != self::MODE_FILELIST) {
 
  954        $subdir = 
"il_" . IL_INST_ID . 
"_file_" . $this->
getId();
 
  959        if (@!is_dir($filedir)) {
 
  963        ilUtil::rCopy($filedir, $a_target_dir . 
"/objects/" . $subdir);
 
  975        $and_hist = ($a_usage_hist_nr !== 
false) ? 
" AND usage_hist_nr = " 
  976            . 
$ilDB->quote($a_usage_hist_nr, 
"integer") : 
"";
 
  979        $set = 
$ilDB->query(
"SELECT id FROM file_usage" . 
" WHERE usage_type = " 
  981            . 
$ilDB->quote($a_id, 
"integer") . 
" AND usage_lang= " 
  982            . 
$ilDB->quote($a_usage_lang, 
"text") . $and_hist);
 
  984            $file_ids[] = 
$row[
"id"];
 
  987        $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = " 
  989            . 
$ilDB->quote((
int) $a_id, 
"integer") . 
" AND usage_lang= " 
  990            . 
$ilDB->quote($a_usage_lang, 
"text") . 
" AND usage_hist_nr = " 
  991            . 
$ilDB->quote((
int) $a_usage_hist_nr, 
"integer"));
 
  993        foreach ($file_ids as $file_id) {
 
 1002    public static function _saveUsage($a_file_id, 
$a_type, $a_id, $a_usage_hist_nr = 0, $a_usage_lang = 
"-")
 
 1012        $ilDB->replace(
"file_usage", array(
 
 1013            "id"            => array(
"integer", (
int) $a_file_id),
 
 1014            "usage_type"    => array(
"text", (
string) 
$a_type),
 
 1015            "usage_id"      => array(
"integer", (
int) $a_id),
 
 1016            "usage_hist_nr" => array(
"integer", (
int) $a_usage_hist_nr),
 
 1017            "usage_lang"    => array(
"text", $a_usage_lang),
 
 1033        $q = 
"SELECT * FROM file_usage WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
 1034        $us_set = 
$ilDB->query($q);
 
 1036        while ($us_rec = 
$ilDB->fetchAssoc($us_set)) {
 
 1038                "type"    => $us_rec[
"usage_type"],
 
 1039                "id"      => $us_rec[
"usage_id"],
 
 1040                "lang"    => $us_rec[
"usage_lang"],
 
 1041                "hist_nr" => $us_rec[
"usage_hist_nr"],
 
 1063        if ($a_usage_lang != 
"") {
 
 1064            $lstr = 
"usage_lang = " . 
$ilDB->quote((
string) $a_usage_lang, 
"text") . 
" AND ";
 
 1068        $q = 
"SELECT * FROM file_usage WHERE " . 
"usage_id = " . 
$ilDB->quote((
int) $a_id, 
"integer")
 
 1069            . 
" AND " . 
"usage_type = " . 
$ilDB->quote((
string) 
$a_type, 
"text") . 
" AND " . $lstr
 
 1070            . 
"usage_hist_nr = " . 
$ilDB->quote((
int) $a_usage_hist_nr, 
"integer");
 
 1071        $file_set = 
$ilDB->query($q);
 
 1073        while ($file_rec = 
$ilDB->fetchAssoc($file_set)) {
 
 1074            $ret[$file_rec[
"id"]] = $file_rec[
"id"];
 
 1085        $ilias = 
$DIC[
'ilias'];
 
 1108        include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 1109        include_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
 1111        $news_item->setContext($this->
getId(), $this->
getType());
 
 1113        $news_item->setTitle($a_lang_var);
 
 1114        $news_item->setContentIsLangVar(
true);
 
 1116            $news_item->setContent(
"<p>" . $this->
getDescription() . 
"</p>");
 
 1118        $news_item->setUserId(
$ilUser->getId());
 
 1120        $news_item->create();
 
 1173        $file_object = 
new self($obj_id, 
false);
 
 1175        $s->sanitizeIfNeeded();
 
 1177        return $file_object->getFile($a_version);
 
 1188        include_once 
'./Modules/File/classes/class.ilObjFileAccess.php';
 
 1191        if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
 
 1194            $suffix = $pi[
"extension"];
 
 1195            if ($suffix != 
"") {
 
 1196                if (substr($new_title, strlen($new_title) - strlen($suffix) - 1) == 
"." . $suffix) {
 
 1197                    $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
 
 1200            $new_title .= 
'.' . $fileExtension;
 
 1217        include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1220        if ($version_ids != 
null && count($version_ids) > 0) {
 
 1222                if (!in_array(
$version[
"hist_entry_id"], $version_ids, 
true)) {
 
 1223                    unset($versions[
$index]);
 
 1235        usort($versions, array($this, 
"compareVersions"));
 
 1250        include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1285            $this->ilErr->raiseError($this->lng->txt(
"obj_not_found"), $this->ilErr->MESSAGE);
 
 1294        if (@!is_dir($dest_dir)) {
 
 1298        copy($source_path, $dest_dir . 
"/" . 
$source[
"filename"]);
 
 1301        include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1303            . $new_version_nr . 
"|" 
 1310        $newest_entry_id = 0;
 
 1311        foreach ($entries as $entry) {
 
 1312            if ($entry[
"action"] == 
"rollback") {
 
 1313                $newest_entry_id = $entry[
"hist_entry_id"];
 
 1326        return $new_version;
 
 1370        return (
int) $v2[
"version"] - (int) $v1[
"version"];
 
 1385            | PREG_SPLIT_NO_EMPTY);
 
 1389        if (empty(
$data[1])) {
 
 1394            "filename"         => 
$data[0],
 
 1395            "version"          => 
$data[1],
 
 1396            "rollback_version" => 
"",
 
 1397            "rollback_user_id" => 
"",
 
 1401        if ($entry[
"action"] == 
"rollback") {
 
 1402            $tokens = explode(
"|", 
$result[
"version"]);
 
 1403            if (count($tokens) > 1) {
 
 1404                $result[
"version"] = $tokens[0];
 
 1405                $result[
"rollback_version"] = $tokens[1];
 
 1407                if (count($tokens) > 2) {
 
 1408                    $result[
"rollback_user_id"] = $tokens[2];
 
 1419        include_once 
"Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
 1423        $parent_obj_ids = array($a_file->
getId());
 
 1425        foreach ($a_file->
getUsages() as $item) {
 
 1426            $parent_obj_id = $mob->getParentObjectIdForUsage($item);
 
 1428                && !in_array($parent_obj_id, $parent_obj_ids)
 
 1430                $parent_obj_ids[] = $parent_obj_id;
 
 1434        include_once 
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
 
 1448        if ($this->
getMode() != self::MODE_OBJECT) {
 
 1452        require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1463        if ($this->
getMode() != self::MODE_OBJECT) {
 
 1467        require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1477        $this->rating = (bool) $a_value;
 
 1514            'file_id'    => [
'integer', $this->
getId()],
 
 1517            'file_size'  => [
'integer', (int) $this->
getFileSize()],
 
 1518            'version'    => [
'integer', (int) $this->
getVersion()],
 
 1519            'f_mode'     => [
'text', $this->
getMode()],
 
 1521            'rating'     => [
'integer', $this->
hasRating()],
 
sprintf('%.4f', $callTime)
$metadata['__DYNAMIC:1__']
An exception for terminatinating execution or to throw for unit testing.
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
Class ilCountPDFPagesPreProcessors.
static handleUpdatedSourceObject($a_src_obj_type, $a_src_obj_id, $a_src_filesize, $a_owner_obj_ids=null, $a_is_prtf=false)
Find and update/create all related entries for source object.
Class to report exception.
static getValidFilename($a_filename)
Get valid filename.
static rename($a_source, $a_target)
Rename a file.
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
static _changeUserId($a_hist_entry_id, $new_user_id)
Changes the user id of the specified history entry.
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
static _getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
static _copyEntriesForObject($a_src_id, $a_dst_id)
copy all history entries for an object
static _getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
static getLogger($a_component_id)
Get component logger.
static getMimeType($a_file='', $a_filename='', $a_mime='')
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes.
static _lookupVersion($a_id)
lookup version
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id.
static _lookupFileSize($a_id)
Lookups the file size of the file in bytes.
static _lookupFileName($a_id)
raiseUploadError($a_raise=true)
clearDataDirectory()
clear data directory
static handleQuotaUpdate(ilObjFile $a_file)
updateWithVersion($version)
Updates the file object with the specified file version.
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
doCreate($a_upload=false)
create object
addFileVersion($a_upload_file, $a_filename)
createProperties($a_upload=false)
The basic properties of a file object are stored in table object_data.
getFile($a_hist_entry_id=null)
doUpdateMetaData()
update meta data
initFileStorage()
init file storage object
static _saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
save usage
beforeMDUpdateListener($a_element)
copy($a_source, $a_destination)
copy file
createPreview($force=false)
Creates a preview for the file object.
doMDUpdateListener($a_element)
isInline()
Returns true, if this file should be displayed inline in a browser window.
__construct($a_id=0, $a_call_by_reference=true)
ilObjFile constructor.
getSpecificVersion($version_id)
Gets a specific file version.
static _lookupAbsolutePath($obj_id, $a_version=null)
doCreateMetaData()
create file object meta data
getVersions($version_ids=null)
Gets the file versions for this object.
setMode($a_mode)
mode is object or filelist
deleteVersions($a_hist_entry_ids=null)
Deletes the specified history entries or all entries if no ids are specified.
replaceFile($a_upload_file, $a_filename)
doCloneObject($a_new_obj, $a_target_id, $a_copy_id=0)
Clone.
export($a_target_dir)
export files of object to target directory note: target directory must be the export target directory...
setNoMetaDataCreation($a_status)
checkFileExtension($new_filename, $new_title)
Check if the file extension does still exist after an update of the title.
static _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
static delete all usages of
getDirectory($a_version=0)
getMode()
mode is object or filelist
deletePreview()
Deletes the preview of the file object.
compareVersions($v1, $v2)
Compares two file versions.
static _writeFileType($a_id, $a_format)
addNewsNotification($a_lang_var)
determineFileSize($a_hist_entry_id=null)
Determine File Size.
setPageCount($page_count)
getUsages()
get all usages of file object
getFileExtension()
Returns the extension of the file name converted to lower-case.
static _lookupVersion($a_id)
lookup version
getDiskUsage()
Gets the disk usage of the object in bytes.
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
guessFileType($a_file="")
Guesses the file type based on the current values returned by getFileType() and getFileExtension().
rollback($version_id)
Makes the specified version the current one and returns theSummary of rollbackVersion.
storeUnzipedFile($a_upload_file, $a_filename)
storeUnzipedFile
isHidden()
Returns true, if this file should be hidden in the repository view.
Class ilObject2 This is an intermediate progress of ilObject class.
setTitle($a_title)
set object title
createMetaData()
create meta data entry
cloneMetaData($target_obj)
Copy meta data.
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
getType()
get object type @access public
getDescription()
get object description
update()
update object in db
getId()
get object id @access public
getTitle()
get object title @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static copyPreviews($a_src_id, $a_dest_id)
Copies the preview images from one preview to a new preview object.
static deletePreview($a_obj_id)
Deletes the preview for the object with the specified id.
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
static getBytesForString($a_str)
Return string as byte array Note: Use this for debugging purposes only.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static escapeShellArg($a_arg)
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
redirection script todo: (a better solution should control the processing via a xml file)
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res
echo;exit;}function LogoutNotification($SessionID){ global $ilDB;$q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE