Skip to content

Commit

Permalink
Update to comment library and removed uid from Comment Edit Form
Browse files Browse the repository at this point in the history
uid is not needed in the comment edit form as we can retrieve that information from the database for comment edits or use current user for new comments.
  • Loading branch information
eSilverStrike committed Mar 12, 2020
1 parent ee1cd46 commit 48b6074
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 24 deletions.
1 change: 0 additions & 1 deletion public_html/layout/denim/comment/commentform.thtml
Expand Up @@ -33,7 +33,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;[<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a>]</span>
</dd>

Expand Down
Expand Up @@ -33,7 +33,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;[<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a>]</span>
</dd>
<dt class="title"><label for="commentform-title">{lang_title}</label></dt>
Expand Down
1 change: 0 additions & 1 deletion public_html/layout/denim_three/comment/commentform.thtml
Expand Up @@ -33,7 +33,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;[<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a>]</span>
</dd>

Expand Down
Expand Up @@ -33,7 +33,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;[<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a>]</span>
</dd>
<dt class="title"><label for="commentform-title">{lang_title}</label></dt>
Expand Down
1 change: 0 additions & 1 deletion public_html/layout/modern_curve/comment/commentform.thtml
Expand Up @@ -16,7 +16,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a></span>
</dd>
<dt class="title"><label for="commentform-title">{lang_title}</label></dt>
Expand Down
Expand Up @@ -16,7 +16,6 @@
<input type="hidden" name="{nprefix}pid" value="{pid}"{xhtml}>
<input type="hidden" name="{nprefix}type" value="{type}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
<input type="hidden" name="{nprefix}uid" value="{uid}"{xhtml}>
{username}<span{hidewhenediting}>&nbsp;<a href="{action_url}" rel="nofollow" class="logoutorcreateaccount">{lang_logoutorcreateaccount}</a></span>
</dd>
<dt class="title"><label for="commentform-title">{lang_title}</label></dt>
Expand Down
29 changes: 11 additions & 18 deletions system/lib-comment.php
Expand Up @@ -54,7 +54,6 @@
define('CMT_CID', $CMT_formVariablePrefix . 'cid');
define('CMT_SID', $CMT_formVariablePrefix . 'sid');
define('CMT_PID', $CMT_formVariablePrefix . 'pid');
define('CMT_UID', $CMT_formVariablePrefix . 'uid');
define('CMT_TYPE', $CMT_formVariablePrefix . 'type');
define('CMT_USERNAME', $CMT_formVariablePrefix . 'username');
define('CMT_MODE', $CMT_formVariablePrefix . 'mode');
Expand Down Expand Up @@ -304,6 +303,8 @@ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false
}

if ($preview) {
// Means array is post variables
// These should all have been filtered already
$A = $comments;
if (empty($A['nice_date'])) {
$A['nice_date'] = time();
Expand Down Expand Up @@ -1102,14 +1103,16 @@ function CMT_commentForm($title, $comment, $sid, $pid = 0, $type, $mode, $postMo
if (isset($A[CMT_CID])) {
$A['cid'] = $A[CMT_CID];
}

$A['type'] = $type;
$A['sid'] = $sid;
$A['pid'] = $pid;
$A['uid'] = $commentUid;
$A['username'] = $A[CMT_USERNAME];
}

// This stuff should always stay the same and has been filtered and checked already by
// CMT_handlePreview and CMT_handleEdit which calls the function we are currently in CMT_commentForm
$A['type'] = $type;
$A['sid'] = $sid;
$A['pid'] = $pid;
$A['uid'] = $commentUid;

$thecomments = CMT_getComment($A, 'flat', $type, 'ASC', false, true);

$start->set_var('comments', $thecomments);
Expand Down Expand Up @@ -2482,10 +2485,9 @@ function CMT_handleCancel()
* @param int $pid
* @param string $type
* @param string $postMode
* @param int $uid
* @return string HTML (possibly a refresh)
*/
function CMT_handleSubmit($title, $sid, $pid, $type, $postMode, $uid)
function CMT_handleSubmit($title, $sid, $pid, $type, $postMode)
{
global $_CONF;

Expand Down Expand Up @@ -2865,15 +2867,6 @@ function CMT_handleComment($mode = '', $type = '', $title = '', $sid = '', $form
$title = Geeklog\Input::request('title'); // apply filters later in CMT_commentForm or CMT_saveComment
}

if (!empty($_REQUEST[CMT_UID])) {
$uid = Geeklog\Input::fRequest(CMT_UID);
} else {
$uid = 1;
if (!empty($_USER['uid'])) {
$uid = $_USER['uid'];
}
}

$postMode = Geeklog\Input::fRequest('postmode', $_CONF['postmode']);
$formType = Geeklog\Input::fRequest('formtype', '');

Expand Down Expand Up @@ -2960,7 +2953,7 @@ function CMT_handleComment($mode = '', $type = '', $title = '', $sid = '', $form
break;

case $LANG03[11]: // Submit new comment
$retval .= CMT_handleSubmit($title, $sid, $pid, $type, $postMode, $uid);
$retval .= CMT_handleSubmit($title, $sid, $pid, $type, $postMode);
break;

case $LANG_ADMIN['delete']:
Expand Down

0 comments on commit 48b6074

Please sign in to comment.