Commit 568074bf authored by Ghada El-Zoghbi's avatar Ghada El-Zoghbi Committed by Gerrit Code Review
Browse files

Bug1075760: reporting objectional material with no message doesn't get sent to...

Bug1075760: reporting objectional material with no message doesn't get sent to admin with digest emails

Email digest table has a not null contraint for the message field:
1. Force the user to enter something in the objectionable comment.
2. Other areas: if a user enteres a message (i.e. in a forum)
which is made up of html (i.e. a smiley face),
the message gets 'cleaned' by stripping html tags.
This leaves it empty and fails when trying to insert into the
email digest table.
Clean the message with html2text instead of str_shorten_html.
3. As a last resort, before inserting into the email digest table,
make sure there is at least a space in the message field (if it's empty).

Change-Id: I05a77e0682017839b34e74241eefb98fb788eab5
Signed-off-by: default avatarGhada El-Zoghbi <>
parent 526a4e61
......@@ -837,7 +837,10 @@ class ActivityTypeInteractionForumNewPost extends ActivityTypePlugin {
$post->posttime = strftime(get_string('strftimedaydatetime'), $post->ctime);
$this->message = strip_tags(str_shorten_html($post->body, 200, true)); // For internal notifications.
// Some messages are all html and when they're 'cleaned' with
// strip_tags(str_shorten_html($post->body, 200, true)) for display,
// they are left empty. Use html2text instead.
$this->message = str_shorten_html(trim(html2text($post->body)), 200, true); // For internal notifications.
$post->textbody = trim(html2text($post->body));
$post->htmlbody = clean_html($post->body);
......@@ -5205,6 +5205,9 @@ function objection_form() {
'title' => get_string('complaint', 'view'),
'rows' => 5,
'cols' => 80,
'rules' => array(
'required' => true
$form['elements']['submit'] = array(
'type' => 'submitcancel',
......@@ -19,7 +19,10 @@ class PluginNotificationEmaildigest extends PluginNotification {
$toinsert = new StdClass;
$toinsert->type = $data->type;
$toinsert->usr = $user->id;
$toinsert->message = $data->message;
// Some messages are all html (or the message is not required).
// When they're 'cleaned' for display, they are left empty.
// Make sure something is in the field as it's NOT NULL in the database.
$toinsert->message = (empty($data->message) ? ' ' : $data->message);
$toinsert->ctime = db_format_timestamp(time());
if (!empty($data->url)) {
$toinsert->url = $data->url;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment