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.
   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   * Form to edit a users forum preferences.
  19   *
  20   * These are stored as columns in the user table, which
  21   * is why they are in /user and not /mod/forum.
  22   *
  23   * @copyright 1999 Martin Dougiamas  http://dougiamas.com
  24   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   * @package core_user
  26   */
  27  
  28  if (!defined('MOODLE_INTERNAL')) {
  29      die('Direct access to this script is forbidden.');    //  It must be included from a Moodle page.
  30  }
  31  
  32  require_once($CFG->dirroot.'/lib/formslib.php');
  33  
  34  /**
  35   * Class user_edit_forum_form.
  36   *
  37   * @copyright 1999 Martin Dougiamas  http://dougiamas.com
  38   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class user_edit_forum_form extends moodleform {
  41  
  42      /**
  43       * Define the form.
  44       */
  45      public function definition () {
  46          global $CFG, $COURSE;
  47  
  48          $mform = $this->_form;
  49  
  50          $choices = array();
  51          $choices['0'] = get_string('emaildigestoff');
  52          $choices['1'] = get_string('emaildigestcomplete');
  53          $choices['2'] = get_string('emaildigestsubjects');
  54          $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
  55          $mform->setDefault('maildigest', core_user::get_property_default('maildigest'));
  56          $mform->addHelpButton('maildigest', 'emaildigest');
  57  
  58          $choices = array();
  59          $choices['1'] = get_string('autosubscribeyes');
  60          $choices['0'] = get_string('autosubscribeno');
  61          $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
  62          $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
  63  
  64          $choices = array();
  65          $choices['1'] = get_string('yes');
  66          $choices['0'] = get_string('no');
  67          $mform->addElement('select', 'useexperimentalui', get_string('useexperimentalui', 'mod_forum'), $choices);
  68          $mform->setDefault('useexperimentalui', '0');
  69  
  70          if (!empty($CFG->forum_trackreadposts)) {
  71              $mform->addElement('header', 'trackreadposts', get_string('trackreadposts_header', 'mod_forum'));
  72              $choices = array();
  73              $choices['0'] = get_string('trackforumsno');
  74              $choices['1'] = get_string('trackforumsyes');
  75              $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
  76              $mform->setDefault('trackforums', core_user::get_property_default('trackforums'));
  77  
  78              $choices = [
  79                  1   => get_string('markasreadonnotificationyes', 'mod_forum'),
  80                  0   => get_string('markasreadonnotificationno', 'mod_forum'),
  81              ];
  82              $mform->addElement('select', 'markasreadonnotification', get_string('markasreadonnotification', 'mod_forum'), $choices);
  83              $mform->addHelpButton('markasreadonnotification', 'markasreadonnotification', 'mod_forum');
  84              $mform->disabledIf('markasreadonnotification', 'trackforums', 'eq', "0");
  85              $mform->setDefault('markasreadonnotification', 1);
  86          }
  87  
  88          // Add some extra hidden fields.
  89          $mform->addElement('hidden', 'id');
  90          $mform->setType('id', PARAM_INT);
  91          $mform->addElement('hidden', 'course', $COURSE->id);
  92          $mform->setType('course', PARAM_INT);
  93  
  94          $this->add_action_buttons(true, get_string('savechanges'));
  95      }
  96  }
  97  
  98