ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDiskQuotaHandler Class Reference

Class ilDiskQuotaHandler. More...

+ Collaboration diagram for ilDiskQuotaHandler:

Static Public Member Functions

static handleUpdatedSourceObject ($a_src_obj_type, $a_src_obj_id, $a_src_filesize, $a_owner_obj_ids=null, $a_is_prtf=false)
 Find and update/create all related entries for source object.
static deleteByOwner ($a_owner_id)
 Delete all entries for owner.
static getFilesizeByOwner ($a_owner_id)
 Get current storage size for owner.
static getFilesizeByTypeAndOwner ($a_owner_id)
 Get current storage size for owner (grouped by type)
static isUploadPossible ($a_additional_size=null)
static getStatusLegend ()

Static Protected Member Functions

static deleteEntry ($a_owner_id, $a_src_obj_type, $a_src_obj_id)
 Delete entry for owner and source object.
static getOwnersBySourceObject ($a_src_obj_type, $a_src_obj_id)
 Get owner ids by source object.
static getSourceObjectsByOwner ($a_owner_id)
 Get all source objects for owner.
static handleEntry ($a_owner_id, $a_src_obj_type, $a_src_obj_id, $a_src_filesize)
 Update/create owner-related entry of source object.

Detailed Description

Class ilDiskQuotaHandler.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilObjFile.php 40384 2013-03-06 13:08:21Z sborn

Definition at line 12 of file class.ilDiskQuotaHandler.php.

Member Function Documentation

static ilDiskQuotaHandler::deleteByOwner (   $a_owner_id)
static

Delete all entries for owner.

Parameters
int$a_owner_id

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

Referenced by ilObjUser\delete().

{
global $ilDB;
$ilDB->manipulate("DELETE FROM il_disk_quota".
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::deleteEntry (   $a_owner_id,
  $a_src_obj_type,
  $a_src_obj_id 
)
staticprotected

Delete entry for owner and source object.

Parameters
int$a_owner_id
string$a_src_obj_type
int$a_src_obj_id

Definition at line 80 of file class.ilDiskQuotaHandler.php.

Referenced by handleUpdatedSourceObject().

{
global $ilDB;
$ilDB->manipulate("DELETE FROM il_disk_quota".
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
" AND src_type = ".$ilDB->quote($a_src_obj_type, "text").
" AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::getFilesizeByOwner (   $a_owner_id)
static

Get current storage size for owner.

Parameters
int$a_owner_id
Returns
int

Definition at line 194 of file class.ilDiskQuotaHandler.php.

References $row.

Referenced by getStatusLegend(), ilObjUserGUI\initForm(), and isUploadPossible().

{
global $ilDB;
$set = $ilDB->query("SELECT sum(src_size) fsize".
" FROM il_disk_quota".
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
$row = $ilDB->fetchAssoc($set);
return (int)$row["fsize"];
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::getFilesizeByTypeAndOwner (   $a_owner_id)
static

Get current storage size for owner (grouped by type)

Parameters
int$a_owner_id
Returns
int

Definition at line 211 of file class.ilDiskQuotaHandler.php.

References $res, and $row.

Referenced by ilObjUserGUI\initForm().

{
global $ilDB;
$res = array();
$set = $ilDB->query("SELECT sum(src_size) filesize, src_type, COUNT(*) count".
" FROM il_disk_quota".
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
" GROUP BY src_type");
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row;
}
return $res;
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::getOwnersBySourceObject (   $a_src_obj_type,
  $a_src_obj_id 
)
staticprotected

Get owner ids by source object.

Parameters
string$a_src_obj_type
int$a_src_obj_id
Returns
array

Definition at line 110 of file class.ilDiskQuotaHandler.php.

References $res, and $row.

Referenced by handleUpdatedSourceObject().

{
global $ilDB;
$res = array();
$set = $ilDB->query("SELECT owner_id".
" FROM il_disk_quota".
" WHERE src_type = ".$ilDB->quote($a_src_obj_type, "text").
" AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row["owner_id"];
}
return $res;
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::getSourceObjectsByOwner (   $a_owner_id)
staticprotected

Get all source objects for owner.

Parameters
int$a_owner_id
Returns
array

Definition at line 134 of file class.ilDiskQuotaHandler.php.

References $res, and $row.

Referenced by handleEntry().

{
global $ilDB;
$res = array();
$set = $ilDB->query("SELECT src_type, src_obj_id".
" FROM il_disk_quota".
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$res[$row["src_type"]][] = $row["src_obj_id"];
}
return $res;
}

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::getStatusLegend ( )
static

Definition at line 259 of file class.ilDiskQuotaHandler.php.

References $ilUser, $lng, ilDiskQuotaActivationChecker\_isPersonalWorkspaceActive(), ilDiskQuotaChecker\_lookupPersonalWorkspaceDiskQuota(), ilFormat\formatSize(), and getFilesizeByOwner().

Referenced by ilImageFileInputGUI\insert(), ilDragDropFileInputGUI\render(), and ilFileInputGUI\render().

{
global $ilUser, $lng;
include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
{
return;
}
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
$usage = ilDiskQuotaHandler::getFilesizeByOwner($ilUser->getId());
include_once "Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
$quota = $quota["disk_quota"];
// administrator
if(is_infinite($quota) || !(int)$quota)
{
return;
}
$lng->loadLanguageModule("file");
return sprintf($lng->txt("personal_workspace_quota_status_legend"),
$quota ? round($usage/$quota*100) : 0);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::handleEntry (   $a_owner_id,
  $a_src_obj_type,
  $a_src_obj_id,
  $a_src_filesize 
)
staticprotected

Update/create owner-related entry of source object.

Parameters
int$a_owner_id
int$a_src_obj_type
int$a_src_obj_id
int$a_src_filesize

Definition at line 159 of file class.ilDiskQuotaHandler.php.

References getSourceObjectsByOwner().

Referenced by handleUpdatedSourceObject().

{
global $ilDB;
$existing = self::getSourceObjectsByOwner($a_owner_id);
// update
if($existing &&
isset($existing[$a_src_obj_type]) &&
in_array($a_src_obj_id, $existing[$a_src_obj_type]))
{
$ilDB->manipulate("UPDATE il_disk_quota".
" SET src_size = ".$ilDB->quote($a_src_filesize, "integer").
" WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
" AND src_type = ".$ilDB->quote($a_src_obj_type, "text").
" AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
}
// insert
else
{
$ilDB->manipulate("INSERT INTO il_disk_quota".
" (owner_id, src_type, src_obj_id, src_size)".
" VALUES (".$ilDB->quote($a_owner_id, "integer").
", ".$ilDB->quote($a_src_obj_type, "text").
", ".$ilDB->quote($a_src_obj_id, "integer").
", ".$ilDB->quote($a_src_filesize, "integer").")");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::handleUpdatedSourceObject (   $a_src_obj_type,
  $a_src_obj_id,
  $a_src_filesize,
  $a_owner_obj_ids = null,
  $a_is_prtf = false 
)
static

Find and update/create all related entries for source object.

Parameters
string$a_src_obj_type
int$a_src_obj_id
int$a_src_filesize
array$a_owner_obj_ids

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

References $row, deleteEntry(), getOwnersBySourceObject(), and handleEntry().

Referenced by ilObjPortfolio\handleQuotaUpdate(), ilVerificationObject\handleQuotaUpdate(), ilObjMediaObject\handleQuotaUpdate(), ilObjBlog\handleQuotaUpdate(), and ilObjFile\handleQuotaUpdate().

{
global $ilDB;
$done = array();
if(is_array($a_owner_obj_ids) && sizeof($a_owner_obj_ids) && (int)$a_src_filesize > 0)
{
// we are (currently) only interested in personal workspace objects
if(!$a_is_prtf)
{
$set = $ilDB->query("SELECT DISTINCT(od.owner)".
" FROM object_data od".
" JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)".
" JOIN tree_workspace t ON (t.child = ref.wsp_id)".
" WHERE ".$ilDB->in("od.obj_id", $a_owner_obj_ids, "", "integer").
" AND t.tree = od.owner");
}
else
{
$set = $ilDB->query("SELECT DISTINCT(od.owner)".
" FROM object_data od".
" JOIN usr_portfolio prtf ON (prtf.id = od.obj_id)".
" WHERE ".$ilDB->in("od.obj_id", $a_owner_obj_ids, "", "integer"));
}
while($row = $ilDB->fetchAssoc($set))
{
$done[] = $row["owner"];
$row["owner"],
$a_src_obj_type,
$a_src_obj_id,
(int)$a_src_filesize
);
}
}
// delete obsolete entries
$existing = self::getOwnersBySourceObject($a_src_obj_type, $a_src_obj_id);
$existing = array_diff($existing, $done);
if(sizeof($existing))
{
foreach($existing as $owner)
{
self::deleteEntry($owner, $a_src_obj_type, $a_src_obj_id);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilDiskQuotaHandler::isUploadPossible (   $a_additional_size = null)
static

Definition at line 229 of file class.ilDiskQuotaHandler.php.

References $ilUser, ilDiskQuotaActivationChecker\_isPersonalWorkspaceActive(), ilDiskQuotaChecker\_lookupPersonalWorkspaceDiskQuota(), and getFilesizeByOwner().

Referenced by ilObjTestVerificationGUI\create(), ilObjExerciseVerificationGUI\create(), ilObjCourseVerificationGUI\create(), ilObjSCORMVerificationGUI\create(), ilObjPortfolioGUI\initCreatePortfolioFromTemplateForm(), ilObjFileGUI\initCreationForms(), ilObjFileGUI\initPropertiesForm(), ilImageFileInputGUI\insert(), ilDragDropFileInputGUI\render(), and ilFileInputGUI\render().

{
global $ilUser;
include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
{
return true;
}
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
$usage = ilDiskQuotaHandler::getFilesizeByOwner($ilUser->getId());
if($a_additional_size)
{
$usage += $a_additional_size;
}
include_once "Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
$quota = $quota["disk_quota"];
// administrator
if(is_infinite($quota))
{
return true;
}
return $usage < $quota;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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