From 169c2cca0851280a965fd78d10e8f24f48c7b727 Mon Sep 17 00:00:00 2001
From: Chris Fitch <cfitch@redcom.com>
Date: Fri, 4 Sep 2009 09:21:10 -0400
Subject: [PATCH] Add BUGNOTE_DATA event so plugins can preprocess bugnote content


diff --git a/core/bugnote_api.php b/core/bugnote_api.php
index ebc70b4..f60a494 100644
--- a/core/bugnote_api.php
+++ b/core/bugnote_api.php
@@ -145,9 +145,14 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_
 		return false;
 	}
 
+	$t_bugnote_text = $p_bugnote_text;
+
+	# Event integration
+	$t_bugnote_text = event_signal( 'EVENT_BUGNOTE_DATA', $t_bugnote_text );
+
 	# insert bugnote text
 	$query = 'INSERT INTO ' . $t_bugnote_text_table . ' ( note ) VALUES ( ' . db_param() . ' )';
-	db_query_bound( $query, Array( $p_bugnote_text ) );
+	db_query_bound( $query, Array( $t_bugnote_text ) );
 
 	# retrieve bugnote text id number
 	$t_bugnote_text_id = db_insert_id( $t_bugnote_text_table );
@@ -187,7 +192,7 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_
 	event_signal( 'EVENT_BUGNOTE_ADD', array( $p_bug_id, $t_bugnote_id ) );
 
 	# only send email if the text is not blank, otherwise, it is just recording of time without a comment.
-	if( TRUE == $p_send_email && !is_blank( $p_bugnote_text ) ) {
+	if( TRUE == $p_send_email && !is_blank( $t_bugnote_text ) ) {
 		email_bugnote_add( $p_bug_id );
 	}
 
diff --git a/core/events_inc.php b/core/events_inc.php
index 226f0f9..3647c72 100644
--- a/core/events_inc.php
+++ b/core/events_inc.php
@@ -98,6 +98,7 @@ event_declare_many( array(
 	# Bugnote events
 	'EVENT_BUGNOTE_ADD_FORM' => EVENT_TYPE_EXECUTE,
 	'EVENT_BUGNOTE_ADD' => EVENT_TYPE_EXECUTE,
+	'EVENT_BUGNOTE_DATA' => EVENT_TYPE_CHAIN,
 	'EVENT_BUGNOTE_EDIT_FORM' => EVENT_TYPE_EXECUTE,
 	'EVENT_BUGNOTE_EDIT' => EVENT_TYPE_EXECUTE,
 	'EVENT_BUGNOTE_DELETED' => EVENT_TYPE_EXECUTE,
-- 
1.6.0.4

