Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * ClamAV admin settings.
  19   *
  20   * @package    antivirus_clamav
  21   * @copyright  2015 Ruslan Kabalin, Lancaster University.
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  if ($ADMIN->fulltree) {
  28      require_once (__DIR__ . '/adminlib.php');
  29      require_once (__DIR__ . '/classes/scanner.php');
  30  
  31      // Running method.
  32      $runningmethodchoice = array(
  33          'commandline' => get_string('runningmethodcommandline', 'antivirus_clamav'),
  34          'unixsocket' => get_string('runningmethodunixsocket', 'antivirus_clamav'),
  35          'tcpsocket' => get_string('runningmethodtcpsocket', 'antivirus_clamav'),
  36      );
  37      $settings->add(new antivirus_clamav_runningmethod_setting('antivirus_clamav/runningmethod',
  38              get_string('runningmethod', 'antivirus_clamav'),
  39              get_string('runningmethoddesc', 'antivirus_clamav'),
  40              'commandline', $runningmethodchoice));
  41  
  42      // Path to ClamAV scanning utility (used in command line running method).
  43      $settings->add(new admin_setting_configexecutable('antivirus_clamav/pathtoclam',
  44              new lang_string('pathtoclam', 'antivirus_clamav'), new lang_string('pathtoclamdesc', 'antivirus_clamav'), ''));
  45  
  46      // Path to ClamAV unix socket (used in unix socket running method).
  47      $settings->add(new antivirus_clamav_pathtounixsocket_setting('antivirus_clamav/pathtounixsocket',
  48              new lang_string('pathtounixsocket', 'antivirus_clamav'),
  49              new lang_string('pathtounixsocketdesc', 'antivirus_clamav'), '', PARAM_PATH));
  50  
  51      // Hostname to reach ClamAV tcp socket (used in tcp socket running method).
  52      $settings->add(new antivirus_clamav_tcpsockethost_setting('antivirus_clamav/tcpsockethost',
  53              new lang_string('tcpsockethost', 'antivirus_clamav'),
  54              new lang_string('tcpsockethostdesc', 'antivirus_clamav'), '', PARAM_HOST));
  55  
  56      // Port to reach ClamAV tcp socket (used in tcp socket running method).
  57      $settings->add(new admin_setting_configtext('antivirus_clamav/tcpsocketport',
  58              new lang_string('tcpsocketport', 'antivirus_clamav'),
  59              new lang_string('tcpsocketportdesc', 'antivirus_clamav'), 3310, PARAM_INT));
  60  
  61      // How to act on ClamAV failure.
  62      $options = array(
  63          'donothing' => new lang_string('configclamdonothing', 'antivirus_clamav'),
  64          'actlikevirus' => new lang_string('configclamactlikevirus', 'antivirus_clamav'),
  65          'tryagain' => new lang_string('configclamtryagain', 'antivirus_clamav')
  66      );
  67      $settings->add(new admin_setting_configselect('antivirus_clamav/clamfailureonupload',
  68              new lang_string('clamfailureonupload', 'antivirus_clamav'),
  69              new lang_string('configclamfailureonupload', 'antivirus_clamav'), 'tryagain', $options));
  70  
  71      // Number of attempts clamav will try when there is error during a scanning process.
  72      $options = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5);
  73      $settings->add(new admin_setting_configselect('antivirus_clamav/tries',
  74          new lang_string('tries', 'antivirus_clamav'),
  75          new lang_string('tries_desc', 'antivirus_clamav'), 1, $options));
  76  }