mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Comment replies
This commit is contained in:
30
comment.php
30
comment.php
@@ -24,6 +24,11 @@
|
|||||||
require_once('class2.php');
|
require_once('class2.php');
|
||||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
||||||
|
|
||||||
|
if (vartrue(e107::getPref('comments_disabled')))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(e_AJAX_REQUEST) // TODO improve security
|
if(e_AJAX_REQUEST) // TODO improve security
|
||||||
{
|
{
|
||||||
@@ -33,8 +38,24 @@ if(e_AJAX_REQUEST) // TODO improve security
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(varset($_GET['mode']) == 'reply' && vartrue($_POST['itemid']))
|
||||||
|
{
|
||||||
|
$status = e107::getComment()->replyComment($_POST['itemid']);
|
||||||
|
$ret['msg'] = "Couldn't delete comment";
|
||||||
|
$ret['error'] = ($status) ? false : true;
|
||||||
|
$ret['html'] = $status;
|
||||||
|
echo json_encode($ret);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']))
|
if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']))
|
||||||
{
|
{
|
||||||
$status = e107::getComment()->deleteComment($_POST['itemid']);
|
$status = e107::getComment()->deleteComment($_POST['itemid']);
|
||||||
@@ -54,6 +75,7 @@ if(e_AJAX_REQUEST) // TODO improve security
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!vartrue($_POST['comment']) && varset($_GET['mode']) == 'submit')
|
if(!vartrue($_POST['comment']) && varset($_GET['mode']) == 'submit')
|
||||||
{
|
{
|
||||||
$ret['error'] = true;
|
$ret['error'] = true;
|
||||||
@@ -68,13 +90,15 @@ if(e_AJAX_REQUEST) // TODO improve security
|
|||||||
$error = e107::getComment()->updateComment($_POST['itemid'],$_POST['comment']);
|
$error = e107::getComment()->updateComment($_POST['itemid'],$_POST['comment']);
|
||||||
|
|
||||||
$ret['error'] = ($error) ? true : false;
|
$ret['error'] = ($error) ? true : false;
|
||||||
$ret['msg'] = ($error) ? $error : "Saved!!!"; //TODO Common LAN
|
$ret['msg'] = ($error) ? $error : "Updated Successfully."; //TODO Common LAN
|
||||||
|
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Insert Comment and return rendered html.
|
// Insert Comment and return rendered html.
|
||||||
if(vartrue($_POST['comment']) && USERID) // ajax render comment
|
if(vartrue($_POST['comment']) && USERID) // ajax render comment
|
||||||
{
|
{
|
||||||
@@ -100,8 +124,10 @@ if(e_AJAX_REQUEST) // TODO improve security
|
|||||||
$row['comment_datestamp'] = time();
|
$row['comment_datestamp'] = time();
|
||||||
$row['comment_blocked'] = (vartrue($pref['comments_moderate']) ? 2 : 0);
|
$row['comment_blocked'] = (vartrue($pref['comments_moderate']) ? 2 : 0);
|
||||||
|
|
||||||
|
$width = ($pid) ? 5 : 0;
|
||||||
|
|
||||||
$ret['html'] = "\n<!-- Appended -->\n";
|
$ret['html'] = "\n<!-- Appended -->\n";
|
||||||
$ret['html'] .= e107::getComment()->render_comment($row,'comment',intval($_POST['itemid']));
|
$ret['html'] .= e107::getComment()->render_comment($row,'comments','comment',intval($_POST['itemid']),$width);
|
||||||
$ret['html'] .= "\n<!-- end Appended -->\n";
|
$ret['html'] .= "\n<!-- end Appended -->\n";
|
||||||
|
|
||||||
$ret['error'] = false;
|
$ret['error'] = false;
|
||||||
|
@@ -32,7 +32,7 @@ e107::css("inline","
|
|||||||
.admin-theme-options { transition: opacity .20s ease-in-out;
|
.admin-theme-options { transition: opacity .20s ease-in-out;
|
||||||
-moz-transition: opacity .20s ease-in-out;
|
-moz-transition: opacity .20s ease-in-out;
|
||||||
-webkit-transition: opacity .20s ease-in-out;
|
-webkit-transition: opacity .20s ease-in-out;
|
||||||
opacity:0.1;
|
opacity:0;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:80px;
|
height:80px;
|
||||||
padding-top:50px;
|
padding-top:50px;
|
||||||
|
@@ -91,7 +91,7 @@ class comment_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
if ($thisaction == "comment" && $pref['nested_comments'])
|
if ($thisaction == "comment" && $pref['nested_comments'])
|
||||||
{
|
{
|
||||||
$REPLY = "<a href='".SITEURL."comment.php?reply.".$thistable.".".$this->var['comment_id'].".".$thisid."'>".COMLAN_326."</a>";
|
$REPLY = "<a id='e-comment-reply-".$this->var['comment_id']."' class='e-comment-reply' data-type='".$this->var['comment_type']."' data-target='".e_BASE."comment.php' href='".SITEURL."comment.php?reply.".$thistable.".".$this->var['comment_id'].".".$thisid."'>".COMLAN_326."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $REPLY;
|
return $REPLY;
|
||||||
@@ -209,9 +209,10 @@ class comment_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
if($this->mode == 'edit')
|
if($this->mode == 'edit')
|
||||||
{
|
{
|
||||||
$value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9);
|
$value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9);
|
||||||
|
$pid = ($this->var['action'] == 'reply') ? $this->var['pid'] : 0;
|
||||||
|
|
||||||
return "<input data-sort='".$pref."' data-target='".e_BASE."comment.php' class='button e-comment-submit' type='submit' name='".$this->var['action']."submit' value='".$value."' />";
|
return "<input data-pid='{$pid}' data-sort='{$pref}' data-target='".e_BASE."comment.php' class='button e-comment-submit' type='submit' name='".$this->var['action']."submit' value='".$value."' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,30 +2,37 @@
|
|||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
$(":input").tipsy({gravity: 'w',fade: true});
|
$(":input").tipsy({gravity: 'w',fade: true, live: true});
|
||||||
|
|
||||||
$(".e-tip").tipsy({gravity: 'sw',fade: true});
|
$(".e-tip").tipsy({gravity: 'sw',fade: true, live: true});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".e-comment-submit").click(function(){
|
$(".e-comment-submit").live("click", function(){
|
||||||
|
|
||||||
var url = $(this).attr("data-target");
|
var url = $(this).attr("data-target");
|
||||||
var sort = $(this).attr("data-sort");
|
var sort = $(this).attr("data-sort");
|
||||||
var data = $("form#e-comment-form").serialize();
|
var pid = parseInt($(this).attr("data-pid"));
|
||||||
var total = parseInt($("#e-comment-total").text());
|
var formid = (pid != '0') ? "#e-comment-form-reply" : "#e-comment-form";
|
||||||
|
var data = $('form'+formid).serialize() ;
|
||||||
|
var total = parseInt($("#e-comment-total").text());
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: url + '?ajax_used=1&mode=submit',
|
url: url + '?ajax_used=1&mode=submit',
|
||||||
data: data,
|
data: data,
|
||||||
success: function(html) {
|
success: function(data) {
|
||||||
|
|
||||||
console.log(html);
|
// console.log(data);
|
||||||
var a = $.parseJSON(html);
|
var a = $.parseJSON(data);
|
||||||
|
|
||||||
$("#comment").val('');
|
$("#comment").val('');
|
||||||
if(sort == 'desc')
|
|
||||||
|
if(pid != 0)
|
||||||
|
{
|
||||||
|
$('#comment-'+pid).after(a.html).hide().slideDown(800);
|
||||||
|
}
|
||||||
|
else if(sort == 'desc')
|
||||||
{
|
{
|
||||||
$(a.html).prependTo('#comments-container').hide().slideDown(800);
|
$(a.html).prependTo('#comments-container').hide().slideDown(800);
|
||||||
}
|
}
|
||||||
@@ -38,6 +45,11 @@ $(document).ready(function()
|
|||||||
if(!a.error)
|
if(!a.error)
|
||||||
{
|
{
|
||||||
$("#e-comment-total").text(total + 1);
|
$("#e-comment-total").text(total + 1);
|
||||||
|
if(pid != '0')
|
||||||
|
{
|
||||||
|
$(formid).hide();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -53,6 +65,47 @@ $(document).ready(function()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".e-comment-reply").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var table = $(this).attr("data-type");
|
||||||
|
var sp = $(this).attr('id').split("-");
|
||||||
|
var id = "#comment-" + sp[3];
|
||||||
|
|
||||||
|
if($('.e-comment-edit-save').length != 0) //prevent creating save button twice.
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url + '?ajax_used=1&mode=reply',
|
||||||
|
data: { itemid: sp[3], table: table },
|
||||||
|
success: function(data) {
|
||||||
|
var a = $.parseJSON(data);
|
||||||
|
|
||||||
|
if(!a.error)
|
||||||
|
{
|
||||||
|
// alert(a.html);
|
||||||
|
$(id).after(a.html).hide().slideDown(800);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".e-comment-edit").live("click", function(){
|
$(".e-comment-edit").live("click", function(){
|
||||||
|
|
||||||
var url = $(this).attr("data-target");
|
var url = $(this).attr("data-target");
|
||||||
@@ -195,13 +248,17 @@ $(document).ready(function()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".e-rate-thumb").click(function(){
|
|
||||||
|
|
||||||
var src = $(this).attr("href");
|
|
||||||
|
|
||||||
var tmp = src.split('#');
|
|
||||||
id = tmp[1];
|
$(".e-rate-thumb").live("click", function(){
|
||||||
src = tmp[0];
|
|
||||||
|
var src = $(this).attr("href");
|
||||||
|
var thumb = $(this);
|
||||||
|
var tmp = src.split('#');
|
||||||
|
var id = tmp[1];
|
||||||
|
var src = tmp[0];
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -221,7 +278,7 @@ $(document).ready(function()
|
|||||||
|
|
||||||
$('#'+id +'-up').text(up);
|
$('#'+id +'-up').text(up);
|
||||||
$('#'+id +'-down').text(down);
|
$('#'+id +'-down').text(down);
|
||||||
$(this).attr('title','Thanks for voting');
|
thumb.attr('title','Thanks for voting');
|
||||||
// alert('Thanks for liking');
|
// alert('Thanks for liking');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -113,6 +113,27 @@ class comment
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function replyComment($id) // Ajax Reply.
|
||||||
|
{
|
||||||
|
$sql = e107::getDb();
|
||||||
|
if($sql->db_Select("comments","*","comment_id= ".intval($id)." LIMIT 1"))
|
||||||
|
{
|
||||||
|
$row = $sql->db_Fetch();
|
||||||
|
// [comment_id] => 65
|
||||||
|
|
||||||
|
return $this->form_comment('reply', $row['comment_type'], $row['comment_item_id'], $row['comment_subject'], false, true,false,false,$id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the comment editing form
|
* Display the comment editing form
|
||||||
*
|
*
|
||||||
@@ -125,7 +146,7 @@ class comment
|
|||||||
* @param unknown_type $rating
|
* @param unknown_type $rating
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE)
|
function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE,$pid = false)
|
||||||
{
|
{
|
||||||
//rating : boolean, to show rating system in comment
|
//rating : boolean, to show rating system in comment
|
||||||
|
|
||||||
@@ -222,8 +243,11 @@ class comment
|
|||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
$text = "\n<div id='e-comment-form'>\n".e107::getMessage()->render('postcomment', true, false, false);//temporary here
|
$indent = ($action == 'reply') ? "style='margin-left:40px'" : "";
|
||||||
$text .= "<form method='post' action='".str_replace('http:', '', $_SERVER['REQUEST_URI'])."' id='e-comment-form' >";
|
$formid = ($action == 'reply') ? "e-comment-form-reply" : "e-comment-form";
|
||||||
|
|
||||||
|
$text = "\n<div id='{$formid}' {$indent}>\n".e107::getMessage()->render('postcomment', true, false, false);//temporary here
|
||||||
|
$text .= "<form id='{$formid}' method='post' action='".str_replace('http:', '', $_SERVER['REQUEST_URI'])."' >";
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
@@ -231,6 +255,7 @@ class comment
|
|||||||
'table' => $table,
|
'table' => $table,
|
||||||
'comval' => strip_tags(trim($comval)),
|
'comval' => strip_tags(trim($comval)),
|
||||||
'itemid' => $itemid,
|
'itemid' => $itemid,
|
||||||
|
'pid' => $pid,
|
||||||
'eaction' => $eaction,
|
'eaction' => $eaction,
|
||||||
'rate' => $rate
|
'rate' => $rate
|
||||||
);
|
);
|
||||||
@@ -241,9 +266,9 @@ class comment
|
|||||||
|
|
||||||
$text .= $tp->parseTemplate($this->template['FORM'], TRUE, e107::getScBatch('comment'));
|
$text .= $tp->parseTemplate($this->template['FORM'], TRUE, e107::getScBatch('comment'));
|
||||||
|
|
||||||
$text .= "<div>"; // All Hidden Elements.
|
$text .= "\n<div>\n"; // All Hidden Elements.
|
||||||
|
|
||||||
$text .= (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='{$id}' />" : '');
|
$text .= (varset($action) == "reply" && $pid ? "<input type='hidden' name='pid' value='{$pid}' />" : '');
|
||||||
$text .=(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='{$id}' />" : "");
|
$text .=(isset($eaction) && $eaction == "edit" ? "<input type='hidden' name='editpid' value='{$id}' />" : "");
|
||||||
$text .=(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='{$content_type}' />" : '');
|
$text .=(isset($content_type) && $content_type ? "<input type='hidden' name='content_type' value='{$content_type}' />" : '');
|
||||||
// $text .= (!$pref['nested_comments']) ? "<input type='hidden' name='subject' value='".$tp->toForm($subject)."' />\n" : "";
|
// $text .= (!$pref['nested_comments']) ? "<input type='hidden' name='subject' value='".$tp->toForm($subject)."' />\n" : "";
|
||||||
@@ -254,8 +279,9 @@ class comment
|
|||||||
<input type='hidden' name='table' value='".$table."' />\n
|
<input type='hidden' name='table' value='".$table."' />\n
|
||||||
<input type='hidden' name='itemid' value='".$itemid."' />\n
|
<input type='hidden' name='itemid' value='".$itemid."' />\n
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>\n";
|
||||||
</div>";
|
|
||||||
|
$text .= "</div>";
|
||||||
|
|
||||||
if ($tablerender)
|
if ($tablerender)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user