ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDiskQuotaChecker.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  public function __construct()
36  {
37  }
38 
70  public static function _lookupDiskQuota($a_user_id)
71  {
72  $info = array();
73 
74  global $DIC;
75  $ilDB = $DIC['ilDB'];
76 
77  $res = $ilDB->queryf(
78  "SELECT keyword, value " .
79  "FROM usr_pref " .
80  "WHERE usr_id = %s " .
81  "AND keyword IN ('disk_quota', 'disk_quota_last_reminder')",
82  array('integer'),
83  array($a_user_id)
84  );
85 
86  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87  switch ($row->keyword) {
88  case 'disk_quota':
89  $info['user_disk_quota'] = $row->value;
90  break;
91  case 'disk_quota_last_reminder':
92  $info['last_reminder'] = $row->value;
93  break;
94  }
95  }
96 
97 
98  // Note: we order by role_id ASC here, in the assumption that
99  // the system role has the lowest ID of all roles.
100  // this way, if a user has the system role, this role
101  // will always returned first.
102  $ilDB->setLimit(1);
103  $res = $ilDB->queryf(
104  "SELECT rd.role_id, rd.disk_quota, od.title " .
105  "FROM rbac_ua ua " .
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)
113  );
114 
116  $info['role_id'] = $row->role_id;
117  $info['role_title'] = $row->title;
118 
119  // Note: Users with the system role have an infinite disk quota
120  // We calculate positive infinity by negating the logarithm of 0.
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']);
123 
124  return $info;
125  }
126 
144  public static function _lookupDiskUsage($a_user_id)
145  {
146  $info = array();
147  $details = array();
148 
149  global $DIC;
150  $ilDB = $DIC['ilDB'];
151 
152  $res = $ilDB->query(
153  "SELECT keyword, value " .
154  "FROM usr_pref " .
155  "WHERE usr_id = " . $ilDB->quote($a_user_id, 'integer') . " " .
156  "AND " . $ilDB->like("keyword", "text", 'disk\\_usage%')
157  );
158 
159  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
160  switch ($row->keyword) {
161  case 'disk_usage.last_update':
162  $info['last_update'] = $row->value;
163  break;
164 
165  case 'disk_usage':
166  $info['disk_usage'] = $row->value;
167  break;
168 
169  default:
170  // The following preg_match is used to extract the type
171  // and the keys 'count' and 'size' from the keywords:
172  // disk_usage.type.count
173  // disk_usage.type.size
174  $matches = array();
175  preg_match('/^disk_usage\\.([^.]+)\\.([^.]+)/', $row->keyword, $matches);
176  $type = $matches[1];
177  $key = $matches[2];
178  if ($type) {
179  $detail_data = $details[$type];
180  if ($detail_data == null) {
181  $detail_data = array('type' => $type);
182  }
183  $detail_data[$key] = $row->value;
184  }
185  $details[$type] = $detail_data;
186  break;
187  }
188  }
189  $info['details'] = $details;
190 
191 
192  //ilDiskQuotaChecker::_updateDiskUsageReport();
193 
194  return $info;
195  }
196 
222  public static function _fetchDiskQuotaReport($a_usage_filter = 3, $a_access_filter = 1, $a_order_column = 'disk_usage', $a_order_by = 'desc')
223  {
224  $data = array();
225  global $DIC;
226  $ilDB = $DIC['ilDB'];
227 
228  if (!$a_order_column) {
229  $a_order_column = 'disk_usage';
230  }
231 
232  switch ($a_usage_filter) {
233  case 1: // all users
234  $where_clause = '';
235  break;
236  case 2: // only users who don't use disk space
237  $where_clause = 'WHERE (p2.value IS NULL) ';
238  break;
239  case 3: // only users who use disk space
240  default:
241  $where_clause = 'WHERE (p2.value+0 > 0) ';
242  break;
243  case 4: // only users who have exceeded their disk quota
244  // #8554 / #10301
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)) ';
247  break;
248  }
249  switch ($a_access_filter) {
250  case 1: // all users
251  $where_clause .= '';
252  break;
253  case 2: // only users who have access
254  default:
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)) ';
257  break;
258  case 3: // only users who don't have access
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)) ';
261  break;
262  }
263 
264  $res = $ilDB->queryf(
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") . "," .
267 
268  // Inactive users get the date 0001-01-01 so that they appear
269  // first when the list is sorted by this field. Users with
270  // unlimited access get the date 9999-12-31 so that they appear
271  // last.
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," .
273 
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, " .
280 
281  // We add 0 to some of the values to convert them into a number.
282  // This is needed for correct sorting.
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 " .
284  "FROM usr_data u " .
285 
286  // Fetch the role with the highest disk quota value.
287  "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
288  "FROM usr_data u " .
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 " .
292 
293  // Fetch the system role in order to determine whether the user has unlimited disk quota
294  "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
295 
296  // Fetch the user disk quota from table usr_pref
297  "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
298 
299  // Fetch the disk usage from table usr_pref
300  "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
301 
302  // Fetch the last update from table usr_pref
303  "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
304 
305  // Fetch the date when the last disk quota reminder was sent from table usr_pref
306  "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' " .
307 
308  $where_clause .
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)
313  );
314  $previous_usr_id = null;
315  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
316  if ($previous_usr_id != $row['usr_id']) {
317  $data[] = $row;
318  $previous_usr_id = $row['usr_id'];
319  }
320  }
321  return $data;
322  }
323 
334  public static function _updateDiskUsageReport()
335  {
336  global $DIC;
337  $ilDB = $DIC['ilDB'];
338 
339  // delete old values
340  $ilDB->manipulate("DELETE FROM usr_pref " .
341  "WHERE " . $ilDB->like("keyword", "text", 'disk_usage%'));
342 
343 
344  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
345  self::__updateDiskUsageReportOfType(new ilObjFileAccess(), 'file');
346 
347  self::__updateDiskUsageReportOfType(new ilObjForumAccess(), 'frm');
348 
349  require_once 'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
350  self::__updateDiskUsageReportOfType(new ilObjFileBasedLMAccess(), 'htlm');
351 
352  require_once 'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
353  self::__updateDiskUsageReportOfType(new ilObjMediaCastAccess(), 'mcst');
354 
355  require_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
356  self::__updateDiskUsageReportOfType(new ilObjSAHSLearningModuleAccess(), 'sahs');
357 
358  require_once 'Services/Mail/classes/class.ilObjMailAccess.php';
359  self::__updateDiskUsageReportOfUsers(new ilObjMailAccess(), 'mail_attachment');
360 
361  // insert the sum of the disk usage of each user
362  // note: second % is needed to not fail on oracle char field
363  $ilDB->manipulate(
364  "INSERT INTO usr_pref " .
365  "(usr_id, keyword, value) " .
366  "SELECT usr_id, 'disk_usage', SUM(value) " .
367  "FROM usr_pref " .
368  "WHERE " . $ilDB->like("keyword", "text", 'disk_usage.%.size%') .
369  "GROUP BY usr_id"
370  );
371 
372  // insert last update
373  $ilDB->manipulate("INSERT INTO usr_pref " .
374  "(usr_id, keyword, value) " .
375  "SELECT usr_id, 'disk_usage.last_update', " . $ilDB->now() . " " .
376  "FROM usr_data");
377  }
378 
392  private static function __updateDiskUsageReportOfType($a_access_obj, $a_type)
393  {
394  $data = array();
395 
396  // repository
397  $res = self::__getRepositoryObjectsByType($a_type);
398  self::__updateDiskUsageReportOfTypeHelper($a_access_obj, $res, $data);
399 
400  // personal workspace
401  $res = self::__getWorkspaceObjectsByType($a_type);
402  self::__updateDiskUsageReportOfTypeHelper($a_access_obj, $res, $data);
403 
404  // saving result to DB
405  if ($data) {
406  foreach ($data as $owner => $item) {
407  self::__saveUserData($owner, $a_type, $item["size"], $item["count"]);
408  }
409  }
410  }
411 
420  private static function __saveUserData($a_user_id, $a_type, $a_size, $a_count)
421  {
422  global $DIC;
423  $ilDB = $DIC['ilDB'];
424 
425  if ($a_user_id && $a_size != null && $a_count != null) {
426  $ilDB->manipulate("INSERT INTO usr_pref " .
427  "(usr_id, keyword, value) " .
428  "VALUES " .
429  "(" . $ilDB->quote($a_user_id, 'integer') . ", " .
430  $ilDB->quote('disk_usage.' . $a_type . '.size') . ", " .
431  $ilDB->quote($a_size, 'integer') . ")");
432 
433  $ilDB->manipulate(
434  "INSERT INTO usr_pref " .
435  "(usr_id, keyword, value) " .
436  "VALUES " .
437  "(" . $ilDB->quote($a_user_id, 'integer') . ", " .
438  $ilDB->quote('disk_usage.' . $a_type . '.count') . ", " .
439  $ilDB->quote($a_count, 'integer') . ")"
440  );
441  }
442  }
443 
452  private static function __updateDiskUsageReportOfTypeHelper($a_access_obj, $a_objects, &$a_result)
453  {
454  while ($row = $a_objects->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
455  if ($row->owner != null) {
456  if (!array_key_exists($row->owner, $a_result)) {
457  // initialize values
458  $a_result[$row->owner] = array("size" => 0, "count" => 0);
459  }
460 
461  $a_result[$row->owner]["size"] += $a_access_obj->_lookupDiskUsage($row->obj_id);
462  $a_result[$row->owner]["count"]++;
463  }
464  }
465  }
466 
474  private static function __getRepositoryObjectsByType($a_type)
475  {
476  global $DIC;
477  $ilDB = $DIC['ilDB'];
478 
479  return $ilDB->query(
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") . " " .
485  "AND t.tree=1 " .
486  "ORDER BY d.owner"
487  );
488  }
489 
497  private static function __getWorkspaceObjectsByType($a_type)
498  {
499  global $DIC;
500  $ilDB = $DIC['ilDB'];
501 
502  return $ilDB->query(
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 " .
509  "ORDER BY d.owner"
510  );
511  }
512 
526  private static function __updateDiskUsageReportOfUsers($a_access_obj, $a_type)
527  {
528  global $DIC;
529  $ilDB = $DIC['ilDB'];
530 
531  // get all users
532  $res = $ilDB->query("SELECT usr_id FROM usr_data");
533 
534  // for each user count the number of objects and sum up the size
535  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
536  $data = $a_access_obj->_lookupDiskUsageOfUser($row->usr_id);
537  self::__saveUserData($row->usr_id, $a_type, $data["size"], $data["count"]);
538  }
539  }
540 
541  public static function _sendSummaryMails()
542  {
543  global $DIC;
544  $ilSetting = $DIC['ilSetting'];
545 
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());
549 
550  include_once 'Services/Mail/classes/class.ilDiskQuotaSummaryNotification.php';
551  $dqsn = new ilDiskQuotaSummaryNotification();
552  $dqsn->send();
553  }
554  }
555 
561  public static function _sendReminderMails()
562  {
563  global $DIC;
564  $ilDB = $DIC['ilDB'];
565 
566  require_once 'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
567  $mail = new ilDiskQuotaReminderMail();
568 
569  $res = $ilDB->queryf(
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") . "," .
572 
573  // Inactive users get the date 0001-01-01 so that they appear
574  // first when the list is sorted by this field. Users with
575  // unlimited access get the date 9999-12-31 so that they appear
576  // last.
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," .
578 
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, " .
586 
587  // We add 0 to some of the values to convert them into a number.
588  // This is needed for correct sorting.
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 " .
590  "FROM usr_data u " .
591 
592  // Fetch the role with the highest disk quota value.
593  "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
594  "FROM usr_data u " .
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 " .
598 
599  // Fetch the system role in order to determine whether the user has unlimited disk quota
600  "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
601 
602  // Fetch the user disk quota from table usr_pref
603  "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
604 
605  // Fetch the disk usage from table usr_pref
606  "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
607 
608  // Fetch the last update from table usr_pref
609  "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
610 
611  // Fetch the date when the last disk quota reminder was sent from table usr_pref
612  "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' " .
613 
614  // Fetch the language of the user
615  "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' " .
616 
617  // Fetch only users who have exceeded their quota, and who have
618  // access, and who have not received a reminder in the past seven days
619  // #8554 / #10301
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)
626  );
627 
628  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
629  $details = self::_lookupDiskUsage($row['usr_id']);
630  $row['disk_usage_details'] = $details['details'];
631 
632  // Send reminder e-mail
633  $mail->setData($row);
634  $mail->send();
635 
636  // Store the date the last reminder was sent in the table usr_pref.
637  if ($row['last_reminder'] != null) {
638  $ilDB->manipulatef(
639  "UPDATE usr_pref SET value= " . $ilDB->now() . " " .
640  "WHERE usr_id=%s AND keyword = 'disk_quota_last_reminder'",
641  array('integer'),
642  array($row['usr_id'])
643  );
644  } else {
645  $ilDB->manipulatef(
646  "INSERT INTO usr_pref (usr_id, keyword, value) " .
647  "VALUES (%s, 'disk_quota_last_reminder', " . $ilDB->now() . ")",
648  array('integer'),
649  array($row['usr_id'])
650  );
651  }
652  }
653  }
654 
659  public static function _lookupDiskUsageReportLastUpdate()
660  {
661  global $DIC;
662  $ilDB = $DIC['ilDB'];
663 
664  require_once 'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
665  $mail = new ilDiskQuotaReminderMail();
666 
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;
671  }
672 
673  public static function _lookupPersonalWorkspaceDiskQuota($a_user_id)
674  {
675  global $DIC;
676  $ilDB = $DIC['ilDB'];
677 
678  $info = array();
679 
680  $res = $ilDB->queryf(
681  "SELECT keyword, value " .
682  "FROM usr_pref " .
683  "WHERE usr_id = %s " .
684  "AND keyword = %s ",
685  array('integer', 'text'),
686  array($a_user_id, "wsp_disk_quota")
687  );
688 
690  $info['user_wsp_disk_quota'] = $row->value;
691 
692 
693  // Note: we order by role_id ASC here, in the assumption that
694  // the system role has the lowest ID of all roles.
695  // this way, if a user has the system role, this role
696  // will always returned first.
697  $ilDB->setLimit(1);
698  $res = $ilDB->queryf(
699  "SELECT rd.role_id, rd.wsp_disk_quota, od.title " .
700  "FROM rbac_ua ua " .
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)
708  );
709 
711  $info['role_id'] = $row->role_id;
712  $info['role_title'] = $row->title;
713 
714  // Note: Users with the system role have an infinite disk quota
715  // We calculate positive infinity by negating the logarithm of 0.
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']);
718 
719  return $info;
720  }
721 }
static _sendReminderMails()
Sends reminder e-mails to all users who have access and who have exceeded their disk quota and who ha...
$type
global $DIC
Definition: saml.php:7
Class ilDiskQuotaChecker.
static _lookupPersonalWorkspaceDiskQuota($a_user_id)
Access class for file objects.
Class ilObjMediaCastAccess.
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. ...
Class ilObjForumAccess.
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 ...
$a_type
Definition: workflow.php:92
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.
Class ilObjMailAccess.
static __saveUserData($a_user_id, $a_type, $a_size, $a_count)
Save disk quota for user.
$row
static _lookupDiskUsage($a_user_id)
Gets the disk usage info for the specified user account.
Class ilDiskQuotaReminderMail.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$info
Definition: index.php:5
$key
Definition: croninfo.php:18
$data
Definition: bench.php:6
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.