MDL-44260 uplodate: move deprecated functions to deprecatedlib
[moodle.git] / lib / uploadlib.php
CommitLineData
18b8fbfa 1<?php
c9b5ebf5 2
72fb21b6 3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
c9b5ebf5 18/**
19 * uploadlib.php - This class handles all aspects of fileuploading
20 *
78bfb562
PS
21 * @package core
22 * @subpackage file
23 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
c9b5ebf5 25 */
26
78bfb562
PS
27defined('MOODLE_INTERNAL') || die();
28
18b8fbfa 29/**
c9b5ebf5 30 * This class handles all aspects of fileuploading
72fb21b6 31 *
114e3209
32 * @deprecated since 2.7 - use new file pickers instead
33 *
72fb21b6 34 * @package moodlecore
35 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
18b8fbfa 37 */
38class upload_manager {
39
18b8fbfa 40 /**
41 * Constructor, sets up configuration stuff so we know how to act.
c9b5ebf5 42 *
18b8fbfa 43 * Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first.
c9b5ebf5 44 *
1e23ff21 45 * @deprecated since 2.7 - use new file pickers instead
c9b5ebf5 46 *
18b8fbfa 47 */
1e23ff21
SL
48 function __construct($inputname='', $deleteothers=false, $handlecollisions=false, $course=null, $recoverifmultiple=false, $modbytes=0, $silent=false, $allownull=false, $allownullmultiple=true) {
49 throw new coding_exception('upload_manager class can not be used any more, please use file picker instead');
96038147 50 }
18b8fbfa 51}
52
53/**************************************************************************************
54THESE FUNCTIONS ARE OUTSIDE THE CLASS BECAUSE THEY NEED TO BE CALLED FROM OTHER PLACES.
55FOR EXAMPLE CLAM_HANDLE_INFECTED_FILE AND CLAM_REPLACE_INFECTED_FILE USED FROM CRON
56UPLOAD_PRINT_FORM_FRAGMENT DOESN'T REALLY BELONG IN THE CLASS BUT CERTAINLY IN THIS FILE
57***************************************************************************************/
58
18b8fbfa 59/**
c9b5ebf5 60 * Emails admins about a clam outcome
61 *
62 * @param string $notice The body of the email to be sent.
18b8fbfa 63 */
3b120e46 64function clam_message_admins($notice) {
117bd748 65
18b8fbfa 66 $site = get_site();
117bd748 67
268ddd50 68 $subject = get_string('clamemailsubject', 'moodle', format_string($site->fullname));
18b8fbfa 69 $admins = get_admins();
70 foreach ($admins as $admin) {
365a5941 71 $eventdata = new stdClass();
23bfe0a4
PS
72 $eventdata->component = 'moodle';
73 $eventdata->name = 'errors';
3b120e46 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 = '';
7c7d3afa 81 message_send($eventdata);
18b8fbfa 82 }
83}
84
c9b5ebf5 85/**
86 * Returns the string equivalent of a numeric clam error code
87 *
88 * @param int $returncode The numeric error code in question.
114e3209 89 * @return string The definition of the error code
c9b5ebf5 90 */
18b8fbfa 91function 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.';
117bd748 108 $returncodes[61] = 'Can\'t fork.';
18b8fbfa 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');
18b8fbfa 116}