MDL-50887 antivirus: Deprecate functions no longer required.

This also removes abandoned strings that are no longer in use (since
1e23ff2 landed).
This commit is contained in:
Ruslan Kabalin
2016-02-25 09:55:45 +00:00
parent 001feb6649
commit 375223c6db
6 changed files with 36 additions and 91 deletions
-1
View File
@@ -57,7 +57,6 @@ $string['allowuserswitchrolestheycantassign'] = 'Allow users without the assign
$string['allowuserthemes'] = 'Allow user themes';
$string['alternativefullnameformat'] = 'Alternative full name format';
$string['alternativefullnameformat_desc'] = 'This defines how names are shown to users with the viewfullnames capability (by default users with the role of manager, teacher or non-editing teacher). Placeholders that can be used are as for the "Full name format" setting.';
$string['antivirus'] = 'Anti-Virus';
$string['appearance'] = 'Appearance';
$string['aspellpath'] = 'Path to aspell';
$string['authentication'] = 'Authentication';
-25
View File
@@ -237,13 +237,6 @@ $string['idnumbercoursecategory_help'] = 'The ID number of a course category is
$string['categoryupdated'] = 'The category \'{$a}\' was updated';
$string['changesmadereallygoaway'] = 'You have made changes. Are you sure you want to navigate away and lose your changes?';
$string['city'] = 'City/town';
$string['clambroken'] = 'Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.';
$string['clamdeletedfile'] = 'The file has been deleted';
$string['clamdeletedfilefailed'] = 'The file could not be deleted';
$string['clamlostandactinglikevirus'] = 'In addition, Moodle is configured so that if clam fails to run, files are treated like viruses. This essentially means that no student can upload a file successfully until you fix this.';
$string['clammovedfile'] = 'The file has been moved to your specified quarantine directory, the new location is {$a}';
$string['clammovedfilebasic'] = 'The file has been moved to a quarantine directory.';
$string['clamquarantinedirfailed'] = 'Could not move the file into your specified quarantine directory, {$a}. You need to fix this as files are being deleted if they\'re found to be infected.';
$string['cleaningtempdata'] = 'Cleaning temp data';
$string['clear'] = 'Clear';
$string['clickhelpiconformoreinfo'] = '... continues ... Click on the help icon to read the full article';
@@ -1967,24 +1960,6 @@ $string['viewfileinpopup'] = 'View file in a popup window';
$string['viewprofile'] = 'View profile';
$string['views'] = 'Views';
$string['viewsolution'] = 'view solution';
$string['virusfound'] = 'Attention administrator! Clam AV has found a virus in a file uploaded by {$a->user} for the course {$a->course}. Here is the output of clamscan:';
$string['virusfoundlater'] = 'A file you uploaded on {$a->date} with the filename {$a->filename} for the course {$a->course} has since been found to contain a virus. Here is a summary of what has happened to your file:
{$a->action}
If this was submitted work, you may want to resubmit it so that your tutor can see it.';
$string['virusfoundlateradmin'] = 'Attention administrator! A file that was uploaded on {$a->date} with the filename {$a->filename} for the course {$a->course} by the user {$a->user} has since been found to contain a virus. Here is a summary of what has happened to the file:
{$a->action}
The user has also been notified.';
$string['virusfoundlateradminnolog'] = 'Attention administrator! A file that was uploaded with the filename {$a->filename} has since been found to contain a virus. Moodle was unable to resolve this file back to the user that originally uploaded it.
Here is a summary of what has happened to the file:
{$a->action}';
$string['virusfoundsubject'] = '{$a}: Virus found!';
$string['virusplaceholder'] = 'This file that has been uploaded was found to contain a virus and has been moved or deleted and the user notified.';
$string['visible'] = 'Visible';
$string['visible_help'] = 'This setting determines whether the course appears in the list of courses. Apart from teachers and administrators, users are not allowed to enter the course.';
$string['visibletostudents'] = 'Visible to {$a}';
+28
View File
@@ -4380,3 +4380,31 @@ function events_pending_count($eventname) {
return $DB->count_records_sql($sql, array($eventname));
}
/**
* Emails admins about a clam outcome
*
* @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
* @param string $notice The body of the email to be sent.
* @return void
*/
function clam_message_admins($notice) {
debugging('clam_message_admins() is deprecated, please use message_admins() method of antivirus_clamav class.', DEBUG_DEVELOPER);
$antivirus = antiviruses_get_antivirus('clamav');
$antivirus->message_admins($notice);
}
/**
* Returns the string equivalent of a numeric clam error code
*
* @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
* @param int $returncode The numeric error code in question.
* @return string The definition of the error code
*/
function get_clam_error_code($returncode) {
debugging('get_clam_error_code() is deprecated, please use get_clam_error_code() method of antivirus_clamav class.', DEBUG_DEVELOPER);
$antivirus = antiviruses_get_antivirus('clamav');
return $antivirus->get_clam_error_code($returncode);
}
+6
View File
@@ -54,6 +54,12 @@ information provided here is intended especially for developers.
are assigned to fields and buttons through a self-contained JS function.
* Added $CFG->urlrewriteclass option to config.php allowing clean / semantic urls to
be implemented in a plugin, eg local_cleanurls.
* $CFG->pathtoclam global setting has been moved to clamav antivirus plugin
setting of the same name.
* clam_message_admins() and get_clam_error_code() have been deprecated, its
functionality is now a part of antivirus_clamav class methods.
* \repository::antivir_scan_file() has been deprecated, antiviruses_scan_file() that
applies antivirus plugins is replacing its functionality.
=== 3.0 ===
-65
View File
@@ -49,68 +49,3 @@ class upload_manager {
throw new coding_exception('upload_manager class can not be used any more, please use file picker instead');
}
}
/**************************************************************************************
THESE FUNCTIONS ARE OUTSIDE THE CLASS BECAUSE THEY NEED TO BE CALLED FROM OTHER PLACES.
FOR EXAMPLE CLAM_HANDLE_INFECTED_FILE AND CLAM_REPLACE_INFECTED_FILE USED FROM CRON
UPLOAD_PRINT_FORM_FRAGMENT DOESN'T REALLY BELONG IN THE CLASS BUT CERTAINLY IN THIS FILE
***************************************************************************************/
/**
* Emails admins about a clam outcome
*
* @param string $notice The body of the email to be sent.
*/
function clam_message_admins($notice) {
$site = get_site();
$subject = get_string('clamemailsubject', 'moodle', format_string($site->fullname));
$admins = get_admins();
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->component = 'moodle';
$eventdata->name = 'errors';
$eventdata->userfrom = get_admin();
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $notice;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
}
/**
* Returns the string equivalent of a numeric clam error code
*
* @param int $returncode The numeric error code in question.
* @return string The definition of the error code
*/
function get_clam_error_code($returncode) {
$returncodes = array();
$returncodes[0] = 'No virus found.';
$returncodes[1] = 'Virus(es) found.';
$returncodes[2] = ' An error occured'; // specific to clamdscan
// all after here are specific to clamscan
$returncodes[40] = 'Unknown option passed.';
$returncodes[50] = 'Database initialization error.';
$returncodes[52] = 'Not supported file type.';
$returncodes[53] = 'Can\'t open directory.';
$returncodes[54] = 'Can\'t open file. (ofm)';
$returncodes[55] = 'Error reading file. (ofm)';
$returncodes[56] = 'Can\'t stat input file / directory.';
$returncodes[57] = 'Can\'t get absolute path name of current working directory.';
$returncodes[58] = 'I/O error, please check your filesystem.';
$returncodes[59] = 'Can\'t get information about current user from /etc/passwd.';
$returncodes[60] = 'Can\'t get information about user \'clamav\' (default name) from /etc/passwd.';
$returncodes[61] = 'Can\'t fork.';
$returncodes[63] = 'Can\'t create temporary files/directories (check permissions).';
$returncodes[64] = 'Can\'t write to temporary directory (please specify another one).';
$returncodes[70] = 'Can\'t allocate and clear memory (calloc).';
$returncodes[71] = 'Can\'t allocate memory (malloc).';
if ($returncodes[$returncode])
return $returncodes[$returncode];
return get_string('clamunknownerror');
}
+2
View File
@@ -1185,11 +1185,13 @@ abstract class repository implements cacheable_object {
* permissions of the file are not modified here!
*
* @static
* @depricated since Moodle 3.0
* @param string $thefile
* @param string $filename name of the file
* @param bool $deleteinfected
*/
public static function antivir_scan_file($thefile, $filename, $deleteinfected) {
debugging('Please upgrade your code to use antiviruses_scan_file instead', DEBUG_DEVELOPER);
antiviruses_scan_file($thefile, $filename, $deleteinfected);
}