| Línea 34... |
Línea 34... |
| 34 |
*/
|
34 |
*/
|
| 35 |
class helper {
|
35 |
class helper {
|
| 36 |
/**
|
36 |
/**
|
| 37 |
* Send a fake message.
|
37 |
* Send a fake message.
|
| 38 |
*
|
38 |
*
|
| 39 |
* {@link message_send()} does not support transaction, this function will simulate a message
|
39 |
* {@see message_send()} does not support transaction, this function will simulate a message
|
| 40 |
* sent from a user to another. We should stop using it once {@link message_send()} will support
|
40 |
* sent from a user to another. We should stop using it once {@see message_send()} will support
|
| 41 |
* transactions. This is not clean at all, this is just used to add rows to the table.
|
41 |
* transactions. This is not clean at all, this is just used to add rows to the table.
|
| 42 |
*
|
42 |
*
|
| 43 |
* @param \stdClass $userfrom user object of the one sending the message.
|
43 |
* @param \stdClass $userfrom user object of the one sending the message.
|
| 44 |
* @param \stdClass $userto user object of the one receiving the message.
|
44 |
* @param \stdClass $userto user object of the one receiving the message.
|
| 45 |
* @param string $message message to send.
|
45 |
* @param string $message message to send.
|
| Línea 116... |
Línea 116... |
| 116 |
* @param int $time the time the message was sent.
|
116 |
* @param int $time the time the message was sent.
|
| 117 |
* @return int the id of the message which was sent.
|
117 |
* @return int the id of the message which was sent.
|
| 118 |
* @throws \dml_exception if the conversation doesn't exist.
|
118 |
* @throws \dml_exception if the conversation doesn't exist.
|
| 119 |
*/
|
119 |
*/
|
| 120 |
public static function send_fake_message_to_conversation(\stdClass $userfrom, int $convid, string $message = 'Hello world!',
|
120 |
public static function send_fake_message_to_conversation(\stdClass $userfrom, int $convid, string $message = 'Hello world!',
|
| 121 |
int $time = null): int {
|
121 |
?int $time = null): int {
|
| 122 |
global $DB;
|
122 |
global $DB;
|
| 123 |
$conversationrec = $DB->get_record('message_conversations', ['id' => $convid], 'id', MUST_EXIST);
|
123 |
$conversationrec = $DB->get_record('message_conversations', ['id' => $convid], 'id', MUST_EXIST);
|
| 124 |
$conversationid = $conversationrec->id;
|
124 |
$conversationid = $conversationrec->id;
|
| 125 |
$time = $time ?? time();
|
125 |
$time = $time ?? time();
|
| 126 |
$record = new \stdClass();
|
126 |
$record = new \stdClass();
|