Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-MDL-26822'

  • Loading branch information...
commit d96b0a969b0ce3b1d0476ad392395137621ce94d 2 parents 8196e3c + ae8c1f3
@skodak skodak authored
Showing with 9 additions and 5 deletions.
  1. +3 −3 enrol/self/lib.php
  2. +6 −2 lib/enrollib.php
View
6 enrol/self/lib.php
@@ -209,12 +209,12 @@ public function enrol_page_hook(stdClass $instance) {
$enrol = enrol_get_plugin('self');
$timestart = time();
if ($instance->enrolperiod) {
- $tineend = $timestart + $instance->enrolperiod;
+ $timeend = $timestart + $instance->enrolperiod;
} else {
- $tineend = 0;
+ $timeend = 0;
}
- $this->enrol_user($instance, $USER->id, $instance->roleid, $timestart, $tineend);
+ $this->enrol_user($instance, $USER->id, $instance->roleid, $timestart, $timeend);
add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere!
if ($instance->password and $instance->customint1 and $data->enrolpassword !== $instance->password) {
View
8 lib/enrollib.php
@@ -1055,9 +1055,13 @@ public function enrol_user(stdClass $instance, $userid, $roleid = NULL, $timesta
$inserted = false;
if ($ue = $DB->get_record('user_enrolments', array('enrolid'=>$instance->id, 'userid'=>$userid))) {
- if ($ue->timestart != $timestart or $ue->timeend != $timeend) {
+ //only update if timestart or timeend or status are different.
+ if ($ue->timestart != $timestart or $ue->timeend != $timeend or (!is_null($status) and $ue->status != $status)) {
$ue->timestart = $timestart;
$ue->timeend = $timeend;
+ if (!is_null($status)) {
+ $ue->status = $status;
+ }
$ue->modifier = $USER->id;
$ue->timemodified = time();
$DB->update_record('user_enrolments', $ue);
@@ -1065,7 +1069,7 @@ public function enrol_user(stdClass $instance, $userid, $roleid = NULL, $timesta
} else {
$ue = new stdClass();
$ue->enrolid = $instance->id;
- $ue->status = ENROL_USER_ACTIVE;
+ $ue->status = is_null($status) ? ENROL_USER_ACTIVE : $status;
$ue->userid = $userid;
$ue->timestart = $timestart;
$ue->timeend = $timeend;
Please sign in to comment.
Something went wrong with that request. Please try again.