# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/moodlelib.php
--- moodle/lib/moodlelib.php Base (1.1477)
+++ moodle/lib/moodlelib.php Locally Modified (Based On 1.1477)
@@ -8915,23 +8915,20 @@
 
     $message_users = null;
 
-    $sql = "SELECT m.id, u.firstname, u.lastname FROM {message} m
+    $messagesql = "SELECT m.id, m.smallmessage, u.firstname, u.lastname FROM {message} m
 JOIN {message_working} mw ON m.id=mw.unreadmessageid
 JOIN {message_processors} p ON mw.processorid=p.id
 JOIN {user} u ON m.useridfrom=u.id
-WHERE m.useridto = :userid AND m.timecreated > :ts AND p.name='popup'";
+WHERE m.useridto = :userid AND p.name='popup'";
+
+    $sql = $messagesql.' AND m.timecreated > :ts';
     $message_users = $DB->get_records_sql($sql, array('userid'=>$USER->id, 'ts'=>$USER->message_lastpopup));
     if (empty($message_users)) {
 
         //if the user was last notified over an hour ago remind them of any new messages regardless of when they were sent
         $canrenotify = (time() - $USER->message_lastpopup) > 3600;
         if ($canrenotify) {
-            $sql = "SELECT m.id, u.firstname, u.lastname FROM {message} m
-JOIN {message_working} mw ON m.id=mw.unreadmessageid
-JOIN {message_processors} p ON mw.processorid=p.id
-JOIN {user} u ON m.useridfrom=u.id
-WHERE m.useridto = :userid AND p.name='popup'";
-            $message_users = $DB->get_records_sql($sql, array('userid'=>$USER->id));
+            $message_users = $DB->get_records_sql($messagesql, array('userid'=>$USER->id));
         }
     }
 
@@ -8942,8 +8939,20 @@
         if (count($message_users)>1) {
             $strmessages = get_string('unreadnewmessages', 'message', count($message_users));
         } else {
-            $strmessages = get_string('unreadnewmessage', 'message', fullname(reset($message_users)) );
+            $message_users = reset($message_users);
+            $strmessages = get_string('unreadnewmessage', 'message', fullname($message_users) );
+
+            if (!empty($message_users->smallmessage)) {
+                //display the first 200 chars of the message in the popup
+                $smallmessage = null;
+                if (strlen($message_users->smallmessage>200)) {
+                    $smallmessage = substr($message_users->smallmessage,0,200).'...';
+                } else {
+                    $smallmessage = $message_users->smallmessage;
         }
+                $strmessages .= '<div id="usermessage">'.$smallmessage.'</div>';
+            }
+        }
 
         $strgomessage = get_string('gotomessages', 'message');
         $strstaymessage = get_string('ignore','admin');
Index: moodle/message/lib.php
--- moodle/message/lib.php Base (1.139)
+++ moodle/message/lib.php Locally Modified (Based On 1.139)
@@ -1495,7 +1495,14 @@
     $time = userdate($message->timecreated, $dateformat);
     $options = new stdClass();
     $options->para = false;
+
+    //if supplied display small messages as fullmessage may contain boilerplate text that shouldnt appear in the messaging UI
+    if (!empty($message->smallmessage)) {
+        $messagetext = format_text($message->smallmessage, null, $options);
+    } else {
     $messagetext = format_text($message->fullmessage, $message->fullmessageformat, $options);
+    }
+
     if ($keywords) {
         $messagetext = highlight($keywords, $messagetext);
     }
@@ -1519,15 +1526,21 @@
     $eventdata->fullmessage      = $message;
     $eventdata->fullmessageformat = $format;
     $eventdata->fullmessagehtml  = '';
-    $eventdata->smallmessage     = '';
+    $eventdata->smallmessage     = $message;
 
     $s = new stdClass();
     $s->sitename = $SITE->shortname;
     $s->url = $CFG->wwwroot.'/message/index.php?id='.$userfrom->id;//.'&user='.$userto->id;
 
     $emailtagline = get_string('emailtagline', 'message', $s);
-    $eventdata->footer = "\n\n---------------------------------------------------------------------\n".$emailtagline;
-    $eventdata->footerhtml = "<br /><br />---------------------------------------------------------------------<br />".$emailtagline;
+    //$eventdata->footer = "\n\n---------------------------------------------------------------------\n".$emailtagline;
+    if (!empty($eventdata->fullmessage)) {
+        $eventdata->fullmessage .= "\n\n---------------------------------------------------------------------\n".$emailtagline;
+    }
+    //$eventdata->footerhtml = "<br /><br />---------------------------------------------------------------------<br />".$emailtagline;
+    if (!empty($eventdata->fullmessagehtml)) {
+        $eventdata->fullmessagehtml .= "<br /><br />---------------------------------------------------------------------<br />".$emailtagline;
+    }
     
     $eventdata->timecreated     = time();
     return message_send($eventdata);
Index: moodle/message/output/email/message_output_email.php
--- moodle/message/output/email/message_output_email.php Base (1.12)
+++ moodle/message/output/email/message_output_email.php Locally Modified (Based On 1.12)
@@ -50,16 +50,18 @@
             $userto->email = $usertoemailaddress;
         }
 
+        $messagetosend = $message->fullmessage;
         //concatenating the footer on here so that it appears on emails but not within the saved message
-        $messagetosend = null;
+        /*$messagetosend = null;
         if (!empty($message->fullmessage)) {
             $messagetosend = $message->fullmessage.$message->footer;
-        }
+        }*/
 
-        $messagetosendhtml = null;
+        $messagetosendhtml = $message->fullmessagehtml;
+        /*$messagetosendhtml = null;
         if (!empty($message->fullmessagehtml)) {
             $messagetosendhtml = $message->fullmessagehtml.$message->footerhtml;
-        }
+        }*/
 
         $result = email_to_user($userto, $userfrom,
             $message->subject, $messagetosend, $messagetosendhtml);
Index: moodle/mod/forum/lang/en/forum.php
--- moodle/mod/forum/lang/en/forum.php Base (1.21)
+++ moodle/mod/forum/lang/en/forum.php Locally Modified (Based On 1.21)
@@ -283,7 +283,7 @@
 $string['postincontext'] = 'See this post in context';
 $string['postmailinfo'] = 'This is a copy of a message posted on the {$a} website.
 
-To add your reply via the website, click on this link:';
+To reply click on this link:';
 $string['postmailnow'] = '<p>This post will be mailed out immediately to all forum subscribers.</p>';
 $string['postrating1'] = 'Mostly Separate Knowing';
 $string['postrating2'] = 'Separate and Connected';
@@ -336,6 +336,8 @@
 $string['shortpost'] = 'Short post';
 $string['showsubscribers'] = 'Show/edit current subscribers';
 $string['singleforum'] = 'A single simple discussion';
+$string['smallmessage'] = '{$a->user} posted in {$a->forumname}<br />To reply: {$a->replylink}';
+//$string['smallmessage'] = 'I just posted in {$a->forumname}<br />{$a->message}To reply: {$a->replylink}';
 $string['startedby'] = 'Started by';
 $string['subject'] = 'Subject';
 $string['subscribe'] = 'Subscribe to this forum';
Index: moodle/mod/forum/lib.php
--- moodle/mod/forum/lib.php Base (1.904)
+++ moodle/mod/forum/lib.php Locally Modified (Based On 1.904)
@@ -635,8 +635,16 @@
                 $eventdata->fullmessage      = $posttext;
                 $eventdata->fullmessageformat = FORMAT_PLAIN;
                 $eventdata->fullmessagehtml  = $posthtml;
-                $eventdata->smallmessage     = '';
 
+                $smallmessagestrings = new stdClass();
+                $smallmessagestrings->user = fullname($userfrom);
+                //$strforums = get_string('forums', 'forum');
+                $smallmessagestrings->forumname = "{$course->shortname}->".format_string($forum->name,true);//format_string($forum->name,true);
+                $smallmessagestrings->replylink = "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
+                $smallmessagestrings->message = $post->message;
+                
+                $eventdata->smallmessage = get_string('smallmessage', 'forum', $smallmessagestrings);
+
                 $mailresult = message_send($eventdata);
                 if (!$mailresult){
                     mtrace("Error: mod/forum/lib.php forum_cron(): Could not send out mail for id $post->id to user $userto->id".
Index: moodle/theme/base/style/message.css
--- moodle/theme/base/style/message.css Base (1.4)
+++ moodle/theme/base/style/message.css Locally Modified (Based On 1.4)
@@ -52,4 +52,5 @@
 .messagesearchresults td span {white-space:nowrap;}
 
 #newmessageoverlay {background-color:LightGrey;padding:20px;position:fixed;bottom:0;right:0;}
+#newmessageoverlay #usermessage {padding:10px;font-weight:bold;}
 .ie6 #newmessageoverlay {position:static;}
