ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
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

@param type $a_type 
@return DB result object

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

489 {
490 global $DIC;
491 $ilDB = $DIC['ilDB'];
492
493 return $ilDB->query("SELECT DISTINCT d.obj_id, d.owner ".
494 "FROM object_data d ".
495 "JOIN object_reference r ON d.obj_id=r.obj_id ".
496 "JOIN tree t ON t.child=r.ref_id ".
497 "WHERE d.type = ".$ilDB->quote($a_type, "text")." ".
498 "AND t.tree=1 ".
499 "ORDER BY d.owner"
500 );
501 }
global $ilDB
global $DIC
$a_type
Definition: workflow.php:93

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 510 of file class.ilDiskQuotaChecker.php.

511 {
512 global $DIC;
513 $ilDB = $DIC['ilDB'];
514
515 return $ilDB->query("SELECT DISTINCT d.obj_id, d.owner ".
516 "FROM object_data d ".
517 "JOIN object_reference_ws r ON d.obj_id=r.obj_id ".
518 "JOIN tree_workspace t ON t.child=r.wsp_id ".
519 "WHERE d.type = ".$ilDB->quote($a_type, "text")." ".
520 "AND t.tree=d.owner ".
521 "ORDER BY d.owner"
522 );
523 }

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 423 of file class.ilDiskQuotaChecker.php.

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

References $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 {
408 foreach($data as $owner => $item)
409 {
410 self::__saveUserData($owner, $a_type, $item["size"], $item["count"]);
411 }
412 }
413 }
static __getRepositoryObjectsByType($a_type)
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

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 455 of file class.ilDiskQuotaChecker.php.

456 {
457 $count = null;
458 $size = null;
459 $owner = null;
460 while ($row = $a_objects->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
461 if ($row->owner != $owner) {
462 if ($owner != null) {
463 $a_result[$owner]["size"] += $size;
464 $a_result[$owner]["count"] += $count;
465 }
466 $owner = $row->owner;
467 $size = 0;
468 $count = 0;
469 }
470 $size += $a_access_obj->_lookupDiskUsage($row->obj_id);
471 $count++;
472 }
473
474 // add last set data
475 if ($owner != null) {
476 $a_result[$owner]["size"] += $size;
477 $a_result[$owner]["count"] += $count;
478 }
479 }
$size
Definition: RandomTest.php:79

References $row, $size, 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 538 of file class.ilDiskQuotaChecker.php.

539 {
540 global $DIC;
541 $ilDB = $DIC['ilDB'];
542
543 // get all users
544 $res = $ilDB->query("SELECT usr_id FROM usr_data");
545
546 // for each user count the number of objects and sum up the size
547 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
548 $data = $a_access_obj->_lookupDiskUsageOfUser($row->usr_id);
549 self::__saveUserData($row->usr_id, $a_type, $data["size"], $data["count"]);
550 }
551 }

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 221 of file class.ilDiskQuotaChecker.php.

222 {
223 $data = array();
224 global $DIC;
225 $ilDB = $DIC['ilDB'];
226
227 if (! $a_order_column) {
228 $a_order_column = 'disk_usage';
229 }
230
231 switch ($a_usage_filter) {
232 case 1: // all users
233 $where_clause = '';
234 break;
235 case 2: // only users who don't use disk space
236 $where_clause = 'WHERE (p2.value IS NULL) ';
237 break;
238 case 3: // only users who use disk space
239 default:
240 $where_clause = 'WHERE (p2.value+0 > 0) ';
241 break;
242 case 4: // only users who have exceeded their disk quota
243 // #8554 / #10301
244 $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
245 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ';
246 break;
247 }
248 switch ($a_access_filter) {
249 case 1: // all users
250 $where_clause .= '';
251 break;
252 case 2: // only users who have access
253 default:
254 $where_clause .= ($where_clause == '' ? 'WHERE ' : ' AND ' ).
255 '(u.active=1 AND (u.time_limit_unlimited = 1 OR '.$ilDB->unixTimestamp().' BETWEEN u.time_limit_from AND u.time_limit_until)) ';
256 break;
257 case 3: // only users who don't have access
258 $where_clause .= ($where_clause == '' ? 'WHERE ' : ' AND ' ).
259 '(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 break;
261 }
262
263 $res = $ilDB->queryf(
264 "SELECT u.usr_id,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active,".
265 "u.time_limit_unlimited, ".$ilDB->fromUnixtime("u.time_limit_from").", ".$ilDB->fromUnixtime("u.time_limit_until").",".
266
267 // Inactive users get the date 0001-01-01 so that they appear
268 // first when the list is sorted by this field. Users with
269 // unlimited access get the date 9999-12-31 so that they appear
270 // last.
271 "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,".
272
273 "CASE WHEN ".$ilDB->unixTimestamp()." BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired,".
274 "rq.role_disk_quota, system_role.rol_id role_id, ".
275 "p1.value+0 user_disk_quota,".
276 "p2.value+0 disk_usage, ".
277 "p3.value last_update, ".
278 "p4.value last_reminder, ".
279
280 // We add 0 to some of the values to convert them into a number.
281 // This is needed for correct sorting.
282 "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 "FROM usr_data u ".
284
285 // Fetch the role with the highest disk quota value.
286 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota ".
287 "FROM usr_data u ".
288 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id ".
289 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s ".
290 "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 ".
291
292 // Fetch the system role in order to determine whether the user has unlimited disk quota
293 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s ".
294
295 // Fetch the user disk quota from table usr_pref
296 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' ".
297
298 // Fetch the disk usage from table usr_pref
299 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' ".
300
301 // Fetch the last update from table usr_pref
302 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' ".
303
304 // Fetch the date when the last disk quota reminder was sent from table usr_pref
305 "LEFT JOIN usr_pref p4 ON p4.usr_id=u.usr_id AND p4.keyword = 'disk_quota_last_reminder' ".
306
307 $where_clause.
308 "ORDER BY ".$a_order_column." ".($a_order_by=='asc'?' ASC':' DESC').", ".
309 "lastname, firstname, login"
310 ,
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 {
318 $data[] = $row;
319 $previous_usr_id = $row['usr_id'];
320 }
321 }
322 return $data;
323 }

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("SELECT keyword, value ".
78 "FROM usr_pref ".
79 "WHERE usr_id = %s ".
80 "AND keyword IN ('disk_quota', 'disk_quota_last_reminder')",
81 array('integer'),
82 array($a_user_id));
83
84 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
85 switch ($row->keyword)
86 {
87 case 'disk_quota' :
88 $info['user_disk_quota'] = $row->value;
89 break;
90 case 'disk_quota_last_reminder' :
91 $info['last_reminder'] = $row->value;
92 break;
93 }
94 }
95
96
97 // Note: we order by role_id ASC here, in the assumption that
98 // the system role has the lowest ID of all roles.
99 // this way, if a user has the system role, this role
100 // will always returned first.
101 $ilDB->setLimit(1);
102 $res = $ilDB->queryf("SELECT rd.role_id, rd.disk_quota, od.title ".
103 "FROM rbac_ua ua ".
104 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent = %s ".
105 "JOIN role_data rd ON ua.rol_id=rd.role_id ".
106 "JOIN object_data od ON od.obj_id=rd.role_id ".
107 "WHERE ua.usr_id = %s ".
108 "ORDER BY disk_quota DESC, role_id ASC",
109 array('integer','integer'),
110 array(ROLE_FOLDER_ID, $a_user_id));
111
113 $info['role_id'] = $row->role_id;
114 $info['role_title'] = $row->title;
115
116 // Note: Users with the system role have an infinite disk quota
117 // We calculate positive infinity by negating the logarithm of 0.
118 $info['role_disk_quota'] = ($row->role_id == SYSTEM_ROLE_ID) ? -log(0) : $row->disk_quota;
119 $info['disk_quota'] = max($info['user_disk_quota'], $info['role_disk_quota']);
120
121 return $info;
122 }
$info
Definition: example_052.php:80

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 141 of file class.ilDiskQuotaChecker.php.

142 {
143 $info = array();
144 $details = array();
145
146 global $DIC;
147 $ilDB = $DIC['ilDB'];
148
149 $res = $ilDB->query("SELECT keyword, value ".
150 "FROM usr_pref ".
151 "WHERE usr_id = ".$ilDB->quote($a_user_id, 'integer')." ".
152 "AND ".$ilDB->like("keyword", "text", 'disk\\_usage%')
153 );
154
155 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
156 switch ($row->keyword)
157 {
158 case 'disk_usage.last_update' :
159 $info['last_update'] = $row->value;
160 break;
161
162 case 'disk_usage' :
163 $info['disk_usage'] = $row->value;
164 break;
165
166 default :
167 // The following preg_match is used to extract the type
168 // and the keys 'count' and 'size' from the keywords:
169 // disk_usage.type.count
170 // disk_usage.type.size
171 $matches = array();
172 preg_match('/^disk_usage\\.([^.]+)\\.([^.]+)/', $row->keyword, $matches);
173 $type = $matches[1];
174 $key = $matches[2];
175 if ($type)
176 {
177 $detail_data = $details[$type];
178 if ($detail_data == null)
179 {
180 $detail_data = array('type'=>$type);
181 }
182 $detail_data[$key] = $row->value;
183 }
184 $details[$type] = $detail_data;
185 break;
186 }
187 }
188 $info['details'] = $details;
189
190
191 //ilDiskQuotaChecker::_updateDiskUsageReport();
192
193 return $info;
194 }

References $DIC, $ilDB, $info, $res, $row, 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 677 of file class.ilDiskQuotaChecker.php.

678 {
679 global $DIC;
680 $ilDB = $DIC['ilDB'];
681
682 require_once 'Services/Mail/classes/class.ilDiskQuotaReminderMail.php';
683 $mail = new ilDiskQuotaReminderMail();
684
685 $res = $ilDB->query("SELECT MAX(value) last_update ".
686 "FROM usr_pref WHERE keyword='disk_usage.last_update'");
688 return ($row != null) ? $row['last_update'] : null;
689 }
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 691 of file class.ilDiskQuotaChecker.php.

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

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 574 of file class.ilDiskQuotaChecker.php.

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

554 {
555 global $DIC;
556 $ilSetting = $DIC['ilSetting'];
557
558 $lastStart = $ilSetting->get('last_cronjob_disk_quota_sum_start_ts', 0);
559 if( !$lastStart || date('dmY', $lastStart) != date('dmY') )
560 {
561 $ilSetting->set('last_cronjob_disk_quota_sum_start_ts', time());
562
563 include_once 'Services/Mail/classes/class.ilDiskQuotaSummaryNotification.php';
564 $dqsn = new ilDiskQuotaSummaryNotification();
565 $dqsn->send();
566 }
567 }
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 335 of file class.ilDiskQuotaChecker.php.

336 {
337 global $DIC;
338 $ilDB = $DIC['ilDB'];
339
340 // delete old values
341 $ilDB->manipulate("DELETE FROM usr_pref ".
342 "WHERE ".$ilDB->like("keyword", "text", 'disk_usage%'));
343
344
345 require_once 'Modules/File/classes/class.ilObjFileAccess.php';
347
348 require_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
350
351 require_once 'Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php';
353
354 require_once 'Modules/MediaCast/classes/class.ilObjMediaCastAccess.php';
356
357 require_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php';
359
360 require_once 'Services/Mail/classes/class.ilObjMailAccess.php';
362
363 // insert the sum of the disk usage of each user
364 // note: second % is needed to not fail on oracle char field
365 $ilDB->manipulate("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: