Merge branch 'wip-MDL-26822'

This commit is contained in:
Petr Skoda 2011-03-21 14:03:33 +01:00
commit d96b0a969b
2 changed files with 9 additions and 5 deletions

View File

@ -209,12 +209,12 @@ class enrol_self_plugin extends enrol_plugin {
$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 File

@ -1055,9 +1055,13 @@ abstract class enrol_plugin {
$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 @@ abstract class enrol_plugin {
} 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;