4require_once(
"Services/Object/classes/class.ilObject2.php");
 
    5require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
 
   35        public function __construct($a_id = 0, $a_call_by_reference = 
true) {
 
   37                $this->raise_upload_error = 
true;
 
   41                parent::__construct($a_id,$a_call_by_reference);
 
   83                $this->file_storage->create();
 
   91                require_once(
"./Services/History/classes/class.ilHistory.php");
 
   96                require_once(
"./Services/News/classes/class.ilNewsItem.php");
 
   98                if ($default_visibility == 
"public")
 
  101                                1, 0, $this->
getId());
 
  105                include_once(
"./Services/Utilities/classes/class.ilStr.php");
 
  106                $this->log->debug(
"ilObjFile::createProperties, ID: ".$this->
getId().
 
  115                $q = 
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) " 
  116                        .
"VALUES (".
$ilDB->quote($this->
getId() ,
'integer').
"," 
  119                        .$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
"," 
  120                        .$ilDB->quote(1 ,
'integer').
",".$ilDB->quote($this->
getMode() ,
'text').
")";
 
  121                $res = $ilDB->manipulate($q);
 
  124                if ($this->
getMode() != 
"filelist")
 
  133                $this->no_meta_data_creation = (bool)$a_status;
 
  138                return !(bool)$this->no_meta_data_creation;
 
  143                return !(bool)$this->no_meta_data_creation;
 
  153                $technical = $md_obj->addTechnical();
 
  156                $format = $technical->addFormat();
 
  159                $technical->update();
 
  166                include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  168                if(!is_object($md_gen = $md->getGeneral()))
 
  173                $md_gen->setTitle(
$title);
 
  181                include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  189                                if(!is_object($md_technical = $md->getTechnical()))
 
  194                                foreach($md_technical->getFormatIds() as 
$id)
 
  196                                        $md_format = $md_technical->getFormat(
$id);
 
  210                $version_subdir = 
"";
 
  215                        $version_subdir = sprintf(
"%03d", $a_version);
 
  219                if(!is_object($this->file_storage))
 
  224                return $this->file_storage->getAbsolutePath().
'/'.$version_subdir;
 
  234                $this->raise_upload_error = $a_raise;
 
  237        function getUploadFile($a_upload_file, $a_filename, $a_prevent_preview = 
false, $handle_secure_name = 
true)
 
  239                if ($handle_secure_name) {
 
  240                        require_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
 
  261                if (!$a_prevent_preview)
 
  274                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  278                        $a_filename.
",".$this->getVersion()
 
  280                $this->setFilename($a_filename);
 
  292                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  296                        $a_filename.
",".$this->getVersion()
 
  298                $this->setFilename($a_filename);
 
  309        function copy($a_source,$a_destination)
 
  332                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  334                if ($a_hist_entry_ids == 
null || count($a_hist_entry_ids) < 1)
 
  336                        $ilDB->manipulate(
"UPDATE file_data SET version = 1 WHERE file_id = ".
$ilDB->quote($this->getId() ,
'integer'));
 
  346                        $actualVersionDeleted = 
false;
 
  352                        foreach ($a_hist_entry_ids as $hist_id)
 
  357                                foreach ($versions as $index => $version)
 
  359                                        if ($version[
"hist_entry_id"] == $hist_id)      
 
  365                                                $version_dir = $this->
getDirectory($version[
"version"]);
 
  369                                                if ($version[
"version"] == $this->
getVersion())
 
  370                                                        $actualVersionDeleted = 
true;
 
  373                                                unset($versions[$index]);                                               
 
  380                        if ($actualVersionDeleted)
 
  383                                $version = reset($versions);
 
  401                $q = 
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  402                $r = $this->
ilias->db->query($q);
 
  418                if ($this->
getMode() != 
"filelist")
 
  435                $q = 
"UPDATE file_data SET file_name = ".$ilDB->quote($this->
getFileName() ,
'text').
 
  436                        ", file_type = ".$ilDB->quote($this->getFiletype() ,
'text').
" ".
 
  437                        ", file_size = ".$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
" ".
 
  438                        ", version = ".$ilDB->quote($this->
getVersion() ,
'integer').
" ".
 
  439                        ", f_mode = ".$ilDB->quote($this->
getMode() ,
'text').
" ".
 
  440                        ", rating = ".$ilDB->quote($this->
hasRating() ,
'integer').
" ".
 
  441                        "WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  442                $res = $ilDB->manipulate($q);
 
  456                if(!is_object($technical = $md_obj->getTechnical()))
 
  458                        $technical = $md_obj->addTechnical();
 
  463                $format_ids = $technical->getFormatIds();
 
  464                if (count($format_ids) > 0)
 
  466                        $format = $technical->getFormat($format_ids[0]);
 
  472                        $format = $technical->addFormat();
 
  476                $technical->update();
 
  484                $this->filename = $a_name;
 
  497                $this->filetype = $a_type;
 
  507                $this->filesize = $a_size;
 
  512                return $this->filesize;
 
  522            require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  530                if (is_null($a_hist_entry_id))
 
  536                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  539                        if ($entry === 
false)
 
  553                $this->version = $a_version;
 
  558                return $this->version ? $this->version : 1;
 
  568                $this->mode = $a_mode;
 
  585                $q = 
"UPDATE file_data SET ".
 
  586                        " file_type = ".$ilDB->quote($a_format ,
'text').
 
  587                        " WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
 
  596                $q = 
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
 
  607            require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  616                require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  625                if (is_null($a_hist_entry_id))
 
  631                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  634                        if ($entry === 
false)
 
  648        function sendFile($a_hist_entry_id = 
null)
 
  650                if (is_null($a_hist_entry_id))
 
  655                        if (@!is_file(
$file))
 
  662                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  665                        if ($entry === 
false)
 
  667                                echo 
"3";
return false;
 
  674                        if (@!is_file(
$file))
 
  685                        global $ilClientIniFile;
 
  700                        if ($ilClientIniFile->readVariable(
'file_access', 
'download_with_uploaded_filename') != 
'1' && is_null($a_hist_entry_id)) {
 
  709                                $download_file_name = end(explode(DIRECTORY_SEPARATOR, 
$file));
 
  727                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  736                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  743                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  756                $path = pathinfo($a_file);
 
  757                if (
$path[
"extension"] != 
"")
 
  763                        $filename = 
"dummy.".$this->getFileExtension();
 
  765                include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  820                $a_new_obj->createDirectory();
 
  827                $query = 
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,rating,f_mode) VALUES (".
 
  828                                $ilDB->quote($a_new_obj->getId() ,
'integer').
",".
 
  831                                $ilDB->quote((
int) $this->
getFileSize() ,
'integer').
", ".
 
  832                                $ilDB->quote($this->
getVersion() ,
'integer').
", ".
 
  833                                $ilDB->quote($this->
hasRating() ,
'integer').
", ".
 
  834                                $ilDB->quote($this->
getMode() ,
'text').
")";
 
  838                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
  842                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  846                include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
 
  848                $obj_settings->cloneSettings($a_new_obj->getId());
 
  849                unset($obj_settings);
 
  852                $a_new_obj->addNewsNotification(
"file_created");
 
  863                if (count($usages) == 0)
 
  875                $q = 
"DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  876                $this->
ilias->db->query($q);
 
  879                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  889                if ($this->
getMode() != 
"filelist")
 
  909                $subdir = 
"il_".IL_INST_ID.
"_file_".$this->
getId();
 
  914                if (@!is_dir($filedir))
 
  925        static function _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr = 0, $a_usage_lang = 
"-")
 
  929                $and_hist = ($a_usage_hist_nr !== 
false)
 
  930                        ? 
" AND usage_hist_nr = ".
$ilDB->quote($a_usage_hist_nr, 
"integer")
 
  934                $set = 
$ilDB->query(
"SELECT id FROM file_usage".
 
  935                        " WHERE usage_type = ".
$ilDB->quote($a_type, 
"text").
 
  936                        " AND usage_id= ".$ilDB->quote($a_id, 
"integer").
 
  937                        " AND usage_lang= ".$ilDB->quote($a_usage_lang, 
"text").
 
  941                        $file_ids[] = 
$row[
"id"];
 
  944                $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = ".
 
  945                        $ilDB->quote($a_type, 
"text").
 
  946                        " AND usage_id = ".$ilDB->quote((
int) $a_id, 
"integer").
 
  947                        " AND usage_lang= ".$ilDB->quote($a_usage_lang, 
"text").
 
  948                        " AND usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr, 
"integer"));
 
  950                foreach($file_ids as $file_id)
 
  959        static function _saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr = 0, $a_usage_lang = 
"-")
 
  981                $ilDB->replace(
"file_usage",
 
  983                                "id" => array(
"integer", (
int) $a_file_id),
 
  984                                "usage_type" => array(
"text", (
string) $a_type),
 
  985                                "usage_id" => array(
"integer", (
int) $a_id),
 
  986                                "usage_hist_nr" => array(
"integer", (
int) $a_usage_hist_nr),
 
  987                                "usage_lang" => array(
"text", $a_usage_lang)
 
 1003                $q = 
"SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->
getId(), 
"integer");
 
 1004                $us_set = 
$ilDB->query($q);
 
 1006                while($us_rec = 
$ilDB->fetchAssoc($us_set))
 
 1008                        $ret[] = array(
"type" => $us_rec[
"usage_type"],
 
 1009                                "id" => $us_rec[
"usage_id"],
 
 1010                                "lang" => $us_rec[
"usage_lang"],
 
 1011                                "hist_nr" => $us_rec[
"usage_hist_nr"]);
 
 1030                if ($a_usage_lang != 
"")
 
 1032                        $lstr = 
"usage_lang = ".$ilDB->quote((
string) $a_usage_lang, 
"text").
" AND ";
 
 1036                $q = 
"SELECT * FROM file_usage WHERE ".
 
 1037                        "usage_id = ".$ilDB->quote((
int) $a_id, 
"integer").
" AND ".
 
 1038                        "usage_type = ".$ilDB->quote((
string) $a_type, 
"text").
" AND ".
 
 1040                        "usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr, 
"integer");
 
 1041                $file_set = 
$ilDB->query($q);
 
 1043                while($file_rec = 
$ilDB->fetchAssoc($file_set))
 
 1045                        $ret[$file_rec[
"id"]] = $file_rec[
"id"];
 
 1075                include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 1076                include_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
 1078                $news_item->setContext($this->
getId(), $this->
getType());
 
 1080                $news_item->setTitle($a_lang_var);
 
 1081                $news_item->setContentIsLangVar(
true);
 
 1084                        $news_item->setContent(
 
 1088                $news_item->setUserId(
$ilUser->getId());
 
 1090                $news_item->create();
 
 1121                        require_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
 
 1136                $version_subdir = 
"";
 
 1138                if (!is_numeric($a_version))
 
 1142                $version_subdir = DIRECTORY_SEPARATOR.sprintf(
"%03d", $a_version);              
 
 1143                return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
 
 1152                include_once 
'./Modules/File/classes/class.ilObjFileAccess.php';
 
 1155                if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
 
 1159                        $suffix = $pi[
"extension"];
 
 1162                                if (substr($new_title,
 
 1163                                        strlen($new_title) - strlen($suffix) - 1)
 
 1166                                        $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
 
 1169                        $new_title .= 
'.'.$fileExtension;
 
 1182                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1185                if ($version_ids != 
null && count($version_ids) > 0)
 
 1187                        foreach ($versions as $index => $version) 
 
 1189                                if (!in_array($version[
"hist_entry_id"], $version_ids, 
true))
 
 1191                                        unset($versions[$index]);
 
 1197                foreach ($versions as $index => $version) 
 
 1200                        $versions[$index] = array_merge($version, 
$params);
 
 1204                usort($versions, array($this, 
"compareVersions"));
 
 1217                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1219                if ($version === 
false)
 
 1224                $version[
"hist_entry_id"] = $version[
"id"];
 
 1225                $version[
"user_id"] = $version[
"usr_id"];
 
 1226                $version[
"date"] = $version[
"hdate"];
 
 1227                unset($version[
"id"], $version[
"usr_id"], $version[
"hdate"]);
 
 1231                return array_merge($version, 
$params);
 
 1245                if ($source === 
false)
 
 1247                        $this->ilErr->raiseError($this->lng->txt(
"obj_not_found"), $this->ilErr->MESSAGE);
 
 1254                $source_path = $this->
getDirectory($source[
"version"]) . 
"/" . $source[
"filename"];
 
 1256                if (@!is_dir($dest_dir))
 
 1259                copy($source_path, $dest_dir . 
"/" . $source[
"filename"]);
 
 1262                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1266                        $source[
"filename"] . 
"," . $new_version_nr . 
"|" . $source[
"version"] . 
"|" . 
$ilUser->getId());
 
 1279                return $new_version;
 
 1318                return (
int)$v2[
"version"] - (int)$v1[
"version"];
 
 1333                if (empty(
$data[1]))
 
 1336                $result = array(
"filename" => 
$data[0], 
"version" => 
$data[1], 
"rollback_version" => 
"", 
"rollback_user_id" => 
"");
 
 1339                if ($entry[
"action"] == 
"rollback")
 
 1341                        $tokens = explode(
"|", 
$result[
"version"]);
 
 1342                        if (count($tokens) > 1)
 
 1344                                $result[
"version"] = $tokens[0];
 
 1345                                $result[
"rollback_version"] = $tokens[1];
 
 1347                                if (count($tokens) > 2)
 
 1348                                        $result[
"rollback_user_id"] = $tokens[2];
 
 1357                include_once 
"Services/MediaObjects/classes/class.ilObjMediaObject.php";        
 
 1361                $parent_obj_ids = array($a_file->
getId());
 
 1365                        $parent_obj_id = $mob->getParentObjectIdForUsage($item);
 
 1366                        if($parent_obj_id && 
 
 1367                                !in_array($parent_obj_id, $parent_obj_ids))
 
 1369                                $parent_obj_ids[]= $parent_obj_id;
 
 1373                include_once 
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
 
 1388                if ($this->
getMode() != 
"object")
 
 1391                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1401                if ($this->
getMode() != 
"object")
 
 1404                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1410                $this->rating = (bool)$a_value;
 
const DB_FETCHMODE_OBJECT
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
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.
static getValidFilename($a_filename)
Get valid filename.
static rename($a_source, $a_target)
Rename a file.
_copyEntriesForObject($a_src_id, $a_dst_id)
copy all history entries for an object
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
static _changeUserId($a_hist_entry_id, $new_user_id)
Changes the user id of the specified history entry.
_removeEntriesForObject($a_obj_id)
remove all history entries for an object
_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.
_getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
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 _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
_lookupVersion($a_id)
lookup version
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.
_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)
doRead()
read file properties
createProperties($a_upload=false)
The basic properties of a file object are stored in table object_data.
getUploadFile($a_upload_file, $a_filename, $a_prevent_preview=false, $handle_secure_name=true)
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)
return absolute path for version
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.
setFileName($a_name)
set filename
replaceFile($a_upload_file, $a_filename)
replace file with new file
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.
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 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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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 deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
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)
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