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.
   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   * Forum post renderable.
  19   *
  20   * @package    mod_forum
  21   * @copyright  2015 Andrew Nicols <andrew@nicols.co.uk>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace mod_forum\output\email;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  require_once (__DIR__ . '/../../../renderer.php');
  30  
  31  /**
  32   * Forum post renderable.
  33   *
  34   * @since      Moodle 3.0
  35   * @package    mod_forum
  36   * @copyright  2015 Andrew Nicols <andrew@nicols.co.uk>
  37   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class renderer extends \mod_forum_renderer {
  40  
  41      /**
  42       * The template name for this renderer.
  43       *
  44       * @return string
  45       */
  46      public function forum_post_template() {
  47          return 'forum_post_email_htmlemail';
  48      }
  49  
  50      /**
  51       * The HTML version of the e-mail message.
  52       *
  53       * @param \stdClass $cm
  54       * @param \stdClass $post
  55       * @return string
  56       */
  57      public function format_message_text($cm, $post) {
  58          $context = \context_module::instance($cm->id);
  59          $message = file_rewrite_pluginfile_urls(
  60              $post->message,
  61              'pluginfile.php',
  62              $context->id,
  63              'mod_forum',
  64              'post',
  65              $post->id,
  66              [
  67                  'includetoken' => true,
  68              ]);
  69          $options = new \stdClass();
  70          $options->para = true;
  71          $options->context = $context;
  72          return format_text($message, $post->messageformat, $options);
  73      }
  74  
  75      /**
  76       * The HTML version of the attachments list.
  77       *
  78       * @param \stdClass $cm
  79       * @param \stdClass $post
  80       * @return string
  81       */
  82      public function format_message_attachments($cm, $post) {
  83          return forum_print_attachments($post, $cm, "html");
  84      }
  85  }