Skip to content

Commit

Permalink
issue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
NinaHerrmann committed Aug 23, 2017
1 parent 7eee3e4 commit a368d74
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ private function handle_course($hasrole, $courseid) {
$dataobject->timestamp = time();
$DB->insert_record_raw('cleanupcoursestrigger_byrole', $dataobject, true, false, true);
return false;
} else if ($intable === true) {
// Second case of function description.
if ($hasrole) {
} else if ($intable && $hasrole) {
// Second case of function description.

$DB->delete_records('cleanupcoursestrigger_byrole', array('id' => $courseid));
return false;
// Third case of the function description.
} else if ($intable && !$hasrole){
$delay = get_config('cleanupcoursestrigger_byrole', 'delay');
$timecreated = $DB->get_record('cleanupcoursestrigger_byrole', array('id' => $courseid), 'timestamp');
$now = time();
$difference = $now - $timecreated->timestamp;
// Checks how long the course has been in the table and deletes the table entry and the course.
if ($difference > $delay) {
$DB->delete_records('cleanupcoursestrigger_byrole', array('id' => $courseid));
return false;
// Third case of the function description.
} else {
$delay = get_config('cleanupcoursestrigger_byrole', 'delay');
$timecreated = $DB->get_record('cleanupcoursestrigger_byrole', array('id' => $courseid), 'timestamp');
$now = time();
$difference = $now - $timecreated->timestamp;
// Checks how long the course has been in the table and deletes the table entry and the course.
if ($difference > $delay) {
$DB->delete_records('cleanupcoursestrigger_byrole', array('id' => $courseid));
return true;
}
return true;
}
}
return false;
Expand Down

0 comments on commit a368d74

Please sign in to comment.