ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 
 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)
 
 replaceFile ($a_upload_file, $a_filename)
 
 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)
 
 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 ()
 
 getPageCount ()
 
 setPageCount ($page_count)
 
- 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 ()
 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 ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public 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...
 
 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 ()
 
 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...
 
 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)
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
- Public Member Functions inherited from ilObject
 __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 ()
 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 ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. 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...
 
 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...
 
 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...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 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...
 
 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)
 
- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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, $a_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 Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

const MODE_FILELIST = "filelist"
 
const MODE_OBJECT = "object"
 
 $raise_upload_error
 
 $mode = self::MODE_OBJECT
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $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
 

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 ()
 
 beforeUpdate ()
 
 doUpdate ()
 
 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

 $no_meta_data_creation
 
 $filename = ''
 
 $filetype = ''
 
 $filemaxsize = "20000000"
 
 $filesize
 
 $page_count = 0
 
 $rating = false
 
 $log = null
 
 $version = 1
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Private Member Functions

 getArrayForDatabase ()
 

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

81 {
82 $this->version = 0;
83 $this->raise_upload_error = true;
84
85 $this->log = ilLoggerFactory::getLogger('file');
86
87 parent::__construct($a_id, $a_call_by_reference);
88
89 if ($this->getId()) {
90 $this->initFileStorage();
91 }
92 }
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 970 of file class.ilObjFile.php.

971 {
972 global $DIC;
973 $ilDB = $DIC['ilDB'];
974
975 $and_hist = ($a_usage_hist_nr !== false) ? " AND usage_hist_nr = "
976 . $ilDB->quote($a_usage_hist_nr, "integer") : "";
977
978 $file_ids = array();
979 $set = $ilDB->query("SELECT id FROM file_usage" . " WHERE usage_type = "
980 . $ilDB->quote($a_type, "text") . " AND usage_id= "
981 . $ilDB->quote($a_id, "integer") . " AND usage_lang= "
982 . $ilDB->quote($a_usage_lang, "text") . $and_hist);
983 while ($row = $ilDB->fetchAssoc($set)) {
984 $file_ids[] = $row["id"];
985 }
986
987 $ilDB->manipulate("DELETE FROM file_usage WHERE usage_type = "
988 . $ilDB->quote($a_type, "text") . " AND usage_id = "
989 . $ilDB->quote((int) $a_id, "integer") . " AND usage_lang= "
990 . $ilDB->quote($a_usage_lang, "text") . " AND usage_hist_nr = "
991 . $ilDB->quote((int) $a_usage_hist_nr, "integer"));
992
993 foreach ($file_ids as $file_id) {
994 self::handleQuotaUpdate(new self($file_id, false));
995 }
996 }
static handleQuotaUpdate(ilObjFile $a_file)
global $DIC
Definition: saml.php:7
global $ilDB
$a_type
Definition: workflow.php:92

References $a_type, $DIC, $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 1057 of file class.ilObjFile.php.

1058 {
1059 global $DIC;
1060 $ilDB = $DIC['ilDB'];
1061
1062 $lstr = "";
1063 if ($a_usage_lang != "") {
1064 $lstr = "usage_lang = " . $ilDB->quote((string) $a_usage_lang, "text") . " AND ";
1065 }
1066
1067 // get usages in learning modules
1068 $q = "SELECT * FROM file_usage WHERE " . "usage_id = " . $ilDB->quote((int) $a_id, "integer")
1069 . " AND " . "usage_type = " . $ilDB->quote((string) $a_type, "text") . " AND " . $lstr
1070 . "usage_hist_nr = " . $ilDB->quote((int) $a_usage_hist_nr, "integer");
1071 $file_set = $ilDB->query($q);
1072 $ret = array();
1073 while ($file_rec = $ilDB->fetchAssoc($file_set)) {
1074 $ret[$file_rec["id"]] = $file_rec["id"];
1075 }
1076
1077 return $ret;
1078 }
$ret
Definition: parser.php:6

References $a_type, $DIC, $ilDB, and $ret.

Referenced by ilPCFileList\afterPageUpdate(), ilCOPageHTMLExport\collectPageElements(), ilPageObjectGUI\downloadFile(), 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
Parameters
int$obj_id
int$a_version
Returns
string
Exceptions

ILIAS\Filesystem\Exception\DirectoryNotFoundException

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

1172 {
1173 $file_object = new self($obj_id, false);
1174 $s = new FilePathSanitizer($file_object);
1175 $s->sanitizeIfNeeded();
1176
1177 return $file_object->getFile($a_version);
1178 }
$s
Definition: pwgen.php:45

References $s.

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

+ Here is the caller graph for this function:

◆ _lookupFileName()

static ilObjFile::_lookupFileName (   $a_id)
static
Parameters
$a_id
Returns
string
Deprecated:
Static methods will be removed in a future version of ILIAS

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

673 {
674 global $DIC;
675 $ilDB = $DIC['ilDB'];
676
677 $q = "SELECT * FROM file_data WHERE file_id = " . $ilDB->quote($a_id, 'integer');
678 $r = $ilDB->query($q);
680
681 $strip_slashes = ilUtil::stripSlashes($row->file_name);
682
683 return $strip_slashes;
684 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$r
Definition: example_031.php:79

References $DIC, $ilDB, $r, $row, ilDBConstants\FETCHMODE_OBJECT, and ilUtil\stripSlashes().

Referenced by 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 688 of file class.ilObjFile.php.

689 {
690 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
691
693 }
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 699 of file class.ilObjFile.php.

700 {
701 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
702
704 }
static _lookupVersion($a_id)
lookup version

References ilObjFileAccess\_lookupVersion().

+ Here is the call 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 1002 of file class.ilObjFile.php.

1003 {
1004 global $DIC;
1005 $ilDB = $DIC['ilDB'];
1006
1007 // check if file really exists
1008 if (ilObject::_lookupType($a_file_id) != "file") {
1009 return;
1010 }
1011 // #15143
1012 $ilDB->replace("file_usage", array(
1013 "id" => array("integer", (int) $a_file_id),
1014 "usage_type" => array("text", (string) $a_type),
1015 "usage_id" => array("integer", (int) $a_id),
1016 "usage_hist_nr" => array("integer", (int) $a_usage_hist_nr),
1017 "usage_lang" => array("text", $a_usage_lang),
1018 ), array());
1019
1020 self::handleQuotaUpdate(new self($a_file_id, false));
1021 }
static _lookupType($a_id, $a_reference=false)
lookup object type

References $a_type, $DIC, $ilDB, ilObject\_lookupType(), 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 655 of file class.ilObjFile.php.

656 {
657 global $DIC;
658 $ilDB = $DIC['ilDB'];
659
660 $q = "UPDATE file_data SET " . " file_type = " . $ilDB->quote($a_format, 'text')
661 . " WHERE file_id = " . $ilDB->quote($a_id, 'integer');
662 $res = $ilDB->manipulate($q);
663 }
foreach($_POST as $key=> $value) $res

References $DIC, $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 360 of file class.ilObjFile.php.

361 {
362 if ($result = $this->getUploadFile($a_upload_file, $a_filename, true)) {
363 ilHistory::_createEntry($this->getId(), "new_version", $result->getName() . "," . $this->getVersion());
364 $this->addNewsNotification("file_updated");
365
366 // create preview
367 $this->createPreview($this->getVersion() > 1);
368 }
369
370 return $result;
371 }
$result
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
createPreview($force=false)
Creates a preview for the file object.
addNewsNotification($a_lang_var)

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

+ Here is the call graph for this function:

◆ addNewsNotification()

ilObjFile::addNewsNotification (   $a_lang_var)

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

1097 {
1098 // BEGIN WebDAV Suppress news notification for hidden files
1099 if ($this->isHidden()) {
1100 return;
1101 }
1102 // END WebDAV Suppress news notification for hidden files
1103
1104 global $DIC;
1105 $ilUser = $DIC['ilUser'];
1106
1107 // Add Notification to news
1108 include_once("./Services/News/classes/class.ilNewsItem.php");
1109 include_once("./Modules/File/classes/class.ilObjFileAccess.php");
1110 $news_item = new ilNewsItem();
1111 $news_item->setContext($this->getId(), $this->getType());
1112 $news_item->setPriority(NEWS_NOTICE);
1113 $news_item->setTitle($a_lang_var);
1114 $news_item->setContentIsLangVar(true);
1115 if ($this->getDescription() != "") {
1116 $news_item->setContent("<p>" . $this->getDescription() . "</p>");
1117 }
1118 $news_item->setUserId($ilUser->getId());
1119 $news_item->setVisibility(NEWS_USERS);
1120 $news_item->create();
1121 }
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
$ilUser
Definition: imgupload.php:18

References $DIC, $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 166 of file class.ilObjFile.php.

167 {
168 return !(bool) $this->no_meta_data_creation;
169 }

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

Reimplemented from ilObject2.

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

901 {
902 global $DIC;
903 $ilDB = $DIC['ilDB'];
904
905 // check, if file is used somewhere
906 $usages = $this->getUsages();
907 if (count($usages) == 0) {
908 return true;
909 }
910
911 return false;
912 }
getUsages()
get all usages of file object

References $DIC, $ilDB, and getUsages().

+ Here is the call graph for this function:

◆ beforeMDUpdateListener()

ilObjFile::beforeMDUpdateListener (   $a_element)
protected

Reimplemented from ilObject2.

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

196 {
197 // Check file extension
198 // Removing the file extension is not allowed
199 include_once 'Services/MetaData/classes/class.ilMD.php';
200 $md = new ilMD($this->getId(), 0, $this->getType());
201 if (!is_object($md_gen = $md->getGeneral())) {
202 return false;
203 }
204 $title = $this->checkFileExtension($this->getFileName(), $md_gen->getTitle());
205 $md_gen->setTitle($title);
206 $md_gen->update();
207
208 return true;
209 }
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 477 of file class.ilObjFile.php.

478 {
479 // no meta data handling for file list files
480 if ($this->getMode() != self::MODE_FILELIST) {
481 $this->updateMetaData();
482 }
483
484 return true;
485 }
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 172 of file class.ilObjFile.php.

173 {
174 return !(bool) $this->no_meta_data_creation;
175 }

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

1187 {
1188 include_once './Modules/File/classes/class.ilObjFileAccess.php';
1189 $fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
1190 $titleExtension = ilObjFileAccess::_getFileExtension($new_title);
1191 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
1192 // remove old extension
1193 $pi = pathinfo($this->getFileName());
1194 $suffix = $pi["extension"];
1195 if ($suffix != "") {
1196 if (substr($new_title, strlen($new_title) - strlen($suffix) - 1) == "." . $suffix) {
1197 $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
1198 }
1199 }
1200 $new_title .= '.' . $fileExtension;
1201 }
1202
1203 return $new_title;
1204 }
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 386 of file class.ilObjFile.php.

387 {
389 $this->createDirectory();
390 }
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 1367 of file class.ilObjFile.php.

1368 {
1369 // v2 - v1 because version should be descending
1370 return (int) $v2["version"] - (int) $v1["version"];
1371 }

◆ copy()

ilObjFile::copy (   $a_source,
  $a_destination 
)

copy file

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

378 {
379 return copy($a_source, $this->getDirectory() . "/" . $a_destination);
380 }
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 265 of file class.ilObjFile.php.

266 {
268 }
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 1445 of file class.ilObjFile.php.

1446 {
1447 // only normal files are supported
1448 if ($this->getMode() != self::MODE_OBJECT) {
1449 return;
1450 }
1451
1452 require_once("./Services/Preview/classes/class.ilPreview.php");
1453 ilPreview::createPreview($this, $force);
1454 }
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(), 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 119 of file class.ilObjFile.php.

120 {
121 global $DIC;
122
123 // Create file directory
124 $this->initFileStorage();
125 $this->file_storage->create();
126
127 if ($a_upload) {
128 return true;
129 }
130
131 // not upload mode
132 ilHistory::_createEntry($this->getId(), "create", $this->getFileName() . ",1");
133 $this->addNewsNotification("file_created");
134
135 // New Item
136 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
137 if ($default_visibility == "public") {
138 ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
139 }
140
141 // log creation
142 $this->log->debug("ilObjFile::createProperties, ID: " . $this->getId() . ", Name: "
143 . $this->getFileName() . ", Type: " . $this->getFileType() . ", Size: "
144 . $this->getFileSize() . ", Mode: " . $this->getMode() . ", Name(Bytes): "
145 . implode(":", ilStr::getBytesForString($this->getFileName())));
146 $this->log->logStack(ilLogLevel::DEBUG);
147
148 $DIC->database()->insert('file_data', $this->getArrayForDatabase());
149
150 // no meta data handling for file list files
151 if ($this->getMode() != self::MODE_FILELIST) {
152 $this->createMetaData();
153 }
154 }
$_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, $DIC, ilHistory\_createEntry(), ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), addNewsNotification(), ilObject2\createMetaData(), ilLogLevel\DEBUG, getArrayForDatabase(), 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 1460 of file class.ilObjFile.php.

1461 {
1462 // only normal files are supported
1463 if ($this->getMode() != self::MODE_OBJECT) {
1464 return;
1465 }
1466
1467 require_once("./Services/Preview/classes/class.ilPreview.php");
1469 }
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 398 of file class.ilObjFile.php.

399 {
400 global $DIC;
401 $ilDB = $DIC['ilDB'];
402
403 if ($a_hist_entry_ids == null || count($a_hist_entry_ids) < 1) {
404 $ilDB->manipulate("UPDATE file_data SET version = 1 WHERE file_id = "
405 . $ilDB->quote($this->getId(), 'integer'));
406 $this->setVersion(0);
407 $this->clearDataDirectory();
408
410
412 } else {
413 $actualVersionDeleted = false;
414
415 // get all versions
416 $versions = $this->getVersions();
417
418 // delete each version
419 foreach ($a_hist_entry_ids as $hist_id) {
420 $entry = null;
421
422 // get version
423 foreach ($versions as $index => $version) {
424 if ($version["hist_entry_id"] == $hist_id) {
425 // remove each history entry
427
428 // delete directory
429 $version_dir = $this->getDirectory($version["version"]);
430 ilUtil::delDir($version_dir);
431
432 // is actual version?
433 if ($version["version"] == $this->getVersion()) {
434 $actualVersionDeleted = true;
435 }
436
437 // remove from array
438 unset($versions[$index]);
439 break;
440 }
441 }
442 }
443
444 // update actual version if it was deleted before
445 if ($actualVersionDeleted) {
446 // get newest version (already sorted by getVersions)
447 $version = reset($versions);
449 } else {
450 // updateWithVersion() will trigger quota, too
452 }
453 }
454 }
static _removeEntryByHistoryID($a_hist_entry_id)
Removes a single entry from the history.
static _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)
$index
Definition: metadata.php:60

References $DIC, $ilDB, $index, $version, 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 710 of file class.ilObjFile.php.

711 {
712 if (is_null($a_hist_entry_id)) {
713 $file = $this->getDirectory($this->getVersion()) . "/" . $this->getFileName();
714 } else {
715 require_once("./Services/History/classes/class.ilHistory.php");
716 $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
717
718 if ($entry === false) {
719 return false;
720 }
721
722 $data = $this->parseInfoParams($entry);
723 $file = $this->getDirectory($data["version"]) . "/" . $data["filename"];
724 }
725 if (is_file($file)) {
726 $this->setFileSize(filesize($file));
727 }
728 }
static _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.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

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

858 {
859 global $DIC;
860 $ilDB = $DIC['ilDB'];
861
862 $a_new_obj->createDirectory();
863 $this->cloneMetaData($a_new_obj);
864
865 // Copy all file versions
866 ilUtil::rCopy($this->getDirectory(), $a_new_obj->getDirectory());
867
868 // object created now copy other settings
869 $query = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,rating,f_mode) VALUES ("
870 . $ilDB->quote($a_new_obj->getId(), 'integer') . ","
871 . $ilDB->quote($this->getFileName(), 'text') . ","
872 . $ilDB->quote($this->getFileType(), 'text') . ","
873 . $ilDB->quote((int) $this->getFileSize(), 'integer') . ", "
874 . $ilDB->quote($this->getVersion(), 'integer') . ", "
875 . $ilDB->quote($this->hasRating(), 'integer') . ", "
876 . $ilDB->quote($this->getMode(), 'text') . ")";
877 $res = $ilDB->manipulate($query);
878
879 // copy all previews
880 require_once("./Services/Preview/classes/class.ilPreview.php");
881 ilPreview::copyPreviews($this->getId(), $a_new_obj->getId());
882
883 // copy history entries
884 require_once("./Services/History/classes/class.ilHistory.php");
885 ilHistory::_copyEntriesForObject($this->getId(), $a_new_obj->getId());
886
887 // Copy learning progress settings
888 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
889 $obj_settings = new ilLPObjSettings($this->getId());
890 $obj_settings->cloneSettings($a_new_obj->getId());
891 unset($obj_settings);
892
893 // add news notification
894 $a_new_obj->addNewsNotification("file_created");
895
896 return $a_new_obj;
897 }
static _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.
$query

References $DIC, $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 106 of file class.ilObjFile.php.

107 {
108 $this->createProperties($a_upload);
109 }
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 181 of file class.ilObjFile.php.

182 {
183 // add technical section with file size and format
184 $md_obj = new ilMD($this->getId(), 0, $this->getType());
185 $technical = $md_obj->addTechnical();
186 $technical->setSize($this->getFileSize());
187 $technical->save();
188 $format = $technical->addFormat();
189 $format->setFormat($this->getFileType());
190 $format->save();
191 $technical->update();
192 }
$format
Definition: metadata.php:141

References $format, 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 915 of file class.ilObjFile.php.

916 {
917 global $DIC;
918 $ilDB = $DIC['ilDB'];
919
920 // delete file data entry
921 $q = "DELETE FROM file_data WHERE file_id = " . $ilDB->quote($this->getId(), 'integer');
922 $this->ilias->db->query($q);
923
924 // delete history entries
925 require_once("./Services/History/classes/class.ilHistory.php");
927
929
930 // delete entire directory and its content
931 if (@is_dir($this->getDirectory())) {
933 }
934
935 // delete meta data
936 if ($this->getMode() != self::MODE_FILELIST) {
937 $this->deleteMetaData();
938 }
939
940 // delete preview
941 $this->deletePreview();
942 }
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 $DIC, $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 212 of file class.ilObjFile.php.

213 {
214 // handling for technical section
215 include_once 'Services/MetaData/classes/class.ilMD.php';
216
217 switch ($a_element) {
218 case 'Technical':
219
220 // Update Format (size is not stored in db)
221 $md = new ilMD($this->getId(), 0, $this->getType());
222 if (!is_object($md_technical = $md->getTechnical())) {
223 return false;
224 }
225
226 foreach ($md_technical->getFormatIds() as $id) {
227 $md_format = $md_technical->getFormat($id);
228 ilObjFile::_writeFileType($this->getId(), $md_format->getFormat());
229 $this->setFileType($md_format->getFormat());
230 break;
231 }
232
233 break;
234 }
235
236 return true;
237 }
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

Reimplemented from ilObject2.

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

458 {
459 global $DIC;
460
461 $q = "SELECT * FROM file_data WHERE file_id = %s";
462 $r = $DIC->database()->queryF($q, ['integer'], [$this->getId()]);
463 $row = $r->fetchObject();
464
465 $this->setFileName($row->file_name);
466 $this->setFileType($row->file_type);
467 $this->setFileSize($row->file_size);
468 $this->setVersion($row->version ? $row->version : 1);
469 $this->setMode($row->f_mode);
470 $this->setRating($row->rating);
471 $this->setPageCount($row->page_count);
472
473 $this->initFileStorage();
474 }
setMode($a_mode)
mode is object or filelist
setFileName($a_name)
setRating($a_value)
setPageCount($page_count)

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

+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

Reimplemented from ilObject2.

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

489 {
490 global $DIC;
491
492 $a_columns = $this->getArrayForDatabase();
493 $DIC->database()->update('file_data', $a_columns, [
494 'file_id' => [
495 'integer',
496 $this->getId(),
497 ],
498 ]);
499
501
502 return true;
503 }

References $DIC, getArrayForDatabase(), ilObject2\getId(), and handleQuotaUpdate().

+ Here is the call graph for this function:

◆ doUpdateMetaData()

ilObjFile::doUpdateMetaData ( )
protected

update meta data

Reimplemented from ilObject2.

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

510 {
511 // add technical section with file size and format
512 $md_obj = new ilMD($this->getId(), 0, $this->getType());
513 if (!is_object($technical = $md_obj->getTechnical())) {
514 $technical = $md_obj->addTechnical();
515 $technical->save();
516 }
517 $technical->setSize($this->getFileSize());
518
519 $format_ids = $technical->getFormatIds();
520 if (count($format_ids) > 0) {
521 $format = $technical->getFormat($format_ids[0]);
522 $format->setFormat($this->getFileType());
523 $format->update();
524 } else {
525 $format = $technical->addFormat();
526 $format->setFormat($this->getFileType());
527 $format->save();
528 }
529 $technical->update();
530 }

References $format, 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 952 of file class.ilObjFile.php.

953 {
954 $subdir = "il_" . IL_INST_ID . "_file_" . $this->getId();
955 ilUtil::makeDir($a_target_dir . "/objects/" . $subdir);
956
957 $filedir = $this->getDirectory($this->getVersion());
958
959 if (@!is_dir($filedir)) {
960 $filedir = $this->getDirectory();
961 }
962
963 ilUtil::rCopy($filedir, $a_target_dir . "/objects/" . $subdir);
964 }
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:

◆ getArrayForDatabase()

ilObjFile::getArrayForDatabase ( )
private
Returns
array

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

1512 {
1513 return [
1514 'file_id' => ['integer', $this->getId()],
1515 'file_name' => ['text', $this->getFileName()],
1516 'file_type' => ['text', $this->getFileType()],
1517 'file_size' => ['integer', (int) $this->getFileSize()],
1518 'version' => ['integer', (int) $this->getVersion()],
1519 'f_mode' => ['text', $this->getMode()],
1520 'page_count' => ['text', $this->getPageCount()],
1521 'rating' => ['integer', $this->hasRating()],
1522 ];
1523 }

References getFileName(), getFileSize(), getFileType(), ilObject2\getId(), getMode(), getPageCount(), getVersion(), and hasRating().

Referenced by createProperties(), and doUpdate().

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

◆ getDirectory()

ilObjFile::getDirectory (   $a_version = 0)
Parameters
int$a_version
Returns
string

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

246 {
247 $version_subdir = "";
248
249 if ($a_version) {
250 // BEGIN WebDAV Avoid double slash before version subdirectory
251 $version_subdir = sprintf("%03d", $a_version);
252 // END WebDAV Avoid double slash before version subdirectory
253 }
254
255 if (!is_object($this->file_storage)) {
256 $this->initFileStorage();
257 }
258
259 $str = $this->file_storage->getAbsolutePath() . '/' . $version_subdir;
260
261 return $str;
262 }
sprintf('%.4f', $callTime)

References initFileStorage(), and sprintf.

Referenced by clearDataDirectory(), copy(), createDirectory(), deleteVersions(), determineFileSize(), doCloneObject(), doDelete(), export(), getFile(), 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 590 of file class.ilObjFile.php.

591 {
592 require_once("./Modules/File/classes/class.ilObjFileAccess.php");
593
594 return ilObjFileAccess::_lookupDiskUsage($this->id);
595 }
static _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 599 of file class.ilObjFile.php.

600 {
601 if (is_null($a_hist_entry_id)) {
602 $file = $this->getDirectory($this->getVersion()) . "/" . $this->getFileName();
603 } else {
604 require_once("./Services/History/classes/class.ilHistory.php");
605 $entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
606
607 if ($entry === false) {
608 return false;
609 }
610
611 $data = $this->parseInfoParams($entry);
612 $file = $this->getDirectory($data["version"]) . "/" . $data["filename"];
613 }
614
615 return $file;
616 }

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

794 {
795 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
796
798 }
getTitle()
get object title @access public

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

Referenced by guessFileType().

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

◆ getFileName()

ilObjFile::getFileName ( )
Returns
string

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

546 {
547 return $this->filename;
548 }

References $filename.

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

+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

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

579 {
580 return $this->filesize;
581 }

References $filesize.

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

+ Here is the caller graph for this function:

◆ getFileType()

ilObjFile::getFileType ( )
Returns
string

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

564 {
565 return $this->filetype;
566 }

References $filetype.

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

+ Here is the caller graph for this function:

◆ getMode()

ilObjFile::getMode ( )

mode is object or filelist

Returns
string mode

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

650 {
651 return $this->mode;
652 }

References $mode.

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

+ Here is the caller graph for this function:

◆ getPageCount()

ilObjFile::getPageCount ( )
Returns
int

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

1494 {
1495 return $this->page_count;
1496 }

References $page_count.

Referenced by getArrayForDatabase().

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

1249 {
1250 include_once("./Services/History/classes/class.ilHistory.php");
1252 if ($version === false) {
1253 return false;
1254 }
1255
1256 // ilHistory returns different keys in _getEntryByHistoryID and _getEntriesForObject
1257 // so this makes it the same
1258 $version["hist_entry_id"] = $version["id"];
1259 $version["user_id"] = $version["usr_id"];
1260 $version["date"] = $version["hdate"];
1261 unset($version["id"], $version["usr_id"], $version["hdate"]);
1262
1263 // parse params
1265
1266 return array_merge($version, $params);
1267 }
$params
Definition: disable.php:11

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

Referenced by rollback().

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

1028 {
1029 global $DIC;
1030 $ilDB = $DIC['ilDB'];
1031
1032 // get usages in learning modules
1033 $q = "SELECT * FROM file_usage WHERE id = " . $ilDB->quote($this->getId(), "integer");
1034 $us_set = $ilDB->query($q);
1035 $ret = array();
1036 while ($us_rec = $ilDB->fetchAssoc($us_set)) {
1037 $ret[] = array(
1038 "type" => $us_rec["usage_type"],
1039 "id" => $us_rec["usage_id"],
1040 "lang" => $us_rec["usage_lang"],
1041 "hist_nr" => $us_rec["usage_hist_nr"],
1042 );
1043 }
1044
1045 return $ret;
1046 }

References $DIC, $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 627 of file class.ilObjFile.php.

628 {
629 return $this->version;
630 }

References $version.

Referenced by addFileVersion(), deleteVersions(), determineFileSize(), doCloneObject(), export(), getArrayForDatabase(), getFile(), replaceFile(), 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 1215 of file class.ilObjFile.php.

1216 {
1217 include_once("./Services/History/classes/class.ilHistory.php");
1218 $versions = ilHistory::_getEntriesForObject($this->getId(), $this->getType());
1219
1220 if ($version_ids != null && count($version_ids) > 0) {
1221 foreach ($versions as $index => $version) {
1222 if (!in_array($version["hist_entry_id"], $version_ids, true)) {
1223 unset($versions[$index]);
1224 }
1225 }
1226 }
1227
1228 // add custom entries
1229 foreach ($versions as $index => $version) {
1231 $versions[$index] = array_merge($version, $params);
1232 }
1233
1234 // sort by version number (hist_entry_id will do for that)
1235 usort($versions, array($this, "compareVersions"));
1236
1237 return $versions;
1238 }
static _getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object

References $index, $params, $version, 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 1082 of file class.ilObjFile.php.

1083 {
1084 global $DIC;
1085 $ilias = $DIC['ilias'];
1086
1087 $zip = PATH_TO_ZIP;
1088
1089 exec($zip . ' ' . ilUtil::escapeShellArg($this->getDirectory() . '/' . $this->getFileName())
1090 . " " . ilUtil::escapeShellArg($this->getDirectory() . '/' . '1.zip'));
1091
1092 return $this->getDirectory() . '/1.zip';
1093 }
static escapeShellArg($a_arg)

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

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

833 {
834 $path = pathinfo($a_file);
835 if ($path["extension"] != "") {
836 $filename = $path["basename"];
837 } else {
838 $filename = "dummy." . $this->getFileExtension();
839 }
840 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
841 $mime = ilMimeTypeUtil::getMimeType($a_file, $filename, $this->getFileType());
842
843 return $mime;
844 }
static getMimeType($a_file='', $a_filename='', $a_mime='')
getFileExtension()
Returns the extension of the file name converted to lower-case.

References $filename, $path, getFileExtension(), 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 1417 of file class.ilObjFile.php.

1418 {
1419 include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
1420 $mob = new ilObjMediaObject();
1421
1422 // file itself could be workspace item
1423 $parent_obj_ids = array($a_file->getId());
1424
1425 foreach ($a_file->getUsages() as $item) {
1426 $parent_obj_id = $mob->getParentObjectIdForUsage($item);
1427 if ($parent_obj_id
1428 && !in_array($parent_obj_id, $parent_obj_ids)
1429 ) {
1430 $parent_obj_ids[] = $parent_obj_id;
1431 }
1432 }
1433
1434 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1435 ilDiskQuotaHandler::handleUpdatedSourceObject($a_file->getType(), $a_file->getId(), $a_file->getDiskUsage(), $parent_obj_ids);
1436 }
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(), and doUpdate().

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

◆ hasRating()

ilObjFile::hasRating ( )
Returns
bool

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

1485 {
1486 return $this->rating;
1487 }

References $rating.

Referenced by doCloneObject(), and getArrayForDatabase().

+ Here is the caller graph for this function:

◆ initFileStorage()

ilObjFile::initFileStorage ( )

init file storage object

@access public

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

1131 {
1132 $this->file_storage = new ilFSStorageFile($this->getId());
1133
1134 return true;
1135 }
Class ilFSStorageFile.

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 ( )

Reimplemented from ilObject2.

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

96 {
97 $this->type = "file";
98 }

◆ isHidden()

ilObjFile::isHidden ( )

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

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

818 {
819 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
820
822 }
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 806 of file class.ilObjFile.php.

807 {
808 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
809
811 }
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 1382 of file class.ilObjFile.php.

1383 {
1384 $data = preg_split("/(.*),(.*)/", $entry["info_params"], 0, PREG_SPLIT_DELIM_CAPTURE
1385 | PREG_SPLIT_NO_EMPTY);
1386
1387 // bugfix: first created file had no version number
1388 // this is a workaround for all files created before the bug was fixed
1389 if (empty($data[1])) {
1390 $data[1] = "1";
1391 }
1392
1393 $result = array(
1394 "filename" => $data[0],
1395 "version" => $data[1],
1396 "rollback_version" => "",
1397 "rollback_user_id" => "",
1398 );
1399
1400 // if rollback, the version contains the rollback version as well
1401 if ($entry["action"] == "rollback") {
1402 $tokens = explode("|", $result["version"]);
1403 if (count($tokens) > 1) {
1404 $result["version"] = $tokens[0];
1405 $result["rollback_version"] = $tokens[1];
1406
1407 if (count($tokens) > 2) {
1408 $result["rollback_user_id"] = $tokens[2];
1409 }
1410 }
1411 }
1412
1413 return $result;
1414 }
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 271 of file class.ilObjFile.php.

272 {
273 $this->raise_upload_error = $a_raise;
274 }

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)
Parameters
$a_upload_file
$a_filename
Exceptions

ILIAS\FileUpload\Collection\Exception\NoSuchElementException

Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

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

347 {
348 if ($result = $this->getUploadFile($a_upload_file, $a_filename, true)) {
349 ilHistory::_createEntry($this->getId(), "replace", $a_filename . "," . $this->getVersion());
350 $this->addNewsNotification("file_updated");
351
352 // create preview
353 $this->createPreview(true);
354 }
355
356 return $result;
357 }

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

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

1278 {
1279 global $DIC;
1280 $ilDB = $DIC['ilDB'];
1281 $ilUser = $DIC['ilUser'];
1282
1283 $source = $this->getSpecificVersion($version_id);
1284 if ($source === false) {
1285 $this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
1286 }
1287
1288 // get the new version number
1289 $new_version_nr = $this->getVersion() + 1;
1290
1291 // copy file
1292 $source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
1293 $dest_dir = $this->getDirectory($new_version_nr);
1294 if (@!is_dir($dest_dir)) {
1295 ilUtil::makeDir($dest_dir);
1296 }
1297
1298 copy($source_path, $dest_dir . "/" . $source["filename"]);
1299
1300 // create new history entry based on the old one
1301 include_once("./Services/History/classes/class.ilHistory.php");
1302 ilHistory::_createEntry($this->getId(), "rollback", $source["filename"] . ","
1303 . $new_version_nr . "|"
1304 . $source["version"] . "|"
1305 . $ilUser->getId());
1306
1307 // get id of newest entry
1308 // bugfix mantis 23596
1309 $entries = ilHistory::_getEntriesForObject($this->getId());
1310 $newest_entry_id = 0;
1311 foreach ($entries as $entry) {
1312 if ($entry["action"] == "rollback") {
1313 $newest_entry_id = $entry["hist_entry_id"];
1314 }
1315 }
1316 $new_version = $this->getSpecificVersion($newest_entry_id);
1317
1318 // change user back to the original uploader
1319 ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
1320
1321 // update this file with the new version
1322 $this->updateWithVersion($new_version);
1323
1324 $this->addNewsNotification("file_updated");
1325
1326 return $new_version;
1327 }
$source
Definition: linkback.php:22
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 $DIC, $ilDB, $ilUser, $source, ilHistory\_changeUserId(), ilHistory\_createEntry(), ilHistory\_getEntriesForObject(), addNewsNotification(), copy(), getDirectory(), ilObject2\getId(), getSpecificVersion(), getVersion(), ilUtil\makeDir(), and updateWithVersion().

+ Here is the call graph for this function:

◆ setFileName()

ilObjFile::setFileName (   $a_name)
Parameters
string$a_name

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

537 {
538 $this->filename = $a_name;
539 }

Referenced by doRead(), and updateWithVersion().

+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize (   $a_size)
Parameters
$a_size

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

573 {
574 $this->filesize = $a_size;
575 }

Referenced by determineFileSize(), and doRead().

+ Here is the caller graph for this function:

◆ setFileType()

ilObjFile::setFileType (   $a_type)
Parameters
string$a_type

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

555 {
556 $this->filetype = $a_type;
557 }

References $a_type.

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

639 {
640 $this->mode = $a_mode;
641 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setNoMetaDataCreation()

ilObjFile::setNoMetaDataCreation (   $a_status)
Parameters
bool$a_status

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

161 {
162 $this->no_meta_data_creation = (bool) $a_status;
163 }

◆ setPageCount()

ilObjFile::setPageCount (   $page_count)
Parameters
int$page_count

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

1503 {
1504 $this->page_count = $page_count;
1505 }

References $page_count.

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setRating()

ilObjFile::setRating (   $a_value)
Parameters
bool$a_value

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

1476 {
1477 $this->rating = (bool) $a_value;
1478 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion (   $a_version)

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

622 {
623 $this->version = $a_version;
624 }

Referenced by deleteVersions(), doRead(), storeUnzipedFile(), 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 1147 of file class.ilObjFile.php.

1148 {
1149 $this->setVersion($this->getVersion() + 1);
1150
1151 if (@!is_dir($this->getDirectory($this->getVersion()))) {
1152 ilUtil::makeDir($this->getDirectory($this->getVersion()));
1153 }
1154
1155 $file = $this->getDirectory($this->getVersion()) . "/" . $a_filename;
1156
1157 ilFileUtils::rename($a_upload_file, $file);
1158
1159 // create preview
1160 $this->createPreview();
1161 }
static rename($a_source, $a_target)
Rename a file.

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

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

1336 {
1337 // update title (checkFileExtension must be called before setFileName!)
1338 $this->setTitle($this->checkFileExtension($version["filename"], $this->getTitle()));
1339
1340 $this->setVersion($version["version"]);
1341 $this->setFileName($version["filename"]);
1342
1343 // evaluate mime type (reset file type before)
1344 $this->setFileType("");
1345 $this->setFileType($this->guessFileType($version["filename"]));
1346
1347 // set filesize
1348 $this->determineFileSize();
1349
1350 $this->update();
1351
1352 // refresh preview
1353 $this->createPreview(true);
1354 }
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().
setTitle($a_title)
set object title
update()
update object in db

References $version, 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 63 of file class.ilObjFile.php.

◆ $filemaxsize

ilObjFile::$filemaxsize = "20000000"
protected

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

◆ $filename

ilObjFile::$filename = ''
protected

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

Referenced by getFileName(), and guessFileType().

◆ $filesize

ilObjFile::$filesize
protected

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

Referenced by getFileSize().

◆ $filetype

ilObjFile::$filetype = ''
protected

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

Referenced by getFileType().

◆ $log

ilObjFile::$log = null
protected

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

◆ $mode

ilObjFile::$mode = self::MODE_OBJECT

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

Referenced by getMode().

◆ $no_meta_data_creation

ilObjFile::$no_meta_data_creation
protected

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

◆ $page_count

ilObjFile::$page_count = 0
protected

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

Referenced by getPageCount(), and setPageCount().

◆ $raise_upload_error

ilObjFile::$raise_upload_error

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

◆ $rating

ilObjFile::$rating = false
protected

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

Referenced by hasRating().

◆ $version

ilObjFile::$version = 1
protected

◆ MODE_FILELIST

const ilObjFile::MODE_FILELIST = "filelist"

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

◆ MODE_OBJECT

const ilObjFile::MODE_OBJECT = "object"

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


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