/** * Validate that the email recipient retrieval uses an existing user record * for an email address that is within Moodle */ public function test_getemailrecipientreturnsvaliduserforexistingemailaddress() { global $DB; $this->create_complete_test_user(); $recipient = rlip_get_email_recipient('*****@*****.**'); $expectedresult = $DB->get_record('user', array('username' => 'rlipusername')); $this->assertEquals($recipient, $expectedresult); }
/** * 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; }