Permalink
Browse files

MDL-39653 enrol_imsenterprise: only mail admins on change

The existing beavhiour was sending useless emails to admins and
generating warnings.

Thanks to Matthew Orlando for the suggested fix.
  • Loading branch information...
danpoltawski committed Sep 26, 2013
1 parent 7bc37de commit 3d986cf8cd2630a964de93f7484bfb997ff7b87e
Showing with 2 additions and 3 deletions.
  1. +2 −3 enrol/imsenterprise/lib.php
@@ -86,6 +86,7 @@ function cron() {
$this->logfp = fopen($logtolocation, 'a');
}
+ $fileisnew = false;
if ( file_exists($filename) ) {
@set_time_limit(0);
$starttime = time();
@@ -106,10 +107,8 @@ function cron() {
if(empty($prev_path) || ($filename != $prev_path)) {
$fileisnew = true;
} elseif(isset($prev_time) && ($filemtime <= $prev_time)) {
- $fileisnew = false;
$this->log_line('File modification time is not more recent than last update - skipping processing.');
} elseif(isset($prev_md5) && ($md5 == $prev_md5)) {
- $fileisnew = false;
$this->log_line('File MD5 hash is same as on last update - skipping processing.');
} else {
$fileisnew = true; // Let's process it!
@@ -216,7 +215,7 @@ function cron() {
$this->log_line('File not found: '.$filename);
}
- if (!empty($mailadmins)) {
+ if (!empty($mailadmins) && $fileisnew) {
$msg = "An IMS enrolment has been carried out within Moodle.\nTime taken: $timeelapsed seconds.\n\n";
if(!empty($logtolocation)){
if($this->logfp){

0 comments on commit 3d986cf

Please sign in to comment.