ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDiskQuotaChecker Class Reference

Class ilDiskQuotaChecker. More...

+ Collaboration diagram for ilDiskQuotaChecker:

Public Member Functions

 __construct ()
 

Static Public Member Functions

static _lookupDiskQuota ($a_user_id)
 Gets the disk quota info for the specified user account. More...
 
static _lookupDiskUsage ($a_user_id)
 Gets the disk usage info for the specified user account. More...
 
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. More...
 
static _updateDiskUsageReport ()
 Updates the disk usage info of all user accounts. More...
 
static _sendSummaryMails ()
 
static _sendReminderMails ()
 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. More...
 
static _lookupDiskUsageReportLastUpdate ()
 Returns the SQL datetime of the last update of the disk usage report. More...
 
static _lookupPersonalWorkspaceDiskQuota ($a_user_id)
 

Static Private Member Functions

static __updateDiskUsageReportOfType ($a_access_obj, $a_type)
 Updates the disk usage report of the specified object type for all user accounts. More...
 
static __saveUserData ($a_user_id, $a_type, $a_size, $a_count)
 Save disk quota for user. More...
 
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 More...
 
static __getRepositoryObjectsByType ($a_type)
 get all objects of the desired type which are in the repository ordered by owner More...
 
static __getWorkspaceObjectsByType ($a_type)
 get all objects of the desired type which are in the personal workspace ordered by owner More...
 
static __updateDiskUsageReportOfUsers ($a_access_obj, $a_type)
 Updates the disk usage report of the specified object type for all user accounts. More...
 

Detailed Description

Class ilDiskQuotaChecker.

Author
Werner Randelshofer, Hochschule Luzern, werne.nosp@m.r.ra.nosp@m.ndels.nosp@m.hofe.nosp@m.r@hsl.nosp@m.u.ch
Version
$Id$

Definition at line 33 of file class.ilDiskQuotaChecker.php.

Constructor & Destructor Documentation

◆ __construct()

ilDiskQuotaChecker::__construct ( )

Definition at line 35 of file class.ilDiskQuotaChecker.php.

36 {
37 }

Member Function Documentation

◆ __getRepositoryObjectsByType()

static ilDiskQuotaChecker::__getRepositoryObjectsByType (   $a_type)
staticprivate

get all objects of the desired type which are in the repository ordered by owner

Parameters
type$a_type
Returns
DB result object

Definition at line 475 of file class.ilDiskQuotaChecker.php.

476 {
477 global $DIC;
478 $ilDB = $DIC['ilDB'];
479
480 return $ilDB->query(
481 "SELECT DISTINCT d.obj_id, d.owner " .
482 "FROM object_data d " .
483 "JOIN object_reference r ON d.obj_id=r.obj_id " .
484 "JOIN tree t ON t.child=r.ref_id " .
485 "WHERE d.type = " . $ilDB->quote($a_type, "text") . " " .
486 "AND t.tree=1 " .
487 "ORDER BY d.owner"
488 );
489 }
global $DIC
Definition: saml.php:7
global $ilDB
$a_type
Definition: workflow.php:92

References $a_type, $DIC, and $ilDB.

Referenced by __updateDiskUsageReportOfType().

+ Here is the caller graph for this function:

◆ __getWorkspaceObjectsByType()

static ilDiskQuotaChecker::__getWorkspaceObjectsByType (   $a_type)
staticprivate

get all objects of the desired type which are in the personal workspace ordered by owner

Parameters
type$a_type
Returns
DB result object

Definition at line 498 of file class.ilDiskQuotaChecker.php.

499 {
500 global $DIC;
501 $ilDB = $DIC['ilDB'];
502
503 return $ilDB->query(
504 "SELECT DISTINCT d.obj_id, d.owner " .
505 "FROM object_data d " .
506 "JOIN object_reference_ws r ON d.obj_id=r.obj_id " .
507 "JOIN tree_workspace t ON t.child=r.wsp_id " .
508 "WHERE d.type = " . $ilDB->quote($a_type, "text") . " " .
509 "AND t.tree=d.owner " .
510 "ORDER BY d.owner"
511 );
512 }

References $a_type, $DIC, and $ilDB.

Referenced by __updateDiskUsageReportOfType().

+ Here is the caller graph for this function:

◆ __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 421 of file class.ilDiskQuotaChecker.php.

422 {
423 global $DIC;
424 $ilDB = $DIC['ilDB'];
425
426 if ($a_user_id && $a_size != null && $a_count != null) {
427 $ilDB->manipulate("INSERT INTO usr_pref " .
428 "(usr_id, keyword, value) " .
429 "VALUES " .
430 "(" . $ilDB->quote($a_user_id, 'integer') . ", " .
431 $ilDB->quote('disk_usage.' . $a_type . '.size') . ", " .
432 $ilDB->quote($a_size, 'integer') . ")");
433
434 $ilDB->manipulate(
435 "INSERT INTO usr_pref " .
436 "(usr_id, keyword, value) " .
437 "VALUES " .
438 "(" . $ilDB->quote($a_user_id, 'integer') . ", " .
439 $ilDB->quote('disk_usage.' . $a_type . '.count') . ", " .
440 $ilDB->quote($a_count, 'integer') . ")"
441 );
442 }
443 }

References $a_type, $DIC, and $ilDB.

Referenced by __updateDiskUsageReportOfType(), and __updateDiskUsageReportOfUsers().

+ Here is the caller graph for this function:

◆ __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_objObject A access object, such as ilObjFileAccess.
$a_typestring 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 393 of file class.ilDiskQuotaChecker.php.

394 {
395 $data = array();
396
397 // repository
400
401 // personal workspace
404
405 // saving result to DB
406 if ($data) {
407 foreach ($data as $owner => $item) {
408 self::__saveUserData($owner, $a_type, $item["size"], $item["count"]);
409 }
410 }
411 }
static __getRepositoryObjectsByType($a_type)
get all objects of the desired type which are in the repository ordered by owner
static __getWorkspaceObjectsByType($a_type)
get all objects of the desired type which are in the personal workspace ordered by owner
static __saveUserData($a_user_id, $a_type, $a_size, $a_count)
Save disk quota for user.
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
foreach($_POST as $key=> $value) $res

References $a_type, $data, $res, __getRepositoryObjectsByType(), __getWorkspaceObjectsByType(), __saveUserData(), and __updateDiskUsageReportOfTypeHelper().

Referenced by _updateDiskUsageReport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __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 453 of file class.ilDiskQuotaChecker.php.

454 {
455 while ($row = $a_objects->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
456 if ($row->owner != null) {
457 if (!array_key_exists($row->owner, $a_result)) {
458 // initialize values
459 $a_result[$row->owner] = array("size" => 0, "count" => 0);
460 }
461
462 $a_result[$row->owner]["size"] += $a_access_obj->_lookupDiskUsage($row->obj_id);
463 $a_result[$row->owner]["count"]++;
464 }
465 }
466 }

References $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __updateDiskUsageReportOfType().

+ Here is the caller graph for this function:

◆ __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_objObject A access object, such as ilObjFileAccess.
$a_typestring 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 527 of file class.ilDiskQuotaChecker.php.

528 {
529 global $DIC;
530 $ilDB = $DIC['ilDB'];
531
532 // get all users
533 $res = $ilDB->query("SELECT usr_id FROM usr_data");
534
535 // for each user count the number of objects and sum up the size
536 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
537 $data = $a_access_obj->_lookupDiskUsageOfUser($row->usr_id);
538 self::__saveUserData($row->usr_id, $a_type, $data["size"], $data["count"]);
539 }
540 }

References $a_type, $data, $DIC, $ilDB, $res, $row, __saveUserData(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _updateDiskUsageReport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _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
stringusage 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
stringaccess 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 222 of file class.ilDiskQuotaChecker.php.

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 }

References $data, $DIC, $ilDB, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilObjFileAccessSettingsGUI\viewDiskQuotaReport().

+ Here is the caller graph for this function:

◆ _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
integeruser id
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.

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 }
$info
Definition: index.php:5

References $DIC, $ilDB, $info, $res, $row, and ilDBConstants\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
integeruser id
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 144 of file class.ilDiskQuotaChecker.php.

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 }
$key
Definition: croninfo.php:18
$type

References $DIC, $ilDB, $info, $key, $res, $row, $type, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _sendReminderMails(), and ilDiskQuotaSummaryNotification\send().

+ Here is the caller graph for this function:

◆ _lookupDiskUsageReportLastUpdate()

static ilDiskQuotaChecker::_lookupDiskUsageReportLastUpdate ( )
static

Returns the SQL datetime of the last update of the disk usage report.

Returns null, if the disk usage report has never been made.

Definition at line 660 of file class.ilDiskQuotaChecker.php.

661 {
662 global $DIC;
663 $ilDB = $DIC['ilDB'];
664
665 require_once 'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
666 $mail = new ilDiskQuotaReminderMail();
667
668 $res = $ilDB->query("SELECT MAX(value) last_update " .
669 "FROM usr_pref WHERE keyword='disk_usage.last_update'");
671 return ($row != null) ? $row['last_update'] : null;
672 }
Class ilDiskQuotaReminderMail.

References $DIC, $ilDB, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilObjFileAccessSettingsGUI\viewDiskQuotaReport().

+ Here is the caller graph for this function:

◆ _lookupPersonalWorkspaceDiskQuota()

static ilDiskQuotaChecker::_lookupPersonalWorkspaceDiskQuota (   $a_user_id)
static

Definition at line 674 of file class.ilDiskQuotaChecker.php.

675 {
676 global $DIC;
677 $ilDB = $DIC['ilDB'];
678
679 $info = array();
680
681 $res = $ilDB->queryf(
682 "SELECT keyword, value " .
683 "FROM usr_pref " .
684 "WHERE usr_id = %s " .
685 "AND keyword = %s ",
686 array('integer', 'text'),
687 array($a_user_id, "wsp_disk_quota")
688 );
689
691 $info['user_wsp_disk_quota'] = $row->value;
692
693
694 // Note: we order by role_id ASC here, in the assumption that
695 // the system role has the lowest ID of all roles.
696 // this way, if a user has the system role, this role
697 // will always returned first.
698 $ilDB->setLimit(1);
699 $res = $ilDB->queryf(
700 "SELECT rd.role_id, rd.wsp_disk_quota, od.title " .
701 "FROM rbac_ua ua " .
702 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s " .
703 "JOIN role_data rd ON ua.rol_id=rd.role_id " .
704 "JOIN object_data od ON od.obj_id=rd.role_id " .
705 "WHERE ua.usr_id = %s " .
706 "ORDER BY wsp_disk_quota DESC, role_id ASC",
707 array('integer','integer'),
708 array(ROLE_FOLDER_ID, $a_user_id)
709 );
710
712 $info['role_id'] = $row->role_id;
713 $info['role_title'] = $row->title;
714
715 // Note: Users with the system role have an infinite disk quota
716 // We calculate positive infinity by negating the logarithm of 0.
717 $info['role_wsp_disk_quota'] = ($row->role_id == SYSTEM_ROLE_ID) ? -log(0) : $row->wsp_disk_quota;
718 $info['disk_quota'] = max($info['user_wsp_disk_quota'], $info['role_wsp_disk_quota']);
719
720 return $info;
721 }

References $DIC, $ilDB, $info, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDiskQuotaHandler\getStatusLegend(), and ilDiskQuotaHandler\isUploadPossible().

+ Here is the caller graph for this function:

◆ _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 562 of file class.ilDiskQuotaChecker.php.

563 {
564 global $DIC;
565 $ilDB = $DIC['ilDB'];
566
567 require_once 'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
568 $mail = new ilDiskQuotaReminderMail();
569
570 $res = $ilDB->queryf(
571 "SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," .
572 "u.time_limit_unlimited, " . $ilDB->fromUnixtime("u.time_limit_from") . ", " . $ilDB->fromUnixtime("u.time_limit_until") . "," .
573
574 // Inactive users get the date 0001-01-01 so that they appear
575 // first when the list is sorted by this field. Users with
576 // unlimited access get the date 9999-12-31 so that they appear
577 // last.
578 "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
580 " CASE WHEN " . $ilDB->unixTimestamp() . " BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," .
581 "rq.role_disk_quota, system_role.rol_id role_id, " .
582 "p1.value+0 user_disk_quota," .
583 "p2.value+0 disk_usage, " .
584 "p3.value last_update, " .
585 "p4.value last_reminder, " .
586 "p5.value language, " .
587
588 // We add 0 to some of the values to convert them into a number.
589 // This is needed for correct sorting.
590 "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 " .
591 "FROM usr_data u " .
592
593 // Fetch the role with the highest disk quota value.
594 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
595 "FROM usr_data u " .
596 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " .
597 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s " .
598 "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 " .
599
600 // Fetch the system role in order to determine whether the user has unlimited disk quota
601 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
602
603 // Fetch the user disk quota from table usr_pref
604 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
605
606 // Fetch the disk usage from table usr_pref
607 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
608
609 // Fetch the last update from table usr_pref
610 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
611
612 // Fetch the date when the last disk quota reminder was sent from table usr_pref
613 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' " .
614
615 // Fetch the language of the user
616 "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' " .
617
618 // Fetch only users who have exceeded their quota, and who have
619 // access, and who have not received a reminder in the past seven days
620 // #8554 / #10301
621 'WHERE (((p1.value+0 >= rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR
622 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' .
623 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' . $ilDB->unixTimestamp() . ' BETWEEN u.time_limit_from AND u.time_limit_until)) ' .
624 'AND (p4.value IS NULL OR p4.value < DATE_SUB(NOW(), INTERVAL 7 DAY)) ',
625 array('integer','integer'),
626 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
627 );
628
629 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
630 $details = self::_lookupDiskUsage($row['usr_id']);
631 $row['disk_usage_details'] = $details['details'];
632
633 // Send reminder e-mail
634 $mail->setData($row);
635 $mail->send();
636
637 // Store the date the last reminder was sent in the table usr_pref.
638 if ($row['last_reminder'] != null) {
639 $ilDB->manipulatef(
640 "UPDATE usr_pref SET value= " . $ilDB->now() . " " .
641 "WHERE usr_id=%s AND keyword = 'disk_quota_last_reminder'",
642 array('integer'),
643 array($row['usr_id'])
644 );
645 } else {
646 $ilDB->manipulatef(
647 "INSERT INTO usr_pref (usr_id, keyword, value) " .
648 "VALUES (%s, 'disk_quota_last_reminder', " . $ilDB->now() . ")",
649 array('integer'),
650 array($row['usr_id'])
651 );
652 }
653 }
654 }
static _lookupDiskUsage($a_user_id)
Gets the disk usage info for the specified user account.

References $DIC, $ilDB, $res, $row, _lookupDiskUsage(), and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilDAVCronDiskQuota\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _sendSummaryMails()

static ilDiskQuotaChecker::_sendSummaryMails ( )
static

Definition at line 542 of file class.ilDiskQuotaChecker.php.

543 {
544 global $DIC;
545 $ilSetting = $DIC['ilSetting'];
546
547 $lastStart = $ilSetting->get('last_cronjob_disk_quota_sum_start_ts', 0);
548 if (!$lastStart || date('dmY', $lastStart) != date('dmY')) {
549 $ilSetting->set('last_cronjob_disk_quota_sum_start_ts', time());
550
551 include_once 'Services/Mail/classes/class.ilDiskQuotaSummaryNotification.php';
552 $dqsn = new ilDiskQuotaSummaryNotification();
553 $dqsn->send();
554 }
555 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilSetting, and date.

Referenced by ilDAVCronDiskQuota\run().

+ Here is the caller graph for this function:

◆ _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 334 of file class.ilDiskQuotaChecker.php.

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';
346
347 require_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
349
350 require_once 'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
352
353 require_once 'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
355
356 require_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
358
359 require_once 'Services/Mail/classes/class.ilObjMailAccess.php';
361
362 // insert the sum of the disk usage of each user
363 // note: second % is needed to not fail on oracle char field
364 $ilDB->manipulate(
365 "INSERT INTO usr_pref " .
366 "(usr_id, keyword, value) " .
367 "SELECT usr_id, 'disk_usage', SUM(value) " .
368 "FROM usr_pref " .
369 "WHERE " . $ilDB->like("keyword", "text", 'disk_usage.%.size%') .
370 "GROUP BY usr_id"
371 );
372
373 // insert last update
374 $ilDB->manipulate("INSERT INTO usr_pref " .
375 "(usr_id, keyword, value) " .
376 "SELECT usr_id, 'disk_usage.last_update', " . $ilDB->now() . " " .
377 "FROM usr_data");
378 }
static __updateDiskUsageReportOfUsers($a_access_obj, $a_type)
Updates the disk usage report of the specified object type for all user accounts.
static __updateDiskUsageReportOfType($a_access_obj, $a_type)
Updates the disk usage report of the specified object type for all user accounts.
Access class for file objects.
Class ilFileBasedLMAccess.
Class ilObjForumAccess.
Class ilObjMailAccess.
Class ilObjMediaCastAccess.

References $DIC, $ilDB, __updateDiskUsageReportOfType(), and __updateDiskUsageReportOfUsers().

Referenced by ilDAVCronDiskQuota\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: