Class ilDiskQuotaChecker.
More...
◆ __getRepositoryObjectsByType()
static ilDiskQuotaChecker::__getRepositoryObjectsByType |
( |
|
$a_type | ) |
|
|
staticprivate |
get all objects of the desired type which are in the repository
ordered by owner
- Parameters
-
- Returns
- DB result object
Definition at line 483 of file class.ilDiskQuotaChecker.php.
487 return $ilDB->query(
"SELECT DISTINCT d.obj_id, d.owner ".
488 "FROM object_data d ".
489 "JOIN object_reference r ON d.obj_id=r.obj_id ".
490 "JOIN tree t ON t.child=r.ref_id ".
491 "WHERE d.type = ".$ilDB->quote($a_type,
"text").
" ".
◆ __getWorkspaceObjectsByType()
static ilDiskQuotaChecker::__getWorkspaceObjectsByType |
( |
|
$a_type | ) |
|
|
staticprivate |
get all objects of the desired type which are in the personal workspace ordered by owner
- Parameters
-
- Returns
- DB result object
Definition at line 504 of file class.ilDiskQuotaChecker.php.
508 return $ilDB->query(
"SELECT DISTINCT d.obj_id, d.owner ".
509 "FROM object_data d ".
510 "JOIN object_reference_ws r ON d.obj_id=r.obj_id ".
511 "JOIN tree_workspace t ON t.child=r.wsp_id ".
512 "WHERE d.type = ".$ilDB->quote($a_type,
"text").
" ".
513 "AND t.tree=d.owner ".
◆ __saveUserData()
static ilDiskQuotaChecker::__saveUserData |
( |
|
$a_user_id, |
|
|
|
$a_type, |
|
|
|
$a_size, |
|
|
|
$a_count |
|
) |
| |
|
staticprivate |
Save disk quota for user.
- Parameters
-
int | $a_user_id | |
string | $a_type | |
int | $a_size | |
int | $a_count | |
Definition at line 419 of file class.ilDiskQuotaChecker.php.
423 if ($a_user_id && $a_size != null && $a_count != null)
425 $ilDB->manipulate(
"INSERT INTO usr_pref ".
426 "(usr_id, keyword, value) ".
428 "(".$ilDB->quote($a_user_id,
'integer').
", ".
429 $ilDB->quote(
'disk_usage.'.$a_type.
'.size').
", ".
430 $ilDB->quote($a_size,
'integer').
")");
432 $ilDB->manipulate(
"INSERT INTO usr_pref ".
433 "(usr_id, keyword, value) ".
435 "(".$ilDB->quote($a_user_id,
'integer').
", ".
436 $ilDB->quote(
'disk_usage.'.$a_type.
'.count').
", ".
437 $ilDB->quote($a_count,
'integer').
")"
◆ __updateDiskUsageReportOfType()
static ilDiskQuotaChecker::__updateDiskUsageReportOfType |
( |
|
$a_access_obj, |
|
|
|
$a_type |
|
) |
| |
|
staticprivate |
Updates the disk usage report of the specified object type for all user accounts.
The results are stored in table usr_pref. For each user which owns files the following rows are inserted:
- Parameters
-
$a_access_obj | Object A access object, such as ilObjFileAccess. |
$a_type | string The type of the access object, such as 'file'. |
Keyword Value Description 'disk_usage.file.count' integer The number of files owned by the user 'disk_usage.file.usage' integer The disk usage of the files
Definition at line 389 of file class.ilDiskQuotaChecker.php.
References $data, and $res.
394 $res = self::__getRepositoryObjectsByType($a_type);
395 self::__updateDiskUsageReportOfTypeHelper($a_access_obj,
$res,
$data);
398 $res = self::__getWorkspaceObjectsByType($a_type);
399 self::__updateDiskUsageReportOfTypeHelper($a_access_obj,
$res,
$data);
404 foreach(
$data as $owner => $item)
406 self::__saveUserData($owner, $a_type, $item[
"size"], $item[
"count"]);
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
◆ __updateDiskUsageReportOfTypeHelper()
static ilDiskQuotaChecker::__updateDiskUsageReportOfTypeHelper |
( |
|
$a_access_obj, |
|
|
|
$a_objects, |
|
|
& |
$a_result |
|
) |
| |
|
staticprivate |
for each objects of an owner, count the number of objects and sum up the size
- Parameters
-
object | $a_access_obj | |
object | $a_objects | |
array | $a_result | |
Definition at line 450 of file class.ilDiskQuotaChecker.php.
References $row, $size, and DB_FETCHMODE_OBJECT.
456 if (
$row->owner != $owner) {
457 if ($owner != null) {
458 $a_result[$owner][
"size"] +=
$size;
459 $a_result[$owner][
"count"] += $count;
461 $owner =
$row->owner;
465 $size += $a_access_obj->_lookupDiskUsage(
$row->obj_id);
470 if ($owner != null) {
471 $a_result[$owner][
"size"] +=
$size;
472 $a_result[$owner][
"count"] += $count;
const DB_FETCHMODE_OBJECT
◆ __updateDiskUsageReportOfUsers()
static ilDiskQuotaChecker::__updateDiskUsageReportOfUsers |
( |
|
$a_access_obj, |
|
|
|
$a_type |
|
) |
| |
|
staticprivate |
Updates the disk usage report of the specified object type for all user accounts.
The results are stored in table usr_pref. For each user which owns files the following rows are inserted:
- Parameters
-
$a_access_obj | Object A access object, such as ilObjFileAccess. |
$a_type | string The type of the access object, such as 'file'. |
Keyword Value Description 'disk_usage.file.count' integer The number of files owned by the user 'disk_usage.file.usage' integer The disk usage of the files
Definition at line 531 of file class.ilDiskQuotaChecker.php.
References $data, $res, $row, and DB_FETCHMODE_OBJECT.
536 $res = $ilDB->query(
"SELECT usr_id FROM usr_data");
540 $data = $a_access_obj->_lookupDiskUsageOfUser(
$row->usr_id);
541 self::__saveUserData(
$row->usr_id, $a_type,
$data[
"size"],
$data[
"count"]);
const DB_FETCHMODE_OBJECT
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
◆ _fetchDiskQuotaReport()
static ilDiskQuotaChecker::_fetchDiskQuotaReport |
( |
|
$a_usage_filter = 3 , |
|
|
|
$a_access_filter = 1 , |
|
|
|
$a_order_column = 'disk_usage' , |
|
|
|
$a_order_by = 'desc' |
|
) |
| |
|
static |
Reads disk quota/disk usage report of the user accounts.
Returns an array or associative arrays with information about the disk usage of each user account.
- Parameters
-
string | usage filter values: 1 = all users 2 = only users who don't use disk space 3 = only users who use disk space 4 = only users who have exceeded their quota |
string | access filter values: 1 = all users 2 = only users who have access 4 = only users who have no access |
- Returns
- array { array { 'usr_id'=>integer, // the user id 'login'=>string, // the login '...'=>..., // all other fields of table usr_data
'disk_usage'=>integer, // the disk usage in bytes 'disk_quota'=>integer, // the disk quota in bytes } }
Definition at line 219 of file class.ilDiskQuotaChecker.php.
References $data, $res, $row, and DB_FETCHMODE_ASSOC.
Referenced by ilObjFileAccessSettingsGUI\viewDiskQuotaReport().
224 if (! $a_order_column) {
225 $a_order_column =
'disk_usage';
228 switch ($a_usage_filter) {
233 $where_clause =
'WHERE (p2.value IS NULL) ';
237 $where_clause =
'WHERE (p2.value+0 > 0) ';
241 $where_clause =
'WHERE (((p1.value+0 > rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR 242 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ';
245 switch ($a_access_filter) {
251 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ' ).
252 '(u.active=1 AND (u.time_limit_unlimited = 1 OR '.$ilDB->unixTimestamp().
' BETWEEN u.time_limit_from AND u.time_limit_until)) ';
255 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ' ).
256 '(u.active=0 OR (u.time_limit_unlimited IS NULL AND '.$ilDB->unixTimestamp().
' NOT BETWEEN u.time_limit_from AND u.time_limit_until)) ';
260 $res = $ilDB->queryf(
261 "SELECT u.usr_id,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active,".
262 "u.time_limit_unlimited, ".$ilDB->fromUnixtime(
"u.time_limit_from").
", ".$ilDB->fromUnixtime(
"u.time_limit_until").
",".
268 "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE ".$ilDB->fromUnixtime(
"u.time_limit_until").
" END END access_until,".
270 "CASE WHEN ".$ilDB->unixTimestamp().
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired,".
271 "rq.role_disk_quota, system_role.rol_id role_id, ".
272 "p1.value+0 user_disk_quota,".
273 "p2.value+0 disk_usage, ".
274 "p3.value last_update, ".
275 "p4.value last_reminder, ".
279 "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota ".
283 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota ".
285 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id ".
286 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s ".
287 "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id ".
290 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s ".
293 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' ".
296 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' ".
299 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' ".
302 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' ".
305 "ORDER BY ".$a_order_column.
" ".($a_order_by==
'asc'?
' ASC':
' DESC').
", ".
306 "lastname, firstname, login" 308 array(
'integer',
'integer'),
309 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
311 $previous_usr_id = null;
313 if ($previous_usr_id !=
$row[
'usr_id'])
316 $previous_usr_id =
$row[
'usr_id'];
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
◆ _lookupDiskQuota()
static ilDiskQuotaChecker::_lookupDiskQuota |
( |
|
$a_user_id | ) |
|
|
static |
Gets the disk quota info for the specified user account.
Returns an associative array with information about the disk quota of this user account.
- Parameters
-
- Returns
- array { "role"=>role_id, // the id of the role which defines the highest // quota for the specified user account "role_title"=>string, // the title of the role
"role_disk_quota"=>integer or positive infinity, // the disk quota specified by the role in bytes. // the disk quota is positive infinity if // the user has the system administrator role
"user_disk_quota"=>integer // the disk quota specified on the user account // form.
"disk_quota"=>integer or positive infinity // the disk quota which is in effect. This is // either role_quota or user_quota whichever // is higher.
"last_reminder"=>string or null // the SQL datetime the last time a disk quota // reminder was sent to the user }
Definition at line 70 of file class.ilDiskQuotaChecker.php.
References $res, $row, and DB_FETCHMODE_OBJECT.
Referenced by ilObjUserGUI\initForm().
76 $res = $ilDB->queryf(
"SELECT keyword, value ".
79 "AND keyword IN ('disk_quota', 'disk_quota_last_reminder')",
84 switch (
$row->keyword)
87 $info[
'user_disk_quota'] =
$row->value;
89 case 'disk_quota_last_reminder' :
90 $info[
'last_reminder'] =
$row->value;
101 $res = $ilDB->queryf(
"SELECT rd.role_id, rd.disk_quota, od.title ".
103 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s ".
104 "JOIN role_data rd ON ua.rol_id=rd.role_id ".
105 "JOIN object_data od ON od.obj_id=rd.role_id ".
106 "WHERE ua.usr_id = %s ".
107 "ORDER BY disk_quota DESC, role_id ASC",
108 array(
'integer',
'integer'),
109 array(ROLE_FOLDER_ID, $a_user_id));
112 $info[
'role_id'] =
$row->role_id;
113 $info[
'role_title'] =
$row->title;
117 $info[
'role_disk_quota'] = (
$row->role_id == SYSTEM_ROLE_ID) ? -log(0) :
$row->disk_quota;
118 $info[
'disk_quota'] = max($info[
'user_disk_quota'], $info[
'role_disk_quota']);
const DB_FETCHMODE_OBJECT
◆ _lookupDiskUsage()
static ilDiskQuotaChecker::_lookupDiskUsage |
( |
|
$a_user_id | ) |
|
|
static |
Gets the disk usage info for the specified user account.
Returns an associative array with information about the disk usage of this user account.
- Parameters
-
- Returns
- array { 'last_update'=>datetime, // SQL datetime of the last update // if this is null, the disk usage is unkown
'disk_usage'=>integer, // the disk usage in bytes
'details' array(array('type'=>string,'count'=>integer,'size'=>integer),...) // an associative array with the disk // usage in bytes for each object type
Definition at line 140 of file class.ilDiskQuotaChecker.php.
References $res, $row, and DB_FETCHMODE_OBJECT.
Referenced by ilObjUserGUI\initForm(), and ilDiskQuotaSummaryNotification\send().
147 $res = $ilDB->query(
"SELECT keyword, value ".
149 "WHERE usr_id = ".$ilDB->quote($a_user_id,
'integer').
" ".
150 "AND ".$ilDB->like(
"keyword",
"text",
'disk\\_usage%')
154 switch (
$row->keyword)
156 case 'disk_usage.last_update' :
157 $info[
'last_update'] =
$row->value;
161 $info[
'disk_usage'] =
$row->value;
170 preg_match(
'/^disk_usage\\.([^.]+)\\.([^.]+)/',
$row->keyword, $matches);
175 $detail_data = $details[$type];
176 if ($detail_data == null)
178 $detail_data = array(
'type'=>$type);
180 $detail_data[$key] =
$row->value;
182 $details[$type] = $detail_data;
186 $info[
'details'] = $details;
const DB_FETCHMODE_OBJECT
◆ _lookupDiskUsageReportLastUpdate()
static ilDiskQuotaChecker::_lookupDiskUsageReportLastUpdate |
( |
| ) |
|
|
static |
◆ _lookupPersonalWorkspaceDiskQuota()
static ilDiskQuotaChecker::_lookupPersonalWorkspaceDiskQuota |
( |
|
$a_user_id | ) |
|
|
static |
Definition at line 680 of file class.ilDiskQuotaChecker.php.
References $res, $row, and DB_FETCHMODE_OBJECT.
Referenced by ilDiskQuotaHandler\getStatusLegend(), ilObjUserGUI\initForm(), and ilDiskQuotaHandler\isUploadPossible().
686 $res = $ilDB->queryf(
"SELECT keyword, value ".
688 "WHERE usr_id = %s ".
690 array(
'integer',
'text'),
691 array($a_user_id,
"wsp_disk_quota"));
694 $info[
'user_wsp_disk_quota'] =
$row->value;
702 $res = $ilDB->queryf(
"SELECT rd.role_id, rd.wsp_disk_quota, od.title ".
704 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s ".
705 "JOIN role_data rd ON ua.rol_id=rd.role_id ".
706 "JOIN object_data od ON od.obj_id=rd.role_id ".
707 "WHERE ua.usr_id = %s ".
708 "ORDER BY wsp_disk_quota DESC, role_id ASC",
709 array(
'integer',
'integer'),
710 array(ROLE_FOLDER_ID, $a_user_id));
713 $info[
'role_id'] =
$row->role_id;
714 $info[
'role_title'] =
$row->title;
718 $info[
'role_wsp_disk_quota'] = (
$row->role_id == SYSTEM_ROLE_ID) ? -log(0) :
$row->wsp_disk_quota;
719 $info[
'disk_quota'] = max($info[
'user_wsp_disk_quota'], $info[
'role_wsp_disk_quota']);
const DB_FETCHMODE_OBJECT
◆ _sendReminderMails()
static ilDiskQuotaChecker::_sendReminderMails |
( |
| ) |
|
|
static |
Sends reminder e-mails to all users who have access and who have exceeded their disk quota and who haven't received a reminder mail in the past 7 days.
Definition at line 565 of file class.ilDiskQuotaChecker.php.
References $res, $row, and DB_FETCHMODE_ASSOC.
Referenced by ilDAVCronDiskQuota\run().
569 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
572 $res = $ilDB->queryf(
573 "SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active,".
574 "u.time_limit_unlimited, ".$ilDB->fromUnixtime(
"u.time_limit_from").
", ".$ilDB->fromUnixtime(
"u.time_limit_until").
",".
580 "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE ".$ilDB->fromUnixtime(
"u.time_limit_until").
" END END access_until,".
582 " CASE WHEN ".$ilDB->unixTimestamp().
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired,".
583 "rq.role_disk_quota, system_role.rol_id role_id, ".
584 "p1.value+0 user_disk_quota,".
585 "p2.value+0 disk_usage, ".
586 "p3.value last_update, ".
587 "p4.value last_reminder, ".
588 "p5.value language, ".
592 "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota ".
596 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota ".
598 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id ".
599 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s ".
600 "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id ".
603 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s ".
606 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' ".
609 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' ".
612 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' ".
615 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' ".
618 "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' ".
623 'WHERE (((p1.value+0 >= rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR 624 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) '.
625 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR '.$ilDB->unixTimestamp().
' BETWEEN u.time_limit_from AND u.time_limit_until)) '.
626 'AND (p4.value IS NULL OR p4.value < DATE_SUB(NOW(), INTERVAL 7 DAY)) ' 629 array(
'integer',
'integer'),
630 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
634 $details = self::_lookupDiskUsage(
$row[
'usr_id']);
635 $row[
'disk_usage_details'] = $details[
'details'];
638 $mail->setData(
$row);
642 if (
$row[
'last_reminder'] != null)
644 $ilDB->manipulatef(
"UPDATE usr_pref SET value= ".$ilDB->now().
" ".
645 "WHERE usr_id=%s AND keyword = 'disk_quota_last_reminder'" 648 array(
$row[
'usr_id'])
653 $ilDB->manipulatef(
"INSERT INTO usr_pref (usr_id, keyword, value) ".
654 "VALUES (%s, 'disk_quota_last_reminder', ".$ilDB->now().
")" 657 array(
$row[
'usr_id'])
Class ilDiskQuotaReminderMail.
◆ _sendSummaryMails()
static ilDiskQuotaChecker::_sendSummaryMails |
( |
| ) |
|
|
static |
Definition at line 545 of file class.ilDiskQuotaChecker.php.
References $ilSetting.
Referenced by ilDAVCronDiskQuota\run().
549 $lastStart = $ilSetting->get(
'last_cronjob_disk_quota_sum_start_ts', 0);
550 if( !$lastStart || date(
'dmY', $lastStart) != date(
'dmY') )
552 $ilSetting->set(
'last_cronjob_disk_quota_sum_start_ts', time());
554 include_once
'Services/Mail/classes/class.ilDiskQuotaSummaryNotification.php';
◆ _updateDiskUsageReport()
static ilDiskQuotaChecker::_updateDiskUsageReport |
( |
| ) |
|
|
static |
Updates the disk usage info of all user accounts.
The result is stored in usr_pref of each user. The following keywords are used:
'disk_usage_last_update' - the unix timestamp of the last update. 'disk_usage.file' - the disk usage of file objects owned by the user.
Definition at line 332 of file class.ilDiskQuotaChecker.php.
Referenced by ilDAVCronDiskQuota\run().
337 $ilDB->manipulate(
"DELETE FROM usr_pref ".
338 "WHERE ".$ilDB->like(
"keyword",
"text",
'disk_usage%'));
341 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
344 require_once
'Modules/Forum/classes/class.ilObjForumAccess.php';
347 require_once
'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
350 require_once
'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
353 require_once
'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
356 require_once
'Services/Mail/classes/class.ilObjMailAccess.php';
357 self::__updateDiskUsageReportOfUsers(
new ilObjMailAccess(),
'mail_attachment');
361 $ilDB->manipulate(
"INSERT INTO usr_pref ".
362 "(usr_id, keyword, value) ".
363 "SELECT usr_id, 'disk_usage', SUM(value) ".
365 "WHERE ".$ilDB->like(
"keyword",
"text",
'disk_usage.%.size%').
370 $ilDB->manipulate(
"INSERT INTO usr_pref ".
371 "(usr_id, keyword, value) ".
372 "SELECT usr_id, 'disk_usage.last_update', ".$ilDB->now().
" ".
Access class for file objects.
Class ilFileBasedLMAccess.
Class ilObjContentObjectAccess.
◆ ilDiskQuotaChecker()
ilDiskQuotaChecker::ilDiskQuotaChecker |
( |
| ) |
|
The documentation for this class was generated from the following file: