Commentform filled when logged in

Discussion corner for Developers of Serendipity.
Post Reply
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Commentform filled when logged in

Post by onli »

At the moment, the commentform uses only the cookie to remember name, email and url. But when logged in, we have a name and an email we could prefill in the form - the realname and the email entered in personal settings. Following patch (also attached) will do just that, but use the cookie first.

This was requested by an user who don't want to store cookies permanently and also don't want to reenter the data again and again.

Code: Select all

--- serendipity-nightly/include/functions_comments.inc.php	2010-05-17 09:43:35.000000000 +0200
+++ /var/www/include/functions_comments.inc.php	2010-08-15 13:43:36.000000000 +0200
@@ -196,8 +196,12 @@
     $commentform_data = array(
         'commentform_action'         => $url,
         'commentform_id'             => $id,
-        'commentform_name'           => isset($data['name'])      ? htmlspecialchars($data['name'])       : (isset($serendipity['COOKIE']['name'])     ? htmlspecialchars($serendipity['COOKIE']['name'])     : ''),
-        'commentform_email'          => isset($data['email'])     ? htmlspecialchars($data['email'])      : (isset($serendipity['COOKIE']['email'])    ? htmlspecialchars($serendipity['COOKIE']['email'])    : ''),
+        'commentform_name'           => isset($data['name']) ? htmlspecialchars($data['name'])  :
+                                        (isset($serendipity['COOKIE']['name']) ? htmlspecialchars($serendipity['COOKIE']['name']) :
+                                        (isset($serendipity['serendipityRealname']) ? htmlspecialchars($serendipity['serendipityRealname']) : '')),
+        'commentform_email'          => isset($data['email'])     ? htmlspecialchars($data['email'])      :
+                                        (isset($serendipity['COOKIE']['email'])    ? htmlspecialchars($serendipity['COOKIE']['email']):
+                                        (isset($serendipity['serendipityEmail']) ? htmlspecialchars($serendipity['serendipityEmail']) : '')),
         'commentform_url'            => isset($data['url'])       ? htmlspecialchars($data['url'])        : (isset($serendipity['COOKIE']['url'])      ? htmlspecialchars($serendipity['COOKIE']['url'])      : ''),
         'commentform_remember'       => isset($data['remember'])  ? 'checked="checked"'                   : (isset($serendipity['COOKIE']['remember']) ? 'checked="checked"' : ''),
         'commentform_replyTo'        => serendipity_generateCommentList($id, $comments, ((isset($data['replyTo']) && ($data['replyTo'])) ? $data['replyTo'] : 0)),
@@ -1174,4 +1178,5 @@
     }
 
     return serendipity_sendMail($to, $subject, $text, $fromEmail, null, $fromName);
+
 }
Attachments
functions_comments.inc.php.diff.txt
(2.15 KiB) Downloaded 462 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Commentform filled when logged in

Post by garvinhicking »

Hi!

I think some plugin got this kind of "identity protection" by using the session data for it...I think it's the "adduser" plugin.

But I do think this patch is also worhtwile using :) Thanks!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Commentform filled when logged in

Post by onli »

:-)
Post Reply