Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   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  
  18  /**
  19   * @package   mod_forum
  20   * @copyright  2009 Petr Skoda (http://skodak.org)
  21   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  defined('MOODLE_INTERNAL') || die;
  25  
  26  if ($ADMIN->fulltree) {
  27      require_once($CFG->dirroot.'/mod/forum/lib.php');
  28  
  29      $settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'),
  30                         get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, forum_get_layout_modes()));
  31  
  32      // Less non-HTML characters than this is short
  33      $settings->add(new admin_setting_configtext('forum_shortpost', get_string('shortpost', 'forum'),
  34                         get_string('configshortpost', 'forum'), 300, PARAM_INT));
  35  
  36      // More non-HTML characters than this is long
  37      $settings->add(new admin_setting_configtext('forum_longpost', get_string('longpost', 'forum'),
  38                         get_string('configlongpost', 'forum'), 600, PARAM_INT));
  39  
  40      // Number of discussions on a page
  41      $settings->add(new admin_setting_configtext('forum_manydiscussions', get_string('manydiscussions', 'forum'),
  42                         get_string('configmanydiscussions', 'forum'), 100, PARAM_INT));
  43  
  44      if (isset($CFG->maxbytes)) {
  45          $maxbytes = 0;
  46          if (isset($CFG->forum_maxbytes)) {
  47              $maxbytes = $CFG->forum_maxbytes;
  48          }
  49          $settings->add(new admin_setting_configselect('forum_maxbytes', get_string('maxattachmentsize', 'forum'),
  50                             get_string('configmaxbytes', 'forum'), 512000, get_max_upload_sizes($CFG->maxbytes, 0, 0, $maxbytes)));
  51      }
  52  
  53      // Default number of attachments allowed per post in all forums
  54      $settings->add(new admin_setting_configtext('forum_maxattachments', get_string('maxattachments', 'forum'),
  55                         get_string('configmaxattachments', 'forum'), 9, PARAM_INT));
  56  
  57      // Default Subscription mode setting.
  58      $options = forum_get_subscriptionmode_options();
  59      $settings->add(new admin_setting_configselect('forum_subscription', get_string('subscriptionmode', 'forum'),
  60          get_string('configsubscriptiontype', 'forum'), FORUM_CHOOSESUBSCRIBE, $options));
  61  
  62      // Default Read Tracking setting.
  63      $options = array();
  64      $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum');
  65      $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum');
  66      $options[FORUM_TRACKING_FORCED] = get_string('trackingon', 'forum');
  67      $settings->add(new admin_setting_configselect('forum_trackingtype', get_string('trackingtype', 'forum'),
  68                         get_string('configtrackingtype', 'forum'), FORUM_TRACKING_OPTIONAL, $options));
  69  
  70      // Default whether user needs to mark a post as read
  71      $settings->add(new admin_setting_configcheckbox('forum_trackreadposts', get_string('trackforum', 'forum'),
  72                         get_string('configtrackreadposts', 'forum'), 1));
  73  
  74      // Default whether user needs to mark a post as read.
  75      $settings->add(new admin_setting_configcheckbox('forum_allowforcedreadtracking', get_string('forcedreadtracking', 'forum'),
  76                         get_string('forcedreadtracking_desc', 'forum'), 0));
  77  
  78      // Default number of days that a post is considered old
  79      $settings->add(new admin_setting_configtext('forum_oldpostdays', get_string('oldpostdays', 'forum'),
  80                         get_string('configoldpostdays', 'forum'), 14, PARAM_INT));
  81  
  82      // Default whether user needs to mark a post as read
  83      $settings->add(new admin_setting_configcheckbox('forum_usermarksread', get_string('usermarksread', 'forum'),
  84                         get_string('configusermarksread', 'forum'), 0));
  85  
  86      $options = array();
  87      for ($i = 0; $i < 24; $i++) {
  88          $options[$i] = sprintf("%02d",$i);
  89      }
  90      // Default time (hour) to execute 'clean_read_records' cron
  91      $settings->add(new admin_setting_configselect('forum_cleanreadtime', get_string('cleanreadtime', 'forum'),
  92                         get_string('configcleanreadtime', 'forum'), 2, $options));
  93  
  94      // Default time (hour) to send digest email
  95      $settings->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'forum'),
  96                         get_string('configdigestmailtime', 'forum'), 17, $options));
  97  
  98      if (empty($CFG->enablerssfeeds)) {
  99          $options = array(0 => get_string('rssglobaldisabled', 'admin'));
 100          $str = get_string('configenablerssfeeds', 'forum').'<br />'.get_string('configenablerssfeedsdisabled2', 'admin');
 101  
 102      } else {
 103          $options = array(0=>get_string('no'), 1=>get_string('yes'));
 104          $str = get_string('configenablerssfeeds', 'forum');
 105      }
 106      $settings->add(new admin_setting_configselect('forum_enablerssfeeds', get_string('enablerssfeeds', 'admin'),
 107                         $str, 0, $options));
 108  
 109      if (!empty($CFG->enablerssfeeds)) {
 110          $options = array(
 111              0 => get_string('none'),
 112              1 => get_string('discussions', 'forum'),
 113              2 => get_string('posts', 'forum')
 114          );
 115          $settings->add(new admin_setting_configselect('forum_rsstype', get_string('rsstypedefault', 'forum'),
 116                  get_string('configrsstypedefault', 'forum'), 0, $options));
 117          $settings->hide_if('forum_rsstype', 'forum_enablerssfeeds', 'neq', '1');
 118  
 119          $options = array(
 120              0  => '0',
 121              1  => '1',
 122              2  => '2',
 123              3  => '3',
 124              4  => '4',
 125              5  => '5',
 126              10 => '10',
 127              15 => '15',
 128              20 => '20',
 129              25 => '25',
 130              30 => '30',
 131              40 => '40',
 132              50 => '50'
 133          );
 134          $settings->add(new admin_setting_configselect('forum_rssarticles', get_string('rssarticles', 'forum'),
 135                  get_string('configrssarticlesdefault', 'forum'), 0, $options));
 136          $settings->hide_if('forum_rssarticles', 'forum_enablerssfeeds', 'neq', '1');
 137      }
 138  
 139      $settings->add(new admin_setting_configcheckbox('forum_enabletimedposts', get_string('timedposts', 'forum'),
 140                         get_string('configenabletimedposts', 'forum'), 1));
 141  }
 142