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  // 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   * A type of forum.
  19   *
  20   * @package    mod_forum
  21   * @copyright  2014 Andrew Robert Nicols <andrew@nicols.co.uk>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  require_once($CFG->dirroot.'/user/selector/lib.php');
  28  
  29  /**
  30   * Abstract class used by forum subscriber selection controls
  31   * @package   mod_forum
  32   * @copyright 2009 Sam Hemelryk
  33   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  abstract class mod_forum_subscriber_selector_base extends user_selector_base {
  36  
  37      /**
  38       * The id of the forum this selector is being used for
  39       * @var int
  40       */
  41      protected $forumid = null;
  42      /**
  43       * The context of the forum this selector is being used for
  44       * @var object
  45       */
  46      protected $context = null;
  47      /**
  48       * The id of the current group
  49       * @var int
  50       */
  51      protected $currentgroup = null;
  52  
  53      /**
  54       * Constructor method
  55       * @param string $name
  56       * @param array $options
  57       */
  58      public function __construct($name, $options) {
  59          $options['accesscontext'] = $options['context'];
  60          parent::__construct($name, $options);
  61          if (isset($options['context'])) {
  62              $this->context = $options['context'];
  63          }
  64          if (isset($options['currentgroup'])) {
  65              $this->currentgroup = $options['currentgroup'];
  66          }
  67          if (isset($options['forumid'])) {
  68              $this->forumid = $options['forumid'];
  69          }
  70      }
  71  
  72      /**
  73       * Returns an array of options to seralise and store for searches
  74       *
  75       * @return array
  76       */
  77      protected function get_options() {
  78          global $CFG;
  79          $options = parent::get_options();
  80          $options['file'] =  substr(__FILE__, strlen($CFG->dirroot.'/'));
  81          $options['context'] = $this->context;
  82          $options['currentgroup'] = $this->currentgroup;
  83          $options['forumid'] = $this->forumid;
  84          return $options;
  85      }
  86  
  87  }