Skip to content

Commit 375223c

Browse files
committed
MDL-50887 antivirus: Deprecate functions no longer required.
This also removes abandoned strings that are no longer in use (since 1e23ff2 landed).
1 parent 001feb6 commit 375223c

File tree

6 files changed

+36
-91
lines changed

6 files changed

+36
-91
lines changed

lang/en/admin.php

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
$string['allowuserthemes'] = 'Allow user themes';
5858
$string['alternativefullnameformat'] = 'Alternative full name format';
5959
$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.';
60-
$string['antivirus'] = 'Anti-Virus';
6160
$string['appearance'] = 'Appearance';
6261
$string['aspellpath'] = 'Path to aspell';
6362
$string['authentication'] = 'Authentication';

lang/en/moodle.php

-25
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,6 @@
237237
$string['categoryupdated'] = 'The category \'{$a}\' was updated';
238238
$string['changesmadereallygoaway'] = 'You have made changes. Are you sure you want to navigate away and lose your changes?';
239239
$string['city'] = 'City/town';
240-
$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.';
241-
$string['clamdeletedfile'] = 'The file has been deleted';
242-
$string['clamdeletedfilefailed'] = 'The file could not be deleted';
243-
$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.';
244-
$string['clammovedfile'] = 'The file has been moved to your specified quarantine directory, the new location is {$a}';
245-
$string['clammovedfilebasic'] = 'The file has been moved to a quarantine directory.';
246-
$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.';
247240
$string['cleaningtempdata'] = 'Cleaning temp data';
248241
$string['clear'] = 'Clear';
249242
$string['clickhelpiconformoreinfo'] = '... continues ... Click on the help icon to read the full article';
@@ -1967,24 +1960,6 @@
19671960
$string['viewprofile'] = 'View profile';
19681961
$string['views'] = 'Views';
19691962
$string['viewsolution'] = 'view solution';
1970-
$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:';
1971-
$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:
1972-
1973-
{$a->action}
1974-
1975-
If this was submitted work, you may want to resubmit it so that your tutor can see it.';
1976-
$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:
1977-
1978-
{$a->action}
1979-
1980-
The user has also been notified.';
1981-
$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.
1982-
1983-
Here is a summary of what has happened to the file:
1984-
1985-
{$a->action}';
1986-
$string['virusfoundsubject'] = '{$a}: Virus found!';
1987-
$string['virusplaceholder'] = 'This file that has been uploaded was found to contain a virus and has been moved or deleted and the user notified.';
19881963
$string['visible'] = 'Visible';
19891964
$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.';
19901965
$string['visibletostudents'] = 'Visible to {$a}';

lib/deprecatedlib.php

+28
Original file line numberDiff line numberDiff line change
@@ -4380,3 +4380,31 @@ function events_pending_count($eventname) {
43804380

43814381
return $DB->count_records_sql($sql, array($eventname));
43824382
}
4383+
4384+
/**
4385+
* Emails admins about a clam outcome
4386+
*
4387+
* @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
4388+
* @param string $notice The body of the email to be sent.
4389+
* @return void
4390+
*/
4391+
function clam_message_admins($notice) {
4392+
debugging('clam_message_admins() is deprecated, please use message_admins() method of antivirus_clamav class.', DEBUG_DEVELOPER);
4393+
4394+
$antivirus = antiviruses_get_antivirus('clamav');
4395+
$antivirus->message_admins($notice);
4396+
}
4397+
4398+
/**
4399+
* Returns the string equivalent of a numeric clam error code
4400+
*
4401+
* @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
4402+
* @param int $returncode The numeric error code in question.
4403+
* @return string The definition of the error code
4404+
*/
4405+
function get_clam_error_code($returncode) {
4406+
debugging('get_clam_error_code() is deprecated, please use get_clam_error_code() method of antivirus_clamav class.', DEBUG_DEVELOPER);
4407+
4408+
$antivirus = antiviruses_get_antivirus('clamav');
4409+
return $antivirus->get_clam_error_code($returncode);
4410+
}

lib/upgrade.txt

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ information provided here is intended especially for developers.
5454
are assigned to fields and buttons through a self-contained JS function.
5555
* Added $CFG->urlrewriteclass option to config.php allowing clean / semantic urls to
5656
be implemented in a plugin, eg local_cleanurls.
57+
* $CFG->pathtoclam global setting has been moved to clamav antivirus plugin
58+
setting of the same name.
59+
* clam_message_admins() and get_clam_error_code() have been deprecated, its
60+
functionality is now a part of antivirus_clamav class methods.
61+
* \repository::antivir_scan_file() has been deprecated, antiviruses_scan_file() that
62+
applies antivirus plugins is replacing its functionality.
5763

5864
=== 3.0 ===
5965

lib/uploadlib.php

-65
Original file line numberDiff line numberDiff line change
@@ -49,68 +49,3 @@ function __construct($inputname='', $deleteothers=false, $handlecollisions=false
4949
throw new coding_exception('upload_manager class can not be used any more, please use file picker instead');
5050
}
5151
}
52-
53-
/**************************************************************************************
54-
THESE FUNCTIONS ARE OUTSIDE THE CLASS BECAUSE THEY NEED TO BE CALLED FROM OTHER PLACES.
55-
FOR EXAMPLE CLAM_HANDLE_INFECTED_FILE AND CLAM_REPLACE_INFECTED_FILE USED FROM CRON
56-
UPLOAD_PRINT_FORM_FRAGMENT DOESN'T REALLY BELONG IN THE CLASS BUT CERTAINLY IN THIS FILE
57-
***************************************************************************************/
58-
59-
/**
60-
* Emails admins about a clam outcome
61-
*
62-
* @param string $notice The body of the email to be sent.
63-
*/
64-
function clam_message_admins($notice) {
65-
66-
$site = get_site();
67-
68-
$subject = get_string('clamemailsubject', 'moodle', format_string($site->fullname));
69-
$admins = get_admins();
70-
foreach ($admins as $admin) {
71-
$eventdata = new stdClass();
72-
$eventdata->component = 'moodle';
73-
$eventdata->name = 'errors';
74-
$eventdata->userfrom = get_admin();
75-
$eventdata->userto = $admin;
76-
$eventdata->subject = $subject;
77-
$eventdata->fullmessage = $notice;
78-
$eventdata->fullmessageformat = FORMAT_PLAIN;
79-
$eventdata->fullmessagehtml = '';
80-
$eventdata->smallmessage = '';
81-
message_send($eventdata);
82-
}
83-
}
84-
85-
/**
86-
* Returns the string equivalent of a numeric clam error code
87-
*
88-
* @param int $returncode The numeric error code in question.
89-
* @return string The definition of the error code
90-
*/
91-
function get_clam_error_code($returncode) {
92-
$returncodes = array();
93-
$returncodes[0] = 'No virus found.';
94-
$returncodes[1] = 'Virus(es) found.';
95-
$returncodes[2] = ' An error occured'; // specific to clamdscan
96-
// all after here are specific to clamscan
97-
$returncodes[40] = 'Unknown option passed.';
98-
$returncodes[50] = 'Database initialization error.';
99-
$returncodes[52] = 'Not supported file type.';
100-
$returncodes[53] = 'Can\'t open directory.';
101-
$returncodes[54] = 'Can\'t open file. (ofm)';
102-
$returncodes[55] = 'Error reading file. (ofm)';
103-
$returncodes[56] = 'Can\'t stat input file / directory.';
104-
$returncodes[57] = 'Can\'t get absolute path name of current working directory.';
105-
$returncodes[58] = 'I/O error, please check your filesystem.';
106-
$returncodes[59] = 'Can\'t get information about current user from /etc/passwd.';
107-
$returncodes[60] = 'Can\'t get information about user \'clamav\' (default name) from /etc/passwd.';
108-
$returncodes[61] = 'Can\'t fork.';
109-
$returncodes[63] = 'Can\'t create temporary files/directories (check permissions).';
110-
$returncodes[64] = 'Can\'t write to temporary directory (please specify another one).';
111-
$returncodes[70] = 'Can\'t allocate and clear memory (calloc).';
112-
$returncodes[71] = 'Can\'t allocate memory (malloc).';
113-
if ($returncodes[$returncode])
114-
return $returncodes[$returncode];
115-
return get_string('clamunknownerror');
116-
}

repository/lib.php

+2
Original file line numberDiff line numberDiff line change
@@ -1185,11 +1185,13 @@ public static function static_function($plugin, $function) {
11851185
* permissions of the file are not modified here!
11861186
*
11871187
* @static
1188+
* @depricated since Moodle 3.0
11881189
* @param string $thefile
11891190
* @param string $filename name of the file
11901191
* @param bool $deleteinfected
11911192
*/
11921193
public static function antivir_scan_file($thefile, $filename, $deleteinfected) {
1194+
debugging('Please upgrade your code to use antiviruses_scan_file instead', DEBUG_DEVELOPER);
11931195
antiviruses_scan_file($thefile, $filename, $deleteinfected);
11941196
}
11951197

0 commit comments

Comments
 (0)