Exemplo n.º 1
0
 /**
  * Validate that the compression method is handles a lack of valid log files
  */
 public function test_compresslogsforemailreturnsfalsewhennologfileisvalid()
 {
     global $DB;
     // Create a summary log with an empty log file path.
     $summarylog = new stdClass();
     $summarylog->logpath = 'testpath';
     $summarylog->plugin = 'dhimport_version1';
     $summarylog->userid = 9999;
     $summarylog->targetstarttime = 0;
     $summarylog->starttime = 0;
     $summarylog->endtime = 0;
     $summarylog->filesuccesses = 0;
     $summarylog->filefailures = 0;
     $summarylog->storedsuccesses = 0;
     $summarylog->storedfailures = 0;
     $summarylog->statusmessage = '';
     $summarylog->logpath = null;
     $logid = $DB->insert_record(RLIP_LOG_TABLE, $summarylog);
     // Obtian the zip file name.
     $zipfilename = rlip_compress_logs_email('dhimport_version1', array($logid));
     // Validate that the scenario was handled.
     $this->assertFalse($zipfilename);
 }
Exemplo n.º 2
0
/**
 * Send log emails to all appropriate users for one plugin run
 *
 * @param string $plugin The plugin for which we are sending logs
 * @param array $logids The list of database record ids pointing to log files
 * @param boolean $manual True if manual, false if scheduled
 */
function rlip_send_log_emails($plugin, $logids, $manual = false)
{
    global $CFG;
    //obtain the sanitized list of emails
    $emails = rlip_get_notification_emails($plugin);
    //create the zip file
    $archive_name = rlip_compress_logs_email($plugin, $logids, $manual);
    if ($archive_name === false) {
        //no logs to send
        return false;
    }
    //send to all appropriate users
    foreach ($emails as $email) {
        $recipient = rlip_get_email_recipient($email);
        rlip_send_log_email($plugin, $recipient, $archive_name);
    }
    @unlink($CFG->dataroot . '/' . $archive_name);
    return true;
}