MDL-30157 enrol_manual: timestart a few seconds before
authorDavid Monllao <davidm@moodle.com>
Thu, 17 Sep 2015 09:06:53 +0000 (17:06 +0800)
committerDavid Monllao <davidm@moodle.com>
Thu, 17 Sep 2015 09:09:36 +0000 (17:09 +0800)
We want to prevent conflicts with get_enrolled_sql trick for db caching
plus users should be able to access the course once enrolled.

enrol/manual/ajax.php
enrol/manual/manage.php

index 5c04cc2..94ccd7b 100644 (file)
@@ -140,7 +140,9 @@ switch ($action) {
                 $timestart = $course->startdate;
                 break;
             case 4:
                 $timestart = $course->startdate;
                 break;
             case 4:
-                $timestart = time();
+                // We mimic get_enrolled_sql round(time(), -2) but always floor as we want users to always access their
+                // courses once they are enrolled.
+                $timestart = intval(substr(time(), 0, 8) . '00') - 1;
                 break;
             case 3:
             default:
                 break;
             case 3:
             default:
index 744be86..0b9ca4c 100644 (file)
@@ -119,7 +119,9 @@ if ($canenrol && optional_param('add', false, PARAM_BOOL) && confirm_sesskey())
                     $timestart = $course->startdate;
                     break;
                 case 4:
                     $timestart = $course->startdate;
                     break;
                 case 4:
-                    $timestart = $now;
+                    // We mimic get_enrolled_sql round(time(), -2) but always floor as we want users to always access their
+                    // courses once they are enrolled.
+                    $timestart = intval(substr($now, 0, 8) . '00') - 1;
                     break;
                 case 3:
                 default:
                     break;
                 case 3:
                 default: