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 311 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   * Adds messaging related settings links for Messaging category to admin tree.
  19   *
  20   * @copyright 2019 Amaia Anabitarte <amaia@moodle.com>
  21   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  defined('MOODLE_INTERNAL') || die();
  25  
  26  if ($hassiteconfig) {
  27      $temp = new admin_settingpage('messages',
  28          new lang_string('messagingssettings', 'admin'),
  29          'moodle/site:config',
  30          empty($CFG->messaging)
  31      );
  32  
  33      $temp->add(new admin_setting_configcheckbox('messagingallusers',
  34              new lang_string('messagingallusers', 'admin'),
  35              new lang_string('configmessagingallusers', 'admin'),
  36               0)
  37      );
  38      $temp->add(new admin_setting_configcheckbox('messagingdefaultpressenter',
  39              new lang_string('messagingdefaultpressenter', 'admin'),
  40              new lang_string('configmessagingdefaultpressenter', 'admin'),
  41              1)
  42      );
  43      $options = array(
  44          DAYSECS => new lang_string('secondstotime86400'),
  45          WEEKSECS => new lang_string('secondstotime604800'),
  46          2620800 => new lang_string('nummonths', 'moodle', 1),
  47          7862400 => new lang_string('nummonths', 'moodle', 3),
  48          15724800 => new lang_string('nummonths', 'moodle', 6),
  49          0 => new lang_string('never')
  50      );
  51      $temp->add(new admin_setting_configselect(
  52              'messagingdeletereadnotificationsdelay',
  53              new lang_string('messagingdeletereadnotificationsdelay', 'admin'),
  54              new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'),
  55              604800,
  56              $options)
  57      );
  58      $temp->add(new admin_setting_configselect(
  59              'messagingdeleteallnotificationsdelay',
  60              new lang_string('messagingdeleteallnotificationsdelay', 'admin'),
  61              new lang_string('configmessagingdeleteallnotificationsdelay', 'admin'),
  62              2620800,
  63              $options)
  64      );
  65      $temp->add(new admin_setting_configcheckbox('messagingallowemailoverride',
  66          new lang_string('messagingallowemailoverride', 'admin'),
  67          new lang_string('configmessagingallowemailoverride', 'admin'),
  68          0));
  69      $ADMIN->add('messaging', $temp);
  70      $ADMIN->add('messaging', new admin_page_managemessageoutputs());
  71  
  72      // Notification outputs plugins.
  73      $plugins = core_plugin_manager::instance()->get_plugins_of_type('message');
  74      core_collator::asort_objects_by_property($plugins, 'displayname');
  75      foreach ($plugins as $plugin) {
  76          /** @var \core\plugininfo\message $plugin */
  77          $plugin->load_settings($ADMIN, 'messaging', $hassiteconfig);
  78      }
  79  }