mirror of
https://github.com/e107inc/e107.git
synced 2025-07-09 17:16:20 +02:00
Issue #1944 (Partial fix) Comments use unique IDs.
This commit is contained in:
@ -85,7 +85,7 @@ if(e_AJAX_REQUEST) // TODO improve security
|
||||
if(!vartrue($_POST['comment']) && varset($_GET['mode']) == 'submit')
|
||||
{
|
||||
$ret['error'] = true;
|
||||
$ret['msg'] = COMLAN_336;
|
||||
$ret['msg'] = COMLAN_336." - ".implode(" ",$_GET);
|
||||
echo json_encode($ret);
|
||||
exit;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class comment_shortcodes extends e_shortcode
|
||||
{
|
||||
var $var;
|
||||
|
||||
function sc_subject_input($parm = '')
|
||||
function sc_subject_input($parm = null)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
$pref = e107::getPref();
|
||||
@ -65,7 +65,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_username($parm='')
|
||||
function sc_username($parm = null)
|
||||
{
|
||||
global $USERNAME;
|
||||
if (isset($this->var['comment_author_id']) && $this->var['comment_author_id'])
|
||||
@ -82,7 +82,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_timedate($parm='')
|
||||
function sc_timedate($parm = null)
|
||||
{
|
||||
if($parm == 'relative')
|
||||
{
|
||||
@ -93,7 +93,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_reply($parm='')
|
||||
function sc_reply($parm = null)
|
||||
{
|
||||
global $REPLY, $action, $table, $id, $thisaction, $thistable, $thisid;
|
||||
|
||||
@ -136,7 +136,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_avatar($parm='')
|
||||
function sc_avatar($parm = null)
|
||||
{
|
||||
return $this->sc_comment_avatar($parm);
|
||||
|
||||
@ -162,14 +162,14 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_comments($parm='')
|
||||
function sc_comments($parm = null)
|
||||
{
|
||||
global $COMMENTS;
|
||||
return (isset($this->var['user_id']) && $this->var['user_id'] ? LAN_COMMENTS.": ".$this->var['user_comments'] : COMLAN_194)."<br />";
|
||||
}
|
||||
|
||||
|
||||
function sc_joined($parm='')
|
||||
function sc_joined($parm = null)
|
||||
{
|
||||
global $JOINED, $gen;
|
||||
$JOINED = '';
|
||||
@ -181,17 +181,17 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_comment_itemid($parm='') // for ajax item id.
|
||||
function sc_comment_itemid($parm = null) // for ajax item id.
|
||||
{
|
||||
return 'comment-'.intval($this->var['comment_id']);
|
||||
}
|
||||
|
||||
|
||||
function sc_comment_moderate($parm='')
|
||||
function sc_comment_moderate($parm = null)
|
||||
{
|
||||
if(!getperms('0') && !getperms("B"))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO put into a <ul> drop-down format.
|
||||
@ -219,7 +219,7 @@ class comment_shortcodes extends e_shortcode
|
||||
|
||||
/* example {COMMENT_BUTTON} */
|
||||
/* example {COMMENT_BUTTON: class=btn btn-default pull-right} */
|
||||
function sc_comment_button($parm = '')
|
||||
function sc_comment_button($parm = null)
|
||||
{
|
||||
$pref = e107::getPref('comments_sort');
|
||||
$form = e107::getForm();
|
||||
@ -232,10 +232,12 @@ class comment_shortcodes extends e_shortcode
|
||||
$class = "e-comment-submit ";
|
||||
$class .= (!empty($parm['class'])) ? $parm['class'] : 'button btn btn-primary e-comment-submit pull-right';
|
||||
$options = array(
|
||||
'class' => $class,
|
||||
'data-pid' => $pid,
|
||||
'data-sort' => $pref,
|
||||
'data-target' => e_HTTP . 'comment.php',
|
||||
'class' => $class,
|
||||
'data-pid' => $pid,
|
||||
'data-sort' => $pref,
|
||||
'data-target' => e_HTTP . 'comment.php',
|
||||
'data-container' => 'comments-container-'.$form->name2id($this->var['table']),
|
||||
'data-input' => 'comment-input-'.$form->name2id($this->var['table'])
|
||||
);
|
||||
|
||||
return $form->submit($this->var['action'] . 'submit', $value, $options);
|
||||
@ -244,7 +246,7 @@ class comment_shortcodes extends e_shortcode
|
||||
|
||||
/* example {AUTHOR_INPUT} */
|
||||
/* example {AUTHOR_INPUT: inputclass=form-control&class=form-group} */
|
||||
function sc_author_input($parm = '')
|
||||
function sc_author_input($parm = null)
|
||||
{
|
||||
if($this->mode == 'edit')
|
||||
{
|
||||
@ -277,12 +279,12 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_comment_rate($parm='')
|
||||
function sc_comment_rate($parm = null)
|
||||
{
|
||||
|
||||
if($this->var['comment_blocked'] > 0 || $this->var['rating_enabled'] == false)
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$curVal = array(
|
||||
@ -296,7 +298,7 @@ class comment_shortcodes extends e_shortcode
|
||||
|
||||
/* example {COMMENT_INPUT} */
|
||||
/* example {COMMENT_INPUT: inputclass=form-control&class=form-group} */
|
||||
function sc_comment_input($parm = '')
|
||||
function sc_comment_input($parm = null)
|
||||
{
|
||||
|
||||
$inputclass = (!empty($parm['inputclass'])) ? $parm['inputclass'] : 'comment-input form-control';
|
||||
@ -304,6 +306,7 @@ class comment_shortcodes extends e_shortcode
|
||||
$options = array(
|
||||
'class' => $inputclass,
|
||||
'placeholder' => COMLAN_403,
|
||||
'id' => 'comment-input-'.e107::getForm()->name2id($this->var['table'])
|
||||
);
|
||||
|
||||
$text = '<div class="'.$class.'">';
|
||||
@ -324,7 +327,7 @@ class comment_shortcodes extends e_shortcode
|
||||
|
||||
|
||||
/*
|
||||
function sc_user_avatar($parm='')
|
||||
function sc_user_avatar($parm = null)
|
||||
{
|
||||
$this->var['user_id'] = USERID;
|
||||
$this->var['user_image'] = USERIMAGE;
|
||||
@ -333,7 +336,7 @@ class comment_shortcodes extends e_shortcode
|
||||
*/
|
||||
|
||||
|
||||
function sc_comment($parm='')
|
||||
function sc_comment($parm=null)
|
||||
{
|
||||
// global $COMMENT, $pref;
|
||||
$tp = e107::getParser();
|
||||
@ -346,7 +349,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_comment_status($parm='')
|
||||
function sc_comment_status($parm = null)
|
||||
{
|
||||
switch ($this->var['comment_blocked'])
|
||||
{
|
||||
@ -359,7 +362,7 @@ class comment_shortcodes extends e_shortcode
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -368,7 +371,7 @@ class comment_shortcodes extends e_shortcode
|
||||
|
||||
|
||||
|
||||
function sc_commentedit($parm='')
|
||||
function sc_commentedit($parm = null)
|
||||
{
|
||||
global $COMMENTEDIT, $comment_edit_query;
|
||||
$pref = e107::getPref();
|
||||
@ -394,14 +397,14 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_rating($parm='')
|
||||
function sc_rating($parm = null)
|
||||
{
|
||||
global $RATING;
|
||||
return $RATING;
|
||||
}
|
||||
|
||||
|
||||
function sc_ipaddress($parm='')
|
||||
function sc_ipaddress($parm = null)
|
||||
{
|
||||
global $IPADDRESS, $e107;
|
||||
//require_once(e_HANDLER."encrypt_handler.php");
|
||||
@ -409,16 +412,16 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_level($parm='')
|
||||
function sc_level($parm = null)
|
||||
{
|
||||
global $LEVEL, $pref;
|
||||
//FIXME - new level handler, currently commented to avoid parse errors
|
||||
//$ldata = get_level($this->var['user_id'], $this->var['user_forums'], $this->var['user_comments'], $this->var['user_chats'], $this->var['user_visits'], $this->var['user_join'], $this->var['user_admin'], $this->var['user_perms'], $pref);
|
||||
return ($this->var['user_admin'] ? vartrue($ldata[0]) : vartrue($ldata[1]));
|
||||
//return ($this->var['user_admin'] ? vartrue($ldata[0]) : vartrue($ldata[1]));
|
||||
}
|
||||
|
||||
|
||||
function sc_location($parm='')
|
||||
function sc_location($parm = null)
|
||||
{
|
||||
global $LOCATION;
|
||||
$tp = e107::getParser();
|
||||
@ -426,7 +429,7 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_signature($parm='')
|
||||
function sc_signature($parm = null)
|
||||
{
|
||||
global $SIGNATURE;
|
||||
$tp = e107::getParser();
|
||||
@ -435,11 +438,11 @@ class comment_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_comment_share($parm='')
|
||||
function sc_comment_share($parm = null)
|
||||
{
|
||||
if(!$xup = e107::getUser()->getProviderName())
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
list($prov,$id) = explode("_",$xup);
|
||||
|
@ -1078,6 +1078,7 @@ class comment
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
$pref = e107::getPref();
|
||||
$frm = e107::getForm();
|
||||
|
||||
if ($this->getCommentPermissions() === FALSE) return;
|
||||
|
||||
@ -1166,15 +1167,17 @@ class comment
|
||||
{
|
||||
$comment = "<br /><div style='text-align:center'><b>".COMLAN_328."</b></div>";
|
||||
}
|
||||
|
||||
|
||||
$containerTarget = "comments-container-".$frm->name2id($table);
|
||||
|
||||
if($text)
|
||||
{
|
||||
//XXX Do NOT add to template - too important to allow for modification.
|
||||
$text = "<ul class='media-list' id='comments-container'>\n".$text."\n</ul>";
|
||||
$text = "<ul class='media-list comments-container' id='".$containerTarget."'>\n".$text."\n</ul>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = "<ul class='media-list' id='comments-container'><li><!-- --></li></ul>";
|
||||
$text = "<ul class='media-list comments-container' id='".$containerTarget."'><li><!-- --></li></ul>";
|
||||
}
|
||||
|
||||
|
||||
@ -1322,6 +1325,9 @@ class comment
|
||||
//return "table=".$table." id=".$id." from=".$from;
|
||||
//$from = $from + $this->commentsPerPage;
|
||||
|
||||
$target = "comments-container-".e107::getForm()->name2id($table);
|
||||
|
||||
$navid = 'comments-nav-'.e107::getForm()->name2id($table);
|
||||
|
||||
// from calculations are done by eNav() js.
|
||||
if($this->totalComments > $this->commentsPerPage)
|
||||
@ -1329,8 +1335,8 @@ class comment
|
||||
$prev = e_HTTP . 'comment.php?mode=list&type=' . $table . '&id=' . $id . '&from=0';
|
||||
$next = e_HTTP . 'comment.php?mode=list&type=' . $table . '&id=' . $id . '&from=0';
|
||||
|
||||
return "<a class='e-ajax btn btn-default btn-secondary btn-mini btn-sm' href='#' data-nav-total='{$this->totalComments}' data-nav-dir='down' data-nav-inc='{$this->commentsPerPage}' data-target='comments-container' data-src='{$prev}'>" . LAN_PREVIOUS . "</a>
|
||||
<a class='e-ajax btn btn-default btn-secondary btn-mini btn-sm' href='#' data-nav-total='{$this->totalComments}' data-nav-dir='up' data-nav-inc='{$this->commentsPerPage}' data-target='comments-container' data-src='{$next}'>" . LAN_NEXT . "</a>";
|
||||
return "<a class='e-ajax btn btn-default btn-secondary btn-mini btn-sm {$navid}' href='#' data-nav-id='{$navid}' data-nav-total='{$this->totalComments}' data-nav-dir='down' data-nav-inc='{$this->commentsPerPage}' data-target='{$target}' data-src='{$prev}'>" . LAN_PREVIOUS . "</a>
|
||||
<a class='e-ajax btn btn-default btn-secondary btn-mini btn-sm {$navid}' href='#' data-nav-id='{$navid}' data-nav-total='{$this->totalComments}' data-nav-dir='up' data-nav-inc='{$this->commentsPerPage}' data-target='{$target}' data-src='{$next}'>" . LAN_NEXT . "</a>";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
ajaxOptions.url = $element.attr('data-src');
|
||||
// Set Ajax type to "GET".
|
||||
ajaxOptions.type = 'GET';
|
||||
|
||||
}
|
||||
|
||||
if(ajaxOptions.wait != null)
|
||||
@ -428,6 +429,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
var val = src.match(/from=(\d+)/);
|
||||
var amt = parseInt(val[1]);
|
||||
|
||||
|
||||
var oldVal = 'from=' + amt;
|
||||
var newVal = null;
|
||||
|
||||
@ -456,6 +458,11 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
newVal = 'from=' + add;
|
||||
}
|
||||
|
||||
if($(e).attr("data-nav-id"))
|
||||
{
|
||||
navid = '.' + $(e).attr("data-nav-id");
|
||||
}
|
||||
|
||||
if(newVal)
|
||||
{
|
||||
src = src.replace(oldVal, newVal);
|
||||
|
@ -155,9 +155,13 @@ $(document).ready(function()
|
||||
var sort = $(this).attr("data-sort");
|
||||
var pid = parseInt($(this).attr("data-pid"));
|
||||
var formid = (pid != '0') ? "#e-comment-form-reply" : "#e-comment-form";
|
||||
var data = $('form'+formid).serialize() ;
|
||||
var total = parseInt($("#e-comment-total").text());
|
||||
|
||||
var data = $('form'+formid).serializeArray() ;
|
||||
var total = parseInt($("#e-comment-total").text());
|
||||
var container = '#' + $(this).attr("data-container");
|
||||
var input = '#' + $(this).attr("data-input");
|
||||
|
||||
//TODO replace _POST['comment'] with $(input).val() so we can rename 'comment' in the form to something unique.
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: url + '?ajax_used=1&mode=submit',
|
||||
@ -167,14 +171,8 @@ $(document).ready(function()
|
||||
// alert(data);
|
||||
// console.log(data);
|
||||
var a = $.parseJSON(data);
|
||||
|
||||
$("#comment").val('');
|
||||
|
||||
if($('#comments-container').length){
|
||||
// alert('true');
|
||||
}else{
|
||||
// $("#e-comment-form").parent().prepend("<div id='comments-container'></div>");
|
||||
}
|
||||
|
||||
$(input).val('');
|
||||
|
||||
if(pid != 0)
|
||||
{
|
||||
@ -182,17 +180,18 @@ $(document).ready(function()
|
||||
}
|
||||
else if(sort == 'desc')
|
||||
{
|
||||
$('#comments-container').prepend(a.html).hide().slideDown(800); // FIXME - works in jquery 1.7, not 1.8
|
||||
$(container).prepend(a.html).hide().slideDown(800); // FIXME - works in jquery 1.7, not 1.8
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#comments-container').append(a.html).hide().slideDown(800); // FIXME - works in jquery 1.7, not 1.8
|
||||
$(container).append(a.html).hide().slideDown(800); // FIXME - works in jquery 1.7, not 1.8
|
||||
alert('Thank you for commenting'); // possibly needed as the submission may go unoticed by the user
|
||||
}
|
||||
|
||||
if(!a.error)
|
||||
{
|
||||
$("#e-comment-total").text(total + 1);
|
||||
|
||||
if(pid != '0')
|
||||
{
|
||||
$(formid).hide();
|
||||
|
Reference in New Issue
Block a user