| Línea 20... |
Línea 20... |
| 20 |
* @package core_message
|
20 |
* @package core_message
|
| 21 |
* @copyright 2008 Luis Rodrigues and Martin Dougiamas
|
21 |
* @copyright 2008 Luis Rodrigues and Martin Dougiamas
|
| 22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 23 |
*/
|
23 |
*/
|
| Línea -... |
Línea 24... |
| - |
|
24 |
|
| - |
|
25 |
use core\url;
|
| 24 |
|
26 |
|
| Línea 25... |
Línea 27... |
| 25 |
defined('MOODLE_INTERNAL') || die();
|
27 |
defined('MOODLE_INTERNAL') || die();
|
| Línea 26... |
Línea 28... |
| 26 |
|
28 |
|
| Línea 42... |
Línea 44... |
| 42 |
* fullmessagehtml string the full version (the message processor will choose with one to use)
|
44 |
* fullmessagehtml string the full version (the message processor will choose with one to use)
|
| 43 |
* smallmessage string the small version of the message
|
45 |
* smallmessage string the small version of the message
|
| 44 |
*
|
46 |
*
|
| 45 |
* Optional parameters of the $eventdata object:
|
47 |
* Optional parameters of the $eventdata object:
|
| 46 |
* notification bool should the message be considered as a notification rather than a personal message
|
48 |
* notification bool should the message be considered as a notification rather than a personal message
|
| 47 |
* contexturl string if this is a notification then you can specify a url to view the event. For example the forum post the user is being notified of.
|
49 |
* contexturl string|url if this is a notification then you can specify a url to view the event.
|
| - |
|
50 |
* For example the forum post the user is being notified of.
|
| 48 |
* contexturlname string the display text for contexturl
|
51 |
* contexturlname string the display text for contexturl
|
| 49 |
*
|
52 |
*
|
| 50 |
* Note: processor failure will not reported as false return value in all scenarios,
|
53 |
* Note: processor failure will not reported as false return value in all scenarios,
|
| 51 |
* for example when it is called while a database transaction is open,
|
54 |
* for example when it is called while a database transaction is open,
|
| 52 |
* earlier versions did not do it consistently either.
|
55 |
* earlier versions did not do it consistently either.
|
| Línea 81... |
Línea 84... |
| 81 |
if (!$eventdata->userfrom) {
|
84 |
if (!$eventdata->userfrom) {
|
| 82 |
debugging('Attempt to send msg from unknown user', DEBUG_NORMAL);
|
85 |
debugging('Attempt to send msg from unknown user', DEBUG_NORMAL);
|
| 83 |
return false;
|
86 |
return false;
|
| 84 |
}
|
87 |
}
|
| Línea -... |
Línea 88... |
| - |
|
88 |
|
| - |
|
89 |
// Cast context URL and name.
|
| - |
|
90 |
if (!empty($eventdata->contexturl)) {
|
| - |
|
91 |
$eventdata->contexturl = (string) $eventdata->contexturl;
|
| - |
|
92 |
}
|
| - |
|
93 |
if (!empty($eventdata->contexturlname)) {
|
| - |
|
94 |
$eventdata->contexturlname = (string) $eventdata->contexturlname;
|
| - |
|
95 |
}
|
| 85 |
|
96 |
|
| 86 |
// Legacy messages (FROM a single user TO a single user) must be converted into conversation messages.
|
97 |
// Legacy messages (FROM a single user TO a single user) must be converted into conversation messages.
|
| 87 |
// Then, these will be passed through the conversation messages code below.
|
98 |
// Then, these will be passed through the conversation messages code below.
|
| 88 |
if (!$eventdata->notification && !$eventdata->convid) {
|
99 |
if (!$eventdata->notification && !$eventdata->convid) {
|
| 89 |
// If messaging is disabled at the site level, then the 'instantmessage' provider is always disabled.
|
100 |
// If messaging is disabled at the site level, then the 'instantmessage' provider is always disabled.
|
| Línea 254... |
Línea 265... |
| 254 |
$tabledata->smallmessage = $eventdata->smallmessage;
|
265 |
$tabledata->smallmessage = $eventdata->smallmessage;
|
| 255 |
$tabledata->eventtype = $eventdata->name;
|
266 |
$tabledata->eventtype = $eventdata->name;
|
| 256 |
$tabledata->component = $eventdata->component;
|
267 |
$tabledata->component = $eventdata->component;
|
| 257 |
$tabledata->timecreated = time();
|
268 |
$tabledata->timecreated = time();
|
| 258 |
$tabledata->customdata = $eventdata->customdata;
|
269 |
$tabledata->customdata = $eventdata->customdata;
|
| 259 |
if (!empty($eventdata->contexturl)) {
|
- |
|
| 260 |
$tabledata->contexturl = (string)$eventdata->contexturl;
|
270 |
$tabledata->contexturl = $eventdata->contexturl ?? null;
|
| 261 |
} else {
|
- |
|
| 262 |
$tabledata->contexturl = null;
|
- |
|
| 263 |
}
|
- |
|
| 264 |
|
- |
|
| 265 |
if (!empty($eventdata->contexturlname)) {
|
- |
|
| 266 |
$tabledata->contexturlname = (string)$eventdata->contexturlname;
|
271 |
$tabledata->contexturlname = $eventdata->contexturlname ?? null;
|
| 267 |
} else {
|
- |
|
| 268 |
$tabledata->contexturlname = null;
|
- |
|
| 269 |
}
|
- |
|
| Línea 270... |
Línea 272... |
| 270 |
|
272 |
|
| 271 |
if ($messageid = message_handle_phpunit_redirection($eventdata, $table, $tabledata)) {
|
273 |
if ($messageid = message_handle_phpunit_redirection($eventdata, $table, $tabledata)) {
|
| 272 |
return $messageid;
|
274 |
return $messageid;
|
| Línea 714... |
Línea 716... |
| 714 |
global $DB;
|
716 |
global $DB;
|
| Línea 715... |
Línea 717... |
| 715 |
|
717 |
|
| 716 |
$transaction = $DB->start_delegated_transaction();
|
718 |
$transaction = $DB->start_delegated_transaction();
|
| 717 |
$DB->delete_records('message_providers', array('component' => $component));
|
719 |
$DB->delete_records('message_providers', array('component' => $component));
|
| 718 |
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_%"));
|
720 |
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_%"));
|
| 719 |
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_%"));
|
721 |
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?'), ["message_provider_{$component}_%"]);
|
| 720 |
$transaction->allow_commit();
|
722 |
$transaction->allow_commit();
|
| 721 |
// Purge all messaging settings from the caches. They are stored by plugin so we have to clear all message settings.
|
723 |
// Purge all messaging settings from the caches. They are stored by plugin so we have to clear all message settings.
|
| 722 |
cache_helper::invalidate_by_definition('core', 'config', array(), 'message');
|
724 |
cache_helper::invalidate_by_definition('core', 'config', array(), 'message');
|