| Línea 65... |
Línea 65... |
| 65 |
* @param \stdClass $messagedata The Inbound Message record
|
65 |
* @param \stdClass $messagedata The Inbound Message record
|
| 66 |
* @param \stdClass $messagedata The message data packet
|
66 |
* @param \stdClass $messagedata The message data packet
|
| 67 |
* @return bool Whether the message was successfully processed.
|
67 |
* @return bool Whether the message was successfully processed.
|
| 68 |
*/
|
68 |
*/
|
| 69 |
public function process_message(\stdClass $record, \stdClass $messagedata) {
|
69 |
public function process_message(\stdClass $record, \stdClass $messagedata) {
|
| 70 |
global $DB, $USER;
|
70 |
global $CFG, $DB, $USER;
|
| Línea 71... |
Línea 71... |
| 71 |
|
71 |
|
| 72 |
// Load the post being replied to.
|
72 |
// Load the post being replied to.
|
| 73 |
$post = $DB->get_record('forum_posts', array('id' => $record->datavalue));
|
73 |
$post = $DB->get_record('forum_posts', array('id' => $record->datavalue));
|
| 74 |
if (!$post) {
|
74 |
if (!$post) {
|
| Línea 133... |
Línea 133... |
| 133 |
$data->message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
|
133 |
$data->message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
|
| 134 |
throw new \core\message\inbound\processing_failed_exception('messageinboundthresholdhit', 'mod_forum', $data);
|
134 |
throw new \core\message\inbound\processing_failed_exception('messageinboundthresholdhit', 'mod_forum', $data);
|
| 135 |
}
|
135 |
}
|
| Línea 136... |
Línea 136... |
| 136 |
|
136 |
|
| 137 |
$subject = clean_param($messagedata->envelope->subject, PARAM_TEXT);
|
- |
|
| 138 |
$restring = get_string('re', 'forum');
|
137 |
$subject = clean_param($messagedata->envelope->subject, PARAM_TEXT);
|
| 139 |
if (strpos($subject, $discussion->name)) {
|
138 |
if (strpos($subject, $discussion->name)) {
|
| 140 |
// The discussion name is mentioned in the e-mail subject. This is probably just the standard reply. Use the
|
139 |
// The discussion name is mentioned in the e-mail subject. This is probably just the standard reply. Use the
|
| 141 |
// standard reply subject instead.
|
- |
|
| 142 |
$newsubject = $restring . ' ' . $discussion->name;
|
140 |
// standard reply subject instead.
|
| 143 |
mtrace("--> Note: Post subject matched discussion name. Optimising from {$subject} to {$newsubject}");
|
141 |
mtrace("--> Note: Post subject matched discussion name. Optimising from {$subject} to {$discussion->name}");
|
| 144 |
$subject = $newsubject;
|
142 |
$subject = $discussion->name;
|
| 145 |
} else if (strpos($subject, $post->subject)) {
|
143 |
} else if (strpos($subject, $post->subject)) {
|
| 146 |
// The replied-to post's subject is mentioned in the e-mail subject.
|
144 |
// The replied-to post's subject is mentioned in the e-mail subject.
|
| 147 |
// Use the previous post's subject instead of the e-mail subject.
|
- |
|
| 148 |
$newsubject = $post->subject;
|
- |
|
| 149 |
if (!strpos($restring, $post->subject)) {
|
- |
|
| 150 |
// The previous post did not contain a re string, add it.
|
- |
|
| 151 |
$newsubject = $restring . ' ' . $newsubject;
|
- |
|
| 152 |
}
|
145 |
// Use the previous post's subject instead of the e-mail subject.
|
| 153 |
mtrace("--> Note: Post subject matched original post subject. Optimising from {$subject} to {$newsubject}");
|
146 |
mtrace("--> Note: Post subject matched original post subject. Optimising from {$subject} to {$post->subject}");
|
| 154 |
$subject = $newsubject;
|
147 |
$subject = $post->subject;
|
| Línea 155... |
Línea 148... |
| 155 |
}
|
148 |
}
|
| 156 |
|
149 |
|
| 157 |
$addpost = new \stdClass();
|
150 |
$addpost = new \stdClass();
|
| Línea 212... |
Línea 205... |
| 212 |
mtrace("--> Processing {$attachment->filename} as an attachment.");
|
205 |
mtrace("--> Processing {$attachment->filename} as an attachment.");
|
| 213 |
$this->process_attachment('*', $usercontext, $addpost->attachments, $attachment);
|
206 |
$this->process_attachment('*', $usercontext, $addpost->attachments, $attachment);
|
| 214 |
$filesize += $attachment->filesize;
|
207 |
$filesize += $attachment->filesize;
|
| 215 |
}
|
208 |
}
|
| Línea -... |
Línea 209... |
| - |
|
209 |
|
| 216 |
|
210 |
$maxbytes = get_user_max_upload_file_size($modcontext, $CFG->maxbytes, $course->maxbytes, $forum->maxbytes);
|
| 217 |
if ($forum->maxbytes < $filesize) {
|
211 |
if ($maxbytes < $filesize) {
|
| 218 |
// Too many attachments.
|
212 |
// Too many attachments.
|
| 219 |
mtrace("--> User attached {$filesize} bytes of files when only {$forum->maxbytes} where allowed. "
|
- |
|
| 220 |
. "Rejecting e-mail.");
|
213 |
mtrace("--> User attached {$filesize} bytes of files when only {$maxbytes} were allowed. Rejecting e-mail.");
|
| 221 |
$data = new \stdClass();
|
214 |
$data = new \stdClass();
|
| 222 |
$data->forum = $forum;
|
215 |
$data->forum = $forum;
|
| 223 |
$data->maxbytes = display_size($forum->maxbytes, 0);
|
216 |
$data->maxbytes = display_size($maxbytes);
|
| 224 |
$data->filesize = display_size($filesize);
|
217 |
$data->filesize = display_size($filesize);
|
| 225 |
throw new \core\message\inbound\processing_failed_exception('messageinboundfilesizeexceeded', 'mod_forum', $data);
|
218 |
throw new \core\message\inbound\processing_failed_exception('messageinboundfilesizeexceeded', 'mod_forum', $data);
|
| 226 |
}
|
219 |
}
|