2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Contains a base class for extension by message processors
20 * @package core_message
21 * @copyright Luis Rodrigues
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 * Base message processor class for extension by message processors
28 * @package core_message
29 * @copyright 2008 Luis Rodrigues
30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 abstract class message_output
{
34 * Process a message received by a user
37 * @param stdClass $message The event data submitted by the message provider to message_send() plus $eventdata->savedmessageid
39 abstract public function send_message($message);
42 * Load the config data from database to put on the config form on the messaging preferences page
44 * @param array $preferences Array of user preferences
45 * @param int $userid The user ID
47 abstract public function load_data(&$preferences, $userid);
50 * Create necessary fields in the config form on the messaging preferences page
52 * @param array $preferences An array of user preferences
54 abstract public function config_form($preferences);
57 * Parse the submitted form and save data into an array of user preferences
59 * @param stdClass $form preferences form class
60 * @param array $preferences preferences array
62 abstract public function process_form($form, &$preferences);
65 * Are the message processor's system settings configured?
67 * @return bool True if all necessary config settings been entered
69 public function is_system_configured() {
74 * Are the message processor's user specific settings configured?
76 * @param stdClass $user the user object, defaults to $USER.
77 * @return bool True if the user has all necessary settings in their messaging preferences
79 public function is_user_configured($user = null) {
84 * Returns the message processors default settings
85 * Should the processor be enabled in users by default?
86 * Is enabling it disallowed, permitted or forced?
88 * @return int The Default message output settings expressed as a bit mask
89 * MESSAGE_DEFAULT_ENABLED + MESSAGE_PERMITTED
91 public function get_default_messaging_settings() {
92 return MESSAGE_PERMITTED
;
96 * Returns true if message can be sent to fake/internal user as well.
97 * If message_output support message to be sent to fake user, then it should return true, like email.
101 public function can_send_to_any_users() {
106 * Returns true if this processor has configurable message preferences. This is
107 * distinct from notification preferences.
111 public function has_message_preferences() {
116 * Determines if this processor should process a message regardless of user preferences or site settings.
120 public function force_process_messages() {
125 * Allow processors to perform cleanup tasks for all notifications by overriding this method
128 * @param int $notificationdeletetime
131 public function cleanup_all_notifications(int $notificationdeletetime): void
{
136 * Allow processors to perform cleanup tasks for read notifications by overriding this method
139 * @param int $notificationdeletetime
142 public function cleanup_read_notifications(int $notificationdeletetime): void
{