ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjFile Class Reference

Class ilObjFile. More...

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

Public Member Functions

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

Static Public Member Functions

static _lookupAbsolutePath ($obj_id, $a_version=null)
 return absolute path for version
- Static Public Member Functions inherited from ilObject2
static _lookupObjIdByImportId ($a_import_id)
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupDescription ($a_id)
 lookup object description
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
static _lookupObjectId ($a_ref_id)
 lookup object id
static _exists ($a_id, $a_reference=false)
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
- Static Public Member Functions inherited from ilObject
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB.
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.
static getLongDescriptions (array $a_obj_ids)
 Get long description data.
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns.
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course.

Data Fields

 $filename
 $filetype
 $filemaxsize = "20000000"
 $raise_upload_error
 $mode = "object"

Protected Member Functions

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

Static Protected Member Functions

static handleQuotaUpdate (ilObjFile $a_file)

Protected Attributes

 $rating

Private Attributes

 $file_storage = null

Detailed Description

Class ilObjFile.

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilObjFile.php 56929 2015-01-08 15:31:22Z jluetzen

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

Constructor & Destructor Documentation

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

Constructor public.

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

Reimplemented from ilObject2.

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

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

{
$this->version = 0;
$this->raise_upload_error = true;
parent::__construct($a_id,$a_call_by_reference);
if($this->getId())
{
$this->initFileStorage();
}
}

+ Here is the call graph for this function:

Member Function Documentation

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

static delete all usages of

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

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

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

{
global $ilDB;
$and_hist = ($a_usage_hist_nr !== false)
? " AND usage_hist_nr = ".$ilDB->quote($a_usage_hist_nr, "integer")
: "";
$file_ids = array();
$set = $ilDB->query("SELECT id FROM file_usage".
" WHERE usage_type = ".$ilDB->quote($a_type, "text").
" AND usage_id= ".$ilDB->quote($a_id, "integer").
" AND usage_lang= ".$ilDB->quote($a_usage_lang, "text").
$and_hist);
while($row = $ilDB->fetchAssoc($set))
{
$file_ids[] = $row["id"];
}
$ilDB->manipulate("DELETE FROM file_usage WHERE usage_type = ".
$ilDB->quote($a_type, "text").
" AND usage_id = ".$ilDB->quote((int) $a_id, "integer").
" AND usage_lang= ".$ilDB->quote($a_usage_lang, "text").
" AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer"));
foreach($file_ids as $file_id)
{
self::handleQuotaUpdate(new self($file_id, false));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

get all files of an object

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

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

References $ilDB, and $ret.

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

{
global $ilDB;
// get usages in learning modules
$q = "SELECT * FROM file_usage WHERE ".
"usage_id = ".$ilDB->quote((int) $a_id, "integer")." AND ".
"usage_type = ".$ilDB->quote((string) $a_type, "text")." AND ".
"usage_lang = ".$ilDB->quote((string) $a_usage_lang, "text")." AND ".
"usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer");
$file_set = $ilDB->query($q);
$ret = array();
while($file_rec = $ilDB->fetchAssoc($file_set))
{
$ret[$file_rec["id"]] = $file_rec["id"];
}
return $ret;
}

+ Here is the caller graph for this function:

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

return absolute path for version

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

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

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

{
$version_subdir = "";
if (!is_numeric($a_version))
{
$a_version = ilObjFile::_lookupVersion ($obj_id);
}
$version_subdir = DIRECTORY_SEPARATOR.sprintf("%03d", $a_version);
return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::_lookupFileName (   $a_id)

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

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

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

{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,'integer');
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
return ilUtil::stripSlashes($row->file_name);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::_lookupFileSize (   $a_id)

Lookups the file size of the file in bytes.

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

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

{
require_once("./Modules/File/classes/class.ilObjFileAccess.php");
}

+ Here is the caller graph for this function:

ilObjFile::_lookupVersion (   $a_id)

lookup version

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

Referenced by _lookupAbsolutePath().

{
require_once("./Modules/File/classes/class.ilObjFileAccess.php");
}

+ Here is the caller graph for this function:

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

save usage

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

References $ilDB, and handleQuotaUpdate().

Referenced by ilPCFileList\saveFileUsage().

{
global $ilDB;
/*
$ilDB->manipulate("DELETE FROM file_usage WHERE usage_type = ".
$ilDB->quote((string) $a_type, "text").
" AND usage_id = ".$ilDB->quote((int) $a_id, "integer").
" AND usage_lang = ".$ilDB->quote($a_usage_lang, "text").
" AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer").
" AND id = ".$ilDB->quote((int) $a_file_id, "integer"));
$ilDB->manipulate("INSERT INTO file_usage (id, usage_type, usage_id, usage_hist_nr, usage_lang) VALUES".
" (".$ilDB->quote((int) $a_file_id, "integer").",".
$ilDB->quote((string) $a_type, "text").",".
$ilDB->quote((int) $a_id, "integer").",".
$ilDB->quote((int) $a_usage_hist_nr, "integer").",".
$ilDB->quote($a_usage_lang, "text").
")");
*/
// #15143
$ilDB->replace("file_usage",
array(
"id" => array("integer", (int) $a_file_id),
"usage_type" => array("text", (string) $a_type),
"usage_id" => array("integer", (int) $a_id),
"usage_hist_nr" => array("integer", (int) $a_usage_hist_nr),
"usage_lang" => array("text", $a_usage_lang)
),
array()
);
self::handleQuotaUpdate(new self($a_file_id, false));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::_writeFileType (   $a_id,
  $a_format 
)

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

References $ilDB, and $res.

Referenced by doMDUpdateListener().

{
global $ilDB;
$q = "UPDATE file_data SET ".
" file_type = ".$ilDB->quote($a_format ,'text').
" WHERE file_id = ".$ilDB->quote($a_id ,'integer');
$res = $ilDB->manipulate($q);
}

+ Here is the caller graph for this function:

ilObjFile::addFileVersion (   $a_upload_file,
  $a_filename 
)

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

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

{
$this->getUploadFile($a_upload_file, $a_filename, true);
require_once("./Services/History/classes/class.ilHistory.php");
$this->getId(),
"new_version",
$a_filename.",".$this->getVersion()
);
$this->setFilename($a_filename);
$this->addNewsNotification("file_updated");
// create preview
$this->createPreview($this->getVersion() > 1);
}

+ Here is the call graph for this function:

ilObjFile::addNewsNotification (   $a_lang_var)

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

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

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

{
// BEGIN WebDAV Suppress news notification for hidden files
if ($this->isHidden()) {
return;
}
// END WebDAV Suppress news notification for hidden files
global $ilUser;
// Add Notification to news
include_once("./Services/News/classes/class.ilNewsItem.php");
include_once("./Modules/File/classes/class.ilObjFileAccess.php");
$news_item = new ilNewsItem();
$news_item->setContext($this->getId(), $this->getType());
$news_item->setPriority(NEWS_NOTICE);
$news_item->setTitle($a_lang_var);
$news_item->setContentIsLangVar(true);
if ($this->getDescription() != "")
{
$news_item->setContent(
"<p>".
$this->getDescription()."</p>");
}
$news_item->setUserId($ilUser->getId());
$news_item->setVisibility(NEWS_USERS);
$news_item->create();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::beforeDelete ( )
protected

Reimplemented from ilObject2.

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

References $ilDB, and getUsages().

{
global $ilDB;
// check, if file is used somewhere
$usages = $this->getUsages();
if (count($usages) == 0)
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilObjFile::beforeMDUpdateListener (   $a_element)
protected

Reimplemented from ilObject2.

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

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

{
// Check file extension
// Removing the file extension is not allowed
include_once 'Services/MetaData/classes/class.ilMD.php';
$md = new ilMD($this->getId(),0, $this->getType());
if(!is_object($md_gen = $md->getGeneral()))
{
return false;
}
$title = $this->checkFileExtension($this->getFileName(), $md_gen->getTitle());
$md_gen->setTitle($title);
$md_gen->update();
return true;
}

+ Here is the call graph for this function:

ilObjFile::beforeUpdate ( )
protected

Reimplemented from ilObject2.

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

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

{
// no meta data handling for file list files
if ($this->getMode() != "filelist")
{
$this->updateMetaData();
}
return true;
}

+ Here is the call graph for this function:

ilObjFile::checkFileExtension (   $new_filename,
  $new_title 
)

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

Returns

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

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

Referenced by beforeMDUpdateListener(), and updateWithVersion().

{
include_once './Modules/File/classes/class.ilObjFileAccess.php';
$fileExtension = ilObjFileAccess::_getFileExtension($new_filename);
$titleExtension = ilObjFileAccess::_getFileExtension($new_title);
if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
{
// remove old extension
$pi = pathinfo($this->getFileName());
$suffix = $pi["extension"];
if ($suffix != "")
{
if (substr($new_title,
strlen($new_title) - strlen($suffix) - 1)
== ".".$suffix)
{
$new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
}
}
$new_title .= '.'.$fileExtension;
}
return $new_title;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::clearDataDirectory ( )

clear data directory

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

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

Referenced by deleteVersions().

{
$this->createDirectory();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
// v2 - v1 because version should be descending
return (int)$v2["version"] - (int)$v1["version"];
}
ilObjFile::copy (   $a_source,
  $a_destination 
)

copy file

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

References getDirectory().

Referenced by rollback().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::createDirectory ( )

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

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

Referenced by clearDataDirectory().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References getMode().

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

{
// only normal files are supported
if ($this->getMode() != "object")
return;
require_once("./Services/Preview/classes/class.ilPreview.php");
ilPreview::createPreview($this, $force);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::createProperties (   $a_upload = false,
  $a_prevent_meta_data_creation = false 
)

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

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

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

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

Referenced by doCreate().

{
global $ilDB,$tree;
// Create file directory
$this->initFileStorage();
$this->file_storage->create();
if($a_upload)
{
return true;
}
// not upload mode
require_once("./Services/History/classes/class.ilHistory.php");
ilHistory::_createEntry($this->getId(), "create", $this->getFileName().",1");
$this->addNewsNotification("file_created");
require_once("./Services/News/classes/class.ilNewsItem.php");
$default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
if ($default_visibility == "public")
{
ilBlockSetting::_write("news", "public_notifications",
1, 0, $this->getId());
}
$q = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) "
."VALUES (".$ilDB->quote($this->getId() ,'integer').","
.$ilDB->quote($this->getFileName() ,'text').","
.$ilDB->quote($this->getFileType() ,'text').","
.$ilDB->quote((int) $this->getFileSize() ,'integer').","
.$ilDB->quote(1 ,'integer').",".$ilDB->quote($this->getMode() ,'text').")";
$res = $ilDB->manipulate($q);
// no meta data handling for file list files
if ($this->getMode() != "filelist" && !$a_prevent_meta_data_creation)
{
$this->createMetaData();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::deletePreview ( )
protected

Deletes the preview of the file object.

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

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

Referenced by doDelete().

{
// only normal files are supported
if ($this->getMode() != "object")
return;
require_once("./Services/Preview/classes/class.ilPreview.php");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::deleteVersions (   $a_hist_entry_ids = null)

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

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

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

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

{
global $ilDB;
require_once("./Services/History/classes/class.ilHistory.php");
if ($a_hist_entry_ids == null || count($a_hist_entry_ids) < 1)
{
$ilDB->manipulate("UPDATE file_data SET version = 1 WHERE file_id = ".$ilDB->quote($this->getId() ,'integer'));
$this->setVersion(0);
}
else
{
$actualVersionDeleted = false;
// get all versions
$versions = $this->getVersions();
// delete each version
foreach ($a_hist_entry_ids as $hist_id)
{
$entry = null;
// get version
foreach ($versions as $index => $version)
{
if ($version["hist_entry_id"] == $hist_id)
{
// remove each history entry
// delete directory
$version_dir = $this->getDirectory($version["version"]);
ilUtil::delDir($version_dir);
// is actual version?
if ($version["version"] == $this->getVersion())
$actualVersionDeleted = true;
// remove from array
unset($versions[$index]);
break;
}
}
}
// update actual version if it was deleted before
if ($actualVersionDeleted)
{
// get newest version (already sorted by getVersions)
$version = reset($versions);
$this->updateWithVersion($version);
}
else
{
// updateWithVersion() will trigger quota, too
}
}
}

+ Here is the call graph for this function:

ilObjFile::determineFileSize (   $a_hist_entry_id = null)

Determine File Size.

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

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

Referenced by updateWithVersion().

{
if (is_null($a_hist_entry_id))
{
$file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
}
else
{
require_once("./Services/History/classes/class.ilHistory.php");
$entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
if ($entry === false)
{
return false;
}
$data = $this->parseInfoParams($entry);
$file = $this->getDirectory($data["version"])."/".$data["filename"];
}
if (is_file($file))
{
$this->setFileSize(filesize($file));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Clone.

public

Parameters
objectclone
inttarget id
intcopy id

Reimplemented from ilObject2.

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

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

{
global $ilDB;
$a_new_obj->createDirectory();
$this->cloneMetaData($a_new_obj);
// Copy all file versions
ilUtil::rCopy($this->getDirectory(),$a_new_obj->getDirectory());
// object created now copy other settings
$query = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,rating,f_mode) VALUES (".
$ilDB->quote($a_new_obj->getId() ,'integer').",".
$ilDB->quote($this->getFileName() ,'text').",".
$ilDB->quote($this->getFileType() ,'text').",".
$ilDB->quote((int) $this->getFileSize() ,'integer').", ".
$ilDB->quote($this->getVersion() ,'integer').", ".
$ilDB->quote($this->hasRating() ,'integer').", ".
$ilDB->quote($this->getMode() ,'text').")";
$res = $ilDB->manipulate($query);
// copy all previews
require_once("./Services/Preview/classes/class.ilPreview.php");
ilPreview::copyPreviews($this->getId(), $a_new_obj->getId());
// copy history entries
require_once("./Services/History/classes/class.ilHistory.php");
ilHistory::_copyEntriesForObject($this->getId(),$a_new_obj->getId());
// add news notification
$a_new_obj->addNewsNotification("file_created");
return $a_new_obj;
}

+ Here is the call graph for this function:

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

create object

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

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

References createProperties().

{
//BEGIN WebDAV Move Property creation into a method of its own.
$this->createProperties($a_upload);
//END WebDAV Move Property creation into a method of its own.
}

+ Here is the call graph for this function:

ilObjFile::doCreateMetaData ( )
protected

create file object meta data

Reimplemented from ilObject2.

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

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

{
// add technical section with file size and format
$md_obj =& new ilMD($this->getId(),0,$this->getType());
$technical = $md_obj->addTechnical();
$technical->setSize($this->getFileSize());
$technical->save();
$format = $technical->addFormat();
$format->setFormat($this->getFileType());
$format->save();
$technical->update();
}

+ Here is the call graph for this function:

ilObjFile::doDelete ( )
protected

Reimplemented from ilObject2.

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

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

{
global $ilDB;
// delete file data entry
$q = "DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
$this->ilias->db->query($q);
// delete history entries
require_once("./Services/History/classes/class.ilHistory.php");
// delete entire directory and its content
if (@is_dir($this->getDirectory()))
{
}
// delete meta data
if ($this->getMode() != "filelist")
{
$this->deleteMetaData();
}
// delete preview
$this->deletePreview();
}

+ Here is the call graph for this function:

ilObjFile::doMDUpdateListener (   $a_element)
protected

Reimplemented from ilObject2.

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

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

{
// handling for technical section
include_once 'Services/MetaData/classes/class.ilMD.php';
//echo "-".$a_element."-";
switch($a_element)
{
case 'Technical':
// Update Format (size is not stored in db)
$md = new ilMD($this->getId(),0, $this->getType());
if(!is_object($md_technical = $md->getTechnical()))
{
return false;
}
foreach($md_technical->getFormatIds() as $id)
{
$md_format = $md_technical->getFormat($id);
ilObjFile::_writeFileType($this->getId(),$md_format->getFormat());
$this->setFileType($md_format->getFormat());
break;
}
break;
}
return true;
}

+ Here is the call graph for this function:

ilObjFile::doRead ( )
protected

read file properties

Reimplemented from ilObject2.

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

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

{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
$r = $this->ilias->db->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
$this->setFileName($row->file_name);
$this->setFileType($row->file_type);
$this->setFileSize($row->file_size);
$this->setVersion($row->version);
$this->setMode($row->f_mode);
$this->setRating($row->rating);
$this->initFileStorage();
}

+ Here is the call graph for this function:

ilObjFile::doUpdate ( )
protected

update file

Reimplemented from ilObject2.

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

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

{
global $ilDB, $ilLog;
//$ilLog->write(__METHOD__.' File type: '.$this->getFileType());
$q = "UPDATE file_data SET file_name = ".$ilDB->quote($this->getFileName() ,'text').
", file_type = ".$ilDB->quote($this->getFiletype() ,'text')." ".
", file_size = ".$ilDB->quote((int) $this->getFileSize() ,'integer')." ".
", version = ".$ilDB->quote($this->getVersion() ,'integer')." ".
", f_mode = ".$ilDB->quote($this->getMode() ,'text')." ".
", rating = ".$ilDB->quote($this->hasRating() ,'integer')." ".
"WHERE file_id = ".$ilDB->quote($this->getId() ,'integer');
$res = $ilDB->manipulate($q);
return true;
}

+ Here is the call graph for this function:

ilObjFile::doUpdateMetaData ( )
protected

update meta data

Reimplemented from ilObject2.

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

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

{
// add technical section with file size and format
$md_obj =& new ilMD($this->getId(),0,$this->getType());
if(!is_object($technical = $md_obj->getTechnical()))
{
$technical = $md_obj->addTechnical();
$technical->save();
}
$technical->setSize($this->getFileSize());
$format_ids = $technical->getFormatIds();
if (count($format_ids) > 0)
{
$format = $technical->getFormat($format_ids[0]);
$format->setFormat($this->getFileType());
$format->update();
}
else
{
$format = $technical->addFormat();
$format->setFormat($this->getFileType());
$format->save();
}
$technical->update();
}

+ Here is the call graph for this function:

ilObjFile::export (   $a_target_dir)

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

Parameters
string$a_target_dirtarget directory

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

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

{
$subdir = "il_".IL_INST_ID."_file_".$this->getId();
ilUtil::makeDir($a_target_dir."/objects/".$subdir);
$filedir = $this->getDirectory($this->getVersion());
if (@!is_dir($filedir))
{
$filedir = $this->getDirectory();
}
ilUtil::rCopy($filedir, $a_target_dir."/objects/".$subdir);
}

+ Here is the call graph for this function:

ilObjFile::getDirectory (   $a_version = 0)

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

References initFileStorage().

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

{
$version_subdir = "";
if ($a_version)
{
// BEGIN WebDAV Avoid double slash before version subdirectory
$version_subdir = sprintf("%03d", $a_version);
// END WebDAV Avoid double slash before version subdirectory
}
if(!is_object($this->file_storage))
{
$this->initFileStorage();
}
return $this->file_storage->getAbsolutePath().'/'.$version_subdir;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::getDiskUsage ( )

Gets the disk usage of the object in bytes.

public

Returns
integer the disk usage in bytes

Reimplemented from ilObject.

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

References ilObjFileAccess\_lookupDiskUsage().

Referenced by handleQuotaUpdate().

{
require_once("./Modules/File/classes/class.ilObjFileAccess.php");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::getFile (   $a_hist_entry_id = null)

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

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

{
if (is_null($a_hist_entry_id))
{
$file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
}
else
{
require_once("./Services/History/classes/class.ilHistory.php");
$entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
if ($entry === false)
{
return false;
}
$data = $this->parseInfoParams($entry);
$file = $this->getDirectory($data["version"])."/".$data["filename"];
}
return $file;
}

+ Here is the call graph for this function:

ilObjFile::getFileExtension ( )

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

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

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

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

{
require_once 'Modules/File/classes/class.ilObjFileAccess.php';
}

+ Here is the call graph for this function:

ilObjFile::getFileName ( )

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

References $filename.

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

{
}

+ Here is the caller graph for this function:

ilObjFile::getFileSize ( )

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

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

{
return $this->filesize;
}

+ Here is the caller graph for this function:

ilObjFile::getFileType ( )

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

References $filetype.

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

{
}

+ Here is the caller graph for this function:

ilObjFile::getMode ( )

mode is object or filelist

Returns
string mode

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

References $mode.

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

{
return $this->mode;
}

+ Here is the caller graph for this function:

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

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

Referenced by rollback().

{
include_once("./Services/History/classes/class.ilHistory.php");
$version = ilHistory::_getEntryByHistoryID($version_id);
if ($version === false)
return false;
// ilHistory returns different keys in _getEntryByHistoryID and _getEntriesForObject
// so this makes it the same
$version["hist_entry_id"] = $version["id"];
$version["user_id"] = $version["usr_id"];
$version["date"] = $version["hdate"];
unset($version["id"], $version["usr_id"], $version["hdate"]);
// parse params
$params = $this->parseInfoParams($version);
return array_merge($version, $params);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

Referenced by addFileVersion(), and replaceFile().

{
$this->setVersion($this->getVersion() + 1);
if (@!is_dir($this->getDirectory($this->getVersion())))
{
}
$file = $this->getDirectory($this->getVersion())."/".$a_filename;
//move_uploaded_file($a_upload_file, $file);
ilUtil::moveUploadedFile($a_upload_file, $a_filename, $file, $this->raise_upload_error);
$this->handleQuotaUpdate($this);
// create preview?
if (!$a_prevent_preview)
{
$this->createPreview(false);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::getUsages ( )

get all usages of file object

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

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

Referenced by beforeDelete(), and handleQuotaUpdate().

{
global $ilDB;
// get usages in learning modules
$q = "SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->getId(), "integer");
$us_set = $ilDB->query($q);
$ret = array();
while($us_rec = $ilDB->fetchAssoc($us_set))
{
$ret[] = array("type" => $us_rec["usage_type"],
"id" => $us_rec["usage_id"],
"lang" => $us_rec["usage_lang"],
"hist_nr" => $us_rec["usage_hist_nr"]);
}
return $ret;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::getVersion ( )

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

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

{
return $this->version;
}

+ Here is the caller graph for this function:

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

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

Referenced by deleteVersions().

{
include_once("./Services/History/classes/class.ilHistory.php");
$versions = ilHistory::_getEntriesForObject($this->getId(), $this->getType());
if ($version_ids != null && count($version_ids) > 0)
{
foreach ($versions as $index => $version)
{
if (!in_array($version["hist_entry_id"], $version_ids, true))
{
unset($versions[$index]);
}
}
}
// add custom entries
foreach ($versions as $index => $version)
{
$params = $this->parseInfoParams($version);
$versions[$index] = array_merge($version, $params);
}
// sort by version number (hist_entry_id will do for that)
usort($versions, array($this, "compareVersions"));
return $versions;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::getXMLZip ( )

Reimplemented from ilObject.

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

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

{
global $ilias;
$zip = PATH_TO_ZIP;
exec($zip.' '.ilUtil::escapeShellArg($this->getDirectory().'/'.$this->getFileName())." ".
ilUtil::escapeShellArg($this->getDirectory().'/'.'1.zip'));
return $this->getDirectory().'/1.zip';
}

+ Here is the call graph for this function:

ilObjFile::guessFileType (   $a_file = "")

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

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

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

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

Referenced by sendFile(), and updateWithVersion().

{
$path = pathinfo($a_file);
if ($path["extension"] != "")
{
$filename = $path["basename"];
}
else
{
$filename = "dummy.".$this->getFileExtension();
}
include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
$mime = ilMimeTypeUtil::getMimeType($a_file, $filename, $this->getFileType());
return $mime;
/*
$fileType = $this->getFileType();
if (strlen($fileType) == 0) {
$fileType = 'application/octet-stream';
}
// Firefox browser assigns 'application/x-pdf' to PDF files, but
// it can only handle them if the have the mime-type 'application/pdf'.
if ($fileType == 'application/x-pdf')
{
$fileType = 'application/pdf';
}
if ($fileType == 'application/octet-stream')
{
$fileExtension = $this->getFileExtension();
$mimeArray = array(
'mpeg' => 'video/mpeg',
'mp3' => 'audio/mpeg',
'pdf' => 'application/pdf',
'gif' => 'image/gif',
'jpg' => 'image/jpg',
'png' => 'image/png',
'htm' => 'text/html',
'html' => 'text/html',
'wma' => 'video/x-ms-wma',
'wmv' => 'video/x-ms-wmv',
'swf' => 'application/x-shockwave-flash',
);
if (array_key_exists($fileExtension, $mimeArray))
{
$fileType = $mimeArray[$fileExtension];
}
}
return $fileType;
*/
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjFile::handleQuotaUpdate ( ilObjFile  $a_file)
staticprotected

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

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

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

{
include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject();
// file itself could be workspace item
$parent_obj_ids = array($a_file->getId());
foreach($a_file->getUsages() as $item)
{
$parent_obj_id = $mob->getParentObjectIdForUsage($item);
if($parent_obj_id &&
!in_array($parent_obj_id, $parent_obj_ids))
{
$parent_obj_ids[]= $parent_obj_id;
}
}
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
$a_file->getId(),
$a_file->getDiskUsage(),
$parent_obj_ids);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::hasRating ( )

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

References $rating.

Referenced by doUpdate().

{
return $this->rating;
}

+ Here is the caller graph for this function:

ilObjFile::initFileStorage ( )

init file storage object

public

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

References ilObject2\getId().

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::initType ( )

Reimplemented from ilObject2.

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

{
$this->type = "file";
}
ilObjFile::isHidden ( )

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

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

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

Referenced by addNewsNotification().

{
require_once 'Modules/File/classes/class.ilObjFileAccess.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjFile::isInline ( )

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

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

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

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

Referenced by sendFile().

{
require_once 'Modules/File/classes/class.ilObjFileAccess.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $result.

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

{
$data = preg_split("/(.*),(.*)/", $entry["info_params"], 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
// bugfix: first created file had no version number
// this is a workaround for all files created before the bug was fixed
if (empty($data[1]))
$data[1] = "1";
$result = array("filename" => $data[0], "version" => $data[1], "rollback_version" => "", "rollback_user_id" => "");
// if rollback, the version contains the rollback version as well
if ($entry["action"] == "rollback")
{
$tokens = explode("|", $result["version"]);
if (count($tokens) > 1)
{
$result["version"] = $tokens[0];
$result["rollback_version"] = $tokens[1];
if (count($tokens) > 2)
$result["rollback_user_id"] = $tokens[2];
}
}
return $result;
}

+ Here is the caller graph for this function:

ilObjFile::raiseUploadError (   $a_raise = true)

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

{
$this->raise_upload_error = $a_raise;
}
ilObjFile::replaceFile (   $a_upload_file,
  $a_filename 
)

replace file with new file

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

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

{
$this->getUploadFile($a_upload_file, $a_filename, true);
require_once("./Services/History/classes/class.ilHistory.php");
$this->getId(),
"replace",
$a_filename.",".$this->getVersion()
);
$this->setFilename($a_filename);
$this->addNewsNotification("file_updated");
// create preview
$this->createPreview(true);
}

+ Here is the call graph for this function:

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

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

{
global $ilDB, $ilUser;
$source = $this->getSpecificVersion($version_id);
if ($source === false)
{
$this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
}
// get the new version number
$new_version_nr = $this->getVersion() + 1;
// copy file
$source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
$dest_dir = $this->getDirectory($new_version_nr);
if (@!is_dir($dest_dir))
ilUtil::makeDir($dest_dir);
copy($source_path, $dest_dir . "/" . $source["filename"]);
// create new history entry based on the old one
include_once("./Services/History/classes/class.ilHistory.php");
$this->getId(),
"rollback",
$source["filename"] . "," . $new_version_nr . "|" . $source["version"] . "|" . $ilUser->getId());
// get id of newest entry
$new_version = $this->getSpecificVersion($ilDB->getLastInsertId());
// change user back to the original uploader
ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
// update this file with the new version
$this->updateWithVersion($new_version);
$this->addNewsNotification("file_updated");
return $new_version;
}

+ Here is the call graph for this function:

ilObjFile::sendFile (   $a_hist_entry_id = null)

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

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

{
if (is_null($a_hist_entry_id))
{
$file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
// if not found lookup for file in file object's main directory for downward c ompability
if (@!is_file($file))
{
$file = $this->getDirectory()."/".$this->getFileName();
}
}
else
{
require_once("./Services/History/classes/class.ilHistory.php");
$entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
if ($entry === false)
{
echo "3";return false;
}
$data = $this->parseInfoParams($entry);
$file = $this->getDirectory($data["version"])."/".$data["filename"];
// if not found lookup for file in file object's main directory for downward compability
if (@!is_file($file))
{
$file = $this->getDirectory()."/".$data[0];
}
// BEGIN WebDAV removed duplicated code
// END WebDAV removed duplicated code
}
if (@is_file($file))
{
global $ilClientIniFile;
// also returning the 'real' filename if a history file is delivered
if ($ilClientIniFile->readVariable('file_access','download_with_uploaded_filename') != '1' && is_null($a_hist_entry_id))
{
}
else
{
ilUtil::deliverFile($file, basename($file), $this->guessFileType($file), $this->isInline());
}
return true;
}
return false;
}

+ Here is the call graph for this function:

ilObjFile::setFileName (   $a_name)

set filename

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

Referenced by doRead(), and updateWithVersion().

{
$this->filename = $a_name;
}

+ Here is the caller graph for this function:

ilObjFile::setFileSize (   $a_size)

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

Referenced by determineFileSize(), and doRead().

{
$this->filesize = $a_size;
}

+ Here is the caller graph for this function:

ilObjFile::setFileType (   $a_type)

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

References $ilLog.

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

{
global $ilLog;
$this->filetype = $a_type;
}

+ Here is the caller graph for this function:

ilObjFile::setMode (   $a_mode)

mode is object or filelist

Parameters
string$a_modemode

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

Referenced by doRead().

{
$this->mode = $a_mode;
}

+ Here is the caller graph for this function:

ilObjFile::setRating (   $a_value)

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

Referenced by doRead().

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

+ Here is the caller graph for this function:

ilObjFile::setVersion (   $a_version)

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

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

{
$this->version = $a_version;
}

+ Here is the caller graph for this function:

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

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

{
$this->setVersion($this->getVersion() + 1);
if (@!is_dir($this->getDirectory($this->getVersion())))
{
}
$file = $this->getDirectory($this->getVersion())."/".$a_filename;
//move_uploaded_file($a_upload_file, $file);
rename($a_upload_file, $file);
// create preview
$this->createPreview();
}

+ Here is the call graph for this function:

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

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

Referenced by deleteVersions(), and rollback().

{
// update title (checkFileExtension must be called before setFileName!)
$this->setTitle($this->checkFileExtension($version["filename"], $this->getTitle()));
$this->setVersion($version["version"]);
$this->setFileName($version["filename"]);
// evaluate mime type (reset file type before)
$this->setFileType("");
$this->setFileType($this->guessFileType($version["filename"]));
// set filesize
$this->update();
// refresh preview
$this->createPreview(true);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilObjFile::$file_storage = null
private

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

Referenced by _lookupAbsolutePath().

ilObjFile::$filemaxsize = "20000000"

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

ilObjFile::$filename

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

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

ilObjFile::$filetype

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

Referenced by getFileType().

ilObjFile::$mode = "object"

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

Referenced by getMode().

ilObjFile::$raise_upload_error

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

ilObjFile::$rating
protected

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

Referenced by hasRating().


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