4require_once 
"Services/Object/classes/class.ilObject2.php";
 
    5include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
 
   39                $this->raise_upload_error = 
true;
 
   40                parent::__construct($a_id,$a_call_by_reference);
 
   58        protected function doCreate($a_upload = 
false, $a_prevent_meta_data_creation = 
false)
 
   79                $this->file_storage->create();
 
   87                require_once(
"./Services/History/classes/class.ilHistory.php");
 
   92                require_once(
"./Services/News/classes/class.ilNewsItem.php");
 
   94                if ($default_visibility == 
"public")
 
   97                                1, 0, $this->
getId());
 
  100                $q = 
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) " 
  101                        .
"VALUES (".
$ilDB->quote($this->
getId() ,
'integer').
"," 
  104                        .$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
"," 
  105                        .$ilDB->quote(1 ,
'integer').
",".$ilDB->quote($this->
getMode() ,
'text').
")";
 
  106                $res = $ilDB->manipulate($q);
 
  109                if ($this->
getMode() != 
"filelist" && !$a_prevent_meta_data_creation)
 
  123                $technical = $md_obj->addTechnical();
 
  126                $format = $technical->addFormat();
 
  129                $technical->update();
 
  136                include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  138                if(!is_object($md_gen = $md->getGeneral()))
 
  143                $md_gen->setTitle(
$title);
 
  151                include_once 
'Services/MetaData/classes/class.ilMD.php';
 
  159                                if(!is_object($md_technical = $md->getTechnical()))
 
  164                                foreach($md_technical->getFormatIds() as 
$id)
 
  166                                        $md_format = $md_technical->getFormat(
$id);
 
  180                $version_subdir = 
"";
 
  185                        $version_subdir = sprintf(
"%03d", $a_version);
 
  189                if(!is_object($this->file_storage))
 
  194                return $this->file_storage->getAbsolutePath().
'/'.$version_subdir;
 
  204                $this->raise_upload_error = $a_raise;
 
  207        function getUploadFile($a_upload_file, $a_filename, $a_prevent_preview = 
false)
 
  223                if (!$a_prevent_preview)
 
  236                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  240                        $a_filename.
",".$this->getVersion()
 
  242                $this->setFilename($a_filename);
 
  254                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  258                        $a_filename.
",".$this->getVersion()
 
  260                $this->setFilename($a_filename);
 
  271        function copy($a_source,$a_destination)
 
  294                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  296                if ($a_hist_entry_ids == 
null || count($a_hist_entry_ids) < 1)
 
  298                        $ilDB->manipulate(
"UPDATE file_data SET version = 1 WHERE file_id = ".
$ilDB->quote($this->getId() ,
'integer'));
 
  308                        $actualVersionDeleted = 
false;
 
  314                        foreach ($a_hist_entry_ids as $hist_id)
 
  319                                foreach ($versions as $index => $version)
 
  321                                        if ($version[
"hist_entry_id"] == $hist_id)      
 
  327                                                $version_dir = $this->
getDirectory($version[
"version"]);
 
  331                                                if ($version[
"version"] == $this->
getVersion())
 
  332                                                        $actualVersionDeleted = 
true;
 
  335                                                unset($versions[$index]);                                               
 
  342                        if ($actualVersionDeleted)
 
  345                                $version = reset($versions);
 
  363                $q = 
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  364                $r = $this->
ilias->db->query($q);
 
  380                if ($this->
getMode() != 
"filelist")
 
  397                $q = 
"UPDATE file_data SET file_name = ".$ilDB->quote($this->
getFileName() ,
'text').
 
  398                        ", file_type = ".$ilDB->quote($this->getFiletype() ,
'text').
" ".
 
  399                        ", file_size = ".$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
" ".
 
  400                        ", version = ".$ilDB->quote($this->
getVersion() ,
'integer').
" ".
 
  401                        ", f_mode = ".$ilDB->quote($this->
getMode() ,
'text').
" ".
 
  402                        ", rating = ".$ilDB->quote($this->
hasRating() ,
'integer').
" ".
 
  403                        "WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  404                $res = $ilDB->manipulate($q);
 
  418                if(!is_object($technical = $md_obj->getTechnical()))
 
  420                        $technical = $md_obj->addTechnical();
 
  425                $format_ids = $technical->getFormatIds();
 
  426                if (count($format_ids) > 0)
 
  428                        $format = $technical->getFormat($format_ids[0]);
 
  434                        $format = $technical->addFormat();
 
  438                $technical->update();
 
  446                $this->filename = $a_name;
 
  459                $this->filetype = $a_type;
 
  469                $this->filesize = $a_size;
 
  474                return $this->filesize;
 
  484            require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  492                if (is_null($a_hist_entry_id))
 
  498                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  501                        if ($entry === 
false)
 
  515                $this->version = $a_version;
 
  520                return $this->version;
 
  530                $this->mode = $a_mode;
 
  547                $q = 
"UPDATE file_data SET ".
 
  548                        " file_type = ".$ilDB->quote($a_format ,
'text').
 
  549                        " WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
 
  558                $q = 
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
 
  559                $r = 
$ilDB->query($q);
 
  569            require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  578                require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  587                if (is_null($a_hist_entry_id))
 
  593                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  596                        if ($entry === 
false)
 
  612                if (is_null($a_hist_entry_id))
 
  617                        if (@!is_file(
$file))
 
  624                        require_once(
"./Services/History/classes/class.ilHistory.php");
 
  627                        if ($entry === 
false)
 
  629                                echo 
"3";
return false;
 
  636                        if (@!is_file(
$file))
 
  647                        global $ilClientIniFile;
 
  650                        if ($ilClientIniFile->readVariable(
'file_access',
'download_with_uploaded_filename') != 
'1' && is_null($a_hist_entry_id))
 
  670                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  679                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  686                require_once 
'Modules/File/classes/class.ilObjFileAccess.php';
 
  699                $path = pathinfo($a_file);
 
  700                if (
$path[
"extension"] != 
"")
 
  706                        $filename = 
"dummy.".$this->getFileExtension();
 
  708                include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
 
  763                $a_new_obj->createDirectory();
 
  770                $query = 
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,rating,f_mode) VALUES (".
 
  771                                $ilDB->quote($a_new_obj->getId() ,
'integer').
",".
 
  774                                $ilDB->quote((
int) $this->
getFileSize() ,
'integer').
", ".
 
  775                                $ilDB->quote($this->
getVersion() ,
'integer').
", ".
 
  776                                $ilDB->quote($this->
hasRating() ,
'integer').
", ".
 
  777                                $ilDB->quote($this->
getMode() ,
'text').
")";
 
  781                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
  785                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  789                $a_new_obj->addNewsNotification(
"file_created");
 
  800                if (count($usages) == 0)
 
  812                $q = 
"DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
 
  813                $this->
ilias->db->query($q);
 
  816                require_once(
"./Services/History/classes/class.ilHistory.php");
 
  826                if ($this->
getMode() != 
"filelist")
 
  846                $subdir = 
"il_".IL_INST_ID.
"_file_".$this->
getId();
 
  851                if (@!is_dir($filedir))
 
  866                $and_hist = ($a_usage_hist_nr !== 
false)
 
  867                        ? 
" AND usage_hist_nr = ".
$ilDB->quote($a_usage_hist_nr, 
"integer")
 
  871                $set = 
$ilDB->query(
"SELECT id FROM file_usage".
 
  872                        " WHERE usage_type = ".
$ilDB->quote($a_type, 
"text").
 
  873                        " AND usage_id= ".$ilDB->quote($a_id, 
"integer").
 
  874                        " AND usage_lang= ".$ilDB->quote($a_usage_lang, 
"text").
 
  878                        $file_ids[] = 
$row[
"id"];
 
  881                $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = ".
 
  882                        $ilDB->quote($a_type, 
"text").
 
  883                        " AND usage_id = ".$ilDB->quote((
int) $a_id, 
"integer").
 
  884                        " AND usage_lang= ".$ilDB->quote($a_usage_lang, 
"text").
 
  885                        " AND usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr, 
"integer"));
 
  887                foreach($file_ids as $file_id)
 
  896        function _saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr = 0, $a_usage_lang = 
"-")
 
  918                $ilDB->replace(
"file_usage",
 
  920                                "id" => array(
"integer", (
int) $a_file_id),
 
  921                                "usage_type" => array(
"text", (
string) $a_type),
 
  922                                "usage_id" => array(
"integer", (
int) $a_id),
 
  923                                "usage_hist_nr" => array(
"integer", (
int) $a_usage_hist_nr),
 
  924                                "usage_lang" => array(
"text", $a_usage_lang)
 
  940                $q = 
"SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->
getId(), 
"integer");
 
  941                $us_set = 
$ilDB->query($q);
 
  943                while($us_rec = 
$ilDB->fetchAssoc($us_set))
 
  945                        $ret[] = array(
"type" => $us_rec[
"usage_type"],
 
  946                                "id" => $us_rec[
"usage_id"],
 
  947                                "lang" => $us_rec[
"usage_lang"],
 
  948                                "hist_nr" => $us_rec[
"usage_hist_nr"]);
 
  967                $q = 
"SELECT * FROM file_usage WHERE ".
 
  968                        "usage_id = ".$ilDB->quote((
int) $a_id, 
"integer").
" AND ".
 
  969                        "usage_type = ".$ilDB->quote((
string) $a_type, 
"text").
" AND ".
 
  970                        "usage_lang = ".$ilDB->quote((
string) $a_usage_lang, 
"text").
" AND ".
 
  971                        "usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr, 
"integer");
 
  972                $file_set = 
$ilDB->query($q);
 
  974                while($file_rec = 
$ilDB->fetchAssoc($file_set))
 
  976                        $ret[$file_rec[
"id"]] = $file_rec[
"id"];
 
 1006                include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 1007                include_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
 1009                $news_item->setContext($this->
getId(), $this->
getType());
 
 1011                $news_item->setTitle($a_lang_var);
 
 1012                $news_item->setContentIsLangVar(
true);
 
 1015                        $news_item->setContent(
 
 1019                $news_item->setUserId(
$ilUser->getId());
 
 1021                $news_item->create();
 
 1055                        rename($a_upload_file,  
$file);
 
 1069                $version_subdir = 
"";
 
 1071                if (!is_numeric($a_version))
 
 1075                $version_subdir = DIRECTORY_SEPARATOR.sprintf(
"%03d", $a_version);              
 
 1076                return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
 
 1085                include_once 
'./Modules/File/classes/class.ilObjFileAccess.php';
 
 1088                if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
 
 1092                        $suffix = $pi[
"extension"];
 
 1095                                if (substr($new_title,
 
 1096                                        strlen($new_title) - strlen($suffix) - 1)
 
 1099                                        $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
 
 1102                        $new_title .= 
'.'.$fileExtension;
 
 1115                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1118                if ($version_ids != 
null && count($version_ids) > 0)
 
 1120                        foreach ($versions as $index => $version) 
 
 1122                                if (!in_array($version[
"hist_entry_id"], $version_ids, 
true))
 
 1124                                        unset($versions[$index]);
 
 1130                foreach ($versions as $index => $version) 
 
 1133                        $versions[$index] = array_merge($version, $params);
 
 1137                usort($versions, array($this, 
"compareVersions"));
 
 1150                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1152                if ($version === 
false)
 
 1157                $version[
"hist_entry_id"] = $version[
"id"];
 
 1158                $version[
"user_id"] = $version[
"usr_id"];
 
 1159                $version[
"date"] = $version[
"hdate"];
 
 1160                unset($version[
"id"], $version[
"usr_id"], $version[
"hdate"]);
 
 1164                return array_merge($version, $params);
 
 1178                if ($source === 
false)
 
 1180                        $this->ilErr->raiseError($this->lng->txt(
"obj_not_found"), $this->ilErr->MESSAGE);
 
 1187                $source_path = $this->
getDirectory($source[
"version"]) . 
"/" . $source[
"filename"];
 
 1189                if (@!is_dir($dest_dir))
 
 1192                copy($source_path, $dest_dir . 
"/" . $source[
"filename"]);
 
 1195                include_once(
"./Services/History/classes/class.ilHistory.php");
 
 1199                        $source[
"filename"] . 
"," . $new_version_nr . 
"|" . $source[
"version"] . 
"|" . 
$ilUser->getId());
 
 1212                return $new_version;
 
 1251                return (
int)$v2[
"version"] - (int)$v1[
"version"];
 
 1266                if (empty(
$data[1]))
 
 1269                $result = array(
"filename" => 
$data[0], 
"version" => 
$data[1], 
"rollback_version" => 
"", 
"rollback_user_id" => 
"");
 
 1272                if ($entry[
"action"] == 
"rollback")
 
 1274                        $tokens = explode(
"|", 
$result[
"version"]);
 
 1275                        if (count($tokens) > 1)
 
 1277                                $result[
"version"] = $tokens[0];
 
 1278                                $result[
"rollback_version"] = $tokens[1];
 
 1280                                if (count($tokens) > 2)
 
 1281                                        $result[
"rollback_user_id"] = $tokens[2];
 
 1290                include_once 
"Services/MediaObjects/classes/class.ilObjMediaObject.php";        
 
 1294                $parent_obj_ids = array($a_file->
getId());
 
 1298                        $parent_obj_id = $mob->getParentObjectIdForUsage($item);
 
 1299                        if($parent_obj_id && 
 
 1300                                !in_array($parent_obj_id, $parent_obj_ids))
 
 1302                                $parent_obj_ids[]= $parent_obj_id;
 
 1306                include_once 
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
 
 1321                if ($this->
getMode() != 
"object")
 
 1324                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1334                if ($this->
getMode() != 
"object")
 
 1337                require_once(
"./Services/Preview/classes/class.ilPreview.php");
 
 1343                $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.
_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 getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
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.
_deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
static delete all usages of
raiseUploadError($a_raise=true)
clearDataDirectory()
clear data directory
static handleQuotaUpdate(ilObjFile $a_file)
updateWithVersion($version)
Updates the file object with the specified file version.
addFileVersion($a_upload_file, $a_filename)
getUploadFile($a_upload_file, $a_filename, $a_prevent_preview=false)
_getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
doRead()
read file properties
getFile($a_hist_entry_id=null)
doUpdateMetaData()
update meta data
initFileStorage()
init file storage object
beforeMDUpdateListener($a_element)
_saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
save usage
copy($a_source, $a_destination)
copy file
createPreview($force=false)
Creates a preview for the file object.
sendFile($a_hist_entry_id=null)
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)
Constructor @access public.
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
_lookupFileSize($a_id)
Lookups the file size of the file in bytes.
getVersions($version_ids=null)
Gets the file versions for this object.
createProperties($a_upload=false, $a_prevent_meta_data_creation=false)
The basic properties of a file object are stored in table object_data.
setMode($a_mode)
mode is object or filelist
_writeFileType($a_id, $a_format)
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...
doCreate($a_upload=false, $a_prevent_meta_data_creation=false)
create object
checkFileExtension($new_filename, $new_title)
Check if the file extension does still exist after an update of the title.
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.
addNewsNotification($a_lang_var)
determineFileSize($a_hist_entry_id=null)
Determine File Size.
_lookupVersion($a_id)
lookup version
getUsages()
get all usages of file object
getFileExtension()
Returns the extension of the file name converted to lower-case.
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 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