ILIAS  release_4-4 Revision
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)
 Constructor public. More...
 
 initType ()
 
 createProperties ($a_upload=false, $a_prevent_meta_data_creation=false)
 The basic properties of a file object are stored in table object_data. More...
 
 getDirectory ($a_version=0)
 
 createDirectory ()
 
 raiseUploadError ($a_raise=true)
 
 getUploadFile ($a_upload_file, $a_filename, $a_prevent_preview=false)
 
 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...
 
 _writeFileType ($a_id, $a_format)
 
 _lookupFileName ($a_id)
 
 _lookupFileSize ($a_id)
 Lookups the file size of the file in bytes. More...
 
 _lookupVersion ($a_id)
 lookup version More...
 
 determineFileSize ($a_hist_entry_id=null)
 Determine File Size. More...
 
 sendFile ($a_hist_entry_id=null)
 
 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...
 
 _deleteAllUsages ($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 static delete all usages of More...
 
 _saveUsage ($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 save usage More...
 
 getUsages ()
 get all usages of file object More...
 
 _getFilesOfObject ($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
 get all files of an 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 public. More...
 
 withReferences ()
 
 read ($a_force_db=false)
 Read data from db. More...
 
 getId ()
 
 setId ($a_id)
 
 setRefId ($a_id)
 
 getRefId ()
 
 getType ()
 
 setType ($a_type)
 
 getPresentationTitle ()
 
 getTitle ()
 
 getUntranslatedTitle ()
 
 setTitle ($a_title)
 
 getDescription ()
 
 setDescription ($a_desc)
 
 getLongDescription ()
 
 getImportId ()
 
 setImportId ($a_import_id)
 
 getOwner ()
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 
 setOwner ($a_owner)
 
 getCreateDate ()
 
 getLastUpdateDate ()
 
 setObjDataRecord ($a_record)
 
 create ($a_clone_mode=false)
 
 update ()
 
 MDUpdateListener ($a_element)
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 
 _getIdForImportId ($a_import_id)
 
 _lookupOwner ($a_id)
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 
 _getLastUpdateOfObjects ($a_objs)
 
 _setDeletedDate ($a_ref_id)
 
 _resetDeletedDate ($a_ref_id)
 
 _lookupDeletedDate ($a_ref_id)
 
 _writeTitle ($a_obj_id, $a_title)
 
 _writeDescription ($a_obj_id, $a_desc)
 
 _writeImportId ($a_obj_id, $a_import_id)
 
 _isInTrash ($a_ref_id)
 
 _hasUntrashedReference ($a_obj_id)
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 
 putInTree ($a_parent_ref)
 
 setPermissions ($a_parent_ref)
 
 createReference ()
 
 countReferences ()
 
 delete ()
 
 initDefaultRoles ()
 
 createRoleFolder ()
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 
 cloneMetaData ($target_obj)
 
 cloneObject ($a_target_id, $a_copy_id=null, $a_omit_tree=false)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor 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 public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title 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 public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 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...
 
 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) public More...
 
 createRoleFolder ()
 creates a local role folder 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...
 

Static Public Member Functions

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)
 
static _lookupTitle ($a_id)
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 
static _lookupObjId ($a_id)
 
static _lookupType ($a_id, $a_reference=false)
 
static _lookupObjectId ($a_ref_id)
 
static _exists ($a_id, $a_reference=false)
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 
static _prepareCloneSelection ($a_ref_ids, $new_type)
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 
- Static Public Member Functions inherited from ilObject
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 setDeletedDates ($a_ref_ids)
 Set deleted date 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 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 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, $a_prevent_meta_data_creation=false)
 create object More...
 
 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
 

Private Attributes

 $file_storage = null
 

Detailed Description

Class ilObjFile.

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

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

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

37  {
38  $this->version = 0;
39  $this->raise_upload_error = true;
40  parent::__construct($a_id,$a_call_by_reference);
41 
42  if($this->getId())
43  {
44  $this->initFileStorage();
45  }
46  }
initFileStorage()
init file storage object
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAllUsages()

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

static delete all usages of

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

References $row.

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

863  {
864  global $ilDB;
865 
866  $and_hist = ($a_usage_hist_nr !== false)
867  ? " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr, "integer")
868  : "";
869 
870  $file_ids = array();
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").
875  $and_hist);
876  while($row = $ilDB->fetchAssoc($set))
877  {
878  $file_ids[] = $row["id"];
879  }
880 
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"));
886 
887  foreach($file_ids as $file_id)
888  {
889  self::handleQuotaUpdate(new self($file_id, false));
890  }
891  }
+ Here is the caller graph for this function:

◆ _getFilesOfObject()

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

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 948 of file class.ilObjFile.php.

References $ret.

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

949  {
950  global $ilDB;
951 
952  // get usages in learning modules
953  $q = "SELECT * FROM file_usage WHERE ".
954  "usage_id = ".$ilDB->quote((int) $a_id, "integer")." AND ".
955  "usage_type = ".$ilDB->quote((string) $a_type, "text")." AND ".
956  "usage_lang = ".$ilDB->quote((string) $a_usage_lang, "text")." AND ".
957  "usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer");
958  $file_set = $ilDB->query($q);
959  $ret = array();
960  while($file_rec = $ilDB->fetchAssoc($file_set))
961  {
962  $ret[$file_rec["id"]] = $file_rec["id"];
963  }
964 
965  return $ret;
966  }
+ 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 1051 of file class.ilObjFile.php.

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

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

1052  {
1053  $file_storage = new ilFSStorageFile($obj_id);
1055  $version_subdir = "";
1056 
1057  if (!is_numeric($a_version))
1058  {
1059  $a_version = ilObjFile::_lookupVersion ($obj_id);
1060  }
1061  $version_subdir = DIRECTORY_SEPARATOR.sprintf("%03d", $a_version);
1062  return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
1063  }
_lookupVersion($a_id)
lookup version
_lookupFileName($a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupFileName()

ilObjFile::_lookupFileName (   $a_id)

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

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

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

555  {
556  global $ilDB;
557 
558  $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,'integer');
559  $r = $ilDB->query($q);
560  $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
561 
562  return ilUtil::stripSlashes($row->file_name);
563  }
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupFileSize()

ilObjFile::_lookupFileSize (   $a_id)

Lookups the file size of the file in bytes.

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

References ilObjFileAccess\_lookupFileSize().

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

568  {
569  require_once("./Modules/File/classes/class.ilObjFileAccess.php");
570  return ilObjFileAccess::_lookupFileSize($a_id);
571  }
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes. ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupVersion()

ilObjFile::_lookupVersion (   $a_id)

lookup version

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

References ilObjFileAccess\_lookupVersion().

Referenced by _lookupAbsolutePath().

577  {
578  require_once("./Modules/File/classes/class.ilObjFileAccess.php");
579  return ilObjFileAccess::_lookupVersion($a_id);
580  }
_lookupVersion($a_id)
lookup version
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _saveUsage()

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

save usage

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

Referenced by ilPCFileList\saveFileUsage().

897  {
898  global $ilDB;
899 
900  $ilDB->manipulate("DELETE FROM file_usage WHERE usage_type = ".
901  $ilDB->quote((string) $a_type, "text").
902  " AND usage_id = ".$ilDB->quote((int) $a_id, "integer").
903  " AND usage_lang = ".$ilDB->quote($a_lang, "text").
904  " AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer").
905  " AND id = ".$ilDB->quote((int) $a_file_id, "integer"));
906 
907  $ilDB->manipulate("INSERT INTO file_usage (id, usage_type, usage_id, usage_hist_nr, usage_lang) VALUES".
908  " (".$ilDB->quote((int) $a_file_id, "integer").",".
909  $ilDB->quote((string) $a_type, "text").",".
910  $ilDB->quote((int) $a_id, "integer").",".
911  $ilDB->quote((int) $a_usage_hist_nr, "integer").",".
912  $ilDB->quote($a_usage_lang, "text").
913  ")");
914 
915  self::handleQuotaUpdate(new self($a_file_id, false));
916  }
+ Here is the caller graph for this function:

◆ _writeFileType()

ilObjFile::_writeFileType (   $a_id,
  $a_format 
)

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

References $res.

Referenced by doMDUpdateListener().

544  {
545  global $ilDB;
546 
547  $q = "UPDATE file_data SET ".
548  " file_type = ".$ilDB->quote($a_format ,'text').
549  " WHERE file_id = ".$ilDB->quote($a_id ,'integer');
550  $res = $ilDB->manipulate($q);
551 
552  }
+ Here is the caller graph for this function:

◆ addFileVersion()

ilObjFile::addFileVersion (   $a_upload_file,
  $a_filename 
)

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

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

251  {
252  $this->getUploadFile($a_upload_file, $a_filename, true);
253 
254  require_once("./Services/History/classes/class.ilHistory.php");
256  $this->getId(),
257  "new_version",
258  $a_filename.",".$this->getVersion()
259  );
260  $this->setFilename($a_filename);
261  $this->addNewsNotification("file_updated");
262 
263  // create preview
264  $this->createPreview($this->getVersion() > 1);
265  }
_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.
createPreview($force=false)
Creates a preview for the file object.
addNewsNotification($a_lang_var)
getUploadFile($a_upload_file, $a_filename, $a_prevent_preview=false)
+ Here is the call graph for this function:

◆ addNewsNotification()

ilObjFile::addNewsNotification (   $a_lang_var)

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

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

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

982  {
983  // BEGIN WebDAV Suppress news notification for hidden files
984  if ($this->isHidden()) {
985  return;
986  }
987  // END WebDAV Suppress news notification for hidden files
988 
989  global $ilUser;
990 
991  // Add Notification to news
992  include_once("./Services/News/classes/class.ilNewsItem.php");
993  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
994  $news_item = new ilNewsItem();
995  $news_item->setContext($this->getId(), $this->getType());
996  $news_item->setPriority(NEWS_NOTICE);
997  $news_item->setTitle($a_lang_var);
998  $news_item->setContentIsLangVar(true);
999  if ($this->getDescription() != "")
1000  {
1001  $news_item->setContent(
1002  "<p>".
1003  $this->getDescription()."</p>");
1004  }
1005  $news_item->setUserId($ilUser->getId());
1006  $news_item->setVisibility(NEWS_USERS);
1007  $news_item->create();
1008  }
const NEWS_USERS
const NEWS_NOTICE
isHidden()
Returns true, if this file should be hidden in the repository view.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

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

References getUsages().

795  {
796  global $ilDB;
797 
798  // check, if file is used somewhere
799  $usages = $this->getUsages();
800  if (count($usages) == 0)
801  {
802  return true;
803  }
804  return false;
805  }
getUsages()
get all usages of file object
+ Here is the call graph for this function:

◆ beforeMDUpdateListener()

ilObjFile::beforeMDUpdateListener (   $a_element)
protected

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

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

133  {
134  // Check file extension
135  // Removing the file extension is not allowed
136  include_once 'Services/MetaData/classes/class.ilMD.php';
137  $md = new ilMD($this->getId(),0, $this->getType());
138  if(!is_object($md_gen = $md->getGeneral()))
139  {
140  return false;
141  }
142  $title = $this->checkFileExtension($this->getFileName(), $md_gen->getTitle());
143  $md_gen->setTitle($title);
144  $md_gen->update();
145  return true;
146  }
checkFileExtension($new_filename, $new_title)
Check if the file extension does still exist after an update of the title.
+ Here is the call graph for this function:

◆ beforeUpdate()

ilObjFile::beforeUpdate ( )
protected

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

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

378  {
379  // no meta data handling for file list files
380  if ($this->getMode() != "filelist")
381  {
382  $this->updateMetaData();
383  }
384 
385  return true;
386  }
getMode()
mode is object or filelist
+ Here is the call graph for this function:

◆ 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 1069 of file class.ilObjFile.php.

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

Referenced by beforeMDUpdateListener(), and updateWithVersion().

1070  {
1071  include_once './Modules/File/classes/class.ilObjFileAccess.php';
1072  $fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
1073  $titleExtension = ilObjFileAccess::_getFileExtension($new_title);
1074  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
1075  {
1076  // remove old extension
1077  $pi = pathinfo($this->getFileName());
1078  $suffix = $pi["extension"];
1079  if ($suffix != "")
1080  {
1081  if (substr($new_title,
1082  strlen($new_title) - strlen($suffix) - 1)
1083  == ".".$suffix)
1084  {
1085  $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
1086  }
1087  }
1088  $new_title .= '.'.$fileExtension;
1089  }
1090  return $new_title;
1091  }
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
+ 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 279 of file class.ilObjFile.php.

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

Referenced by deleteVersions().

280  {
281  ilUtil::delDir($this->getDirectory());
282  $this->createDirectory();
283  }
getDirectory($a_version=0)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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 1234 of file class.ilObjFile.php.

1235  {
1236  // v2 - v1 because version should be descending
1237  return (int)$v2["version"] - (int)$v1["version"];
1238  }

◆ copy()

ilObjFile::copy (   $a_source,
  $a_destination 
)

copy file

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

References getDirectory().

Referenced by rollback().

272  {
273  return copy($a_source,$this->getDirectory()."/".$a_destination);
274  }
copy($a_source, $a_destination)
copy file
getDirectory($a_version=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDirectory()

ilObjFile::createDirectory ( )

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

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

Referenced by clearDataDirectory().

198  {
200  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getDirectory($a_version=0)
+ 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 1304 of file class.ilObjFile.php.

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

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

1305  {
1306  // only normal files are supported
1307  if ($this->getMode() != "object")
1308  return;
1309 
1310  require_once("./Services/Preview/classes/class.ilPreview.php");
1311  ilPreview::createPreview($this, $force);
1312  }
getMode()
mode is object or filelist
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createProperties()

ilObjFile::createProperties (   $a_upload = false,
  $a_prevent_meta_data_creation = 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 73 of file class.ilObjFile.php.

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

Referenced by doCreate().

74  {
75  global $ilDB,$tree;
76 
77  // Create file directory
78  $this->initFileStorage();
79  $this->file_storage->create();
80 
81  if($a_upload)
82  {
83  return true;
84  }
85 
86  // not upload mode
87  require_once("./Services/History/classes/class.ilHistory.php");
88  ilHistory::_createEntry($this->getId(), "create", $this->getFileName().",1");
89  $this->addNewsNotification("file_created");
90 
91 
92  require_once("./Services/News/classes/class.ilNewsItem.php");
93  $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
94  if ($default_visibility == "public")
95  {
96  ilBlockSetting::_write("news", "public_notifications",
97  1, 0, $this->getId());
98  }
99 
100  $q = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) "
101  ."VALUES (".$ilDB->quote($this->getId() ,'integer').","
102  .$ilDB->quote($this->getFileName() ,'text').","
103  .$ilDB->quote($this->getFileType() ,'text').","
104  .$ilDB->quote((int) $this->getFileSize() ,'integer').","
105  .$ilDB->quote(1 ,'integer').",".$ilDB->quote($this->getMode() ,'text').")";
106  $res = $ilDB->manipulate($q);
107 
108  // no meta data handling for file list files
109  if ($this->getMode() != "filelist" && !$a_prevent_meta_data_creation)
110  {
111  $this->createMetaData();
112  }
113  }
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
$_GET["client_id"]
getMode()
mode is object or filelist
_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.
addNewsNotification($a_lang_var)
initFileStorage()
init file storage object
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
+ 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 1317 of file class.ilObjFile.php.

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

Referenced by doDelete().

1318  {
1319  // only normal files are supported
1320  if ($this->getMode() != "object")
1321  return;
1322 
1323  require_once("./Services/Preview/classes/class.ilPreview.php");
1324  ilPreview::deletePreview($this->getId());
1325  }
getMode()
mode is object or filelist
static deletePreview($a_obj_id)
Deletes the preview for the object with the specified id.
+ 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 290 of file class.ilObjFile.php.

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

291  {
292  global $ilDB;
293 
294  require_once("./Services/History/classes/class.ilHistory.php");
295 
296  if ($a_hist_entry_ids == null || count($a_hist_entry_ids) < 1)
297  {
298  $ilDB->manipulate("UPDATE file_data SET version = 1 WHERE file_id = ".$ilDB->quote($this->getId() ,'integer'));
299  $this->setVersion(0);
300  $this->clearDataDirectory();
301 
303 
304  self::handleQuotaUpdate($this);
305  }
306  else
307  {
308  $actualVersionDeleted = false;
309 
310  // get all versions
311  $versions = $this->getVersions();
312 
313  // delete each version
314  foreach ($a_hist_entry_ids as $hist_id)
315  {
316  $entry = null;
317 
318  // get version
319  foreach ($versions as $index => $version)
320  {
321  if ($version["hist_entry_id"] == $hist_id)
322  {
323  // remove each history entry
325 
326  // delete directory
327  $version_dir = $this->getDirectory($version["version"]);
328  ilUtil::delDir($version_dir);
329 
330  // is actual version?
331  if ($version["version"] == $this->getVersion())
332  $actualVersionDeleted = true;
333 
334  // remove from array
335  unset($versions[$index]);
336  break;
337  }
338  }
339  }
340 
341  // update actual version if it was deleted before
342  if ($actualVersionDeleted)
343  {
344  // get newest version (already sorted by getVersions)
345  $version = reset($versions);
346  $this->updateWithVersion($version);
347  }
348  else
349  {
350  // updateWithVersion() will trigger quota, too
351  self::handleQuotaUpdate($this);
352  }
353  }
354  }
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
clearDataDirectory()
clear data directory
setVersion($a_version)
getDirectory($a_version=0)
_removeEntriesForObject($a_obj_id)
remove all history entries for an object
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getVersions($version_ids=null)
Gets the file versions for this object.
updateWithVersion($version)
Updates the file object with the specified file version.
+ Here is the call graph for this function:

◆ determineFileSize()

ilObjFile::determineFileSize (   $a_hist_entry_id = null)

Determine File Size.

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

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

Referenced by updateWithVersion().

586  {
587  if (is_null($a_hist_entry_id))
588  {
589  $file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
590  }
591  else
592  {
593  require_once("./Services/History/classes/class.ilHistory.php");
594  $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
595 
596  if ($entry === false)
597  {
598  return false;
599  }
600 
601  $data = $this->parseInfoParams($entry);
602  $file = $this->getDirectory($data["version"])."/".$data["filename"];
603  }
604  if (is_file($file))
605  {
606  $this->setFileSize(filesize($file));
607  }
608  }
print $file
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
getDirectory($a_version=0)
setFileSize($a_size)
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ 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.

public

Parameters
objectclone
inttarget id
intcopy id

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

References $query, $res, ilHistory\_copyEntriesForObject(), ilObject2\cloneMetaData(), ilPreview\copyPreviews(), getDirectory(), ilObject2\getId(), and ilUtil\rCopy().

760  {
761  global $ilDB;
762 
763  $a_new_obj->createDirectory();
764  $this->cloneMetaData($a_new_obj);
765 
766  // Copy all file versions
767  ilUtil::rCopy($this->getDirectory(),$a_new_obj->getDirectory());
768 
769  // object created now copy other settings
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').",".
772  $ilDB->quote($this->getFileName() ,'text').",".
773  $ilDB->quote($this->getFileType() ,'text').",".
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').")";
778  $res = $ilDB->manipulate($query);
779 
780  // copy all previews
781  require_once("./Services/Preview/classes/class.ilPreview.php");
782  ilPreview::copyPreviews($this->getId(), $a_new_obj->getId());
783 
784  // copy history entries
785  require_once("./Services/History/classes/class.ilHistory.php");
786  ilHistory::_copyEntriesForObject($this->getId(),$a_new_obj->getId());
787 
788  // add news notification
789  $a_new_obj->addNewsNotification("file_created");
790 
791  return $a_new_obj;
792  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getDirectory($a_version=0)
_copyEntriesForObject($a_src_id, $a_dst_id)
copy all history entries for an object
static copyPreviews($a_src_id, $a_dest_id)
Copies the preview images from one preview to a new preview object.
cloneMetaData($target_obj)
+ Here is the call graph for this function:

◆ doCreate()

ilObjFile::doCreate (   $a_upload = false,
  $a_prevent_meta_data_creation = false 
)
protected

create object

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

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

References createProperties().

59  {
60  //BEGIN WebDAV Move Property creation into a method of its own.
61  $this->createProperties($a_upload);
62  //END WebDAV Move Property creation into a method of its own.
63  }
createProperties($a_upload=false, $a_prevent_meta_data_creation=false)
The basic properties of a file object are stored in table object_data.
+ Here is the call graph for this function:

◆ doCreateMetaData()

ilObjFile::doCreateMetaData ( )
protected

create file object meta data

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

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

120  {
121  // add technical section with file size and format
122  $md_obj =& new ilMD($this->getId(),0,$this->getType());
123  $technical = $md_obj->addTechnical();
124  $technical->setSize($this->getFileSize());
125  $technical->save();
126  $format = $technical->addFormat();
127  $format->setFormat($this->getFileType());
128  $format->save();
129  $technical->update();
130  }
+ Here is the call graph for this function:

◆ doDelete()

ilObjFile::doDelete ( )
protected

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

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

808  {
809  global $ilDB;
810 
811  // delete file data entry
812  $q = "DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
813  $this->ilias->db->query($q);
814 
815  // delete history entries
816  require_once("./Services/History/classes/class.ilHistory.php");
818 
819  // delete entire directory and its content
820  if (@is_dir($this->getDirectory()))
821  {
822  ilUtil::delDir($this->getDirectory());
823  }
824 
825  // delete meta data
826  if ($this->getMode() != "filelist")
827  {
828  $this->deleteMetaData();
829  }
830 
831  self::handleQuotaUpdate($this);
832 
833  // delete preview
834  $this->deletePreview();
835  }
getMode()
mode is object or filelist
getDirectory($a_version=0)
deletePreview()
Deletes the preview of the file object.
redirection script todo: (a better solution should control the processing via a xml file) ...
_removeEntriesForObject($a_obj_id)
remove all history entries for an object
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ doMDUpdateListener()

ilObjFile::doMDUpdateListener (   $a_element)
protected

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

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

149  {
150  // handling for technical section
151  include_once 'Services/MetaData/classes/class.ilMD.php';
152 //echo "-".$a_element."-";
153  switch($a_element)
154  {
155  case 'Technical':
156 
157  // Update Format (size is not stored in db)
158  $md = new ilMD($this->getId(),0, $this->getType());
159  if(!is_object($md_technical = $md->getTechnical()))
160  {
161  return false;
162  }
163 
164  foreach($md_technical->getFormatIds() as $id)
165  {
166  $md_format = $md_technical->getFormat($id);
167  ilObjFile::_writeFileType($this->getId(),$md_format->getFormat());
168  $this->setFileType($md_format->getFormat());
169  break;
170  }
171 
172  break;
173  }
174  return true;
175  }
setFileType($a_type)
_writeFileType($a_id, $a_format)
+ Here is the call graph for this function:

◆ doRead()

ilObjFile::doRead ( )
protected

read file properties

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

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

360  {
361  global $ilDB;
362 
363  $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
364  $r = $this->ilias->db->query($q);
365  $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
366 
367  $this->setFileName($row->file_name);
368  $this->setFileType($row->file_type);
369  $this->setFileSize($row->file_size);
370  $this->setVersion($row->version);
371  $this->setMode($row->f_mode);
372  $this->setRating($row->rating);
373 
374  $this->initFileStorage();
375  }
setFileType($a_type)
setFileName($a_name)
set filename
setMode($a_mode)
mode is object or filelist
setVersion($a_version)
setFileSize($a_size)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
redirection script todo: (a better solution should control the processing via a xml file) ...
initFileStorage()
init file storage object
setRating($a_value)
$r
+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

update file

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

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

392  {
393  global $ilDB, $ilLog;
394 
395  //$ilLog->write(__METHOD__.' File type: '.$this->getFileType());
396 
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);
405 
406  self::handleQuotaUpdate($this);
407 
408  return true;
409  }
getMode()
mode is object or filelist
+ Here is the call graph for this function:

◆ doUpdateMetaData()

ilObjFile::doUpdateMetaData ( )
protected

update meta data

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

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

415  {
416  // add technical section with file size and format
417  $md_obj =& new ilMD($this->getId(),0,$this->getType());
418  if(!is_object($technical = $md_obj->getTechnical()))
419  {
420  $technical = $md_obj->addTechnical();
421  $technical->save();
422  }
423  $technical->setSize($this->getFileSize());
424 
425  $format_ids = $technical->getFormatIds();
426  if (count($format_ids) > 0)
427  {
428  $format = $technical->getFormat($format_ids[0]);
429  $format->setFormat($this->getFileType());
430  $format->update();
431  }
432  else
433  {
434  $format = $technical->addFormat();
435  $format->setFormat($this->getFileType());
436  $format->save();
437  }
438  $technical->update();
439  }
+ 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 844 of file class.ilObjFile.php.

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

845  {
846  $subdir = "il_".IL_INST_ID."_file_".$this->getId();
847  ilUtil::makeDir($a_target_dir."/objects/".$subdir);
848 
849  $filedir = $this->getDirectory($this->getVersion());
850 
851  if (@!is_dir($filedir))
852  {
853  $filedir = $this->getDirectory();
854  }
855 
856  ilUtil::rCopy($filedir, $a_target_dir."/objects/".$subdir);
857  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getDirectory($a_version=0)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:

◆ getDirectory()

ilObjFile::getDirectory (   $a_version = 0)

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

References initFileStorage().

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

179  {
180  $version_subdir = "";
181 
182  if ($a_version)
183  {
184  // BEGIN WebDAV Avoid double slash before version subdirectory
185  $version_subdir = sprintf("%03d", $a_version);
186  // END WebDAV Avoid double slash before version subdirectory
187  }
188 
189  if(!is_object($this->file_storage))
190  {
191  $this->initFileStorage();
192  }
193 
194  return $this->file_storage->getAbsolutePath().'/'.$version_subdir;
195  }
initFileStorage()
init file storage object
+ 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.

public

Returns
integer the disk usage in bytes

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

References ilObjFileAccess\_lookupDiskUsage().

Referenced by handleQuotaUpdate().

483  {
484  require_once("./Modules/File/classes/class.ilObjFileAccess.php");
485  return ilObjFileAccess::_lookupDiskUsage($this->id);
486  }
_lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the file object with the specified object id...
+ 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 490 of file class.ilObjFile.php.

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

491  {
492  if (is_null($a_hist_entry_id))
493  {
494  $file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
495  }
496  else
497  {
498  require_once("./Services/History/classes/class.ilHistory.php");
499  $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
500 
501  if ($entry === false)
502  {
503  return false;
504  }
505 
506  $data = $this->parseInfoParams($entry);
507  $file = $this->getDirectory($data["version"])."/".$data["filename"];
508  }
509  return $file;
510  }
print $file
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
getDirectory($a_version=0)
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ 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 669 of file class.ilObjFile.php.

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

669  {
670  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
672  }
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
+ Here is the call graph for this function:

◆ getFileName()

ilObjFile::getFileName ( )

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

References $filename.

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

450  {
451  return $this->filename;
452  }
+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

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

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

473  {
474  return $this->filesize;
475  }
+ Here is the caller graph for this function:

◆ getFileType()

ilObjFile::getFileType ( )

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

References $filetype.

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

463  {
464  return $this->filetype;
465  }
+ Here is the caller graph for this function:

◆ getMode()

ilObjFile::getMode ( )

mode is object or filelist

Returns
string mode

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

References $mode.

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

539  {
540  return $this->mode;
541  }
+ 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 1134 of file class.ilObjFile.php.

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

Referenced by rollback().

1135  {
1136  include_once("./Services/History/classes/class.ilHistory.php");
1137  $version = ilHistory::_getEntryByHistoryID($version_id);
1138  if ($version === false)
1139  return false;
1140 
1141  // ilHistory returns different keys in _getEntryByHistoryID and _getEntriesForObject
1142  // so this makes it the same
1143  $version["hist_entry_id"] = $version["id"];
1144  $version["user_id"] = $version["usr_id"];
1145  $version["date"] = $version["hdate"];
1146  unset($version["id"], $version["usr_id"], $version["hdate"]);
1147 
1148  // parse params
1149  $params = $this->parseInfoParams($version);
1150  return array_merge($version, $params);
1151  }
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
+ 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 
)

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

References $file, createPreview(), getDirectory(), getVersion(), handleQuotaUpdate(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), and setVersion().

Referenced by addFileVersion(), and replaceFile().

208  {
209  $this->setVersion($this->getVersion() + 1);
210 
211  if (@!is_dir($this->getDirectory($this->getVersion())))
212  {
214  }
215 
216  $file = $this->getDirectory($this->getVersion())."/".$a_filename;
217  //move_uploaded_file($a_upload_file, $file);
218  ilUtil::moveUploadedFile($a_upload_file, $a_filename, $file, $this->raise_upload_error);
219 
220  $this->handleQuotaUpdate($this);
221 
222  // create preview?
223  if (!$a_prevent_preview)
224  {
225  $this->createPreview(false);
226  }
227  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
print $file
setVersion($a_version)
getDirectory($a_version=0)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
createPreview($force=false)
Creates a preview for the file object.
static handleQuotaUpdate(ilObjFile $a_file)
+ 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 921 of file class.ilObjFile.php.

References $ret, and ilObject2\getId().

Referenced by beforeDelete(), and handleQuotaUpdate().

922  {
923  global $ilDB;
924 
925  // get usages in learning modules
926  $q = "SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->getId(), "integer");
927  $us_set = $ilDB->query($q);
928  $ret = array();
929  while($us_rec = $ilDB->fetchAssoc($us_set))
930  {
931  $ret[] = array("type" => $us_rec["usage_type"],
932  "id" => $us_rec["usage_id"],
933  "lang" => $us_rec["usage_lang"],
934  "hist_nr" => $us_rec["usage_hist_nr"]);
935  }
936 
937  return $ret;
938  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVersion()

ilObjFile::getVersion ( )

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

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

519  {
520  return $this->version;
521  }
+ 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 1099 of file class.ilObjFile.php.

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

Referenced by deleteVersions().

1100  {
1101  include_once("./Services/History/classes/class.ilHistory.php");
1102  $versions = ilHistory::_getEntriesForObject($this->getId(), $this->getType());
1103 
1104  if ($version_ids != null && count($version_ids) > 0)
1105  {
1106  foreach ($versions as $index => $version)
1107  {
1108  if (!in_array($version["hist_entry_id"], $version_ids, true))
1109  {
1110  unset($versions[$index]);
1111  }
1112  }
1113  }
1114 
1115  // add custom entries
1116  foreach ($versions as $index => $version)
1117  {
1118  $params = $this->parseInfoParams($version);
1119  $versions[$index] = array_merge($version, $params);
1120  }
1121 
1122  // sort by version number (hist_entry_id will do for that)
1123  usort($versions, array($this, "compareVersions"));
1124 
1125  return $versions;
1126  }
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
_getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXMLZip()

ilObjFile::getXMLZip ( )

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

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

970  {
971  global $ilias;
972 
973  $zip = PATH_TO_ZIP;
974 
975  exec($zip.' '.ilUtil::escapeShellArg($this->getDirectory().'/'.$this->getFileName())." ".
976  ilUtil::escapeShellArg($this->getDirectory().'/'.'1.zip'));
977 
978  return $this->getDirectory().'/1.zip';
979  }
getDirectory($a_version=0)
static escapeShellArg($a_arg)
+ 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 697 of file class.ilObjFile.php.

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

Referenced by sendFile(), and updateWithVersion().

697  {
698 
699  $path = pathinfo($a_file);
700  if ($path["extension"] != "")
701  {
702  $filename = $path["basename"];
703  }
704  else
705  {
706  $filename = "dummy.".$this->getFileExtension();
707  }
708  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
709  $mime = ilMimeTypeUtil::getMimeType($a_file, $filename, $this->getFileType());
710  return $mime;
711 
712 /*
713  $fileType = $this->getFileType();
714  if (strlen($fileType) == 0) {
715  $fileType = 'application/octet-stream';
716  }
717 
718  // Firefox browser assigns 'application/x-pdf' to PDF files, but
719  // it can only handle them if the have the mime-type 'application/pdf'.
720  if ($fileType == 'application/x-pdf')
721  {
722  $fileType = 'application/pdf';
723  }
724 
725  if ($fileType == 'application/octet-stream')
726  {
727  $fileExtension = $this->getFileExtension();
728  $mimeArray = array(
729  'mpeg' => 'video/mpeg',
730  'mp3' => 'audio/mpeg',
731  'pdf' => 'application/pdf',
732  'gif' => 'image/gif',
733  'jpg' => 'image/jpg',
734  'png' => 'image/png',
735  'htm' => 'text/html',
736  'html' => 'text/html',
737  'wma' => 'video/x-ms-wma',
738  'wmv' => 'video/x-ms-wmv',
739  'swf' => 'application/x-shockwave-flash',
740  );
741  if (array_key_exists($fileExtension, $mimeArray))
742  {
743  $fileType = $mimeArray[$fileExtension];
744  }
745  }
746  return $fileType;
747 */
748  }
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
$path
Definition: index.php:22
+ 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 1274 of file class.ilObjFile.php.

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

Referenced by getUploadFile().

1275  {
1276  include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
1277  $mob = new ilObjMediaObject();
1278 
1279  // file itself could be workspace item
1280  $parent_obj_ids = array($a_file->getId());
1281 
1282  foreach($a_file->getUsages() as $item)
1283  {
1284  $parent_obj_id = $mob->getParentObjectIdForUsage($item);
1285  if($parent_obj_id &&
1286  !in_array($parent_obj_id, $parent_obj_ids))
1287  {
1288  $parent_obj_ids[]= $parent_obj_id;
1289  }
1290  }
1291 
1292  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1294  $a_file->getId(),
1295  $a_file->getDiskUsage(),
1296  $parent_obj_ids);
1297  }
Class ilObjMediaObject.
getUsages()
get all usages of file object
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasRating()

ilObjFile::hasRating ( )

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

References $rating.

Referenced by doUpdate().

1333  {
1334  return $this->rating;
1335  }
+ Here is the caller graph for this function:

◆ initFileStorage()

ilObjFile::initFileStorage ( )

init file storage object

public

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

References ilObject2\getId().

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

1017  {
1018  $this->file_storage = new ilFSStorageFile($this->getId());
1019  return true;
1020  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initType()

ilObjFile::initType ( )

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

49  {
50  $this->type = "file";
51  }

◆ isHidden()

ilObjFile::isHidden ( )

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

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

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

Referenced by addNewsNotification().

685  {
686  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
687  return ilObjFileAccess::_isFileHidden($this->getTitle());
688  }
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
+ 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 678 of file class.ilObjFile.php.

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

Referenced by sendFile().

678  {
679  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
680  return ilObjFileAccess::_isFileInline($this->getTitle());
681  }
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
+ Here is the call graph for this function:
+ Here is the caller 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 1246 of file class.ilObjFile.php.

References $data, and $result.

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

1247  {
1248  $data = preg_split("/(.*),(.*)/", $entry["info_params"], 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
1249 
1250  // bugfix: first created file had no version number
1251  // this is a workaround for all files created before the bug was fixed
1252  if (empty($data[1]))
1253  $data[1] = "1";
1254 
1255  $result = array("filename" => $data[0], "version" => $data[1], "rollback_version" => "", "rollback_user_id" => "");
1256 
1257  // if rollback, the version contains the rollback version as well
1258  if ($entry["action"] == "rollback")
1259  {
1260  $tokens = explode("|", $result["version"]);
1261  if (count($tokens) > 1)
1262  {
1263  $result["version"] = $tokens[0];
1264  $result["rollback_version"] = $tokens[1];
1265 
1266  if (count($tokens) > 2)
1267  $result["rollback_user_id"] = $tokens[2];
1268  }
1269  }
1270 
1271  return $result;
1272  }
$result
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the caller graph for this function:

◆ raiseUploadError()

ilObjFile::raiseUploadError (   $a_raise = true)

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

203  {
204  $this->raise_upload_error = $a_raise;
205  }

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)

replace file with new file

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

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

233  {
234  $this->getUploadFile($a_upload_file, $a_filename, true);
235 
236  require_once("./Services/History/classes/class.ilHistory.php");
238  $this->getId(),
239  "replace",
240  $a_filename.",".$this->getVersion()
241  );
242  $this->setFilename($a_filename);
243  $this->addNewsNotification("file_updated");
244 
245  // create preview
246  $this->createPreview(true);
247  }
_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.
createPreview($force=false)
Creates a preview for the file object.
addNewsNotification($a_lang_var)
getUploadFile($a_upload_file, $a_filename, $a_prevent_preview=false)
+ 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 1159 of file class.ilObjFile.php.

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

1160  {
1161  global $ilDB, $ilUser;
1162 
1163  $source = $this->getSpecificVersion($version_id);
1164  if ($source === false)
1165  {
1166  $this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
1167  }
1168 
1169  // get the new version number
1170  $new_version_nr = $this->getVersion() + 1;
1171 
1172  // copy file
1173  $source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
1174  $dest_dir = $this->getDirectory($new_version_nr);
1175  if (@!is_dir($dest_dir))
1176  ilUtil::makeDir($dest_dir);
1177 
1178  copy($source_path, $dest_dir . "/" . $source["filename"]);
1179 
1180  // create new history entry based on the old one
1181  include_once("./Services/History/classes/class.ilHistory.php");
1183  $this->getId(),
1184  "rollback",
1185  $source["filename"] . "," . $new_version_nr . "|" . $source["version"] . "|" . $ilUser->getId());
1186 
1187  // get id of newest entry
1188  $new_version = $this->getSpecificVersion($ilDB->getLastInsertId());
1189 
1190  // change user back to the original uploader
1191  ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
1192 
1193  // update this file with the new version
1194  $this->updateWithVersion($new_version);
1195 
1196  $this->addNewsNotification("file_updated");
1197 
1198  return $new_version;
1199  }
static _changeUserId($a_hist_entry_id, $new_user_id)
Changes the user id of the specified history entry.
copy($a_source, $a_destination)
copy file
getDirectory($a_version=0)
_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.
getSpecificVersion($version_id)
Gets a specific file version.
addNewsNotification($a_lang_var)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilUser
Definition: imgupload.php:15
updateWithVersion($version)
Updates the file object with the specified file version.
+ Here is the call graph for this function:

◆ sendFile()

ilObjFile::sendFile (   $a_hist_entry_id = null)

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

References $data, $file, ilHistory\_getEntryByHistoryID(), ilUtil\deliverFile(), getDirectory(), getFileName(), ilObject2\getTitle(), getVersion(), guessFileType(), isInline(), and parseInfoParams().

611  {
612  if (is_null($a_hist_entry_id))
613  {
614  $file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
615 
616  // if not found lookup for file in file object's main directory for downward c ompability
617  if (@!is_file($file))
618  {
619  $file = $this->getDirectory()."/".$this->getFileName();
620  }
621  }
622  else
623  {
624  require_once("./Services/History/classes/class.ilHistory.php");
625  $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
626 
627  if ($entry === false)
628  {
629  echo "3";return false;
630  }
631 
632  $data = $this->parseInfoParams($entry);
633  $file = $this->getDirectory($data["version"])."/".$data["filename"];
634 
635  // if not found lookup for file in file object's main directory for downward compability
636  if (@!is_file($file))
637  {
638  $file = $this->getDirectory()."/".$data[0];
639  }
640 
641  // BEGIN WebDAV removed duplicated code
642  // END WebDAV removed duplicated code
643  }
644 
645  if (@is_file($file))
646  {
647  global $ilClientIniFile;
648 
649  // also returning the 'real' filename if a history file is delivered
650  if ($ilClientIniFile->readVariable('file_access','download_with_uploaded_filename') != '1' && is_null($a_hist_entry_id))
651  {
652  ilUtil::deliverFile($file, $this->getTitle(), $this->guessFileType($file), $this->isInline());
653  }
654  else
655  {
656  ilUtil::deliverFile($file, basename($file), $this->guessFileType($file), $this->isInline());
657  }
658  return true;
659  }
660 
661  return false;
662  }
print $file
parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
getDirectory($a_version=0)
isInline()
Returns true, if this file should be displayed inline in a browser window.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
_getEntryByHistoryID($a_hist_entry_id)
returns a single history entry
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
guessFileType($a_file="")
Guesses the file type based on the current values returned by getFileType() and getFileExtension().
+ Here is the call graph for this function:

◆ setFileName()

ilObjFile::setFileName (   $a_name)

set filename

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

Referenced by doRead(), and updateWithVersion().

445  {
446  $this->filename = $a_name;
447  }
+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize (   $a_size)

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

Referenced by determineFileSize(), and doRead().

468  {
469  $this->filesize = $a_size;
470  }
+ Here is the caller graph for this function:

◆ setFileType()

ilObjFile::setFileType (   $a_type)

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

References $ilLog.

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

455  {
456  global $ilLog;
457 
458 
459  $this->filetype = $a_type;
460  }
+ 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 528 of file class.ilObjFile.php.

Referenced by doRead().

529  {
530  $this->mode = $a_mode;
531  }
+ Here is the caller graph for this function:

◆ setRating()

ilObjFile::setRating (   $a_value)

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

Referenced by doRead().

1328  {
1329  $this->rating = (bool)$a_value;
1330  }
+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion (   $a_version)

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

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

514  {
515  $this->version = $a_version;
516  }
+ 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 1030 of file class.ilObjFile.php.

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

1031  {
1032  $this->setVersion($this->getVersion() + 1);
1033 
1034  if (@!is_dir($this->getDirectory($this->getVersion())))
1035  {
1036  ilUtil::makeDir($this->getDirectory($this->getVersion()));
1037  }
1038 
1039  $file = $this->getDirectory($this->getVersion())."/".$a_filename;
1040  //move_uploaded_file($a_upload_file, $file);
1041  rename($a_upload_file, $file);
1042 
1043  // create preview
1044  $this->createPreview();
1045  }
print $file
setVersion($a_version)
getDirectory($a_version=0)
createPreview($force=false)
Creates a preview for the file object.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ 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 1206 of file class.ilObjFile.php.

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

Referenced by deleteVersions(), and rollback().

1207  {
1208  // update title (checkFileExtension must be called before setFileName!)
1209  $this->setTitle($this->checkFileExtension($version["filename"], $this->getTitle()));
1210 
1211  $this->setVersion($version["version"]);
1212  $this->setFileName($version["filename"]);
1213 
1214  // evaluate mime type (reset file type before)
1215  $this->setFileType("");
1216  $this->setFileType($this->guessFileType($version["filename"]));
1217 
1218  // set filesize
1219  $this->determineFileSize();
1220 
1221  $this->update();
1222 
1223  // refresh preview
1224  $this->createPreview(true);
1225  }
setFileType($a_type)
setFileName($a_name)
set filename
setVersion($a_version)
checkFileExtension($new_filename, $new_title)
Check if the file extension does still exist after an update of the title.
setTitle($a_title)
createPreview($force=false)
Creates a preview for the file object.
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().
+ 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 27 of file class.ilObjFile.php.

Referenced by _lookupAbsolutePath().

◆ $filemaxsize

ilObjFile::$filemaxsize = "20000000"

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

◆ $filename

ilObjFile::$filename

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

Referenced by getFileName().

◆ $filetype

ilObjFile::$filetype

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

Referenced by getFileType().

◆ $mode

ilObjFile::$mode = "object"

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

Referenced by getMode().

◆ $raise_upload_error

ilObjFile::$raise_upload_error

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

◆ $rating

ilObjFile::$rating
protected

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

Referenced by hasRating().


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