MDL-83080 message: handle core\url instance data as contexturl.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
issueNumber: MDL-83080
|
||||
notes:
|
||||
core_message:
|
||||
- message: >-
|
||||
The `contexturl` property to `\core\message\message` instances can now
|
||||
contain `\core\url` values in addition to plain strings
|
||||
type: improved
|
||||
@@ -14,18 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* New messaging class.
|
||||
*
|
||||
* @package core_message
|
||||
* @since Moodle 2.9
|
||||
* @copyright 2015 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\message;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use core\url;
|
||||
|
||||
/**
|
||||
* New messaging class.
|
||||
@@ -46,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*
|
||||
* Optional parameters of the $eventdata object:
|
||||
* notification bool Should the message be considered as a notification rather than a personal message
|
||||
* contexturl string If this is a notification then you can specify a url to view the event.
|
||||
* contexturl string|url 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.
|
||||
* contexturlname string The display text for contexturl.
|
||||
* replyto string An email address which can be used to send an reply.
|
||||
@@ -102,7 +93,7 @@ class message {
|
||||
/** @var int Is it a notification? */
|
||||
private $notification;
|
||||
|
||||
/** @var string context url. */
|
||||
/** @var string|url context url. */
|
||||
private $contexturl;
|
||||
|
||||
/** @var string context name. */
|
||||
|
||||
+14
-12
@@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use core\url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__ . '/../message/lib.php');
|
||||
@@ -44,7 +46,8 @@ require_once(__DIR__ . '/../message/lib.php');
|
||||
*
|
||||
* Optional parameters of the $eventdata object:
|
||||
* notification bool should the message be considered as a notification rather than a personal message
|
||||
* 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.
|
||||
* contexturl string|url 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.
|
||||
* contexturlname string the display text for contexturl
|
||||
*
|
||||
* Note: processor failure will not reported as false return value in all scenarios,
|
||||
@@ -83,6 +86,14 @@ function message_send(\core\message\message $eventdata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cast context URL and name.
|
||||
if (!empty($eventdata->contexturl)) {
|
||||
$eventdata->contexturl = (string) $eventdata->contexturl;
|
||||
}
|
||||
if (!empty($eventdata->contexturlname)) {
|
||||
$eventdata->contexturlname = (string) $eventdata->contexturlname;
|
||||
}
|
||||
|
||||
// Legacy messages (FROM a single user TO a single user) must be converted into conversation messages.
|
||||
// Then, these will be passed through the conversation messages code below.
|
||||
if (!$eventdata->notification && !$eventdata->convid) {
|
||||
@@ -256,17 +267,8 @@ function message_send(\core\message\message $eventdata) {
|
||||
$tabledata->component = $eventdata->component;
|
||||
$tabledata->timecreated = time();
|
||||
$tabledata->customdata = $eventdata->customdata;
|
||||
if (!empty($eventdata->contexturl)) {
|
||||
$tabledata->contexturl = (string)$eventdata->contexturl;
|
||||
} else {
|
||||
$tabledata->contexturl = null;
|
||||
}
|
||||
|
||||
if (!empty($eventdata->contexturlname)) {
|
||||
$tabledata->contexturlname = (string)$eventdata->contexturlname;
|
||||
} else {
|
||||
$tabledata->contexturlname = null;
|
||||
}
|
||||
$tabledata->contexturl = $eventdata->contexturl ?? null;
|
||||
$tabledata->contexturlname = $eventdata->contexturlname ?? null;
|
||||
|
||||
if ($messageid = message_handle_phpunit_redirection($eventdata, $table, $tabledata)) {
|
||||
return $messageid;
|
||||
|
||||
Reference in New Issue
Block a user