ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjFile Class Reference

Class ilObjFile. More...

+ Inheritance diagram for ilObjFile:
+ Collaboration diagram for ilObjFile:

Public Member Functions

 __construct ($a_id=0, $a_call_by_reference=true)
 ilObjFile constructor. More...
 
 initType ()
 Init type. More...
 
 createProperties ($a_upload=false)
 The basic properties of a file object are stored in table object_data. More...
 
 setNoMetaDataCreation ($a_status)
 
 getDirectory ($a_version=0)
 
 createDirectory ()
 
 raiseUploadError ($a_raise=true)
 
 getUploadFile ($a_upload_file, $a_filename, $a_prevent_preview=false, $handle_secure_name=true)
 
 replaceFile ($a_upload_file, $a_filename)
 replace file with new file More...
 
 addFileVersion ($a_upload_file, $a_filename)
 
 copy ($a_source, $a_destination)
 copy file More...
 
 clearDataDirectory ()
 clear data directory More...
 
 deleteVersions ($a_hist_entry_ids=null)
 Deletes the specified history entries or all entries if no ids are specified. More...
 
 setFileName ($a_name)
 set filename More...
 
 getFileName ()
 
 setFileType ($a_type)
 
 getFileType ()
 
 setFileSize ($a_size)
 
 getFileSize ()
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 getFile ($a_hist_entry_id=null)
 
 setVersion ($a_version)
 
 getVersion ()
 
 setMode ($a_mode)
 mode is object or filelist More...
 
 getMode ()
 mode is object or filelist More...
 
 determineFileSize ($a_hist_entry_id=null)
 Determine File Size. More...
 
 getFileExtension ()
 Returns the extension of the file name converted to lower-case. More...
 
 isInline ()
 Returns true, if this file should be displayed inline in a browser window. More...
 
 isHidden ()
 Returns true, if this file should be hidden in the repository view. More...
 
 guessFileType ($a_file="")
 Guesses the file type based on the current values returned by getFileType() and getFileExtension(). More...
 
 export ($a_target_dir)
 export files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_file_<file_id>/..." will be appended to this directory More...
 
 getUsages ()
 get all usages of file object More...
 
 getXMLZip ()
 
 addNewsNotification ($a_lang_var)
 
 initFileStorage ()
 init file storage object More...
 
 storeUnzipedFile ($a_upload_file, $a_filename)
 storeUnzipedFile More...
 
 checkFileExtension ($new_filename, $new_title)
 Check if the file extension does still exist after an update of the title. More...
 
 getVersions ($version_ids=null)
 Gets the file versions for this object. More...
 
 getSpecificVersion ($version_id)
 Gets a specific file version. More...
 
 rollback ($version_id)
 Makes the specified version the current one and returns theSummary of rollbackVersion. More...
 
 compareVersions ($v1, $v2)
 Compares two file versions. More...
 
 parseInfoParams ($entry)
 Parses the info parameters ("info_params") of the specified history entry. More...
 
 setRating ($a_value)
 
 hasRating ()
 
- Public Member Functions inherited from ilObject2
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 Read data from db. More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ($a_clone_mode=false)
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _writeFileType ($a_id, $a_format)
 
static _lookupFileName ($a_id)
 
static _lookupFileSize ($a_id)
 Lookups the file size of the file in bytes. More...
 
static _lookupVersion ($a_id)
 lookup version More...
 
static _deleteAllUsages ($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 static delete all usages of More...
 
static _saveUsage ($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 save usage More...
 
static _getFilesOfObject ($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 get all files of an object More...
 
static _lookupAbsolutePath ($obj_id, $a_version=null)
 return absolute path for version More...
 
- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type)
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $filename
 
 $filetype
 
 $filemaxsize = "20000000"
 
 $raise_upload_error
 
 $mode = "object"
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Protected Member Functions

 doCreate ($a_upload=false)
 create object More...
 
 beforeCreateMetaData ()
 
 beforeUpdateMetaData ()
 
 doCreateMetaData ()
 create file object meta data More...
 
 beforeMDUpdateListener ($a_element)
 
 doMDUpdateListener ($a_element)
 
 doRead ()
 read file properties More...
 
 beforeUpdate ()
 
 doUpdate ()
 update file More...
 
 doUpdateMetaData ()
 update meta data More...
 
 doCloneObject ($a_new_obj, $a_target_id, $a_copy_id=0)
 Clone. More...
 
 beforeDelete ()
 
 doDelete ()
 
 updateWithVersion ($version)
 Updates the file object with the specified file version. More...
 
 createPreview ($force=false)
 Creates a preview for the file object. More...
 
 deletePreview ()
 Deletes the preview of the file object. More...
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate ()
 
 beforeCreate ()
 
 doUpdate ()
 
 beforeUpdate ()
 
 doMDUpdateListener ($a_element)
 
 beforeMDUpdateListener ($a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject ($new_obj, $a_target_id, $a_copy_id=null)
 
 beforeCloneObject ()
 

Static Protected Member Functions

static handleQuotaUpdate (ilObjFile $a_file)
 

Protected Attributes

 $rating = false
 
 $log = null
 

Private Attributes

 $file_storage = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjFile::__construct (   $a_id = 0,
  $a_call_by_reference = true 
)

ilObjFile constructor.

Parameters
int$a_idID of the object, ref_id or obj_id possible
bool$a_call_by_referencedefines the $a_id a ref_id

Reimplemented from ilObject2.

Definition at line 35 of file class.ilObjFile.php.

35 {
36 $this->version = 0;
37 $this->raise_upload_error = true;
38
39 $this->log = ilLoggerFactory::getLogger('file');
40
41 parent::__construct($a_id,$a_call_by_reference);
42
43 if($this->getId())
44 {
45 $this->initFileStorage();
46 }
47 }
static getLogger($a_component_id)
Get component logger.
initFileStorage()
init file storage object
getId()
get object id @access public

References ilObject2\getId(), ilLoggerFactory\getLogger(), and initFileStorage().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAllUsages()

static ilObjFile::_deleteAllUsages (   $a_type,
  $a_id,
  $a_usage_hist_nr = 0,
  $a_usage_lang = "-" 
)
static

static delete all usages of

Definition at line 925 of file class.ilObjFile.php.

926 {
927 global $ilDB;
928
929 $and_hist = ($a_usage_hist_nr !== false)
930 ? " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr, "integer")
931 : "";
932
933 $file_ids = array();
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").
938 $and_hist);
939 while($row = $ilDB->fetchAssoc($set))
940 {
941 $file_ids[] = $row["id"];
942 }
943
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"));
949
950 foreach($file_ids as $file_id)
951 {
952 self::handleQuotaUpdate(new self($file_id, false));
953 }
954 }
static handleQuotaUpdate(ilObjFile $a_file)
global $ilDB

References $ilDB, $row, and handleQuotaUpdate().

Referenced by ilPCFileList\beforePageDelete(), and ilPCFileList\saveFileUsage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getFilesOfObject()

static ilObjFile::_getFilesOfObject (   $a_type,
  $a_id,
  $a_usage_hist_nr = 0,
  $a_usage_lang = "-" 
)
static

get all files of an object

Parameters
string$a_typeobject type (e.g. "lm:pg")
int$a_idobject id
Returns
array array of file ids

Definition at line 1025 of file class.ilObjFile.php.

1026 {
1027 global $ilDB;
1028
1029 $lstr = "";
1030 if ($a_usage_lang != "")
1031 {
1032 $lstr = "usage_lang = ".$ilDB->quote((string) $a_usage_lang, "text")." AND ";
1033 }
1034
1035 // get usages in learning modules
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 ".
1039 $lstr.
1040 "usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer");
1041 $file_set = $ilDB->query($q);
1042 $ret = array();
1043 while($file_rec = $ilDB->fetchAssoc($file_set))
1044 {
1045 $ret[$file_rec["id"]] = $file_rec["id"];
1046 }
1047
1048 return $ret;
1049 }

References $ilDB, and $ret.

Referenced by ilPCFileList\afterPageUpdate(), ilCOPageHTMLExport\collectPageElements(), ilObjGlossary\exportHTMLGlossaryTerms(), ilObjContentObject\exportHTMLGlossaryTerms(), ilObjContentObject\exportHTMLPages(), ilPageObject\getLastUpdateOfIncludedElements(), and ilCOPageExporter\getXmlExportHeadDependencies().

+ Here is the caller graph for this function:

◆ _lookupAbsolutePath()

static ilObjFile::_lookupAbsolutePath (   $obj_id,
  $a_version = null 
)
static

return absolute path for version

Definition at line 1132 of file class.ilObjFile.php.

1133 {
1134 $file_storage = new ilFSStorageFile($obj_id);
1136 $version_subdir = "";
1137
1138 if (!is_numeric($a_version))
1139 {
1140 $a_version = ilObjFile::_lookupVersion ($obj_id);
1141 }
1142 $version_subdir = DIRECTORY_SEPARATOR.sprintf("%03d", $a_version);
1143 return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
1144 }
static _lookupFileName($a_id)
static _lookupVersion($a_id)
lookup version

References $file_storage, $filename, _lookupFileName(), and _lookupVersion().

Referenced by ilContainerGUI\copyFile(), ilObjFolder\recurseFolder(), and ilObjWorkspaceFolder\recurseFolder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupFileName()

static ilObjFile::_lookupFileName (   $a_id)
static

Definition at line 592 of file class.ilObjFile.php.

593 {
594 global $ilDB;
595
596 $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,'integer');
597 $r = $ilDB->query($q);
598 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
599
600 return ilUtil::stripSlashes($row->file_name);
601 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$r
Definition: example_031.php:79

References $ilDB, $r, $row, DB_FETCHMODE_OBJECT, and ilUtil\stripSlashes().

Referenced by _lookupAbsolutePath(), ilSCORM2004PageGUI\setDefaultLinkXml(), and ilFilePreviewRenderer\supports().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupFileSize()

static ilObjFile::_lookupFileSize (   $a_id)
static

Lookups the file size of the file in bytes.

Definition at line 605 of file class.ilObjFile.php.

606 {
607 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
609 }
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes.

References ilObjFileAccess\_lookupFileSize().

Referenced by ilPageObject\addFileSizes(), ilObjFileDAV\getContentLength(), and ilObjFileGUI\infoScreenForward().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupVersion()

static ilObjFile::_lookupVersion (   $a_id)
static

lookup version

Definition at line 614 of file class.ilObjFile.php.

615 {
616 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
618 }
_lookupVersion($a_id)
lookup version

References ilObjFileAccess\_lookupVersion().

Referenced by _lookupAbsolutePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _saveUsage()

static ilObjFile::_saveUsage (   $a_file_id,
  $a_type,
  $a_id,
  $a_usage_hist_nr = 0,
  $a_usage_lang = "-" 
)
static

save usage

Definition at line 959 of file class.ilObjFile.php.

960 {
961 global $ilDB;
962
963 /*
964 $ilDB->manipulate("DELETE FROM file_usage WHERE usage_type = ".
965 $ilDB->quote((string) $a_type, "text").
966 " AND usage_id = ".$ilDB->quote((int) $a_id, "integer").
967 " AND usage_lang = ".$ilDB->quote($a_usage_lang, "text").
968 " AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer").
969 " AND id = ".$ilDB->quote((int) $a_file_id, "integer"));
970
971 $ilDB->manipulate("INSERT INTO file_usage (id, usage_type, usage_id, usage_hist_nr, usage_lang) VALUES".
972 " (".$ilDB->quote((int) $a_file_id, "integer").",".
973 $ilDB->quote((string) $a_type, "text").",".
974 $ilDB->quote((int) $a_id, "integer").",".
975 $ilDB->quote((int) $a_usage_hist_nr, "integer").",".
976 $ilDB->quote($a_usage_lang, "text").
977 ")");
978 */
979
980 // #15143
981 $ilDB->replace("file_usage",
982 array(
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)
988 ),
989 array()
990 );
991
992 self::handleQuotaUpdate(new self($a_file_id, false));
993 }

References $ilDB, and handleQuotaUpdate().

Referenced by ilPCFileList\saveFileUsage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeFileType()

static ilObjFile::_writeFileType (   $a_id,
  $a_format 
)
static

Definition at line 581 of file class.ilObjFile.php.

582 {
583 global $ilDB;
584
585 $q = "UPDATE file_data SET ".
586 " file_type = ".$ilDB->quote($a_format ,'text').
587 " WHERE file_id = ".$ilDB->quote($a_id ,'integer');
588 $res = $ilDB->manipulate($q);
589
590 }

References $ilDB, and $res.

Referenced by doMDUpdateListener().

+ Here is the caller graph for this function:

◆ addFileVersion()

ilObjFile::addFileVersion (   $a_upload_file,
  $a_filename 
)

Definition at line 288 of file class.ilObjFile.php.

289 {
290 $this->getUploadFile($a_upload_file, $a_filename, true);
291
292 require_once("./Services/History/classes/class.ilHistory.php");
294 $this->getId(),
295 "new_version",
296 $a_filename.",".$this->getVersion()
297 );
298 $this->setFilename($a_filename);
299 $this->addNewsNotification("file_updated");
300
301 // create preview
302 $this->createPreview($this->getVersion() > 1);
303 }
_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.
getUploadFile($a_upload_file, $a_filename, $a_prevent_preview=false, $handle_secure_name=true)
createPreview($force=false)
Creates a preview for the file object.
addNewsNotification($a_lang_var)

References ilHistory\_createEntry(), addNewsNotification(), createPreview(), ilObject2\getId(), getUploadFile(), and getVersion().

+ Here is the call graph for this function:

◆ addNewsNotification()

ilObjFile::addNewsNotification (   $a_lang_var)

Definition at line 1064 of file class.ilObjFile.php.

1065 {
1066 // BEGIN WebDAV Suppress news notification for hidden files
1067 if ($this->isHidden()) {
1068 return;
1069 }
1070 // END WebDAV Suppress news notification for hidden files
1071
1072 global $ilUser;
1073
1074 // Add Notification to news
1075 include_once("./Services/News/classes/class.ilNewsItem.php");
1076 include_once("./Modules/File/classes/class.ilObjFileAccess.php");
1077 $news_item = new ilNewsItem();
1078 $news_item->setContext($this->getId(), $this->getType());
1079 $news_item->setPriority(NEWS_NOTICE);
1080 $news_item->setTitle($a_lang_var);
1081 $news_item->setContentIsLangVar(true);
1082 if ($this->getDescription() != "")
1083 {
1084 $news_item->setContent(
1085 "<p>".
1086 $this->getDescription()."</p>");
1087 }
1088 $news_item->setUserId($ilUser->getId());
1089 $news_item->setVisibility(NEWS_USERS);
1090 $news_item->create();
1091 }
const NEWS_USERS
const NEWS_NOTICE
isHidden()
Returns true, if this file should be hidden in the repository view.
getType()
get object type @access public
getDescription()
get object description
global $ilUser
Definition: imgupload.php:15

References $ilUser, ilObject2\getDescription(), ilObject2\getId(), ilObject2\getType(), isHidden(), NEWS_NOTICE, and NEWS_USERS.

Referenced by addFileVersion(), createProperties(), replaceFile(), and rollback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beforeCreateMetaData()

ilObjFile::beforeCreateMetaData ( )
protected

Reimplemented from ilObject2.

Definition at line 136 of file class.ilObjFile.php.

137 {
138 return !(bool)$this->no_meta_data_creation;
139 }

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 857 of file class.ilObjFile.php.

858 {
859 global $ilDB;
860
861 // check, if file is used somewhere
862 $usages = $this->getUsages();
863 if (count($usages) == 0)
864 {
865 return true;
866 }
867 return false;
868 }
getUsages()
get all usages of file object

References $ilDB, and getUsages().

+ Here is the call graph for this function:

◆ beforeMDUpdateListener()

ilObjFile::beforeMDUpdateListener (   $a_element)
protected

Reimplemented from ilObject2.

Definition at line 162 of file class.ilObjFile.php.

163 {
164 // Check file extension
165 // Removing the file extension is not allowed
166 include_once 'Services/MetaData/classes/class.ilMD.php';
167 $md = new ilMD($this->getId(),0, $this->getType());
168 if(!is_object($md_gen = $md->getGeneral()))
169 {
170 return false;
171 }
172 $title = $this->checkFileExtension($this->getFileName(), $md_gen->getTitle());
173 $md_gen->setTitle($title);
174 $md_gen->update();
175 return true;
176 }
checkFileExtension($new_filename, $new_title)
Check if the file extension does still exist after an update of the title.

References ilObject\$title, checkFileExtension(), getFileName(), ilObject2\getId(), and ilObject2\getType().

+ Here is the call graph for this function:

◆ beforeUpdate()

ilObjFile::beforeUpdate ( )
protected

Reimplemented from ilObject2.

Definition at line 415 of file class.ilObjFile.php.

416 {
417 // no meta data handling for file list files
418 if ($this->getMode() != "filelist")
419 {
420 $this->updateMetaData();
421 }
422
423 return true;
424 }
getMode()
mode is object or filelist
updateMetaData()
update meta data entry

References getMode(), and ilObject2\updateMetaData().

+ Here is the call graph for this function:

◆ beforeUpdateMetaData()

ilObjFile::beforeUpdateMetaData ( )
protected

Reimplemented from ilObject2.

Definition at line 141 of file class.ilObjFile.php.

142 {
143 return !(bool)$this->no_meta_data_creation;
144 }

◆ checkFileExtension()

ilObjFile::checkFileExtension (   $new_filename,
  $new_title 
)

Check if the file extension does still exist after an update of the title.

Returns

Definition at line 1150 of file class.ilObjFile.php.

1151 {
1152 include_once './Modules/File/classes/class.ilObjFileAccess.php';
1153 $fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
1154 $titleExtension = ilObjFileAccess::_getFileExtension($new_title);
1155 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
1156 {
1157 // remove old extension
1158 $pi = pathinfo($this->getFileName());
1159 $suffix = $pi["extension"];
1160 if ($suffix != "")
1161 {
1162 if (substr($new_title,
1163 strlen($new_title) - strlen($suffix) - 1)
1164 == ".".$suffix)
1165 {
1166 $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
1167 }
1168 }
1169 $new_title .= '.'.$fileExtension;
1170 }
1171 return $new_title;
1172 }
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.

References ilObjFileAccess\_getFileExtension(), and getFileName().

Referenced by beforeMDUpdateListener(), and updateWithVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearDataDirectory()

ilObjFile::clearDataDirectory ( )

clear data directory

Definition at line 317 of file class.ilObjFile.php.

318 {
320 $this->createDirectory();
321 }
getDirectory($a_version=0)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References createDirectory(), ilUtil\delDir(), and getDirectory().

Referenced by deleteVersions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compareVersions()

ilObjFile::compareVersions (   $v1,
  $v2 
)

Compares two file versions.

Parameters
array$v1First file version to compare.
array$v2Second file version to compare.
Returns
int Returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Definition at line 1315 of file class.ilObjFile.php.

1316 {
1317 // v2 - v1 because version should be descending
1318 return (int)$v2["version"] - (int)$v1["version"];
1319 }

◆ copy()

ilObjFile::copy (   $a_source,
  $a_destination 
)

copy file

Definition at line 309 of file class.ilObjFile.php.

310 {
311 return copy($a_source,$this->getDirectory()."/".$a_destination);
312 }
copy($a_source, $a_destination)
copy file

References copy(), and getDirectory().

Referenced by copy(), and rollback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDirectory()

ilObjFile::createDirectory ( )

Definition at line 227 of file class.ilObjFile.php.

228 {
230 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References getDirectory(), and ilUtil\makeDirParents().

Referenced by clearDataDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPreview()

ilObjFile::createPreview (   $force = false)
protected

Creates a preview for the file object.

Parameters
bool$forcetrue, to force the creation of the preview; false, to create the preview only if the file is newer.

Definition at line 1385 of file class.ilObjFile.php.

1386 {
1387 // only normal files are supported
1388 if ($this->getMode() != "object")
1389 return;
1390
1391 require_once("./Services/Preview/classes/class.ilPreview.php");
1392 ilPreview::createPreview($this, $force);
1393 }
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.

References ilPreview\createPreview(), and getMode().

Referenced by addFileVersion(), getUploadFile(), replaceFile(), storeUnzipedFile(), and updateWithVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createProperties()

ilObjFile::createProperties (   $a_upload = false)

The basic properties of a file object are stored in table object_data.

This is not sufficient for a file object. Therefore we create additional properties in table file_data. This method has been put into a separate operation, to allow a WebDAV Null resource (class.ilObjNull.php) to become a file object.

Definition at line 77 of file class.ilObjFile.php.

78 {
79 global $ilDB,$tree;
80
81 // Create file directory
82 $this->initFileStorage();
83 $this->file_storage->create();
84
85 if($a_upload)
86 {
87 return true;
88 }
89
90 // not upload mode
91 require_once("./Services/History/classes/class.ilHistory.php");
92 ilHistory::_createEntry($this->getId(), "create", $this->getFileName().",1");
93 $this->addNewsNotification("file_created");
94
95
96 require_once("./Services/News/classes/class.ilNewsItem.php");
97 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
98 if ($default_visibility == "public")
99 {
100 ilBlockSetting::_write("news", "public_notifications",
101 1, 0, $this->getId());
102 }
103
104 // log creation
105 include_once("./Services/Utilities/classes/class.ilStr.php");
106 $this->log->debug("ilObjFile::createProperties, ID: ".$this->getId().
107 ", Name: ".$this->getFileName().
108 ", Type: ".$this->getFileType().
109 ", Size: ".$this->getFileSize().
110 ", Mode: ".$this->getMode().
111 ", Name(Bytes): ".implode(":", ilStr::getBytesForString($this->getFileName()))
112 );
113 $this->log->logStack(ilLogLevel::DEBUG);
114
115 $q = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) "
116 ."VALUES (".$ilDB->quote($this->getId() ,'integer').","
117 .$ilDB->quote($this->getFileName() ,'text').","
118 .$ilDB->quote($this->getFileType() ,'text').","
119 .$ilDB->quote((int) $this->getFileSize() ,'integer').","
120 .$ilDB->quote(1 ,'integer').",".$ilDB->quote($this->getMode() ,'text').")";
121 $res = $ilDB->manipulate($q);
122
123 // no meta data handling for file list files
124 if ($this->getMode() != "filelist")
125 {
126 $this->createMetaData();
127 }
128 }
$_GET["client_id"]
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
createMetaData()
create meta data entry
static getBytesForString($a_str)
Return string as byte array Note: Use this for debugging purposes only.

References $_GET, $ilDB, $res, ilHistory\_createEntry(), ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), addNewsNotification(), ilObject2\createMetaData(), ilLogLevel\DEBUG, ilStr\getBytesForString(), getFileName(), getFileSize(), getFileType(), ilObject2\getId(), getMode(), and initFileStorage().

Referenced by doCreate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePreview()

ilObjFile::deletePreview ( )
protected

Deletes the preview of the file object.

Definition at line 1398 of file class.ilObjFile.php.

1399 {
1400 // only normal files are supported
1401 if ($this->getMode() != "object")
1402 return;
1403
1404 require_once("./Services/Preview/classes/class.ilPreview.php");
1406 }
static deletePreview($a_obj_id)
Deletes the preview for the object with the specified id.

References ilPreview\deletePreview(), ilObject2\getId(), and getMode().

Referenced by doDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteVersions()

ilObjFile::deleteVersions (   $a_hist_entry_ids = null)

Deletes the specified history entries or all entries if no ids are specified.

Parameters
array$a_hist_entry_idsThe ids of the entries to delete or null to delete all entries

Definition at line 328 of file class.ilObjFile.php.

329 {
330 global $ilDB;
331
332 require_once("./Services/History/classes/class.ilHistory.php");
333
334 if ($a_hist_entry_ids == null || count($a_hist_entry_ids) < 1)
335 {
336 $ilDB->manipulate("UPDATE file_data SET version = 1 WHERE file_id = ".$ilDB->quote($this->getId() ,'integer'));
337 $this->setVersion(0);
338 $this->clearDataDirectory();
339
341
343 }
344 else
345 {
346 $actualVersionDeleted = false;
347
348 // get all versions
349 $versions = $this->getVersions();
350
351 // delete each version
352 foreach ($a_hist_entry_ids as $hist_id)
353 {
354 $entry = null;
355
356 // get version
357 foreach ($versions as $index => $version)
358 {
359 if ($version["hist_entry_id"] == $hist_id)
360 {
361 // remove each history entry
363
364 // delete directory
365 $version_dir = $this->getDirectory($version["version"]);
366 ilUtil::delDir($version_dir);
367
368 // is actual version?
369 if ($version["version"] == $this->getVersion())
370 $actualVersionDeleted = true;
371
372 // remove from array
373 unset($versions[$index]);
374 break;
375 }
376 }
377 }
378
379 // update actual version if it was deleted before
380 if ($actualVersionDeleted)
381 {
382 // get newest version (already sorted by getVersions)
383 $version = reset($versions);
384 $this->updateWithVersion($version);
385 }
386 else
387 {
388 // updateWithVersion() will trigger quota, too
390 }
391 }
392 }
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
_removeEntriesForObject($a_obj_id)
remove all history entries for an object
clearDataDirectory()
clear data directory
updateWithVersion($version)
Updates the file object with the specified file version.
getVersions($version_ids=null)
Gets the file versions for this object.
setVersion($a_version)

References $ilDB, ilHistory\_removeEntriesForObject(), ilHistory\_removeEntryByHistoryID(), clearDataDirectory(), ilUtil\delDir(), getDirectory(), ilObject2\getId(), getVersion(), getVersions(), handleQuotaUpdate(), setVersion(), and updateWithVersion().

+ Here is the call graph for this function:

◆ determineFileSize()

ilObjFile::determineFileSize (   $a_hist_entry_id = null)

Determine File Size.

Definition at line 623 of file class.ilObjFile.php.

624 {
625 if (is_null($a_hist_entry_id))
626 {
627 $file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
628 }
629 else
630 {
631 require_once("./Services/History/classes/class.ilHistory.php");
632 $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
633
634 if ($entry === false)
635 {
636 return false;
637 }
638
639 $data = $this->parseInfoParams($entry);
640 $file = $this->getDirectory($data["version"])."/".$data["filename"];
641 }
642 if (is_file($file))
643 {
644 $this->setFileSize(filesize($file));
645 }
646 }
print $file
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
setFileSize($a_size)
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
$data

References $data, $file, ilHistory\_getEntryByHistoryID(), getDirectory(), getFileName(), getVersion(), parseInfoParams(), and setFileSize().

Referenced by updateWithVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doCloneObject()

ilObjFile::doCloneObject (   $a_new_obj,
  $a_target_id,
  $a_copy_id = 0 
)
protected

Clone.

@access public

Parameters
objectclone
inttarget id
intcopy id

Reimplemented from ilObject2.

Definition at line 816 of file class.ilObjFile.php.

817 {
818 global $ilDB;
819
820 $a_new_obj->createDirectory();
821 $this->cloneMetaData($a_new_obj);
822
823 // Copy all file versions
824 ilUtil::rCopy($this->getDirectory(),$a_new_obj->getDirectory());
825
826 // object created now copy other settings
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').",".
829 $ilDB->quote($this->getFileName() ,'text').",".
830 $ilDB->quote($this->getFileType() ,'text').",".
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').")";
835 $res = $ilDB->manipulate($query);
836
837 // copy all previews
838 require_once("./Services/Preview/classes/class.ilPreview.php");
839 ilPreview::copyPreviews($this->getId(), $a_new_obj->getId());
840
841 // copy history entries
842 require_once("./Services/History/classes/class.ilHistory.php");
843 ilHistory::_copyEntriesForObject($this->getId(),$a_new_obj->getId());
844
845 // Copy learning progress settings
846 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
847 $obj_settings = new ilLPObjSettings($this->getId());
848 $obj_settings->cloneSettings($a_new_obj->getId());
849 unset($obj_settings);
850
851 // add news notification
852 $a_new_obj->addNewsNotification("file_created");
853
854 return $a_new_obj;
855 }
_copyEntriesForObject($a_src_id, $a_dst_id)
copy all history entries for an object
cloneMetaData($target_obj)
Copy meta data.
static copyPreviews($a_src_id, $a_dest_id)
Copies the preview images from one preview to a new preview object.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.

References $ilDB, $query, $res, ilHistory\_copyEntriesForObject(), ilObject2\cloneMetaData(), ilPreview\copyPreviews(), getDirectory(), getFileName(), getFileSize(), getFileType(), ilObject2\getId(), getMode(), getVersion(), hasRating(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ doCreate()

ilObjFile::doCreate (   $a_upload = false)
protected

create object

Parameters
boolupload mode (if enabled no entries in file_data will be done)

Definition at line 62 of file class.ilObjFile.php.

63 {
64 //BEGIN WebDAV Move Property creation into a method of its own.
65 $this->createProperties($a_upload);
66 //END WebDAV Move Property creation into a method of its own.
67 }
createProperties($a_upload=false)
The basic properties of a file object are stored in table object_data.

References createProperties().

+ Here is the call graph for this function:

◆ doCreateMetaData()

ilObjFile::doCreateMetaData ( )
protected

create file object meta data

Reimplemented from ilObject2.

Definition at line 149 of file class.ilObjFile.php.

150 {
151 // add technical section with file size and format
152 $md_obj = new ilMD($this->getId(),0,$this->getType());
153 $technical = $md_obj->addTechnical();
154 $technical->setSize($this->getFileSize());
155 $technical->save();
156 $format = $technical->addFormat();
157 $format->setFormat($this->getFileType());
158 $format->save();
159 $technical->update();
160 }

References getFileSize(), getFileType(), ilObject2\getId(), and ilObject2\getType().

+ Here is the call graph for this function:

◆ doDelete()

ilObjFile::doDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 870 of file class.ilObjFile.php.

871 {
872 global $ilDB;
873
874 // delete file data entry
875 $q = "DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
876 $this->ilias->db->query($q);
877
878 // delete history entries
879 require_once("./Services/History/classes/class.ilHistory.php");
881
882 // delete entire directory and its content
883 if (@is_dir($this->getDirectory()))
884 {
886 }
887
888 // delete meta data
889 if ($this->getMode() != "filelist")
890 {
891 $this->deleteMetaData();
892 }
893
895
896 // delete preview
897 $this->deletePreview();
898 }
deletePreview()
Deletes the preview of the file object.
deleteMetaData()
delete meta data entry
redirection script todo: (a better solution should control the processing via a xml file)

References $ilDB, ilHistory\_removeEntriesForObject(), ilUtil\delDir(), ilObject2\deleteMetaData(), deletePreview(), getDirectory(), ilObject2\getId(), getMode(), and handleQuotaUpdate().

+ Here is the call graph for this function:

◆ doMDUpdateListener()

ilObjFile::doMDUpdateListener (   $a_element)
protected

Reimplemented from ilObject2.

Definition at line 178 of file class.ilObjFile.php.

179 {
180 // handling for technical section
181 include_once 'Services/MetaData/classes/class.ilMD.php';
182//echo "-".$a_element."-";
183 switch($a_element)
184 {
185 case 'Technical':
186
187 // Update Format (size is not stored in db)
188 $md = new ilMD($this->getId(),0, $this->getType());
189 if(!is_object($md_technical = $md->getTechnical()))
190 {
191 return false;
192 }
193
194 foreach($md_technical->getFormatIds() as $id)
195 {
196 $md_format = $md_technical->getFormat($id);
197 ilObjFile::_writeFileType($this->getId(),$md_format->getFormat());
198 $this->setFileType($md_format->getFormat());
199 break;
200 }
201
202 break;
203 }
204 return true;
205 }
setFileType($a_type)
static _writeFileType($a_id, $a_format)

References ilObject\$id, _writeFileType(), ilObject2\getId(), ilObject2\getType(), and setFileType().

+ Here is the call graph for this function:

◆ doRead()

ilObjFile::doRead ( )
protected

read file properties

Reimplemented from ilObject2.

Definition at line 397 of file class.ilObjFile.php.

398 {
399 global $ilDB;
400
401 $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
402 $r = $this->ilias->db->query($q);
403 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
404
405 $this->setFileName($row->file_name);
406 $this->setFileType($row->file_type);
407 $this->setFileSize($row->file_size);
408 $this->setVersion($row->version);
409 $this->setMode($row->f_mode);
410 $this->setRating($row->rating);
411
412 $this->initFileStorage();
413 }
setMode($a_mode)
mode is object or filelist
setFileName($a_name)
set filename
setRating($a_value)

References $ilDB, $r, $row, DB_FETCHMODE_OBJECT, ilObject2\getId(), initFileStorage(), setFileName(), setFileSize(), setFileType(), setMode(), setRating(), and setVersion().

+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

update file

Reimplemented from ilObject2.

Definition at line 429 of file class.ilObjFile.php.

430 {
431 global $ilDB, $ilLog;
432
433 //$ilLog->write(__METHOD__.' File type: '.$this->getFileType());
434
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);
443
445
446 return true;
447 }

References $ilDB, $ilLog, $res, getFileName(), getFileSize(), ilObject2\getId(), getMode(), getVersion(), handleQuotaUpdate(), and hasRating().

+ Here is the call graph for this function:

◆ doUpdateMetaData()

ilObjFile::doUpdateMetaData ( )
protected

update meta data

Reimplemented from ilObject2.

Definition at line 452 of file class.ilObjFile.php.

453 {
454 // add technical section with file size and format
455 $md_obj = new ilMD($this->getId(),0,$this->getType());
456 if(!is_object($technical = $md_obj->getTechnical()))
457 {
458 $technical = $md_obj->addTechnical();
459 $technical->save();
460 }
461 $technical->setSize($this->getFileSize());
462
463 $format_ids = $technical->getFormatIds();
464 if (count($format_ids) > 0)
465 {
466 $format = $technical->getFormat($format_ids[0]);
467 $format->setFormat($this->getFileType());
468 $format->update();
469 }
470 else
471 {
472 $format = $technical->addFormat();
473 $format->setFormat($this->getFileType());
474 $format->save();
475 }
476 $technical->update();
477 }

References getFileSize(), getFileType(), ilObject2\getId(), and ilObject2\getType().

+ Here is the call graph for this function:

◆ export()

ilObjFile::export (   $a_target_dir)

export files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_file_<file_id>/..." will be appended to this directory

Parameters
string$a_target_dirtarget directory

Definition at line 907 of file class.ilObjFile.php.

908 {
909 $subdir = "il_".IL_INST_ID."_file_".$this->getId();
910 ilUtil::makeDir($a_target_dir."/objects/".$subdir);
911
912 $filedir = $this->getDirectory($this->getVersion());
913
914 if (@!is_dir($filedir))
915 {
916 $filedir = $this->getDirectory();
917 }
918
919 ilUtil::rCopy($filedir, $a_target_dir."/objects/".$subdir);
920 }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References getDirectory(), ilObject2\getId(), getVersion(), ilUtil\makeDir(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ getDirectory()

ilObjFile::getDirectory (   $a_version = 0)

Definition at line 208 of file class.ilObjFile.php.

209 {
210 $version_subdir = "";
211
212 if ($a_version)
213 {
214 // BEGIN WebDAV Avoid double slash before version subdirectory
215 $version_subdir = sprintf("%03d", $a_version);
216 // END WebDAV Avoid double slash before version subdirectory
217 }
218
219 if(!is_object($this->file_storage))
220 {
221 $this->initFileStorage();
222 }
223
224 return $this->file_storage->getAbsolutePath().'/'.$version_subdir;
225 }

References initFileStorage().

Referenced by clearDataDirectory(), copy(), createDirectory(), deleteVersions(), determineFileSize(), doCloneObject(), doDelete(), export(), getFile(), getUploadFile(), getXMLZip(), rollback(), and storeUnzipedFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDiskUsage()

ilObjFile::getDiskUsage ( )

Gets the disk usage of the object in bytes.

@access public

Returns
integer the disk usage in bytes

Reimplemented from ilObject.

Definition at line 520 of file class.ilObjFile.php.

521 {
522 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
523 return ilObjFileAccess::_lookupDiskUsage($this->id);
524 }
_lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id.

References ilObjFileAccess\_lookupDiskUsage().

Referenced by handleQuotaUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFile()

ilObjFile::getFile (   $a_hist_entry_id = null)

Definition at line 528 of file class.ilObjFile.php.

529 {
530 if (is_null($a_hist_entry_id))
531 {
532 $file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
533 }
534 else
535 {
536 require_once("./Services/History/classes/class.ilHistory.php");
537 $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
538
539 if ($entry === false)
540 {
541 return false;
542 }
543
544 $data = $this->parseInfoParams($entry);
545 $file = $this->getDirectory($data["version"])."/".$data["filename"];
546 }
547 return $file;
548 }

References $data, $file, ilHistory\_getEntryByHistoryID(), getDirectory(), getFileName(), getVersion(), and parseInfoParams().

+ Here is the call graph for this function:

◆ getFileExtension()

ilObjFile::getFileExtension ( )

Returns the extension of the file name converted to lower-case.

e.g. returns 'pdf' for 'document.pdf'.

Definition at line 726 of file class.ilObjFile.php.

726 {
727 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
729 }
getTitle()
get object title @access public

References ilObjFileAccess\_getFileExtension(), and ilObject2\getTitle().

+ Here is the call graph for this function:

◆ getFileName()

ilObjFile::getFileName ( )

Definition at line 487 of file class.ilObjFile.php.

488 {
489 return $this->filename;
490 }

References $filename.

Referenced by beforeMDUpdateListener(), checkFileExtension(), createProperties(), determineFileSize(), doCloneObject(), doUpdate(), and getFile().

+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

Definition at line 510 of file class.ilObjFile.php.

511 {
512 return $this->filesize;
513 }

Referenced by createProperties(), doCloneObject(), doCreateMetaData(), doUpdate(), and doUpdateMetaData().

+ Here is the caller graph for this function:

◆ getFileType()

ilObjFile::getFileType ( )

Definition at line 500 of file class.ilObjFile.php.

501 {
502 return $this->filetype;
503 }

References $filetype.

Referenced by createProperties(), doCloneObject(), doCreateMetaData(), doUpdateMetaData(), and guessFileType().

+ Here is the caller graph for this function:

◆ getMode()

ilObjFile::getMode ( )

mode is object or filelist

Returns
string mode

Definition at line 576 of file class.ilObjFile.php.

577 {
578 return $this->mode;
579 }

References $mode.

Referenced by beforeUpdate(), createPreview(), createProperties(), deletePreview(), doCloneObject(), doDelete(), and doUpdate().

+ Here is the caller graph for this function:

◆ getSpecificVersion()

ilObjFile::getSpecificVersion (   $version_id)

Gets a specific file version.

Parameters
int$version_idThe version id to get.
Returns
array The specific version or false if the version was not found.

Definition at line 1215 of file class.ilObjFile.php.

1216 {
1217 include_once("./Services/History/classes/class.ilHistory.php");
1218 $version = ilHistory::_getEntryByHistoryID($version_id);
1219 if ($version === false)
1220 return false;
1221
1222 // ilHistory returns different keys in _getEntryByHistoryID and _getEntriesForObject
1223 // so this makes it the same
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"]);
1228
1229 // parse params
1230 $params = $this->parseInfoParams($version);
1231 return array_merge($version, $params);
1232 }
$params
Definition: example_049.php:96

References $params, ilHistory\_getEntryByHistoryID(), and parseInfoParams().

Referenced by rollback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUploadFile()

ilObjFile::getUploadFile (   $a_upload_file,
  $a_filename,
  $a_prevent_preview = false,
  $handle_secure_name = true 
)

Definition at line 237 of file class.ilObjFile.php.

238 {
239 if ($handle_secure_name) {
240 require_once('./Services/Utilities/classes/class.ilFileUtils.php');
241 $a_filename = ilFileUtils::getValidFilename($a_filename);
242 $this->setFileName($a_filename);
243 $this->setTitle($a_filename);
244 $this->update();
245 }
246 if($this->version) {
247 $this->setVersion($this->getVersion() + 1);
248 }
249
250 if (@!is_dir($this->getDirectory($this->getVersion())))
251 {
253 }
254
255 $file = $this->getDirectory($this->getVersion())."/".$a_filename;
256 ilUtil::moveUploadedFile($a_upload_file, $a_filename, $file, $this->raise_upload_error);
257
258 $this->handleQuotaUpdate($this);
259
260 // create preview?
261 if (!$a_prevent_preview)
262 {
263 $this->createPreview(false);
264 }
265 }
static getValidFilename($a_filename)
Get valid filename.
setTitle($a_title)
set object title
update()
update object in db
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References $file, createPreview(), getDirectory(), ilFileUtils\getValidFilename(), getVersion(), handleQuotaUpdate(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), setFileName(), ilObject2\setTitle(), setVersion(), and ilObject2\update().

Referenced by addFileVersion(), and replaceFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsages()

ilObjFile::getUsages ( )

get all usages of file object

Definition at line 998 of file class.ilObjFile.php.

999 {
1000 global $ilDB;
1001
1002 // get usages in learning modules
1003 $q = "SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->getId(), "integer");
1004 $us_set = $ilDB->query($q);
1005 $ret = array();
1006 while($us_rec = $ilDB->fetchAssoc($us_set))
1007 {
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"]);
1012 }
1013
1014 return $ret;
1015 }

References $ilDB, $ret, and ilObject2\getId().

Referenced by beforeDelete(), and handleQuotaUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVersion()

ilObjFile::getVersion ( )

Definition at line 556 of file class.ilObjFile.php.

557 {
558 return $this->version ? $this->version : 1;
559 }

Referenced by addFileVersion(), deleteVersions(), determineFileSize(), doCloneObject(), doUpdate(), export(), getFile(), getUploadFile(), rollback(), and storeUnzipedFile().

+ Here is the caller graph for this function:

◆ getVersions()

ilObjFile::getVersions (   $version_ids = null)

Gets the file versions for this object.

Parameters
array$version_idsThe file versions to get. If not specified all versions are returned.
Returns
The file versions.

Definition at line 1180 of file class.ilObjFile.php.

1181 {
1182 include_once("./Services/History/classes/class.ilHistory.php");
1183 $versions = ilHistory::_getEntriesForObject($this->getId(), $this->getType());
1184
1185 if ($version_ids != null && count($version_ids) > 0)
1186 {
1187 foreach ($versions as $index => $version)
1188 {
1189 if (!in_array($version["hist_entry_id"], $version_ids, true))
1190 {
1191 unset($versions[$index]);
1192 }
1193 }
1194 }
1195
1196 // add custom entries
1197 foreach ($versions as $index => $version)
1198 {
1199 $params = $this->parseInfoParams($version);
1200 $versions[$index] = array_merge($version, $params);
1201 }
1202
1203 // sort by version number (hist_entry_id will do for that)
1204 usort($versions, array($this, "compareVersions"));
1205
1206 return $versions;
1207 }
_getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object

References $params, ilHistory\_getEntriesForObject(), ilObject2\getId(), ilObject2\getType(), and parseInfoParams().

Referenced by deleteVersions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXMLZip()

ilObjFile::getXMLZip ( )

Reimplemented from ilObject.

Definition at line 1052 of file class.ilObjFile.php.

1053 {
1054 global $ilias;
1055
1056 $zip = PATH_TO_ZIP;
1057
1058 exec($zip.' '.ilUtil::escapeShellArg($this->getDirectory().'/'.$this->getFileName())." ".
1059 ilUtil::escapeShellArg($this->getDirectory().'/'.'1.zip'));
1060
1061 return $this->getDirectory().'/1.zip';
1062 }
static escapeShellArg($a_arg)

References ilObject\$ilias, ilUtil\escapeShellArg(), and getDirectory().

+ Here is the call graph for this function:

◆ guessFileType()

ilObjFile::guessFileType (   $a_file = "")

Guesses the file type based on the current values returned by getFileType() and getFileExtension().

If getFileType() returns 'application/octet-stream', the file extension is used to guess a more accurate file type.

Definition at line 754 of file class.ilObjFile.php.

754 {
755
756 $path = pathinfo($a_file);
757 if ($path["extension"] != "")
758 {
759 $filename = $path["basename"];
760 }
761 else
762 {
763 $filename = "dummy.".$this->getFileExtension();
764 }
765 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
766 $mime = ilMimeTypeUtil::getMimeType($a_file, $filename, $this->getFileType());
767 return $mime;
768
769/*
770 $fileType = $this->getFileType();
771 if (strlen($fileType) == 0) {
772 $fileType = 'application/octet-stream';
773 }
774
775 // Firefox browser assigns 'application/x-pdf' to PDF files, but
776 // it can only handle them if the have the mime-type 'application/pdf'.
777 if ($fileType == 'application/x-pdf')
778 {
779 $fileType = 'application/pdf';
780 }
781
782 if ($fileType == 'application/octet-stream')
783 {
784 $fileExtension = $this->getFileExtension();
785 $mimeArray = array(
786 'mpeg' => 'video/mpeg',
787 'mp3' => 'audio/mpeg',
788 'pdf' => 'application/pdf',
789 'gif' => 'image/gif',
790 'jpg' => 'image/jpg',
791 'png' => 'image/png',
792 'htm' => 'text/html',
793 'html' => 'text/html',
794 'wma' => 'video/x-ms-wma',
795 'wmv' => 'video/x-ms-wmv',
796 'swf' => 'application/x-shockwave-flash',
797 );
798 if (array_key_exists($fileExtension, $mimeArray))
799 {
800 $fileType = $mimeArray[$fileExtension];
801 }
802 }
803 return $fileType;
804*/
805 }
static getMimeType($a_file='', $a_filename='', $a_mime='')
$path
Definition: index.php:22

References $filename, $path, getFileType(), and ilMimeTypeUtil\getMimeType().

Referenced by updateWithVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleQuotaUpdate()

static ilObjFile::handleQuotaUpdate ( ilObjFile  $a_file)
staticprotected

Definition at line 1355 of file class.ilObjFile.php.

1356 {
1357 include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
1358 $mob = new ilObjMediaObject();
1359
1360 // file itself could be workspace item
1361 $parent_obj_ids = array($a_file->getId());
1362
1363 foreach($a_file->getUsages() as $item)
1364 {
1365 $parent_obj_id = $mob->getParentObjectIdForUsage($item);
1366 if($parent_obj_id &&
1367 !in_array($parent_obj_id, $parent_obj_ids))
1368 {
1369 $parent_obj_ids[]= $parent_obj_id;
1370 }
1371 }
1372
1373 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1375 $a_file->getId(),
1376 $a_file->getDiskUsage(),
1377 $parent_obj_ids);
1378 }
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.
getDiskUsage()
Gets the disk usage of the object in bytes.
Class ilObjMediaObject.

References getDiskUsage(), ilObject2\getId(), ilObject2\getType(), getUsages(), and ilDiskQuotaHandler\handleUpdatedSourceObject().

Referenced by _deleteAllUsages(), _saveUsage(), deleteVersions(), doDelete(), doUpdate(), and getUploadFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasRating()

ilObjFile::hasRating ( )

Definition at line 1413 of file class.ilObjFile.php.

1414 {
1415 return $this->rating;
1416 }

References $rating.

Referenced by doCloneObject(), and doUpdate().

+ Here is the caller graph for this function:

◆ initFileStorage()

ilObjFile::initFileStorage ( )

init file storage object

@access public

Definition at line 1099 of file class.ilObjFile.php.

1100 {
1101 $this->file_storage = new ilFSStorageFile($this->getId());
1102 return true;
1103 }

References ilObject2\getId().

Referenced by __construct(), createProperties(), doRead(), and getDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initType()

ilObjFile::initType ( )

Init type.

Reimplemented from ilObject2.

Definition at line 52 of file class.ilObjFile.php.

53 {
54 $this->type = "file";
55 }

◆ isHidden()

ilObjFile::isHidden ( )

Returns true, if this file should be hidden in the repository view.

Definition at line 742 of file class.ilObjFile.php.

742 {
743 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
745 }
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.

References ilObjFileAccess\_isFileHidden(), and ilObject2\getTitle().

Referenced by addNewsNotification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInline()

ilObjFile::isInline ( )

Returns true, if this file should be displayed inline in a browser window.

This is especially useful for PDF documents, HTML pages, and for images which are directly supported by the browser.

Definition at line 735 of file class.ilObjFile.php.

735 {
736 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
738 }
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.

References ilObjFileAccess\_isFileInline(), and ilObject2\getTitle().

+ Here is the call graph for this function:

◆ parseInfoParams()

ilObjFile::parseInfoParams (   $entry)

Parses the info parameters ("info_params") of the specified history entry.

Parameters
array$entryThe history entry.
Returns
array Returns an array containing the "filename" and "version" contained within the "info_params".

Definition at line 1327 of file class.ilObjFile.php.

1328 {
1329 $data = preg_split("/(.*),(.*)/", $entry["info_params"], 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
1330
1331 // bugfix: first created file had no version number
1332 // this is a workaround for all files created before the bug was fixed
1333 if (empty($data[1]))
1334 $data[1] = "1";
1335
1336 $result = array("filename" => $data[0], "version" => $data[1], "rollback_version" => "", "rollback_user_id" => "");
1337
1338 // if rollback, the version contains the rollback version as well
1339 if ($entry["action"] == "rollback")
1340 {
1341 $tokens = explode("|", $result["version"]);
1342 if (count($tokens) > 1)
1343 {
1344 $result["version"] = $tokens[0];
1345 $result["rollback_version"] = $tokens[1];
1346
1347 if (count($tokens) > 2)
1348 $result["rollback_user_id"] = $tokens[2];
1349 }
1350 }
1351
1352 return $result;
1353 }
$result
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

References $data, $result, and PREG_SPLIT_DELIM_CAPTURE.

Referenced by determineFileSize(), getFile(), getSpecificVersion(), and getVersions().

+ Here is the caller graph for this function:

◆ raiseUploadError()

ilObjFile::raiseUploadError (   $a_raise = true)

Definition at line 232 of file class.ilObjFile.php.

233 {
234 $this->raise_upload_error = $a_raise;
235 }

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)

replace file with new file

Definition at line 270 of file class.ilObjFile.php.

271 {
272 $this->getUploadFile($a_upload_file, $a_filename, true);
273
274 require_once("./Services/History/classes/class.ilHistory.php");
276 $this->getId(),
277 "replace",
278 $a_filename.",".$this->getVersion()
279 );
280 $this->setFilename($a_filename);
281 $this->addNewsNotification("file_updated");
282
283 // create preview
284 $this->createPreview(true);
285 }

References ilHistory\_createEntry(), addNewsNotification(), createPreview(), ilObject2\getId(), and getUploadFile().

+ Here is the call graph for this function:

◆ rollback()

ilObjFile::rollback (   $version_id)

Makes the specified version the current one and returns theSummary of rollbackVersion.

Parameters
int$version_idThe id of the version to make the current one.
Returns
array The new actual version.

Definition at line 1240 of file class.ilObjFile.php.

1241 {
1242 global $ilDB, $ilUser;
1243
1244 $source = $this->getSpecificVersion($version_id);
1245 if ($source === false)
1246 {
1247 $this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
1248 }
1249
1250 // get the new version number
1251 $new_version_nr = $this->getVersion() + 1;
1252
1253 // copy file
1254 $source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
1255 $dest_dir = $this->getDirectory($new_version_nr);
1256 if (@!is_dir($dest_dir))
1257 ilUtil::makeDir($dest_dir);
1258
1259 copy($source_path, $dest_dir . "/" . $source["filename"]);
1260
1261 // create new history entry based on the old one
1262 include_once("./Services/History/classes/class.ilHistory.php");
1264 $this->getId(),
1265 "rollback",
1266 $source["filename"] . "," . $new_version_nr . "|" . $source["version"] . "|" . $ilUser->getId());
1267
1268 // get id of newest entry
1269 $new_version = $this->getSpecificVersion($ilDB->getLastInsertId());
1270
1271 // change user back to the original uploader
1272 ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
1273
1274 // update this file with the new version
1275 $this->updateWithVersion($new_version);
1276
1277 $this->addNewsNotification("file_updated");
1278
1279 return $new_version;
1280 }
static _changeUserId($a_hist_entry_id, $new_user_id)
Changes the user id of the specified history entry.
getSpecificVersion($version_id)
Gets a specific file version.

References $ilDB, $ilUser, ilHistory\_changeUserId(), ilHistory\_createEntry(), addNewsNotification(), copy(), getDirectory(), ilObject2\getId(), getSpecificVersion(), getVersion(), ilUtil\makeDir(), and updateWithVersion().

+ Here is the call graph for this function:

◆ setFileName()

ilObjFile::setFileName (   $a_name)

set filename

Definition at line 482 of file class.ilObjFile.php.

483 {
484 $this->filename = $a_name;
485 }

Referenced by doRead(), getUploadFile(), and updateWithVersion().

+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize (   $a_size)

Definition at line 505 of file class.ilObjFile.php.

506 {
507 $this->filesize = $a_size;
508 }

Referenced by determineFileSize(), and doRead().

+ Here is the caller graph for this function:

◆ setFileType()

ilObjFile::setFileType (   $a_type)

Definition at line 492 of file class.ilObjFile.php.

493 {
494 global $ilLog;
495
496
497 $this->filetype = $a_type;
498 }

References $ilLog.

Referenced by doMDUpdateListener(), doRead(), and updateWithVersion().

+ Here is the caller graph for this function:

◆ setMode()

ilObjFile::setMode (   $a_mode)

mode is object or filelist

Parameters
string$a_modemode

Definition at line 566 of file class.ilObjFile.php.

567 {
568 $this->mode = $a_mode;
569 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setNoMetaDataCreation()

ilObjFile::setNoMetaDataCreation (   $a_status)

Definition at line 131 of file class.ilObjFile.php.

132 {
133 $this->no_meta_data_creation = (bool)$a_status;
134 }

◆ setRating()

ilObjFile::setRating (   $a_value)

Definition at line 1408 of file class.ilObjFile.php.

1409 {
1410 $this->rating = (bool)$a_value;
1411 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion (   $a_version)

Definition at line 551 of file class.ilObjFile.php.

552 {
553 $this->version = $a_version;
554 }

Referenced by deleteVersions(), doRead(), getUploadFile(), and updateWithVersion().

+ Here is the caller graph for this function:

◆ storeUnzipedFile()

ilObjFile::storeUnzipedFile (   $a_upload_file,
  $a_filename 
)

storeUnzipedFile

Stores Files unzipped from uploaded archive in filesystem

Parameters
string$a_upload_file
string$a_filename

Definition at line 1113 of file class.ilObjFile.php.

1114 {
1115 if (@!is_dir($this->getDirectory($this->getVersion())))
1116 {
1117 ilUtil::makeDir($this->getDirectory($this->getVersion()));
1118 }
1119
1120 $file = $this->getDirectory($this->getVersion())."/".$a_filename;
1121 require_once('./Services/Utilities/classes/class.ilFileUtils.php');
1122 ilFileUtils::rename($a_upload_file, $file);
1123
1124 // create preview
1125 $this->createPreview();
1126 }
static rename($a_source, $a_target)
Rename a file.

References $file, createPreview(), getDirectory(), getVersion(), ilUtil\makeDir(), and ilFileUtils\rename().

+ Here is the call graph for this function:

◆ updateWithVersion()

ilObjFile::updateWithVersion (   $version)
protected

Updates the file object with the specified file version.

Parameters
array$versionThe version to update the file object with.

Definition at line 1287 of file class.ilObjFile.php.

1288 {
1289 // update title (checkFileExtension must be called before setFileName!)
1290 $this->setTitle($this->checkFileExtension($version["filename"], $this->getTitle()));
1291
1292 $this->setVersion($version["version"]);
1293 $this->setFileName($version["filename"]);
1294
1295 // evaluate mime type (reset file type before)
1296 $this->setFileType("");
1297 $this->setFileType($this->guessFileType($version["filename"]));
1298
1299 // set filesize
1300 $this->determineFileSize();
1301
1302 $this->update();
1303
1304 // refresh preview
1305 $this->createPreview(true);
1306 }
determineFileSize($a_hist_entry_id=null)
Determine File Size.
guessFileType($a_file="")
Guesses the file type based on the current values returned by getFileType() and getFileExtension().

References checkFileExtension(), createPreview(), determineFileSize(), ilObject2\getTitle(), guessFileType(), setFileName(), setFileType(), ilObject2\setTitle(), setVersion(), and ilObject2\update().

Referenced by deleteVersions(), and rollback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $file_storage

ilObjFile::$file_storage = null
private

Definition at line 25 of file class.ilObjFile.php.

Referenced by _lookupAbsolutePath().

◆ $filemaxsize

ilObjFile::$filemaxsize = "20000000"

Definition at line 20 of file class.ilObjFile.php.

◆ $filename

ilObjFile::$filename

Definition at line 18 of file class.ilObjFile.php.

Referenced by _lookupAbsolutePath(), getFileName(), and guessFileType().

◆ $filetype

ilObjFile::$filetype

Definition at line 19 of file class.ilObjFile.php.

Referenced by getFileType().

◆ $log

ilObjFile::$log = null
protected

Definition at line 26 of file class.ilObjFile.php.

◆ $mode

ilObjFile::$mode = "object"

Definition at line 22 of file class.ilObjFile.php.

Referenced by getMode().

◆ $raise_upload_error

ilObjFile::$raise_upload_error

Definition at line 21 of file class.ilObjFile.php.

◆ $rating

ilObjFile::$rating = false
protected

Definition at line 23 of file class.ilObjFile.php.

Referenced by hasRating().


The documentation for this class was generated from the following file: