Page 1 of 1

Commentform filled when logged in

Posted: Sun Aug 15, 2010 2:05 pm
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);
+
 }

Re: Commentform filled when logged in

Posted: Mon Aug 16, 2010 10:41 am
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

Re: Commentform filled when logged in

Posted: Mon Aug 16, 2010 11:25 am
by onli
:-)