0

Once upon a time, with an older version of AdaptiveTheme, I got this to work by patching templates/comment.tpl.php. The patch I was looking looked something like:

-      print t('Submitted by !username on !datetime',
-      array('!username' => $author, '!datetime' => '<time datetime="' . $datetime . '">' . $created . '</time>'));
+      if ( function_exists('user_access') && user_access('administer site configuration') ) {
+          $authorstring = 'Submitted by !username on !datetime from !hostname';
+      }
+      else {
+          $authorstring = 'Submitted by !username on !datetime';
+      }
+      print t($authorstring,
+      array('!username' => $author, '!datetime' => '<time datetime="' . $datetime . '">' . $created . '</time>', '!hostname' => $comment->hostname));

That was for a much older version of AdaptiveTheme (7.x-1.x, I think).

Thanks to hints from Laryn, I now have a working patch that does what I need. Here it is:

From 8c064aca6e2fd35da411473c5e50ce471d30d3cf Mon Sep 17 00:00:00 2001
From: Zed Pobre 
Date: Tue, 4 Nov 2014 02:54:21 -0500
Subject: [PATCH] Administrators see submitter IP addresses in comments

---
 at_core/inc/preprocess.inc |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/at_core/inc/preprocess.inc b/at_core/inc/preprocess.inc
index ef50fda..ba9b45e 100755
--- a/at_core/inc/preprocess.inc
+++ b/at_core/inc/preprocess.inc
@@ -832,13 +832,23 @@ function adaptivetheme_preprocess_comment(&$vars) {

   $vars['datetime'] = format_date($vars['comment']->created, 'custom', 'Y-m-d\TH:i:s\Z'); // Generate the timestamp, PHP "c" format is wrong

-  $vars['submitted'] = t('Submitted by !username on !datetime',
-    array(
-      '!username' => $vars['author'],
-      '!datetime' => '' . $vars['created'] . '',
-    )
-  );
-
+  if ( function_exists('user_access') && user_access('administer site configuration') ) {
+    $vars['submitted'] = t('Submitted by !username on !datetime from !ipaddress',
+                           array(
+                             '!username' => $vars['author'],
+                             '!datetime' => '' . $vars['created'] . '',
+                             '!ipaddress' => ip_address(),
+                                )
+                          );
+  }
+  else {
+    $vars['submitted'] = t('Submitted by !username on !datetime',
+                           array(
+                             '!username' => $vars['author'],
+                             '!datetime' => '' . $vars['created'] . '',
+                                )
+                          );
+  }
   // Unpublished?
   $vars['unpublished'] = ''; // Initialize for backwards compatibility
   if ($vars['status'] === 'comment-unpublished') {
--
1.7.10.4
0

2 Answers 2

1

It looks like you're adding your code within the adaptivetheme_preprocess_node function but you should be working within the adaptivetheme_preprocess_comment function (a little further down the page).

Specifically the following could be modified with your code above as a starting point (starting at line 835 in preprocess.inc for AdaptiveTheme 3.2):

  $vars['submitted'] = t('Submitted by !username on !datetime',
array(
  '!username' => $vars['author'],
  '!datetime' => '<time datetime="' . $vars['datetime'] . '" pubdate="pubdate">' . $vars['created'] . '</time>',
)
);
2
  • Excellent -- this was half of it. As an admin, I am now seeing 'from' appended, so the code is actually being seen. Unfortunately, it looks like $comment->hostname is coming up blank, so I need a new mechanism to get the submitter IP in there. Do you know what that might be? Never mind -- got it. There's a new ip_address() function that does the trick. I'll be updating the question with my final patch shortly, but I'll give you completion credit for getting me there.
    – Zed
    Commented Nov 4, 2014 at 7:50
  • Great -- thanks for following up and posting the final solution!
    – Laryn
    Commented Nov 4, 2014 at 17:31
0

Also you can use module https://www.drupal.org/project/user_ip_address which allows to add field with submitter ip address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.