ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjFile Class Reference

Class ilObjFile. More...

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

Public Member Functions

 appendStream (FileStream $stream, string $title)
 
 appendUpload (UploadResult $result, string $title)
 
 replaceWithStream (FileStream $stream, string $title)
 
 replaceWithUpload (UploadResult $result, string $title)
 
 getFile ($a_hist_entry_id=null)
 
 getDirectory ($a_version=0)
 
 getVersion ()
 
 setVersion ($a_version)
 
 getFileName ()
 
 setFileName ($a_name)
 
 setRating ($a_value)
 
 setResourceId (?string $resource_id)
 
 getResourceId ()
 
 getStorageID ()
 
 getMode ()
 
 setMode ($a_mode)
 
 getFileSize ()
 
 setFileSize ($a_size)
 
 getFileType ()
 
 setFileType ($a_type)
 
 hasRating ()
 
 getMaxVersion ()
 
 setMaxVersion ($a_max_version)
 
 getPageCount ()
 
 setPageCount ($page_count)
 
 getAction ()
 
 setAction ($a_action)
 
 handleChangedObjectTitle (string $new_title)
 
 initType ()
 
 createDirectory ()
 
 raiseUploadError ($raise=false)
 
 replaceFile ($a_upload_file, $a_filename)
 
 getUploadFile ($a_upload_file, string $title, bool $a_prevent_preview=false)
 @description This Method is used to append a fileupload by it's POST-name to the current ilObjFile More...
 
 isHidden ()
 
 clearDataDirectory ()
 @ineritdoc More...
 
 deleteVersions ($a_hist_entry_ids=null)
 @ineritdoc More...
 
 sendFile ($a_hist_entry_id=null)
 
 isInline ()
 
 export (string $target_dir)
 
 storeUnzipedFile ($a_upload_file, $a_filename)
 storeUnzipedFile Stores Files unzipped from uploaded archive in filesystem More...
 
 getVersions ($version_ids=null)
 
 rollback (int $version_id)
 Makes the specified version the current one. More...
 
 checkFileExtension ($new_filename, $new_title)
 
 getFileExtension ()
 
- 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...
 
 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 ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 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...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. 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...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 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...
 
 getDirectory ($a_version=0)
 
 createDirectory ()
 
 replaceFile ($a_upload_file, $a_filename)
 
 clearDataDirectory ()
 
 deleteVersions ($a_hist_entry_ids=null)
 Deletes the specified history entries or all entries if no ids are specified. More...
 
 setFileType ($a_type)
 
 getFileType ()
 
 getStorageID ()
 
 setFileSize ($a_size)
 
 handleChangedObjectTitle (string $new_title)
 
 getFileSize ()
 
 getFile ($a_hist_entry_id=null)
 
 setVersion ($a_version)
 
 getVersion ()
 
 setMaxVersion ($a_max_version)
 
 getMaxVersion ()
 
 sendFile ($a_hist_entry_id=null)
 
 getFileExtension ()
 Returns the extension of the file name converted to lower-case. More...
 
 storeUnzipedFile ($a_upload_file, $a_filename)
 
 getVersions ($version_ids=null)
 Gets the file versions for this object. More...
 
 export (string $target_dir)
 @depracated More...
 

Data Fields

const MODE_FILELIST = "filelist"
 
const MODE_OBJECT = "object"
 
 $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

 initImplementation ()
 
 doCreate ($a_upload=false)
 
 doUpdate ()
 
 beforeUpdate ()
 
 beforeDelete ()
 
 doDelete ()
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate ()
 
 beforeCreate ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 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 ()
 

Protected Attributes

 $implementation
 
 $page_count = 0
 
 $rating = false
 
 $log
 
 $filename = ''
 
 $filetype = ''
 
 $filesize
 
 $version = 1
 
 $max_version = 1
 
 $action
 
 $resource_id
 
 $manager
 
 $upload
 
 $stakeholder
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Private Member Functions

 updateObjectFromRevision (Revision $r, bool $create_previews=true)
 
 appendSuffixToTitle (string $title, string $filename)
 
 getArrayForDatabase ()
 
 prepareUpload ()
 

Additional Inherited Members

- 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, $a_deleted_by)
 
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 lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. 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, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. 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...
 

Detailed Description

Member Function Documentation

◆ appendStream()

ilObjFile::appendStream ( FileStream  $stream,
string  $title 
)
Exceptions
FileNamePolicyException

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

182 : int
183 {
184 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
185 $revision = $this->manager->appendNewRevisionFromStream($i, $stream, $this->stakeholder, $title);
186 } else {
187 $i = $this->manager->stream($stream, $this->stakeholder, $title);
188 $revision = $this->manager->getCurrentRevision($i);
189 $this->setResourceId($i->serialize());
190 $this->initImplementation();
191 }
192 $this->updateObjectFromRevision($revision);
193
194 return $revision->getVersionNumber();
195 }
updateObjectFromRevision(Revision $r, bool $create_previews=true)
setResourceId(?string $resource_id)
$i
Definition: metadata.php:24

References $i, ilObject\$title, getResourceId(), initImplementation(), setResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ appendSuffixToTitle()

ilObjFile::appendSuffixToTitle ( string  $title,
string  $filename 
)
private

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

167 : string
168 {
169 // bugfix mantis 0026160 && 0030391 and 0032340
170 $title_info = new SplFileInfo($title);
171 $filename_info = new SplFileInfo($filename);
172
173 $filename = str_replace('.' . $title_info->getExtension(), '', $title_info->getPathname());
174 $extension = $filename_info->getExtension();
175
176 return $this->secure($filename . '.' . $extension);
177 }

References $filename, and ilObject\$title.

Referenced by appendUpload(), and replaceWithUpload().

+ Here is the caller graph for this function:

◆ appendUpload()

ilObjFile::appendUpload ( UploadResult  $result,
string  $title 
)
Exceptions
FileNamePolicyException

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

200 : int
201 {
202 $title = $this->appendSuffixToTitle($title, $result->getName());
203 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
204 $revision = $this->manager->appendNewRevision($i, $result, $this->stakeholder, $title);
205 } else {
206 $i = $this->manager->upload($result, $this->stakeholder, $title);
207 $revision = $this->manager->getCurrentRevision($i);
208 $this->setResourceId($i->serialize());
209 $this->initImplementation();
210 }
213 }
214 $this->updateObjectFromRevision($revision);
215
216 return $revision->getVersionNumber();
217 }
$result
appendSuffixToTitle(string $title, string $filename)
setPageCount($page_count)

References $i, $result, ilObject\$title, appendSuffixToTitle(), ILIAS\FileUpload\DTO\UploadResult\getMetaData(), getResourceId(), initImplementation(), ilCountPDFPagesPreProcessors\PAGE_COUNT, setPageCount(), setResourceId(), and updateObjectFromRevision().

Referenced by getUploadFile().

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

◆ beforeDelete()

ilObjFile::beforeDelete ( )
protected

Reimplemented from ilObject2.

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

562 {
563 // check, if file is used somewhere
564 $usages = $this->getUsages();
565 if (count($usages) == 0) {
566 return true;
567 }
568
569 return false;
570 }

◆ beforeUpdate()

ilObjFile::beforeUpdate ( )
protected

Reimplemented from ilObject2.

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

552 {
553 // no meta data handling for file list files
554 if ($this->getMode() != self::MODE_FILELIST) {
555 $this->updateMetaData();
556 }
557
558 return true;
559 }
updateMetaData()
update meta data entry

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

+ Here is the call graph for this function:

◆ checkFileExtension()

ilObjFile::checkFileExtension (   $new_filename,
  $new_title 
)
Parameters
$new_filename
$new_title
Returns
string
Deprecated:

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

779 {
780 $fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
781 $titleExtension = ilObjFileAccess::_getFileExtension($new_title);
782 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
783 // remove old extension
784 $pi = pathinfo($this->getFileName());
785 $suffix = $pi["extension"];
786 if ($suffix != "") {
787 if (substr($new_title, strlen($new_title) - strlen($suffix) - 1) == "." . $suffix) {
788 $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
789 }
790 }
791 $new_title .= '.' . $fileExtension;
792 }
793
794 return $new_title;
795 }
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.

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

+ Here is the call graph for this function:

◆ clearDataDirectory()

ilObjFile::clearDataDirectory ( )

@ineritdoc

Deprecated:

Implements ilObjFileImplementationInterface.

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

682 {
683 $this->implementation->clearDataDirectory();
684 }

◆ createDirectory()

ilObjFile::createDirectory ( )
Returns
void
Deprecated:

Implements ilObjFileImplementationInterface.

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

625 {
626 // we no longer create directories
627 }

◆ deleteVersions()

ilObjFile::deleteVersions (   $a_hist_entry_ids = null)

@ineritdoc

Deprecated:

Implements ilObjFileImplementationInterface.

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

691 {
692 $this->implementation->deleteVersions($a_hist_entry_ids);
693 }

◆ doCreate()

ilObjFile::doCreate (   $a_upload = false)
protected
Parameters
false$a_upload

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

432 {
433 $this->createProperties($a_upload);
434 $this->notifyCreation($this->getId(), $this->getDescription());
435 }
getDescription()
get object description
getId()
get object id @access public
createProperties($a_upload=false)
The basic properties of a file object are stored in table object_data.
notifyCreation(int $obj_id, string $additional_message=null)

References createProperties(), ilObject2\getDescription(), ilObject\getId(), and notifyCreation().

+ Here is the call graph for this function:

◆ doDelete()

ilObjFile::doDelete ( )
protected

Reimplemented from ilObject2.

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

573 {
574 global $DIC;
575
576 // delete file data entry
577 $DIC->database()->manipulateF("DELETE FROM file_data WHERE file_id = %s", ['integer'], [$this->getId()]);
578
579 // delete history entries
581
582 // delete meta data
583 if ($this->getMode() != self::MODE_FILELIST) {
584 $this->deleteMetaData();
585 }
586
587 // delete preview
588 $this->deletePreview();
589
590 // delete resource
591 $identification = $this->getResourceId();
592 if ($identification && $identification != '-') {
593 $resource = $this->manager->find($identification);
594 if ($resource !== null) {
595 $this->manager->remove($resource, $this->stakeholder);
596 }
597 }
598 }
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
deleteMetaData()
delete meta data entry
global $DIC
Definition: goto.php:24

References $DIC, ilHistory\_removeEntriesForObject(), ilObject2\deleteMetaData(), ilObject\getId(), getMode(), and getResourceId().

+ Here is the call graph for this function:

◆ doUpdate()

ilObjFile::doUpdate ( )
protected

Reimplemented from ilObject2.

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

526 {
527 global $DIC;
528
529 $a_columns = $this->getArrayForDatabase();
530 $DIC->database()->update('file_data', $a_columns, [
531 'file_id' => [
532 'integer',
533 $this->getId(),
534 ],
535 ]);
536
537 // update metadata with the current file version
538 $meta_version_column = ['meta_version' => ['integer', (int) $this->getVersion()]];
539 $DIC->database()->update('il_meta_lifecycle', $meta_version_column, [
540 'rbac_id' => [
541 'integer',
542 $this->getId(),
543 ],
544 ]);
545
546 $this->notifyUpdate($this->getId(), $this->getDescription());
547
548 return true;
549 }
notifyUpdate(int $obj_id, string $additional_message=null)

References $DIC, getArrayForDatabase(), ilObject2\getDescription(), ilObject\getId(), getVersion(), and notifyUpdate().

+ Here is the call graph for this function:

◆ export()

ilObjFile::export ( string  $target_dir)
Parameters
string$target_dir
Deprecated:

Implements ilObjFileImplementationInterface.

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

717 : void
718 {
719 $this->implementation->export($target_dir);
720 }

◆ getAction()

ilObjFile::getAction ( )
Returns
string
Deprecated:

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

406 {
407 return $this->action;
408 }

References $action.

◆ getArrayForDatabase()

ilObjFile::getArrayForDatabase ( )
private
Returns
array

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

603 : array
604 {
605 return [
606 'file_id' => ['integer', $this->getId()],
607 'file_name' => ['text', $this->getFileName()],
608 'file_type' => ['text', $this->getFileType()],
609 'file_size' => ['integer', (int) $this->getFileSize()],
610 'version' => ['integer', (int) $this->getVersion()],
611 'max_version' => ['integer', (int) $this->getMaxVersion()],
612 'f_mode' => ['text', $this->getMode()],
613 'page_count' => ['text', $this->getPageCount()],
614 'rating' => ['integer', $this->hasRating()],
615 'rid' => ['text', $this->resource_id ?? ''],
616 ];
617 }

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

Referenced by 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
Deprecated:

Implements ilObjFileImplementationInterface.

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

264 {
265 return $this->implementation->getDirectory($a_version);
266 }

Referenced by storeUnzipedFile().

+ Here is the caller graph for this function:

◆ getFile()

ilObjFile::getFile (   $a_hist_entry_id = null)
Parameters
null$a_hist_entry_id
Returns
string
Deprecated:

Implements ilObjFileImplementationInterface.

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

259 {
260 return $this->implementation->getFile($a_hist_entry_id);
261 }

◆ getFileExtension()

ilObjFile::getFileExtension ( )
Returns
string
Deprecated:

Implements ilObjFileImplementationInterface.

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

802 {
803 return $this->implementation->getFileExtension();
804 }

◆ getFileName()

ilObjFile::getFileName ( )
Returns
string

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

282 {
283 return $this->filename;
284 }

References $filename.

Referenced by checkFileExtension(), getArrayForDatabase(), and initImplementation().

+ Here is the caller graph for this function:

◆ getFileSize()

ilObjFile::getFileSize ( )

Implements ilObjFileImplementationInterface.

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

339 {
340 return $this->filesize;
341 }

References $filesize.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getFileType()

ilObjFile::getFileType ( )
Returns
string

Implements ilObjFileImplementationInterface.

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

355 {
356 return $this->filetype;
357 }

References $filetype.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getMaxVersion()

ilObjFile::getMaxVersion ( )

Implements ilObjFileImplementationInterface.

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

376 {
377 return $this->max_version;
378 }

References $max_version.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getMode()

ilObjFile::getMode ( )
Returns
string

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

326 {
327 return $this->mode;
328 }

References $mode.

Referenced by beforeUpdate(), doDelete(), and getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getPageCount()

ilObjFile::getPageCount ( )
Returns
int

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

389 {
390 return $this->page_count;
391 }

References $page_count.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getResourceId()

ilObjFile::getResourceId ( )

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

312 : ?string
313 {
314 return $this->resource_id ?? '-';
315 }

Referenced by appendStream(), appendUpload(), doDelete(), replaceWithStream(), replaceWithUpload(), and rollback().

+ Here is the caller graph for this function:

◆ getStorageID()

ilObjFile::getStorageID ( )

Implements ilObjFileImplementationInterface.

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

317 : ?string
318 {
319 return $this->implementation->getStorageID();
320 }

◆ getUploadFile()

ilObjFile::getUploadFile (   $a_upload_file,
string  $title,
bool  $a_prevent_preview = false 
)

@description This Method is used to append a fileupload by it's POST-name to the current ilObjFile

Deprecated:
See also
appendUpload(), appendStream()

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

656 : bool
657 {
658 $this->prepareUpload();
659
660 $results = $this->upload->getResults();
661 $upload = $results[$a_upload_file];
662
663 $this->appendUpload($upload, $title);
664
665 return true;
666 }
appendUpload(UploadResult $result, string $title)
$results

References $results, $upload, appendUpload(), and prepareUpload().

+ Here is the call graph for this function:

◆ getVersion()

ilObjFile::getVersion ( )

Implements ilObjFileImplementationInterface.

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

269 {
270 return $this->version;
271 }

References $version.

Referenced by doUpdate(), getArrayForDatabase(), initImplementation(), and storeUnzipedFile().

+ Here is the caller graph for this function:

◆ getVersions()

ilObjFile::getVersions (   $version_ids = null)
Parameters
null$version_ids
Returns
array|ilObjFileVersion[]

Implements ilObjFileImplementationInterface.

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

752 : array
753 {
754 return $this->implementation->getVersions($version_ids);
755 }

◆ handleChangedObjectTitle()

ilObjFile::handleChangedObjectTitle ( string  $new_title)

Implements ilObjFileImplementationInterface.

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

420 {
421 $this->setTitle($new_title);
422 $this->implementation->handleChangedObjectTitle($new_title);
423 }
setTitle($a_title)
set object title

References ilObject2\setTitle().

+ Here is the call graph for this function:

◆ hasRating()

ilObjFile::hasRating ( )
Returns
bool

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

371 {
372 return $this->rating;
373 }

References $rating.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ initImplementation()

ilObjFile::initImplementation ( )
protected

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

132 : void
133 {
134 if ($this->resource_id && ($id = $this->manager->find($this->resource_id)) !== null) {
135 $resource = $this->manager->getResource($id);
136 $this->implementation = new ilObjFileImplementationStorage(
137 $resource,
138 (int) $this->getId()
139 );
140 $this->setMaxVersion($resource->getMaxRevision());
141 $this->setVersion($resource->getMaxRevision());
142 } else {
143 $this->implementation = new ilObjFileImplementationLegacy(
144 (int) $this->getId(),
145 (int) $this->getVersion(),
146 (string) $this->getFileName()
147 );
148 $s = new FilePathSanitizer($this);
149 $s->sanitizeIfNeeded();
150 }
151 }
Class ilObjFileImplementationLegacy.
Class ilObjFileImplementationStorage.
setMaxVersion($a_max_version)
setVersion($a_version)

References ilObject\$id, getFileName(), ilObject\getId(), getVersion(), setMaxVersion(), and setVersion().

Referenced by appendStream(), and appendUpload().

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

620 {
621 $this->type = "file";
622 }

◆ isHidden()

ilObjFile::isHidden ( )
Returns
bool
Deprecated:

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

673 {
675 }
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.
getTitle()
get object title @access public

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

+ Here is the call graph for this function:

◆ isInline()

ilObjFile::isInline ( )
Returns
bool
Deprecated:

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

709 {
711 }
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:

◆ prepareUpload()

ilObjFile::prepareUpload ( )
private

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

640 : void
641 {
642 if (true !== $this->upload->hasBeenProcessed()) {
643 if (defined('PATH_TO_GHOSTSCRIPT') && PATH_TO_GHOSTSCRIPT !== "") {
644 $this->upload->register(new ilCountPDFPagesPreProcessors());
645 }
646
647 $this->upload->process();
648 }
649 }
Class ilCountPDFPagesPreProcessors.

Referenced by getUploadFile().

+ Here is the caller graph for this function:

◆ raiseUploadError()

ilObjFile::raiseUploadError (   $raise = false)

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

630 {
631 // we no longer support that
632 }

◆ replaceFile()

ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)
Parameters
$a_upload_file
$a_filename
Returns
\ILIAS\FileUpload\DTO\UploadResult
Exceptions

ILIAS\FileUpload\Collection\Exception\NoSuchElementException

Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

Deprecated:

Implements ilObjFileImplementationInterface.

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

636 {
637 return null;
638 }

◆ replaceWithStream()

ilObjFile::replaceWithStream ( FileStream  $stream,
string  $title 
)
Exceptions
FileNamePolicyException

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

222 : int
223 {
224 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
225 $revision = $this->manager->replaceWithStream($i, $stream, $this->stakeholder, $title);
226 } else {
227 throw new LogicException('only files with existing resource and revision can be replaced');
228 }
229 $this->updateObjectFromRevision($revision);
230
231 return $revision->getVersionNumber();
232 }

References $i, ilObject\$title, getResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ replaceWithUpload()

ilObjFile::replaceWithUpload ( UploadResult  $result,
string  $title 
)
Exceptions
FileNamePolicyException

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

237 : int
238 {
239 $title = $this->appendSuffixToTitle($title, $result->getName());
240 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
241 $revision = $this->manager->replaceWithUpload($i, $result, $this->stakeholder, $title);
242 } else {
243 throw new LogicException('only files with existing resource and revision can be replaced');
244 }
245 if ($result->getMetaData()->has(ilCountPDFPagesPreProcessors::PAGE_COUNT)) {
247 }
248 $this->updateObjectFromRevision($revision);
249
250 return $revision->getVersionNumber();
251 }

References $i, $result, ilObject\$title, appendSuffixToTitle(), ILIAS\FileUpload\DTO\UploadResult\getMetaData(), getResourceId(), ilCountPDFPagesPreProcessors\PAGE_COUNT, setPageCount(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ rollback()

ilObjFile::rollback ( int  $version_id)

Makes the specified version the current one.

Parameters
int$version_idThe id of the version to make the current one.

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

761 : void
762 {
763 if ($this->getResourceId() && $i = $this->manager->find($this->getResourceId())) {
764 $this->manager->rollbackRevision($i, $version_id);
765 $latest_revision = $this->manager->getCurrentRevision($i);
766 $this->updateObjectFromRevision($latest_revision);
767 } else {
768 throw new LogicException('only files with existing resource and revision can be replaced');
769 }
770 }

References $i, getResourceId(), and updateObjectFromRevision().

+ Here is the call graph for this function:

◆ sendFile()

ilObjFile::sendFile (   $a_hist_entry_id = null)
Parameters
null$a_hist_entry_id
Returns
bool

Implements ilObjFileImplementationInterface.

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

699 : void
700 {
701 $this->implementation->sendFile($a_hist_entry_id);
702 }

◆ setAction()

ilObjFile::setAction (   $a_action)
Parameters
$a_action
Deprecated:

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

415 {
416 $this->action = $a_action;
417 }

◆ setFileName()

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

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

290 {
291 $this->filename = $a_name;
292 }

Referenced by updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ setFileSize()

ilObjFile::setFileSize (   $a_size)
Parameters
$a_size

Implements ilObjFileImplementationInterface.

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

347 {
348 $this->filesize = $a_size;
349 }

Referenced by updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ setFileType()

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

Implements ilObjFileImplementationInterface.

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

363 {
364 $this->filetype = $a_type;
365 }

Referenced by updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ setMaxVersion()

ilObjFile::setMaxVersion (   $a_max_version)
Parameters
$a_max_version
Deprecated:

Implements ilObjFileImplementationInterface.

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

381 {
382 $this->max_version = $a_max_version;
383 }

Referenced by initImplementation(), and updateObjectFromRevision().

+ Here is the caller graph for this function:

◆ setMode()

ilObjFile::setMode (   $a_mode)
Parameters
$a_modeself::MODE_FILELIST or self::MODE_OBJECT

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

334 {
335 $this->mode = $a_mode;
336 }

◆ setPageCount()

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

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

397 {
398 $this->page_count = $page_count;
399 }

References $page_count.

Referenced by appendUpload(), and replaceWithUpload().

+ Here is the caller graph for this function:

◆ setRating()

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

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

298 {
299 $this->rating = (bool) $a_value;
300 }

◆ setResourceId()

ilObjFile::setResourceId ( ?string  $resource_id)
Parameters
string | null$resource_id
Returns
ilObjFile

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

306 : ilObjFile
307 {
308 $this->resource_id = $resource_id;
309 return $this;
310 }
Class ilObjFile.

References $resource_id.

Referenced by appendStream(), and appendUpload().

+ Here is the caller graph for this function:

◆ setVersion()

ilObjFile::setVersion (   $a_version)
Parameters
$a_version
Deprecated:

Implements ilObjFileImplementationInterface.

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

274 {
275 $this->version = $a_version;
276 }

Referenced by initImplementation(), storeUnzipedFile(), and updateObjectFromRevision().

+ 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
Deprecated:

Implements ilObjFileImplementationInterface.

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

731 {
732 $this->setVersion($this->getVersion() + 1);
733
734 if (@!is_dir($this->getDirectory($this->getVersion()))) {
735 ilUtil::makeDir($this->getDirectory($this->getVersion()));
736 }
737
738 $file = $this->getDirectory($this->getVersion()) . "/" . $a_filename;
739
740 $file = ilFileUtils::getValidFilename($file);
741
742 ilFileUtils::rename($a_upload_file, $file);
743
744 // create preview
745 $this->createPreview();
746 }
static getValidFilename($a_filename)
Get valid filename.
static rename($a_source, $a_target)
Rename a file.
getDirectory($a_version=0)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References getDirectory(), ilFileUtils\getValidFilename(), getVersion(), ilUtil\makeDir(), ilFileUtils\rename(), and setVersion().

+ Here is the call graph for this function:

◆ updateObjectFromRevision()

ilObjFile::updateObjectFromRevision ( Revision  $r,
bool  $create_previews = true 
)
private

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

153 : void
154 {
155 $this->setTitle($r->getTitle());
156 $this->setFileName($r->getInformation()->getTitle());
157 $this->setVersion($r->getVersionNumber());
158 $this->setMaxVersion($r->getVersionNumber());
159 $this->setFileSize($r->getInformation()->getSize());
160 $this->setFileType($r->getInformation()->getMimeType());
161 $this->update();
162 if ($create_previews) {
163 $this->createPreview(true);
164 }
165 }
setFileSize($a_size)
setFileType($a_type)
setFileName($a_name)
update()
update object in db

References ILIAS\ResourceStorage\Revision\Revision\getInformation(), ILIAS\ResourceStorage\Revision\Revision\getTitle(), ILIAS\ResourceStorage\Revision\Revision\getVersionNumber(), setFileName(), setFileSize(), setFileType(), setMaxVersion(), ilObject2\setTitle(), setVersion(), and ilObject2\update().

Referenced by appendStream(), appendUpload(), replaceWithStream(), replaceWithUpload(), and rollback().

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

Field Documentation

◆ $action

ilObjFile::$action
protected

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

Referenced by getAction().

◆ $filename

ilObjFile::$filename = ''
protected

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

Referenced by appendSuffixToTitle(), and getFileName().

◆ $filesize

ilObjFile::$filesize
protected

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

Referenced by getFileSize().

◆ $filetype

ilObjFile::$filetype = ''
protected

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

Referenced by getFileType().

◆ $implementation

ilObjFile::$implementation
protected

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

◆ $log

ilObjFile::$log
protected

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

◆ $manager

ilObjFile::$manager
protected

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

◆ $max_version

ilObjFile::$max_version = 1
protected

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

Referenced by getMaxVersion().

◆ $mode

ilObjFile::$mode = self::MODE_OBJECT

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

Referenced by getMode().

◆ $page_count

ilObjFile::$page_count = 0
protected

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

Referenced by getPageCount(), and setPageCount().

◆ $rating

ilObjFile::$rating = false
protected

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

Referenced by hasRating().

◆ $resource_id

ilObjFile::$resource_id
protected

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

Referenced by setResourceId().

◆ $stakeholder

ilObjFile::$stakeholder
protected

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

◆ $upload

ilObjFile::$upload
protected

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

Referenced by getUploadFile().

◆ $version

ilObjFile::$version = 1
protected

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

Referenced by getVersion().

◆ MODE_FILELIST

const ilObjFile::MODE_FILELIST = "filelist"

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

◆ MODE_OBJECT

const ilObjFile::MODE_OBJECT = "object"

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


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