Skip to content

Commit

Permalink
Group: get current time correclty for comparison with registration en…
Browse files Browse the repository at this point in the history
…d (40532)
  • Loading branch information
schmitz-ilias committed Apr 25, 2024
1 parent bf78040 commit 9858e6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/ILIAS/Group/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ In contrast to the behaviour in courses it is possible for group members with pe

## Mid Term
- Only group users with permission "edit_permission" or group administrators are allowed to administrate group administrators.
- The datetimes in the columns "registration_start" and "registration_end" in
the db table "grp_settings" are saved in the local timezone of the server. They
should instead be saved in UTC, and existing values corrected accordingly.

## Long Term

Expand Down
8 changes: 7 additions & 1 deletion components/ILIAS/Group/classes/class.ilObjGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,12 @@ public static function findGroupsWithNotEnoughMembers(): array
$res = array();
$before = new ilDateTime(time(), IL_CAL_UNIX);
$now_date = $before->get(IL_CAL_DATETIME, '', ilTimeZone::UTC);
/*
* For groups, registration_start and registration_end are currently not
* persisted in UTC but the local timezone, so when fetching the current time
* here we need to do the same.
*/
$now_date_local = $before->get(IL_CAL_DATETIME);
$now = $before->get(IL_CAL_UNIX);

$set = $ilDB->query($q = "SELECT obj_id, registration_min_members" .
Expand All @@ -1562,7 +1568,7 @@ public static function findGroupsWithNotEnoughMembers(): array
" AND leave_end < " . $ilDB->quote($now, "integer") . ")" .
" OR (leave_end IS NULL" .
" AND registration_end IS NOT NULL" .
" AND registration_end < " . $ilDB->quote($now_date, "text") . "))" .
" AND registration_end < " . $ilDB->quote($now_date_local, "text") . "))" .
" AND (period_start IS NULL OR period_start > " . $ilDB->quote($now_date, ilDBConstants::T_TEXT) . ")");
while ($row = $ilDB->fetchAssoc($set)) {
$refs = ilObject::_getAllReferences((int) $row['obj_id']);
Expand Down

0 comments on commit 9858e6f

Please sign in to comment.