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);
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) ';
240 $where_clause =
'WHERE (p2.value > p1.value AND p2.value > rq.role_disk_quota) ';
243 switch ($a_access_filter) {
249 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ' ).
250 '(u.active=1 AND (u.time_limit_unlimited = 1 OR '.$ilDB->unixTimestamp().
' BETWEEN u.time_limit_from AND u.time_limit_until)) ';
253 $where_clause .= ($where_clause ==
'' ?
'WHERE ' :
' AND ' ).
254 '(u.active=0 OR (u.time_limit_unlimited IS NULL AND '.$ilDB->unixTimestamp().
' NOT BETWEEN u.time_limit_from AND u.time_limit_until)) ';
258 $res = $ilDB->queryf(
259 "SELECT u.usr_id,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active,".
260 "u.time_limit_unlimited, ".$ilDB->fromUnixtime(
"u.time_limit_from").
", ".$ilDB->fromUnixtime(
"u.time_limit_until").
",".
266 "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,".
268 "CASE WHEN ".$ilDB->unixTimestamp().
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired,".
269 "rq.role_disk_quota, system_role.rol_id role_id, ".
270 "p1.value+0 user_disk_quota,".
271 "p2.value+0 disk_usage, ".
272 "p3.value last_update, ".
273 "p4.value last_reminder, ".
277 "CASE WHEN rq.role_disk_quota+0>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota+0 ELSE p1.value+0 END disk_quota ".
281 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota ".
283 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id ".
284 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s ".
285 "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 ".
288 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s ".
291 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' ".
294 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' ".
297 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' ".
300 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' ".
303 "ORDER BY ".$a_order_column.
" ".($a_order_by==
'asc'?
' ASC':
' DESC').
", ".
304 "lastname, firstname, login"
306 array(
'integer',
'integer'),
307 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
309 $previous_usr_id = null;
311 if ($previous_usr_id !=
$row[
'usr_id'])
314 $previous_usr_id =
$row[
'usr_id'];
335 $ilDB->manipulate(
"DELETE FROM usr_pref ".
336 "WHERE ".$ilDB->like(
"keyword",
"text",
'disk_usage%'));
339 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
342 require_once
'Modules/Forum/classes/class.ilObjForumAccess.php';
345 require_once
'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
348 require_once
'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
351 require_once
'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
354 require_once
'Services/Mail/classes/class.ilObjMailAccess.php';
359 $ilDB->manipulate(
"INSERT INTO usr_pref ".
360 "(usr_id, keyword, value) ".
361 "SELECT usr_id, 'disk_usage', SUM(value) ".
363 "WHERE ".$ilDB->like(
"keyword",
"text",
'disk_usage.%.size%').
368 $ilDB->manipulate(
"INSERT INTO usr_pref ".
369 "(usr_id, keyword, value) ".
370 "SELECT usr_id, 'disk_usage.last_update', ".$ilDB->now().
" ".
393 $res = $ilDB->query(
"SELECT DISTINCT d.obj_id, d.owner ".
394 "FROM object_data d ".
395 "JOIN object_reference r ON d.obj_id=r.obj_id ".
396 "JOIN tree t ON t.child=r.ref_id ".
397 "WHERE d.type = ".$ilDB->quote($a_type,
"text").
" ".
408 if (
$row->owner != $owner) {
409 if ($owner != null) {
410 $ilDB->manipulate(
"INSERT INTO usr_pref ".
411 "(usr_id, keyword, value) ".
413 "(".$ilDB->quote($owner,
'integer').
", ".
414 $ilDB->quote(
'disk_usage.'.$a_type.
'.size').
", ".
415 $ilDB->quote(
$size,
'integer').
")");
417 $ilDB->manipulate(
"INSERT INTO usr_pref ".
418 "(usr_id, keyword, value) ".
420 "(".$ilDB->quote($owner,
'integer').
", ".
421 $ilDB->quote(
'disk_usage.'.$a_type.
'.count').
", ".
422 $ilDB->quote($count,
'integer').
")"
426 $owner =
$row->owner;
430 $size += $a_access_obj->_lookupDiskUsage(
$row->obj_id);
433 if ($owner != null) {
434 $ilDB->manipulate(
"INSERT INTO usr_pref ".
435 "(usr_id, keyword, value) ".
437 "(".$ilDB->quote($owner,
'integer').
", ".
438 $ilDB->quote(
'disk_usage.'.$a_type.
'.size').
", ".
439 $ilDB->quote(
$size,
'integer').
")");
441 $ilDB->manipulate(
"INSERT INTO usr_pref ".
442 "(usr_id, keyword, value) ".
444 "(".$ilDB->quote($owner,
'integer').
", ".
445 $ilDB->quote(
'disk_usage.'.$a_type.
'.count').
", ".
446 $ilDB->quote($count,
'integer').
")");
469 $res = $ilDB->query(
"SELECT usr_id FROM usr_data");
473 $data = $a_access_obj->_lookupDiskUsageOfUser(
$row->usr_id);
475 if (
$data[
'size'] != null &&
$data[
'count'] != null)
477 $ilDB->manipulate(
"INSERT INTO usr_pref ".
478 "(usr_id, keyword, value) ".
480 "(".$ilDB->quote(
$row->usr_id,
'integer').
", ".
481 $ilDB->quote(
'disk_usage.'.$a_type.
'.size').
", ".
482 $ilDB->quote(
$data[
'size'],
'integer').
")");
483 $ilDB->manipulate(
"INSERT INTO usr_pref ".
484 "(usr_id, keyword, value) ".
486 "(".$ilDB->quote(
$row->usr_id,
'integer').
", ".
487 $ilDB->quote(
'disk_usage.'.$a_type.
'.count').
", ".
488 $ilDB->quote(
$data[
'count'],
'integer').
")");
501 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
504 $res = $ilDB->queryf(
505 "SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active,".
506 "u.time_limit_unlimited, ".$ilDB->fromUnixtime(
"u.time_limit_from").
", ".$ilDB->fromUnixtime(
"u.time_limit_until").
",".
512 "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,".
514 " CASE WHEN ".$ilDB->unixTimestamp().
" BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired,".
515 "rq.role_disk_quota, system_role.rol_id role_id, ".
516 "p1.value+0 user_disk_quota,".
517 "p2.value+0 disk_usage, ".
518 "p3.value last_update, ".
519 "p4.value last_reminder, ".
520 "p5.value language, ".
524 "CASE WHEN rq.role_disk_quota+0>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota+0 ELSE p1.value+0 END disk_quota ".
528 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota ".
530 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id ".
531 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s ".
532 "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 ".
535 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s ".
538 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' ".
541 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' ".
544 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' ".
547 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' ".
550 "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' ".
554 'WHERE (p2.value > p1.value AND p2.value > rq.role_disk_quota) '.
555 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR '.$ilDB->unixTimestamp().
' BETWEEN u.time_limit_from AND u.time_limit_until)) '.
556 'AND (p4.value IS NULL OR p4.value < DATE_SUB(NOW(), INTERVAL 7 DAY)) '
559 array(
'integer',
'integer'),
560 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
565 $row[
'disk_usage_details'] = $details[
'details'];
568 $mail->setData(
$row);
572 if (
$row[
'last_reminder'] != null)
574 $ilDB->manipulatef(
"UPDATE usr_pref SET value= ".$ilDB->now().
" ".
575 "WHERE usr_id=%s AND keyword = 'disk_quota_last_reminder'"
578 array(
$row[
'usr_id'])
583 $ilDB->manipulatef(
"INSERT INTO usr_pref (usr_id, keyword, value) ".
584 "VALUES (%s, 'disk_quota_last_reminder', ".$ilDB->now().
")"
587 array(
$row[
'usr_id'])
601 require_once
'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
604 $res = $ilDB->query(
"SELECT MAX(value) last_update ".
605 "FROM usr_pref WHERE keyword='disk_usage.last_update'");
607 return (
$row != null) ?
$row[
'last_update'] : null;