mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
Merge branch 'MDL-69522-custom-message-m' of https://github.com/Peterburnett/moodle
This commit is contained in:
commit
790cb18211
@ -106,7 +106,18 @@ class manager {
|
||||
if ($deleteinfected) {
|
||||
unlink($file);
|
||||
}
|
||||
throw new \core\antivirus\scanner_exception('virusfound', '', array('item' => $filename));
|
||||
|
||||
// Get custom message to display to user from antivirus engine.
|
||||
$displaymessage = $antivirus->get_virus_found_message();
|
||||
$placeholders = array_merge(['item' => $filename], $displaymessage['placeholders']);
|
||||
|
||||
throw new \core\antivirus\scanner_exception(
|
||||
$displaymessage['string'],
|
||||
'',
|
||||
$placeholders,
|
||||
null,
|
||||
$displaymessage['component']
|
||||
);
|
||||
} else if ($result === $antivirus::SCAN_RESULT_ERROR) {
|
||||
// Here we need to generate a different incident based on an error.
|
||||
$incidentdetails = $antivirus->get_incident_details($file, $filename, $notice, false);
|
||||
@ -163,7 +174,17 @@ class manager {
|
||||
$event = \core\event\virus_infected_data_detected::create($params);
|
||||
$event->trigger();
|
||||
|
||||
throw new \core\antivirus\scanner_exception('virusfound', '', array('item' => get_string('datastream', 'antivirus')));
|
||||
// Get custom message to display to user from antivirus engine.
|
||||
$displaymessage = $antivirus->get_virus_found_message();
|
||||
$placeholders = array_merge(['item' => get_string('datastream', 'antivirus')], $displaymessage['placeholders']);
|
||||
|
||||
throw new \core\antivirus\scanner_exception(
|
||||
$displaymessage['string'],
|
||||
'',
|
||||
$placeholders,
|
||||
null,
|
||||
$displaymessage['component']
|
||||
);
|
||||
} else if ($result === $antivirus::SCAN_RESULT_ERROR) {
|
||||
// Here we need to generate a different incident based on an error.
|
||||
$incidentdetails = $antivirus->get_incident_details('', $filename, $notice, false);
|
||||
|
@ -238,4 +238,14 @@ abstract class scanner {
|
||||
public function get_messages() : array {
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for the antivirus message displayed in the exception.
|
||||
*
|
||||
* @return array array of string and component to pass to exception constructor.
|
||||
*/
|
||||
public function get_virus_found_message() {
|
||||
// Base antivirus found string.
|
||||
return ['string' => 'virusfound', 'component' => 'antivirus', 'placeholders' => []];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user