Format a notification for HTML.

@param string $messagetype
@param stdClass $info
@param stdClass $course
@param stdClass $context
@param string $modulename
@param stdClass $coursemodule
@param string $assignmentname
512674
protected static function format_notification_message_html($messagetype,
                                                             $info,
                                                             $course,
                                                             $context,
                                                             $modulename,
                                                             $coursemodule,
                                                             $assignmentname) {
        global $CFG;
        $formatparams = array('context' => $context->get_course_context());
        $posthtml  = '<p><font face="sans-serif">' .
                     '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' .
                     format_string($course->shortname, true, $formatparams) .
                     '</a> ->' .
                     '<a href="' . $CFG->wwwroot . '/mod/assign/index.php?id=' . $course->id . '">' .
                     $modulename .
                     '</a> ->' .
                     '<a href="' . $CFG->wwwroot . '/mod/assign/view.php?id=' . $coursemodule->id . '">' .
                     format_string($assignmentname, true, $formatparams) .
                     '</a></font></p>';
        $posthtml .= '<hr /><font face="sans-serif">';
        $posthtml .= '<p>' . get_string($messagetype . 'html', 'assign', $info) . '</p>';
        $posthtml .= '</font><hr />';
        return $posthtml;
    }
508602
public function clearNotificationListeners($notification_type)
    {
        if (!NotificationType::isNotificationTypeValid($notification_type)) {
            $this->_logger->log(Logger::ERROR, "Invalid notification type.");
            $this->_errorHandler->handleError(new InvalidNotificationTypeException('Invalid notification type.'));
            return;
        }

        $this->_notifications[$notification_type] = [];
        $this->_logger->log(Logger::INFO, "All callbacks for notification type '{$notification_type}' have been removed.");
    }
832250
public function notice($message, $type = null)
  {
    $type = is_null($type)
      ? 'info'
      : (is_bool($type)
        ? ($type
          ? 'success'
          : 'error')
        : $type);

    $this->getSession()->getFlashBag()->add($type, $message);

    return $this;
  }
1349194
public function makeNotification()
    {
        $this->options['name'] = $this->ask('Notification Name (Example: MyNotification)');

        if ($this->confirm('Would you like to create a template for this notification command?')) {
            $this->options['--markdown'] = strtolower($this->options['name']);
        }
    }
1176525
public static function notice($message = '', array $data = [], $is_replace = false, $modular = 'unknown_module')
    {
        return parent::log('notice', $message, $data, $is_replace, $modular);
    }
246578
private function add ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true)
		{
			$this->_data[] = new Notification ($message, $type, $isRaw, $canHide);
		}
402838
public function addMessageType(\BisonLab\SakonninBundle\Entity\MessageType $message_types)
    {
        $this->message_types[] = $message_types;

        return $this;
    }
161525
protected function add($type, $msg, array $context)
	{
		if (!isset($context['attrName']) && isset($this->attrName))
		{
			$context['attrName'] = $this->attrName;
		}

		if (!isset($context['tag']) && isset($this->tag))
		{
			$context['tag'] = $this->tag;
		}

		$this->logs[] = [$type, $msg, $context];
	}
1335361
protected function logLine($messageType, $messageText)
    {
        switch ($messageType) {
            case Process::ERR:
                $typeStr = "[Error]";
                break;
            default:
                $typeStr = "";
                break;
        }

        echo sprintf("\n%s %s\n", $typeStr, $messageText);
    }
897862
protected function isValidNotificationType(string $notificationType): void
    {
        $allowedNotificationType = $this->getAllowedNotificationType();
        if (!\in_array($notificationType, $allowedNotificationType, true)) {
            throw new InvalidTypeException(sprintf(
                'notificationType must be either "%s".',
                implode(', ', $allowedNotificationType)
            ));
        }
    }
510875
private function create($messageClass, $message)
    {
        $interfaces = array_values(class_implements($messageClass, true));
        return new IncomingLogicalMessage($message, $messageClass, $interfaces);
    }
845765
protected function send_post($course, $forum, $discussion, $post, $cm, $context) {
        global $CFG, $PAGE;

        $author = $this->get_post_author($post->userid, $course, $forum, $cm, $context);
        if (empty($author)) {
            return false;
        }

        // Prepare to actually send the post now, and build up the content.
        $cleanforumname = str_replace('"', "'", strip_tags(format_string($forum->name)));

        $shortname = format_string($course->shortname, true, [
                'context' => \context_course::instance($course->id),
            ]);

        // Generate a reply-to address from using the Inbound Message handler.
        $replyaddress = $this->get_reply_address($course, $forum, $discussion, $post, $cm, $context);

        $data = new \mod_forum\output\forum_post_email(
            $course,
            $cm,
            $forum,
            $discussion,
            $post,
            $author,
            $this->recipient,
            $this->can_post($course, $forum, $discussion, $post, $cm, $context)
        );
        $data->viewfullnames = $this->can_view_fullnames($course, $forum, $discussion, $post, $cm, $context);

        // Not all of these variables are used in the default string but are made available to support custom subjects.
        $site = get_site();
        $a = (object) [
            'subject' => $data->get_subject(),
            'forumname' => $cleanforumname,
            'sitefullname' => format_string($site->fullname),
            'siteshortname' => format_string($site->shortname),
            'courseidnumber' => $data->get_courseidnumber(),
            'coursefullname' => $data->get_coursefullname(),
            'courseshortname' => $data->get_coursename(),
        ];
        $postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0);

        // Message headers are stored against the message author.
        $author->customheaders = $this->get_message_headers($course, $forum, $discussion, $post, $a, $data);

        $eventdata = new \core\message\message();
        $eventdata->courseid            = $course->id;
        $eventdata->component           = 'mod_forum';
        $eventdata->name                = 'posts';
        $eventdata->userfrom            = $author;
        $eventdata->userto              = $this->recipient;
        $eventdata->subject             = $postsubject;
        $eventdata->fullmessage         = $this->get_renderer()->render($data);
        $eventdata->fullmessageformat   = FORMAT_PLAIN;
        $eventdata->fullmessagehtml     = $this->get_renderer(true)->render($data);
        $eventdata->notification        = 1;
        $eventdata->replyto             = $replyaddress;
        if (!empty($replyaddress)) {
            // Add extra text to email messages if they can reply back.
            $eventdata->set_additional_content('email', [
                    'fullmessage' => [
                        'footer' => "\n\n" . get_string('replytopostbyemail', 'mod_forum'),
                    ],
                    'fullmessagehtml' => [
                        'footer' => \html_writer::tag('p', get_string('replytopostbyemail', 'mod_forum')),
                    ]
                ]);
        }

        $eventdata->smallmessage = get_string('smallmessage', 'forum', (object) [
                'user' => fullname($author),
                'forumname' => "$shortname: " . format_string($forum->name, true) . ": " . $discussion->name,
                'message' => $post->message,
            ]);

        $contexturl = new \moodle_url('/mod/forum/discuss.php', ['d' => $discussion->id], "p{$post->id}");
        $eventdata->contexturl = $contexturl->out();
        $eventdata->contexturlname = $discussion->name;
        // User image.
        $userpicture = new \user_picture($author);
        $userpicture->includetoken = $this->recipient->id; // Generate an out-of-session token for the user receiving the message.
        $eventdata->customdata = [
            'cmid' => $cm->id,
            'instance' => $forum->id,
            'discussionid' => $discussion->id,
            'postid' => $post->id,
            'notificationiconurl' => $userpicture->get_url($PAGE)->out(false),
            'actionbuttons' => [
                'reply' => get_string_manager()->get_string('reply', 'forum', null, $eventdata->userto->lang),
            ],
        ];

        return message_send($eventdata);
    }
1172524
protected function notify($message, $type = 'info')
    {
        if ($this->notifier) {
            $messages = is_array($message) ? $message : [$message];
            foreach ($messages as $text) {
                if ($type === 'error') {
                    $this->notifier->error($text);
                } else {
                    $this->notifier->info($text);
                }
            }
        }

        return $this;
    }
428931
protected function addFlashMessage($messageType, $message, array $parameters = [])
    {
        $this->addFlash(
            'tags.' . $messageType,
            $this->get('translator')->trans(
                $messageType . '.' . $message,
                $parameters,
                'eztags_admin_flash'
            )
        );
    }
1075578
public function notification($string, $type = null)
    {
        if (is_null($type)) {
            $type = 'info';
        }

        Session::flash('notification', $string);
        Session::flash('notificationType', 'alert-'.$type);
    }
1355849
public function setContentPartForMimeType(Message $message, $mimeType, $stringOrHandle, $charset)
    {
        $part = ($mimeType === 'text/html') ? $message->getHtmlPart() : $message->getTextPart();
        if ($part === null) {
            $part = $this->createContentPartForMimeType($message, $mimeType, $charset);
        } else {
            $contentType = $part->getContentType();
            $part->setRawHeader('Content-Type', "$contentType;\r\n\tcharset=\"$charset\"");
        }
        $part->setContent($stringOrHandle);
    }
95737
private function createHtmlByType(array $notifications, $type)
    {
        $html = "<div class='alert-box {$type} radius' data-alert>";
        foreach ($notifications as $notification) {
            $html .= "{$notification}";
            // If it's not the last notification, add a line break for the next one
            if (end($notifications) !== $notification) {
                $html .= "<br />";
            }
        }
        $html .= "<a href='#' class='close'>&times;</a>";
        $html .= "</div>";

        return $html;
    }