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']);
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;
219 public static function _fetchDiskQuotaReport($a_usage_filter = 3, $a_access_filter = 1, $a_order_column=
'disk_usage',$a_order_by=
'desc')
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'];
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';
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().
" ".
404 foreach($data as $owner => $item)
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').
")"
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;
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").
" ".
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 ".
536 $res = $ilDB->query(
"SELECT usr_id FROM usr_data");
540 $data = $a_access_obj->_lookupDiskUsageOfUser(
$row->usr_id);
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';
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)
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'])
671 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
674 $res = $ilDB->query(
"SELECT MAX(value) last_update ".
675 "FROM usr_pref WHERE keyword='disk_usage.last_update'");
677 return (
$row != null) ?
$row[
'last_update'] : null;
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']);