--- comment_notify.module 2010-03-11 05:29:40.000000000 +0700
+++ comment_notify.module 2010-04-18 22:49:30.000000000 +0700
@@ -357,6 +357,7 @@ function comment_notify_user($type, &$ed
* The comment array as found in hook_comment $op = publish.
*/
function _comment_notify_mailalert($comment) {
+ $tempcommteaser = $comment['comment'];
$comment = (object) $comment;
global $language;
global $base_url;
@@ -364,6 +365,7 @@ function _comment_notify_mailalert($comm
$nid = $comment->nid;
$cid = $comment->cid;
+ $commteaser = truncate($tempcommteaser, 50, "...");
// Check to see if a notification has already been sent for this
// comment so that edits to a comment don't trigger an additional
@@ -415,6 +417,7 @@ function _comment_notify_mailalert($comm
'!commname' => $comment->name,
'!commtext' => drupal_html_to_text($comment_text),
'!commsubj' => $comment->subject,
+ '!commteaser' => $commteaser,
'!comment_url' => url('node/'. $nid, array('absolute' => TRUE, 'fragment' => 'comment-'. $cid)),
'!node_title' => $node->title,
'!node_teaser' => drupal_html_to_text($node_teaser),
@@ -475,6 +478,7 @@ function _comment_notify_mailalert($comm
'!commname' => $comment->name,
'!commtext' => drupal_html_to_text($comment_text),
'!commsubj' => $comment->subject,
+ '!commteaser' => $commteaser,
'!comment_url' => url('node/'. $nid, array('absolute' => TRUE, 'fragment' => 'comment-'. $cid)),
'!node_title' => $node->title,
'!node_teaser' => drupal_html_to_text($node_teaser),
@@ -654,6 +658,7 @@ function comment_notify_settings() {
!commname = the username who posted the comment
!commtext = the text of the posted comment
!commsubj = the subject of the posted comment
+ !commteaser = a 50-character teaser of the posted comment
!comment_url = the full url of the post and comment - note: if you have paging enabled, this does not work correct - set your max comments per page so that all fit on one page or reverse order them
!nid = the node id the comment was posted on
!node_title = the title of the node that was commented on
@@ -686,6 +691,7 @@ function comment_notify_settings() {
!commname = the username who posted the comment
!commtext = the text of the posted comment
!commsubj = the subject of the posted comment
+ !commteaser = a 50-character teaser of the posted comment
!comment_url = the full url of the post and comment - note: if you have paging enabled, this does not work correct - set your max comments per page so that all fit on one page or reverse order them
!nid = the node id the comment was posted on
!node_title = the title of the node that was commented on
@@ -721,3 +727,23 @@ function comment_notify_settings_validat
form_set_error('comment_notify_available_alerts', 'You must enable at least one subscription mode.');
}
}
+
+/* truncate function added to truncate comment text */
+
+function truncate($text,$numb,$etc = "...") {
+if (strlen($text) > $numb) {
+$text = substr($text, 0, $numb);
+$text = substr($text,0,strrpos($text," "));
+
+$punctuation = ".!?:;,-"; //punctuation you want removed
+
+$text = (strspn(strrev($text), $punctuation)!=0)
+ ?
+ substr($text, 0, -strspn(strrev($text), $punctuation))
+ :
+$text;
+
+$text = $text.$etc;
+}
+return $text;
+}