ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. More...
 
static deleteByOwner ($a_owner_id)
 Delete all entries for owner. More...
 
static getFilesizeByOwner ($a_owner_id)
 Get current storage size for owner. More...
 
static getFilesizeByTypeAndOwner ($a_owner_id)
 Get current storage size for owner (grouped by type) More...
 
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. More...
 
static getOwnersBySourceObject ($a_src_obj_type, $a_src_obj_id)
 Get owner ids by source object. More...
 
static getSourceObjectsByOwner ($a_owner_id)
 Get all source objects for owner. More...
 
static handleEntry ($a_owner_id, $a_src_obj_type, $a_src_obj_id, $a_src_filesize)
 Update/create owner-related entry of source object. More...
 

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

◆ deleteByOwner()

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.

96 {
97 global $ilDB;
98
99 $ilDB->manipulate("DELETE FROM il_disk_quota".
100 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
101 }
global $ilDB

References $ilDB.

Referenced by ilObjUser\delete().

+ Here is the caller graph for this function:

◆ deleteEntry()

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.

81 {
82 global $ilDB;
83
84 $ilDB->manipulate("DELETE FROM il_disk_quota".
85 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
86 " AND src_type = ".$ilDB->quote($a_src_obj_type, "text").
87 " AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
88 }

References $ilDB.

Referenced by handleUpdatedSourceObject().

+ Here is the caller graph for this function:

◆ getFilesizeByOwner()

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.

195 {
196 global $ilDB;
197
198 $set = $ilDB->query("SELECT sum(src_size) fsize".
199 " FROM il_disk_quota".
200 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
201 $row = $ilDB->fetchAssoc($set);
202 return (int)$row["fsize"];
203 }

References $ilDB, and $row.

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

+ Here is the caller graph for this function:

◆ getFilesizeByTypeAndOwner()

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.

212 {
213 global $ilDB;
214
215 $res = array();
216
217 $set = $ilDB->query("SELECT sum(src_size) filesize, src_type, COUNT(*) count".
218 " FROM il_disk_quota".
219 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
220 " GROUP BY src_type");
221 while($row = $ilDB->fetchAssoc($set))
222 {
223 $res[] = $row;
224 }
225
226 return $res;
227 }

References $ilDB, $res, and $row.

Referenced by ilObjUserGUI\initForm().

+ Here is the caller graph for this function:

◆ getOwnersBySourceObject()

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.

111 {
112 global $ilDB;
113
114 $res = array();
115
116 $set = $ilDB->query("SELECT owner_id".
117 " FROM il_disk_quota".
118 " WHERE src_type = ".$ilDB->quote($a_src_obj_type, "text").
119 " AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
120 while($row = $ilDB->fetchAssoc($set))
121 {
122 $res[] = $row["owner_id"];
123 }
124
125 return $res;
126 }

References $ilDB, $res, and $row.

Referenced by handleUpdatedSourceObject().

+ Here is the caller graph for this function:

◆ getSourceObjectsByOwner()

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.

135 {
136 global $ilDB;
137
138 $res = array();
139
140 $set = $ilDB->query("SELECT src_type, src_obj_id".
141 " FROM il_disk_quota".
142 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer"));
143 while($row = $ilDB->fetchAssoc($set))
144 {
145 $res[$row["src_type"]][] = $row["src_obj_id"];
146 }
147
148 return $res;
149 }

References $ilDB, $res, and $row.

Referenced by handleEntry().

+ Here is the caller graph for this function:

◆ getStatusLegend()

static ilDiskQuotaHandler::getStatusLegend ( )
static

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

260 {
261 global $ilUser, $lng;
262
263 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
265 {
266 return;
267 }
268
269 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
271
272 include_once "Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
274 $quota = $quota["disk_quota"];
275
276 // administrator
277 if(is_infinite($quota) || !(int)$quota)
278 {
279 return;
280 }
281
282 $lng->loadLanguageModule("file");
283 return sprintf($lng->txt("personal_workspace_quota_status_legend"),
284 ilFormat::formatSize($usage),
285 ilFormat::formatSize($quota),
286 $quota ? round($usage/$quota*100) : 0);
287 }
static _lookupPersonalWorkspaceDiskQuota($a_user_id)
static getFilesizeByOwner($a_owner_id)
Get current storage size for owner.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15

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

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

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

◆ handleEntry()

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.

160 {
161 global $ilDB;
162
163 $existing = self::getSourceObjectsByOwner($a_owner_id);
164
165 // update
166 if($existing &&
167 isset($existing[$a_src_obj_type]) &&
168 in_array($a_src_obj_id, $existing[$a_src_obj_type]))
169 {
170 $ilDB->manipulate("UPDATE il_disk_quota".
171 " SET src_size = ".$ilDB->quote($a_src_filesize, "integer").
172 " WHERE owner_id = ".$ilDB->quote($a_owner_id, "integer").
173 " AND src_type = ".$ilDB->quote($a_src_obj_type, "text").
174 " AND src_obj_id = ".$ilDB->quote($a_src_obj_id, "integer"));
175 }
176 // insert
177 else
178 {
179 $ilDB->manipulate("INSERT INTO il_disk_quota".
180 " (owner_id, src_type, src_obj_id, src_size)".
181 " VALUES (".$ilDB->quote($a_owner_id, "integer").
182 ", ".$ilDB->quote($a_src_obj_type, "text").
183 ", ".$ilDB->quote($a_src_obj_id, "integer").
184 ", ".$ilDB->quote($a_src_filesize, "integer").")");
185 }
186 }
static getSourceObjectsByOwner($a_owner_id)
Get all source objects for owner.

References $ilDB, and getSourceObjectsByOwner().

Referenced by handleUpdatedSourceObject().

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

◆ handleUpdatedSourceObject()

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.

23 {
24 global $ilDB;
25
26 $done = array();
27
28 if(is_array($a_owner_obj_ids) && sizeof($a_owner_obj_ids) && (int)$a_src_filesize > 0)
29 {
30 // we are (currently) only interested in personal workspace objects
31
32 if(!$a_is_prtf)
33 {
34 $set = $ilDB->query("SELECT DISTINCT(od.owner)".
35 " FROM object_data od".
36 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)".
37 " JOIN tree_workspace t ON (t.child = ref.wsp_id)".
38 " WHERE ".$ilDB->in("od.obj_id", $a_owner_obj_ids, "", "integer").
39 " AND t.tree = od.owner");
40 }
41 else
42 {
43 $set = $ilDB->query("SELECT DISTINCT(od.owner)".
44 " FROM object_data od".
45 " JOIN usr_portfolio prtf ON (prtf.id = od.obj_id)".
46 " WHERE ".$ilDB->in("od.obj_id", $a_owner_obj_ids, "", "integer"));
47 }
48 while($row = $ilDB->fetchAssoc($set))
49 {
50 $done[] = $row["owner"];
51
53 $row["owner"],
54 $a_src_obj_type,
55 $a_src_obj_id,
56 (int)$a_src_filesize
57 );
58 }
59 }
60
61 // delete obsolete entries
62 $existing = self::getOwnersBySourceObject($a_src_obj_type, $a_src_obj_id);
63 $existing = array_diff($existing, $done);
64 if(sizeof($existing))
65 {
66 foreach($existing as $owner)
67 {
68 self::deleteEntry($owner, $a_src_obj_type, $a_src_obj_id);
69 }
70 }
71 }
static handleEntry($a_owner_id, $a_src_obj_type, $a_src_obj_id, $a_src_filesize)
Update/create owner-related entry of source object.
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.

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

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

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

◆ isUploadPossible()

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

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

230 {
231 global $ilUser;
232
233 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
235 {
236 return true;
237 }
238
239 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
241 if($a_additional_size)
242 {
243 $usage += $a_additional_size;
244 }
245
246 include_once "Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
248 $quota = $quota["disk_quota"];
249
250 // administrator
251 if(is_infinite($quota))
252 {
253 return true;
254 }
255
256 return $usage < $quota;
257 }

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

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

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