diff --git a/lib.php b/lib.php index 42b1b1f4..113c2cd9 100644 --- a/lib.php +++ b/lib.php @@ -281,8 +281,8 @@ public function unenrol_user(stdClass $instance, $userid) { $refundperiod = get_config('enrol_wallet', 'unenrolrefundperiod'); $now = time(); if ( - $now > $enrolend - || ($now - $enrolstart) > $refundperiod + (!empty($enrolend) && $now > $enrolend) // The enrolmet already ended. + || ($now > $enrolstart && !empty($refundperiod) && ($now - $enrolstart) > $refundperiod) // Passed the period. ) { // Condition for refunding aren't met. return parent::unenrol_user($instance, $userid); @@ -311,6 +311,7 @@ public function unenrol_user(stdClass $instance, $userid) { if ($credit <= 0) { return parent::unenrol_user($instance, $userid); } else if ($credit > $cost) { + // Shouldn't happen. $credit = $cost; } @@ -1587,7 +1588,7 @@ public function course_updated($inserted, $course, $data) { * @param object $context context of existing course or parent category if course does not exist * @return array errors array */ - public function course_edit_validation($instance, array $data, $context) { + public function course_edit_validation($instance, $data, $context) { if (empty($instance)) { if (isset($data['instanceid'])) { $data['id'] = $data['instanceid'];