78 "SELECT keyword, value " .
80 "WHERE usr_id = %s " .
81 "AND keyword IN ('disk_quota', 'disk_quota_last_reminder')",
87 switch (
$row->keyword) {
91 case 'disk_quota_last_reminder':
104 "SELECT rd.role_id, rd.disk_quota, od.title " .
106 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s " .
107 "JOIN role_data rd ON ua.rol_id=rd.role_id " .
108 "JOIN object_data od ON od.obj_id=rd.role_id " .
109 "WHERE ua.usr_id = %s " .
110 "ORDER BY disk_quota DESC, role_id ASC",
111 array(
'integer',
'integer'),
112 array(ROLE_FOLDER_ID, $a_user_id)
121 $info[
'role_disk_quota'] = (
$row->role_id == SYSTEM_ROLE_ID) ? -log(0) :
$row->disk_quota;
122 $info[
'disk_quota'] = max(
$info[
'user_disk_quota'],
$info[
'role_disk_quota']);
150 $ilDB = $DIC[
'ilDB'];
153 "SELECT keyword, value " .
155 "WHERE usr_id = " .
$ilDB->quote($a_user_id,
'integer') .
" " .
156 "AND " .
$ilDB->like(
"keyword",
"text",
'disk\\_usage%')
160 switch (
$row->keyword) {
161 case 'disk_usage.last_update':
175 preg_match(
'/^disk_usage\\.([^.]+)\\.([^.]+)/',
$row->keyword, $matches);
179 $detail_data = $details[
$type];
180 if ($detail_data == null) {
181 $detail_data = array(
'type' =>
$type);
185 $details[
$type] = $detail_data;
189 $info[
'details'] = $details;
222 public static function _fetchDiskQuotaReport($a_usage_filter = 3, $a_access_filter = 1, $a_order_column =
'disk_usage', $a_order_by =
'desc')
226 $ilDB = $DIC[
'ilDB'];
228 if (!$a_order_column) {
229 $a_order_column =
'disk_usage';
232 switch ($a_usage_filter) {
237 $where_clause =
'WHERE (p2.value IS NULL) ';
241 $where_clause =
'WHERE (p2.value+0 > 0) ';
245 $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 246 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ';
249 switch ($a_access_filter) {
255 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ') .
256 '(u.active=1 AND (u.time_limit_unlimited = 1 OR ' .
$ilDB->unixTimestamp() .
' BETWEEN u.time_limit_from AND u.time_limit_until)) ';
259 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ') .
260 '(u.active=0 OR (u.time_limit_unlimited IS NULL AND ' .
$ilDB->unixTimestamp() .
' NOT BETWEEN u.time_limit_from AND u.time_limit_until)) ';
265 "SELECT u.usr_id,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," .
266 "u.time_limit_unlimited, " .
$ilDB->fromUnixtime(
"u.time_limit_from") .
", " .
$ilDB->fromUnixtime(
"u.time_limit_until") .
"," .
272 "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," .
274 "CASE WHEN " .
$ilDB->unixTimestamp() .
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," .
275 "rq.role_disk_quota, system_role.rol_id role_id, " .
276 "p1.value+0 user_disk_quota," .
277 "p2.value+0 disk_usage, " .
278 "p3.value last_update, " .
279 "p4.value last_reminder, " .
283 "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 " .
287 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
289 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " .
290 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s " .
291 "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 " .
294 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
297 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
300 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
303 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
306 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' " .
309 "ORDER BY " . $a_order_column .
" " . ($a_order_by ==
'asc'?
' ASC':
' DESC') .
", " .
310 "lastname, firstname, login",
311 array(
'integer',
'integer'),
312 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
314 $previous_usr_id = null;
316 if ($previous_usr_id !=
$row[
'usr_id']) {
318 $previous_usr_id =
$row[
'usr_id'];
337 $ilDB = $DIC[
'ilDB'];
340 $ilDB->manipulate(
"DELETE FROM usr_pref " .
341 "WHERE " .
$ilDB->like(
"keyword",
"text",
'disk_usage%'));
344 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
349 require_once
'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
352 require_once
'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
355 require_once
'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
358 require_once
'Services/Mail/classes/class.ilObjMailAccess.php';
359 self::__updateDiskUsageReportOfUsers(
new ilObjMailAccess(),
'mail_attachment');
364 "INSERT INTO usr_pref " .
365 "(usr_id, keyword, value) " .
366 "SELECT usr_id, 'disk_usage', SUM(value) " .
368 "WHERE " .
$ilDB->like(
"keyword",
"text",
'disk_usage.%.size%') .
373 $ilDB->manipulate(
"INSERT INTO usr_pref " .
374 "(usr_id, keyword, value) " .
375 "SELECT usr_id, 'disk_usage.last_update', " .
$ilDB->now() .
" " .
397 $res = self::__getRepositoryObjectsByType(
$a_type);
398 self::__updateDiskUsageReportOfTypeHelper($a_access_obj,
$res,
$data);
402 self::__updateDiskUsageReportOfTypeHelper($a_access_obj,
$res,
$data);
406 foreach (
$data as $owner => $item) {
407 self::__saveUserData($owner,
$a_type, $item[
"size"], $item[
"count"]);
423 $ilDB = $DIC[
'ilDB'];
425 if ($a_user_id && $a_size != null && $a_count != null) {
426 $ilDB->manipulate(
"INSERT INTO usr_pref " .
427 "(usr_id, keyword, value) " .
429 "(" .
$ilDB->quote($a_user_id,
'integer') .
", " .
430 $ilDB->quote(
'disk_usage.' .
$a_type .
'.size') .
", " .
431 $ilDB->quote($a_size,
'integer') .
")");
434 "INSERT INTO usr_pref " .
435 "(usr_id, keyword, value) " .
437 "(" .
$ilDB->quote($a_user_id,
'integer') .
", " .
438 $ilDB->quote(
'disk_usage.' .
$a_type .
'.count') .
", " .
439 $ilDB->quote($a_count,
'integer') .
")" 455 if (
$row->owner != null) {
456 if (!array_key_exists(
$row->owner, $a_result)) {
458 $a_result[
$row->owner] = array(
"size" => 0,
"count" => 0);
461 $a_result[
$row->owner][
"size"] += $a_access_obj->_lookupDiskUsage(
$row->obj_id);
462 $a_result[
$row->owner][
"count"]++;
477 $ilDB = $DIC[
'ilDB'];
480 "SELECT DISTINCT d.obj_id, d.owner " .
481 "FROM object_data d " .
482 "JOIN object_reference r ON d.obj_id=r.obj_id " .
483 "JOIN tree t ON t.child=r.ref_id " .
484 "WHERE d.type = " .
$ilDB->quote(
$a_type,
"text") .
" " .
500 $ilDB = $DIC[
'ilDB'];
503 "SELECT DISTINCT d.obj_id, d.owner " .
504 "FROM object_data d " .
505 "JOIN object_reference_ws r ON d.obj_id=r.obj_id " .
506 "JOIN tree_workspace t ON t.child=r.wsp_id " .
507 "WHERE d.type = " .
$ilDB->quote(
$a_type,
"text") .
" " .
508 "AND t.tree=d.owner " .
529 $ilDB = $DIC[
'ilDB'];
532 $res =
$ilDB->query(
"SELECT usr_id FROM usr_data");
536 $data = $a_access_obj->_lookupDiskUsageOfUser(
$row->usr_id);
546 $lastStart =
$ilSetting->get(
'last_cronjob_disk_quota_sum_start_ts', 0);
547 if (!$lastStart || date(
'dmY', $lastStart) != date(
'dmY')) {
548 $ilSetting->set(
'last_cronjob_disk_quota_sum_start_ts', time());
550 include_once
'Services/Mail/classes/class.ilDiskQuotaSummaryNotification.php';
564 $ilDB = $DIC[
'ilDB'];
566 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
570 "SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," .
571 "u.time_limit_unlimited, " .
$ilDB->fromUnixtime(
"u.time_limit_from") .
", " .
$ilDB->fromUnixtime(
"u.time_limit_until") .
"," .
577 "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," .
579 " CASE WHEN " .
$ilDB->unixTimestamp() .
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," .
580 "rq.role_disk_quota, system_role.rol_id role_id, " .
581 "p1.value+0 user_disk_quota," .
582 "p2.value+0 disk_usage, " .
583 "p3.value last_update, " .
584 "p4.value last_reminder, " .
585 "p5.value language, " .
589 "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 " .
593 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
595 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " .
596 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s " .
597 "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 " .
600 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
603 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
606 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
609 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
612 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' " .
615 "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' " .
620 'WHERE (((p1.value+0 >= rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR 621 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' .
622 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' .
$ilDB->unixTimestamp() .
' BETWEEN u.time_limit_from AND u.time_limit_until)) ' .
623 'AND (p4.value IS NULL OR p4.value < DATE_SUB(NOW(), INTERVAL 7 DAY)) ',
624 array(
'integer',
'integer'),
625 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
629 $details = self::_lookupDiskUsage(
$row[
'usr_id']);
630 $row[
'disk_usage_details'] = $details[
'details'];
633 $mail->setData(
$row);
637 if (
$row[
'last_reminder'] != null) {
639 "UPDATE usr_pref SET value= " .
$ilDB->now() .
" " .
640 "WHERE usr_id=%s AND keyword = 'disk_quota_last_reminder'",
642 array(
$row[
'usr_id'])
646 "INSERT INTO usr_pref (usr_id, keyword, value) " .
647 "VALUES (%s, 'disk_quota_last_reminder', " .
$ilDB->now() .
")",
649 array(
$row[
'usr_id'])
662 $ilDB = $DIC[
'ilDB'];
664 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
667 $res =
$ilDB->query(
"SELECT MAX(value) last_update " .
668 "FROM usr_pref WHERE keyword='disk_usage.last_update'");
670 return (
$row != null) ?
$row[
'last_update'] : null;
676 $ilDB = $DIC[
'ilDB'];
681 "SELECT keyword, value " .
683 "WHERE usr_id = %s " .
685 array(
'integer',
'text'),
686 array($a_user_id,
"wsp_disk_quota")
690 $info[
'user_wsp_disk_quota'] =
$row->value;
699 "SELECT rd.role_id, rd.wsp_disk_quota, od.title " .
701 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s " .
702 "JOIN role_data rd ON ua.rol_id=rd.role_id " .
703 "JOIN object_data od ON od.obj_id=rd.role_id " .
704 "WHERE ua.usr_id = %s " .
705 "ORDER BY wsp_disk_quota DESC, role_id ASC",
706 array(
'integer',
'integer'),
707 array(ROLE_FOLDER_ID, $a_user_id)
716 $info[
'role_wsp_disk_quota'] = (
$row->role_id == SYSTEM_ROLE_ID) ? -log(0) :
$row->wsp_disk_quota;
717 $info[
'disk_quota'] = max(
$info[
'user_wsp_disk_quota'],
$info[
'role_wsp_disk_quota']);
static _sendSummaryMails()
static _sendReminderMails()
Sends reminder e-mails to all users who have access and who have exceeded their disk quota and who ha...
Class ilDiskQuotaChecker.
static _lookupPersonalWorkspaceDiskQuota($a_user_id)
Access class for file objects.
static _updateDiskUsageReport()
Updates the disk usage info of all user accounts.
static __updateDiskUsageReportOfType($a_access_obj, $a_type)
Updates the disk usage report of the specified object type for all user accounts. ...
static __updateDiskUsageReportOfTypeHelper($a_access_obj, $a_objects, &$a_result)
for each objects of an owner, count the number of objects and sum up the size
static __getWorkspaceObjectsByType($a_type)
get all objects of the desired type which are in the personal workspace ordered by owner ...
static _lookupDiskUsageReportLastUpdate()
Returns the SQL datetime of the last update of the disk usage report.
static __updateDiskUsageReportOfUsers($a_access_obj, $a_type)
Updates the disk usage report of the specified object type for all user accounts. ...
Class ilFileBasedLMAccess.
foreach($_POST as $key=> $value) $res
static _lookupDiskQuota($a_user_id)
Gets the disk quota info for the specified user account.
static __saveUserData($a_user_id, $a_type, $a_size, $a_count)
Save disk quota for user.
static _lookupDiskUsage($a_user_id)
Gets the disk usage info for the specified user account.
Class ilDiskQuotaReminderMail.
Class ilObjContentObjectAccess.
static __getRepositoryObjectsByType($a_type)
get all objects of the desired type which are in the repository ordered by owner
static _fetchDiskQuotaReport($a_usage_filter=3, $a_access_filter=1, $a_order_column='disk_usage', $a_order_by='desc')
Reads disk quota/disk usage report of the user accounts.