Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310]

   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   * Solr search engine settings.
  19   *
  20   * @package    search_solr
  21   * @copyright  2015 Daniel Neis
  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  
  29      if (!during_initial_install()) {
  30          if (!function_exists('solr_get_version')) {
  31              $settings->add(new admin_setting_heading('search_solr_settings', '', get_string('extensionerror', 'search_solr')));
  32  
  33          } else {
  34              $settings->add(new admin_setting_heading('search_solr_connection',
  35                      new lang_string('connectionsettings', 'search_solr'), ''));
  36              $settings->add(new admin_setting_configtext('search_solr/server_hostname', new lang_string('solrserverhostname', 'search_solr'), new lang_string('solrserverhostname_desc', 'search_solr'), '127.0.0.1', PARAM_HOST));
  37              $settings->add(new admin_setting_configtext('search_solr/indexname', new lang_string('solrindexname', 'search_solr'), '', '', PARAM_ALPHANUMEXT));
  38              $settings->add(new admin_setting_configcheckbox('search_solr/secure', new lang_string('solrsecuremode', 'search_solr'), '', 0, 1, 0));
  39  
  40              $secure = get_config('search_solr', 'secure');
  41              $defaultport = !empty($secure) ? 8443 : 8983;
  42              $settings->add(new admin_setting_configtext('search_solr/server_port', new lang_string('solrhttpconnectionport', 'search_solr'), '', $defaultport, PARAM_INT));
  43              $settings->add(new admin_setting_configtext('search_solr/server_username', new lang_string('solrauthuser', 'search_solr'), '', '', PARAM_RAW));
  44              $settings->add(new admin_setting_configpasswordunmask('search_solr/server_password', new lang_string('solrauthpassword', 'search_solr'), '', ''));
  45              $settings->add(new admin_setting_configtext('search_solr/server_timeout', new lang_string('solrhttpconnectiontimeout', 'search_solr'), new lang_string('solrhttpconnectiontimeout_desc', 'search_solr'), 30, PARAM_INT));
  46              $settings->add(new admin_setting_configtext('search_solr/ssl_cert', new lang_string('solrsslcert', 'search_solr'), new lang_string('solrsslcert_desc', 'search_solr'), '', PARAM_RAW));
  47              $settings->add(new admin_setting_configtext('search_solr/ssl_key', new lang_string('solrsslkey', 'search_solr'), new lang_string('solrsslkey_desc', 'search_solr'), '', PARAM_RAW));
  48              $settings->add(new admin_setting_configpasswordunmask('search_solr/ssl_keypassword', new lang_string('solrsslkeypassword', 'search_solr'), new lang_string('solrsslkeypassword_desc', 'search_solr'), ''));
  49              $settings->add(new admin_setting_configtext('search_solr/ssl_cainfo', new lang_string('solrsslcainfo', 'search_solr'), new lang_string('solrsslcainfo_desc', 'search_solr'), '', PARAM_RAW));
  50              $settings->add(new admin_setting_configtext('search_solr/ssl_capath', new lang_string('solrsslcapath', 'search_solr'), new lang_string('solrsslcapath_desc', 'search_solr'), '', PARAM_RAW));
  51  
  52              $settings->add(new admin_setting_heading('search_solr_fileindexing',
  53                      new lang_string('fileindexsettings', 'search_solr'), ''));
  54              $settings->add(new admin_setting_configcheckbox('search_solr/fileindexing',
  55                      new lang_string('fileindexing', 'search_solr'),
  56                      new lang_string('fileindexing_help', 'search_solr'), 1));
  57              $settings->add(new admin_setting_configtext('search_solr/maxindexfilekb',
  58                      new lang_string('maxindexfilekb', 'search_solr'),
  59                      new lang_string('maxindexfilekb_help', 'search_solr'), '2097152', PARAM_INT));
  60  
  61              // Alternate connection.
  62              $settings->add(new admin_setting_heading('search_solr_alternatesettings',
  63                      new lang_string('searchalternatesettings', 'admin'),
  64                      new lang_string('searchalternatesettings_desc', 'admin')));
  65              $settings->add(new admin_setting_configtext('search_solr/alternateserver_hostname',
  66                      new lang_string('solrserverhostname', 'search_solr'),
  67                      new lang_string('solrserverhostname_desc', 'search_solr'), '127.0.0.1', PARAM_HOST));
  68              $settings->add(new admin_setting_configtext('search_solr/alternateindexname',
  69                      new lang_string('solrindexname', 'search_solr'), '', '', PARAM_ALPHANUMEXT));
  70              $settings->add(new admin_setting_configcheckbox('search_solr/alternatesecure',
  71                      new lang_string('solrsecuremode', 'search_solr'), '', 0, 1, 0));
  72  
  73              $secure = get_config('search_solr', 'alternatesecure');
  74              $defaultport = !empty($secure) ? 8443 : 8983;
  75              $settings->add(new admin_setting_configtext('search_solr/alternateserver_port',
  76                      new lang_string('solrhttpconnectionport', 'search_solr'), '', $defaultport, PARAM_INT));
  77              $settings->add(new admin_setting_configtext('search_solr/alternateserver_username',
  78                      new lang_string('solrauthuser', 'search_solr'), '', '', PARAM_RAW));
  79              $settings->add(new admin_setting_configpasswordunmask('search_solr/alternateserver_password',
  80                      new lang_string('solrauthpassword', 'search_solr'), '', ''));
  81              $settings->add(new admin_setting_configtext('search_solr/alternatessl_cert',
  82                      new lang_string('solrsslcert', 'search_solr'),
  83                      new lang_string('solrsslcert_desc', 'search_solr'), '', PARAM_RAW));
  84              $settings->add(new admin_setting_configtext('search_solr/alternatessl_key',
  85                      new lang_string('solrsslkey', 'search_solr'),
  86                      new lang_string('solrsslkey_desc', 'search_solr'), '', PARAM_RAW));
  87              $settings->add(new admin_setting_configpasswordunmask('search_solr/alternatessl_keypassword',
  88                      new lang_string('solrsslkeypassword', 'search_solr'),
  89                      new lang_string('solrsslkeypassword_desc', 'search_solr'), ''));
  90              $settings->add(new admin_setting_configtext('search_solr/alternatessl_cainfo',
  91                      new lang_string('solrsslcainfo', 'search_solr'),
  92                      new lang_string('solrsslcainfo_desc', 'search_solr'), '', PARAM_RAW));
  93              $settings->add(new admin_setting_configtext('search_solr/alternatessl_capath',
  94                      new lang_string('solrsslcapath', 'search_solr'),
  95                      new lang_string('solrsslcapath_desc', 'search_solr'), '', PARAM_RAW));
  96          }
  97      }
  98  }