# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/accesslib.php
--- moodle/lib/accesslib.php Base (1.662)
+++ moodle/lib/accesslib.php Locally Modified (Based On 1.662)
@@ -2497,16 +2497,16 @@
 
 /**
  * This function makes a role-assignment (a role for a user in a particular context)
- *
+ * if we're inbetween $timestart and $timeend (if specified)
  * @param int $roleid the role of the id
  * @param int $userid userid
  * @param int $contextid id of the context
  * @param string $component example 'enrol_ldap', defaults to '' which means manual assignment,
  * @prama int $itemid id of enrolment/auth plugin
  * @param string $timemodified defaults to current time
- * @return int new/existing id of the assignment
+ * @return int new/existing id of the assignment or false for when theres been no assignment done..
  */
-function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0, $timemodified = '') {
+function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0, $timemodified = '', $timestart = 0, $timeend = 0) {
     global $USER, $CFG, $DB;
 
     // first of all detect if somebody is using old style parameters
@@ -2564,6 +2564,7 @@
         return $ra->id;
     }
 
+    if (($timestart==0 || time() > $timestart) && ($timeend==0 || time() < $timeend)) {
     // Create a new entry
     $ra = new object();
     $ra->roleid       = $roleid;
@@ -2587,7 +2588,10 @@
     events_trigger('role_assigned', $ra);
 
     return $ra->id;
+    } else {
+        return false;
 }
+}
 
 /**
  * Removes one role assignment
Index: moodle/lib/enrollib.php
--- moodle/lib/enrollib.php Base (1.22)
+++ moodle/lib/enrollib.php Locally Modified (Based On 1.22)
@@ -974,9 +974,9 @@
 
         if ($roleid) {
             if ($this->roles_protected()) {
-                role_assign($roleid, $userid, $context->id, 'enrol_'.$name, $instance->id);
+                role_assign($roleid, $userid, $context->id, 'enrol_'.$name, $instance->id, $ue->timemodified, $timestart, $timeend);
             } else {
-                role_assign($roleid, $userid, $context->id);
+                role_assign($roleid, $userid, $context->id,'',$ue->timemodified,'',$timestart,$timeend);
             }
         }
 
