Way to indicate comments made by (logged in) user/admin

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

Why dont u use a simple

Code: Select all

.serendipity_comment_author_Bernardo { background: orange; }
:?:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Way to indicate comments made by (logged in) user/admin

Post by Don Chambers »

Timbalu wrote:Why dont u use a simple

Code: Select all

.serendipity_comment_author_Bernardo { background: orange; }
:?:
That is a great idea as long as the comment author name is always the same. I thought there might be a possibility of using different comment author names due to this:
Bernardo wrote:My intention was to check the given mail address because the blog owner might want to name himself (for example) "The big bad administer man" (and not the exact name from the blog config).
If, however, the comment author remains unchanged, Timbalu's suggestion above works quite nicely because it requires no conditional test as the comment author name is always appended to the class "serendipity_comment_author".

So after further review, I hate to say that my earlier posts were incorrect. $commentform_entry.email is always going to be the same as the entry author's email, so comparing the two is pointless.

$comment.clear_email is the only non-obfuscated, comment-specific email address available. However, as Bernardo pointed out, this is only available to logged-in users.

So, that leaves us with $comment.author, $comment.url, which Bernardo is already using, and $comment.ip.

Assuming the above is correct, here are the choices as I see them:
  • Compare the comment author name to the entry author name and set a specific class {if $entry.author == $comment.author}_admin{/if}.
    ----
  • If your ip address never changes, you could use any name, or any email address and still trigger the class. {if $comment.ip=="123.456.789.000"}_admin{/if}
    ----
  • Use the comment author name as a defined class in your stylesheet as suggested by Timbalu above, ie .serendipity_comment_author_Bernardo {...}
    ----
  • Test for a specific comment author by name.. {if $comment.author=="Bernardo"}_admin{/if}
Sorry for leading you down the wrong path - this was an eye-opener for me too! I do wish we had a safe way to test a comment's email address without the risk of revealing it to the public. Anyone have an idea for this?
=Don=
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Don Chambers wrote:Before I review these tpls, can you verify that these three comments are saved with different email addresses, and that all three do not actually have the same email address?
Comments 1 and 3 have the same mail address (same user), but a different mail address than comment 2 (blog owner).

Verified by:
1. When I log in and hover over the username, the addresses are different.
2. I looked up the comments in the database: Same result.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

What about using the admin author id?

Code: Select all

{if $comment.authorid == 1}_admin{/if}
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Timbalu wrote:What about using the admin author id?

Code: Select all

{if $comment.authorid == 1}_admin{/if}
Same result as in earlier attached pic. $comment.authorid is always 1.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

Yepp true. Its not the admin id, sorry! :?
You have to stick with

Code: Select all

[email] => john[at]example.com
[clear_email] => john@example.com
[author] => John Doe
or

Code: Select all

.serendipity_comment_author_Bernardo { background: orange; }
AFAIS.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Timbalu wrote:Yepp true. Its not the admin id, sorry! :?
You have to stick with

Code: Select all

[email] => john[at]example.com
[clear_email] => john@example.com
[author] => John Doe
or

Code: Select all

.serendipity_comment_author_Bernardo { background: orange; }
AFAIS.
As mentioned earlier: Those variables are not usable, until I am logged in (which renders them completely useless for any anonymous user).
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

Bernardo wrote:As mentioned earlier: Those variables are not usable, until I am logged in (which renders them completely useless for any anonymous user).
I did test it. They are still avaiable, even if logged out.
But maybe I just don't understand what you are trying to do...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Timbalu wrote:I did test it. They are still avaiable, even if logged out.
But maybe I just don't understand what you are trying to do...
What else can I tell you? I tested them too. They are available when logged in, and unavailable when logged out.

Sorry, but I'm out...I'll try to debug it myself. Maybe Don comes up with a solution.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Way to indicate comments made by (logged in) user/admin

Post by Don Chambers »

Timbalu wrote:
Bernardo wrote:As mentioned earlier: Those variables are not usable, until I am logged in (which renders them completely useless for any anonymous user).
I did test it. They are still avaiable, even if logged out.
But maybe I just don't understand what you are trying to do...
No, they are not available.... maybe your browser has them cached?

To see what is available, I simply insert {debug} into my tpl to trigger a pop-up window with everything listed. Here is what I have for a sample comment on a test site...'

When NOT logged in:
{$comments} Array (4)
0 => Array (23)
id => "6"
entry_id => "5"
timestamp => "1242491090"
ctitle => ""
email => false
url => ""
ip => "24.14.151.116"
body => "This is the first comment. It is an ..."
type => "NORMAL"
subscribed => "false"
author => "Tom Jones"
title => "Lorem Ipsum"
entrytimestamp => "1236369479"
entryid => "5"
authorid => "1"
commentid => "6"
parent_id => "0"
no_email => true
comment => "This is the first comment. It is an ..."
link_delete => "http://www.optional-necessity.com/san..."
pos => 1
trace => "1"
depth => 0
ARE Logged in:
{$comments} Array (4)
0 => Array (23)
id => "6"
entry_id => "5"
timestamp => "1242491090"
ctitle => ""
email => "nowhere[at]example.com"
url => ""
ip => "24.14.151.116"
body => "This is the first comment. It is an ..."
type => "NORMAL"
subscribed => "false"
author => "Tom Jones"
title => "Lorem Ipsum"
entrytimestamp => "1236369479"
entryid => "5"
authorid => "1"
commentid => "6"
parent_id => "0"
comment => "This is the first comment. It is an ..."
link_delete => "http://www.optional-necessity.com/san..."
clear_email => "nowhere@example.com"
pos => 1
trace => "1"
depth => 0
When NOT logged in, comment.email is "false", and comment.clear_email does not exist.

I think the options are those I mentioned in my previous post.
=Don=
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Don Chambers wrote: So after further review, I hate to say that my earlier posts were incorrect. $commentform_entry.email is always going to be the same as the entry author's email, so comparing the two is pointless.

$comment.clear_email is the only non-obfuscated, comment-specific email address available. However, as Bernardo pointed out, this is only available to logged-in users.

So, that leaves us with $comment.author, $comment.url, which Bernardo is already using, and $comment.ip.

Assuming the above is correct, here are the choices as I see them:
  • Compare the comment author name to the entry author name and set a specific class {if $entry.author == $comment.author}_admin{/if}.
    ----
  • If your ip address never changes, you could use any name, or any email address and still trigger the class. {if $comment.ip=="123.456.789.000"}_admin{/if}
    ----
  • Use the comment author name as a defined class in your stylesheet as suggested by Timbalu above, ie .serendipity_comment_author_Bernardo {...}
    ----
  • Test for a specific comment author by name.. {if $comment.author=="Bernardo"}_admin{/if}
Sorry for leading you down the wrong path - this was an eye-opener for me too! I do wish we had a safe way to test a comment's email address without the risk of revealing it to the public. Anyone have an idea for this?
Don! Thank you so much! :D
I had the constant feeling that I made something wrong because everyone kept telling me the complete opposite. That's a relief...

So...to sum it up: This feature I wanted to use has to be implemented first, right?
At the moment I might stick with the commenters url to check this, until someone comes up with a better solution. Okay, okay...

Many thanks for all your help! :)
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

Don, this is my output: Not logged-in, no-Cache
Comment vars: author, email, clear_email are available, as these are the only comments done by a logged-in admin. That was the question, wasn't it?

<pre>{$comments|print_r}</pre>

Code: Select all

Array
(
    [0] => Array
        (
            [id] => 1
            [email] => 
            [author] => 
        )

    [1] => Array
        (
            [id] => 2
            [email] => john[at]example.com
            [author] => John Doe
            [clear_email] => john@example.com
        )

    [2] => Array
        (
            [id] => 3
            [email] => 
            [author] => Herta
        )

    [3] => Array
        (
            [id] => 4
            [email] => john[at]example.com
            [author] => John Doe
            [clear_email] => john@example.com

        )

)
Kommentar wurde hinzugefügt. : Hinweis: Dieser Kommentar wird ohne Bewilligung nicht dargestellt.

@Bernardo
didn't want to bother you, if you want help from "Don seulement", just say that first. :roll:

::Edited after issue solved!
Last edited by Timbalu on Wed Mar 21, 2012 5:13 pm, edited 1 time in total.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Bernardo
Regular
Posts: 37
Joined: Sat Jan 09, 2010 8:39 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Bernardo »

Timbalu wrote: @Bernardo
didn't want to bother you, if you want help from "Don seulement", just say that first. :roll:
That's not the point...I felt quite misunderstood all the way down here. So after I tried my best to explain in several comments what I wanted to accomplish, it was quite frustrating to read this again:
Timbalu wrote:But maybe I just don't understand what you are trying to do...
So, please don't be pissed or something...I appreciate your help. And, moreover, Don really seems to have at least understood what I was talking about the whole time. :)

Doesn't explain though, why you seem to have these variables without being logged in...
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Way to indicate comments made by (logged in) user/admin

Post by Timbalu »

Bernardo wrote:Doesn't explain though, why you seem to have these variables without being logged in...
May be cause I just filled in Name and Comment, nothing else.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Way to indicate comments made by (logged in) user/admin

Post by Don Chambers »

I think I have the answer as to why Timbalu sees email, clear_email, etc, and I do not.... I have the anti-spam plugin configured to hide email addresses. When configured to hide email addresses, a logged in admin will still have access to $comment.email and $comment.clear_email. When logged out, these are not available. If anti-spam plugin is configured to show email addresses, they are always available.

If you did want the email addresses hidden from the public, you could configure the plugin to show them, but modify your tpl so they are never actually shown. Then you could perform your conditional test on $comment.clear_email.
=Don=
Post Reply