From a33674cd3833473597341246009965d9a943f46d Mon Sep 17 00:00:00 2001
From: garvinhicking <garvinhicking>
Date: Wed, 7 Sep 2005 12:56:16 +0000
Subject: [PATCH] Fix ugly constant printing in templates, thanks to Sebastian
 for spotting.

---
 docs/NEWS |  6 ++++++
 index.php | 12 +++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/docs/NEWS b/docs/NEWS
index 8867a61..291ca77 100644
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,12 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * Fix "DATA_TRACKBACK_APPROVED" showing of constants when approving
+      trackbacks/comments instead of the properly formatted message.
+      (Would've required a template change for a "pretty solution", but
+       the current fix is a BC-compatible fix by defining constants a bit
+       differently) (garvinhicking)
+
     * Reduce memory usage by splitting up function files, optimizing
       spartacus parsing. New files:
         include/functions_rss.inc.php
diff --git a/index.php b/index.php
index 20e5076..94a73e7 100644
--- a/index.php
+++ b/index.php
@@ -34,7 +34,7 @@ if (isset($_SERVER['HTTP_REFERER']) && empty($_SESSION['HTTP_REFERER'])) {
 
 if (preg_match(PAT_UNSUBSCRIBE, $uri, $res)) {
     if (serendipity_cancelSubscription(urldecode($res[1]), $res[2])) {
-        define('DATA_UNSUBSCRIBED', urldecode($res[1]));
+        define('DATA_UNSUBSCRIBED', sprintf(UNSUBSCRIBE_OK, urldecode($res[1])));
     }
 
     $uri = '/' . PATH_UNSUBSCRIBE . '/' . $res[2] . '-untitled.html';
@@ -44,9 +44,9 @@ if (preg_match(PAT_UNSUBSCRIBE, $uri, $res)) {
 
 if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
     if ($res[1] == 'comment' && serendipity_deleteComment($res[2], $res[3], 'comments')) {
-        define('DATA_COMMENT_DELETED', $res[2]);
+        define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
     } elseif ( $res[1] == 'trackback' && serendipity_deleteComment($res[2], $res[3], 'trackbacks') ) {
-        define('DATA_TRACKBACK_DELETED', $res[2]);
+        define('DATA_TRACKBACK_DELETED', sprintf(TRACKBACK_DELETED, $res[2]));
     }
 } else {
     define('DATA_COMMENT_DELETED', false);
@@ -55,9 +55,11 @@ if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser']
 
 if (preg_match(PAT_APPROVE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
     if ($res[1] == 'comment' && serendipity_approveComment($res[2], $res[3])) {
-        define('DATA_COMMENT_APPROVED', $res[2]);
+        define('DATA_COMMENT_APPROVED', sprintf(COMMENT_APPROVED, $res[2]));
+        define('DATA_TRACKBACK_APPROVED', false);
     } elseif ($res[1] == 'trackback' && serendipity_approveComment($res[2], $res[3])) {
-        define('DATA_TRACKBACK_APPROVED', $res[2]);
+        define('DATA_COMMENT_APPROVED', false);
+        define('DATA_TRACKBACK_APPROVED', sprintf(TRACKBACK_APPROVED, $res[2]));
     }
 } else {
     define('DATA_COMMENT_APPROVED', false);
-- 
2.39.5