mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Ajax comment creating, editing, deleting, approving - functional.
This commit is contained in:
81
comment.php
81
comment.php
@@ -24,13 +24,59 @@
|
|||||||
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);
|
||||||
|
|
||||||
// print_r($_POST);
|
|
||||||
// exit;
|
|
||||||
|
|
||||||
if(e_AJAX_REQUEST)
|
if(e_AJAX_REQUEST) // TODO improve security
|
||||||
{
|
{
|
||||||
|
|
||||||
if(vartrue($_POST['comment']) && USERID)
|
if(!ANON && !USER)
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']))
|
||||||
|
{
|
||||||
|
$status = e107::getComment()->deleteComment($_POST['itemid']);
|
||||||
|
$ret['msg'] = "Couldn't delete comment";
|
||||||
|
$ret['error'] = ($status) ? false : true;
|
||||||
|
echo json_encode($ret);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']))
|
||||||
|
{
|
||||||
|
$status = e107::getComment()->approveComment($_POST['itemid']);
|
||||||
|
$ret['msg'] = ($status) ? "Comment approved" : "Couldn't approve comment";
|
||||||
|
$ret['error'] = ($status) ? false : true;
|
||||||
|
$ret['html'] = "Approved"; //TODO LAN
|
||||||
|
echo json_encode($ret);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!vartrue($_POST['comment']) && varset($_GET['mode']) == 'submit')
|
||||||
|
{
|
||||||
|
$ret['error'] = true;
|
||||||
|
$ret['msg'] = "Please write something first."; //TODO LAN
|
||||||
|
echo json_encode($ret);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Comment
|
||||||
|
if(e107::getPref('allowCommentEdit') && varset($_GET['mode']) == 'edit' && vartrue($_POST['comment']) && vartrue($_POST['itemid']))
|
||||||
|
{
|
||||||
|
$error = e107::getComment()->updateComment($_POST['itemid'],$_POST['comment']);
|
||||||
|
|
||||||
|
$ret['error'] = ($error) ? true : false;
|
||||||
|
$ret['msg'] = ($error) ? $error : "Saved!!!"; //TODO Common LAN
|
||||||
|
|
||||||
|
echo json_encode($ret);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Insert Comment and return rendered html.
|
||||||
|
if(vartrue($_POST['comment']) && USERID) // ajax render comment
|
||||||
{
|
{
|
||||||
$pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
|
$pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
|
||||||
|
|
||||||
@@ -40,8 +86,9 @@ if(e_AJAX_REQUEST)
|
|||||||
|
|
||||||
$newid = e107::getComment()->enter_comment($clean_authorname, $clean_comment, $_POST['table'], intval($_POST['itemid']), $pid, $clean_subject);
|
$newid = e107::getComment()->enter_comment($clean_authorname, $clean_comment, $_POST['table'], intval($_POST['itemid']), $pid, $clean_subject);
|
||||||
|
|
||||||
if($newid)
|
if(is_numeric($newid) && ($_GET['mode'] == 'submit'))
|
||||||
{
|
{
|
||||||
|
$row = array();
|
||||||
$row['comment_id'] = $newid;
|
$row['comment_id'] = $newid;
|
||||||
$row['comment_item_id'] = intval($_POST['itemid']);
|
$row['comment_item_id'] = intval($_POST['itemid']);
|
||||||
$row['comment_type'] = e107::getComment()->getCommentType($tp->toDB($_POST['table'],true));
|
$row['comment_type'] = e107::getComment()->getCommentType($tp->toDB($_POST['table'],true));
|
||||||
@@ -53,20 +100,30 @@ if(e_AJAX_REQUEST)
|
|||||||
$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);
|
||||||
|
|
||||||
echo "\n<!-- Appended -->\n";
|
$ret['html'] = "\n<!-- Appended -->\n";
|
||||||
echo e107::getComment()->render_comment($row,'comment',intval($_POST['itemid']));
|
$ret['html'] .= e107::getComment()->render_comment($row,'comment',intval($_POST['itemid']));
|
||||||
echo "\n<!-- end Appended -->\n";
|
$ret['html'] .= "\n<!-- end Appended -->\n";
|
||||||
|
|
||||||
|
$ret['error'] = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret['error'] = true;
|
||||||
|
$ret['msg'] = $newid;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(e_HANDLER."news_class.php");
|
|
||||||
|
|
||||||
|
|
||||||
|
require_once(e_HANDLER."news_class.php"); // FIXME shouldn't be here.
|
||||||
require_once(e_HANDLER."comment_class.php");
|
require_once(e_HANDLER."comment_class.php");
|
||||||
define("PAGE_NAME", COMLAN_99);
|
define("PAGE_NAME", COMLAN_99);
|
||||||
|
|
||||||
|
@@ -1274,6 +1274,12 @@ $text .= "
|
|||||||
<col class='col-control' />
|
<col class='col-control' />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class='label'>Allow users to post comments: </td>
|
||||||
|
<td class='control'>
|
||||||
|
".$frm->radio_switch('comments_disabled', $pref['comments_disabled'], LAN_NO, LAN_YES,array('reverse'=>1))."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='label'>".PRFLAN_32."</td>
|
<td class='label'>".PRFLAN_32."</td>
|
||||||
<td class='control'>
|
<td class='control'>
|
||||||
@@ -1300,12 +1306,7 @@ $text .= "
|
|||||||
".$frm->radio_switch('allowCommentEdit', $pref['allowCommentEdit'], LAN_YES, LAN_NO)."
|
".$frm->radio_switch('allowCommentEdit', $pref['allowCommentEdit'], LAN_YES, LAN_NO)."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class='label'>".PRFLAN_161.": </td>
|
|
||||||
<td class='control'>
|
|
||||||
".$frm->radio_switch('comments_disabled', $pref['comments_disabled'], LAN_YES, LAN_NO)."
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='label'>".PRFLAN_166.": </td>
|
<td class='label'>".PRFLAN_166.": </td>
|
||||||
<td class='control'>
|
<td class='control'>
|
||||||
@@ -1314,9 +1315,10 @@ $text .= "
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='label'>Moderate Comments: </td>
|
<td class='label'>Approve Comments: </td>
|
||||||
<td class='control'>
|
<td class='control'>
|
||||||
".$frm->radio_switch('comments_moderate', $pref['comments_moderate'], LAN_YES, LAN_NO)."
|
".$frm->radio_switch('comments_moderate', $pref['comments_moderate'], LAN_YES, LAN_NO)."
|
||||||
|
<div class='field-help'>Posted comments will require approval before being visible to others</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -182,6 +182,12 @@ class comment_shortcodes extends e_shortcode
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO put into a <ul> drop-down format.
|
||||||
|
$text = "<a href='#' data-target='".e_BASE."comment.php' id='e-comment-delete-".$this->var['comment_id']."' class='e-comment-delete'>Delete</a> ";
|
||||||
|
$text .= "<a href='#' data-target='".e_BASE."comment.php' id='e-comment-approve-".$this->var['comment_id']."' class='e-comment-approve'>Approve</a> ";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
$url = e_PAGE."?".e_QUERY;
|
$url = e_PAGE."?".e_QUERY;
|
||||||
|
|
||||||
$unblock = "[<a href='".e_ADMIN_ABS."comment.php?unblock-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_1."</a>] ";
|
$unblock = "[<a href='".e_ADMIN_ABS."comment.php?unblock-".$comrow['comment_id']."-$url-".$comrow['comment_item_id']."'>".COMLAN_1."</a>] ";
|
||||||
@@ -281,17 +287,19 @@ class comment_shortcodes extends e_shortcode
|
|||||||
switch ($this->var['comment_blocked'])
|
switch ($this->var['comment_blocked'])
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
return "Pending Approval"; // TODO LAN
|
$text = "Pending Approval"; // TODO LAN
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return COMLAN_0;
|
$text = COMLAN_0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "<span id='comment-status-".$this->var['comment_id']."'>".$text."</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,12 +315,12 @@ class comment_shortcodes extends e_shortcode
|
|||||||
//Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all?
|
//Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all?
|
||||||
if (strstr(e_QUERY, "&"))
|
if (strstr(e_QUERY, "&"))
|
||||||
{
|
{
|
||||||
return "<a class='comment-edit' href='".e_SELF."?".e_QUERY."&comment=edit&comment_id=".$this->var['comment_id']."'>{$adop_icon}</a>";
|
return "<a data-target='".e_BASE."comment.php' id='e-comment-edit-".$this->var['comment_id']."' class='e-comment-edit' href='".e_SELF."?".e_QUERY."&comment=edit&comment_id=".$this->var['comment_id']."'>{$adop_icon}</a>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$this->var['comment_id']."'><img src='".e_IMAGE."generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>";
|
// return "<a href='".e_SELF."?".$comment_edit_query.".edit.".$this->var['comment_id']."'><img src='".e_IMAGE."generic/newsedit.png' alt='".COMLAN_318."' title='".COMLAN_318."' style='border: 0;' /></a>";
|
||||||
return "<a class='comment-edit' href='".SITEURL."comment.php?".$comment_edit_query.".edit.".$this->var['comment_id']."#e-comment-form'>".$adop_icon."</a>";
|
return "<a data-target='".e_BASE."comment.php' id='e-comment-edit-".$this->var['comment_id']."' class='e-comment-edit' href='".SITEURL."comment.php?".$comment_edit_query.".edit.".$this->var['comment_id']."#e-comment-form'>".$adop_icon."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -421,99 +421,7 @@ $(document).ready(function()
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(".e-comment-submit").click(function(){
|
|
||||||
|
|
||||||
var url = $(this).attr("data-target");
|
|
||||||
var sort = $(this).attr("data-sort");
|
|
||||||
var data = $("form#e-comment-form").serialize();
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: url + '?ajax_used=1',
|
|
||||||
data: data,
|
|
||||||
success: function(html) {
|
|
||||||
|
|
||||||
$("#comment").val('');
|
|
||||||
if(sort == 'desc')
|
|
||||||
{
|
|
||||||
$(html).prependTo('#comments-container').hide().slideDown(800);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$(html).appendTo('#comments-container').hide().slideDown(800);
|
|
||||||
alert('Thank you for commenting'); // possibly needed as the submission may go unoticed by the user
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".e-comment-delete").click(function(){ //TODO - for admin use on front-end.
|
|
||||||
|
|
||||||
var url = $(this).attr("data-target");
|
|
||||||
var sort = $(this).attr("data-sort");
|
|
||||||
var data = $("form#e-comment-form").serialize();
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: url + '?ajax_used=1',
|
|
||||||
data: data,
|
|
||||||
success: function(html) {
|
|
||||||
// var sort = $(this).attr("data-sort");
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(".e-rate-thumb").click(function(){
|
|
||||||
|
|
||||||
var src = $(this).attr("href");
|
|
||||||
|
|
||||||
var tmp = src.split('#');
|
|
||||||
id = tmp[1];
|
|
||||||
src = tmp[0];
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: src,
|
|
||||||
data: { ajax_used: 1, mode: 'thumb' },
|
|
||||||
dataType: "html",
|
|
||||||
success: function(html) {
|
|
||||||
|
|
||||||
if(html == '')
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var tmp = html.split('|');
|
|
||||||
up= tmp[0];
|
|
||||||
down = tmp[1];
|
|
||||||
|
|
||||||
$('#'+id +'-up').text(up);
|
|
||||||
$('#'+id +'-down').text(down);
|
|
||||||
$(this).attr('title','Thanks for voting');
|
|
||||||
// alert('Thanks for liking');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -2,7 +2,230 @@
|
|||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
$(":input").tipsy({gravity: 'w',fade: true});
|
$(":input").tipsy({gravity: 'w',fade: true});
|
||||||
$(".e-tip").tipsy({gravity: 'sw',fade: true});
|
|
||||||
|
$(".e-tip").tipsy({gravity: 'sw',fade: true});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".e-comment-submit").click(function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var sort = $(this).attr("data-sort");
|
||||||
|
var data = $("form#e-comment-form").serialize();
|
||||||
|
var total = parseInt($("#e-comment-total").text());
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url + '?ajax_used=1&mode=submit',
|
||||||
|
data: data,
|
||||||
|
success: function(html) {
|
||||||
|
|
||||||
|
console.log(html);
|
||||||
|
var a = $.parseJSON(html);
|
||||||
|
|
||||||
|
$("#comment").val('');
|
||||||
|
if(sort == 'desc')
|
||||||
|
{
|
||||||
|
$(a.html).prependTo('#comments-container').hide().slideDown(800);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(a.html).appendTo('#comments-container').hide().slideDown(800);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alert(a.msg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".e-comment-edit").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var sp = $(this).attr('id').split("-");
|
||||||
|
var id = "#comment-" + sp[3] + "-edit";
|
||||||
|
|
||||||
|
if($('.e-comment-edit-save').length != 0) //prevent creating save button twice.
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(id).attr('contentEditable',true);
|
||||||
|
$(id).after("<div class='e-comment-edit-save'><input data-target='"+url+"' id='e-comment-edit-save-"+sp[3]+"' class='button e-comment-edit-save' type='button' value='Save' /></div>");
|
||||||
|
$('div.e-comment-edit-save').hide().fadeIn(800);
|
||||||
|
$(id).addClass("e-comment-edit-active");
|
||||||
|
$(id).focus();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("input.e-comment-edit-save").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var sp = $(this).attr('id').split("-");
|
||||||
|
var id = "#comment-" + sp[4] + "-edit";
|
||||||
|
var comment = $(id).text();
|
||||||
|
|
||||||
|
$(id).attr('contentEditable',false);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url + '?ajax_used=1&mode=edit',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
comment: comment,
|
||||||
|
itemid: sp[4]
|
||||||
|
},
|
||||||
|
success:function (data) {
|
||||||
|
|
||||||
|
var a = $.parseJSON(data);
|
||||||
|
|
||||||
|
if(!a.error)
|
||||||
|
{
|
||||||
|
$("div.e-comment-edit-save")
|
||||||
|
.hide()
|
||||||
|
.addClass("e-comment-edit-success")
|
||||||
|
.html(a.msg)
|
||||||
|
.fadeIn('slow')
|
||||||
|
.delay(1000)
|
||||||
|
.fadeOut('slow');
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("div.e-comment-edit-save")
|
||||||
|
.addClass("e-comment-edit-error")
|
||||||
|
.html(a.msg)
|
||||||
|
.fadeIn('slow')
|
||||||
|
.delay(1000)
|
||||||
|
.fadeOut('slow');
|
||||||
|
}
|
||||||
|
$(id).removeClass("e-comment-edit-active");
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
$('div.e-comment-edit-save').remove();
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
// .delay(1000);
|
||||||
|
// alert(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".e-comment-delete").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var sp = $(this).attr('id').split("-");
|
||||||
|
var id = "#comment-" + sp[3];
|
||||||
|
var total = parseInt($("#e-comment-total").text());
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url + '?ajax_used=1&mode=delete',
|
||||||
|
data: { itemid: sp[3] },
|
||||||
|
success: function(data) {
|
||||||
|
var a = $.parseJSON(data);
|
||||||
|
|
||||||
|
if(!a.error)
|
||||||
|
{
|
||||||
|
$(id).hide('slow');
|
||||||
|
$("#e-comment-total").text(total - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".e-comment-approve").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var sp = $(this).attr('id').split("-");
|
||||||
|
var id = "#comment-status-" + sp[3];
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url + '?ajax_used=1&mode=approve',
|
||||||
|
data: { itemid: sp[3] },
|
||||||
|
success: function(data) {
|
||||||
|
|
||||||
|
|
||||||
|
var a = $.parseJSON(data);
|
||||||
|
|
||||||
|
|
||||||
|
if(!a.error)
|
||||||
|
{
|
||||||
|
//TODO modify status of html on page.
|
||||||
|
$(id).text(a.html)
|
||||||
|
.fadeIn('slow')
|
||||||
|
.addClass('e-comment-edit-success'); //TODO another class?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alert(a.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".e-rate-thumb").click(function(){
|
||||||
|
|
||||||
|
var src = $(this).attr("href");
|
||||||
|
|
||||||
|
var tmp = src.split('#');
|
||||||
|
id = tmp[1];
|
||||||
|
src = tmp[0];
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: src,
|
||||||
|
data: { ajax_used: 1, mode: 'thumb' },
|
||||||
|
dataType: "html",
|
||||||
|
success: function(html) {
|
||||||
|
|
||||||
|
if(html == '')
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmp = html.split('|');
|
||||||
|
up= tmp[0];
|
||||||
|
down = tmp[1];
|
||||||
|
|
||||||
|
$('#'+id +'-up').text(up);
|
||||||
|
$('#'+id +'-down').text(down);
|
||||||
|
$(this).attr('title','Thanks for voting');
|
||||||
|
// alert('Thanks for liking');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
@@ -246,9 +246,10 @@ class comment
|
|||||||
$text .= (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='{$id}' />" : '');
|
$text .= (isset($action) && $action == "reply" ? "<input type='hidden' name='pid' value='{$id}' />" : '');
|
||||||
$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" : "";
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
|
<input type='hidden' name='subject' value='".$tp->toForm($subject)."' />
|
||||||
<input type='hidden' name='e-token' value='".e_TOKEN."' />\n
|
<input type='hidden' name='e-token' value='".e_TOKEN."' />\n
|
||||||
<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
|
||||||
@@ -441,6 +442,42 @@ class comment
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deleteComment($id) // delete a single comment by comment id.
|
||||||
|
{
|
||||||
|
if(!getperms('0') && !getperms("B"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return e107::getDb()->db_Delete("comments","comment_id = ".intval($id)." LIMIT 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
function approveComment($id) // appropve a single comment by comment id.
|
||||||
|
{
|
||||||
|
if(!getperms('0') && !getperms("B"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e107::getDb()->db_Update("comments","comment_blocked=0 WHERE comment_id = ".intval($id)." LIMIT 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateComment($id,$comment)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if(!e107::getDb()->db_Update("comments","comment_comment=\"".$tp->toDB($comment)."\" WHERE comment_id = ".intval($id)." LIMIT 1"))
|
||||||
|
{
|
||||||
|
return "Update Failed"; // trigger ajax error message.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a comment to an item
|
* Add a comment to an item
|
||||||
* e-token POST value should be always valid when using this method.
|
* e-token POST value should be always valid when using this method.
|
||||||
@@ -496,6 +533,7 @@ class comment
|
|||||||
$subject = $tp->toDB($subject);
|
$subject = $tp->toDB($subject);
|
||||||
$cuser_id = 0;
|
$cuser_id = 0;
|
||||||
$cuser_name = 'Anonymous'; // Preset as an anonymous comment
|
$cuser_name = 'Anonymous'; // Preset as an anonymous comment
|
||||||
|
|
||||||
if (!$sql->db_Select("comments", "*", "comment_comment='".$comment."' AND comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' "))
|
if (!$sql->db_Select("comments", "*", "comment_comment='".$comment."' AND comment_item_id='".intval($id)."' AND comment_type='".$tp->toDB($type, true)."' "))
|
||||||
{
|
{
|
||||||
if ($_POST['comment'])
|
if ($_POST['comment'])
|
||||||
@@ -506,8 +544,8 @@ class comment
|
|||||||
$cuser_name = USERNAME;
|
$cuser_name = USERNAME;
|
||||||
$cuser_mail = USEREMAIL;
|
$cuser_mail = USEREMAIL;
|
||||||
}
|
}
|
||||||
elseif ($_POST['author_name'] != '')
|
elseif ($_POST['author_name'] != '') // See if author name is registered user
|
||||||
{ // See if author name is registered user
|
{
|
||||||
if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' "))
|
if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' "))
|
||||||
{
|
{
|
||||||
if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' AND user_ip='".$tp->toDB($ip, true)."' "))
|
if ($sql2->db_Select("user", "*", "user_name='".$tp->toDB($_POST['author_name'])."' AND user_ip='".$tp->toDB($ip, true)."' "))
|
||||||
@@ -523,8 +561,8 @@ class comment
|
|||||||
define("emessage", COMLAN_310);
|
define("emessage", COMLAN_310);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // User not on-line, so can't be entering comments
|
||||||
{ // User not on-line, so can't be entering comments
|
{
|
||||||
$cuser_name = $tp->toDB($author_name);
|
$cuser_name = $tp->toDB($author_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,6 +623,10 @@ class comment
|
|||||||
if (!($inserted_id = $sql->db_Insert("comments", $edata_li)))
|
if (!($inserted_id = $sql->db_Insert("comments", $edata_li)))
|
||||||
{
|
{
|
||||||
//echo "<b>".COMLAN_323."</b> ".COMLAN_11;
|
//echo "<b>".COMLAN_323."</b> ".COMLAN_11;
|
||||||
|
if(e_AJAX_REQUEST)
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
|
e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -630,6 +672,12 @@ class comment
|
|||||||
|
|
||||||
if (defined("emessage"))
|
if (defined("emessage"))
|
||||||
{
|
{
|
||||||
|
if(e_AJAX_REQUEST)
|
||||||
|
{
|
||||||
|
return emessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
message_handler("ALERT", emessage);
|
message_handler("ALERT", emessage);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -870,7 +918,7 @@ class comment
|
|||||||
if ($tablerender)
|
if ($tablerender)
|
||||||
{
|
{
|
||||||
|
|
||||||
echo $ns->tablerender($this->totalComments." ".COMLAN_99, $TEMPL, 'comment', TRUE);
|
echo $ns->tablerender("<span id='e-comment-total'>".$this->totalComments."</span> ".COMLAN_99, $TEMPL, 'comment', TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -745,7 +745,14 @@ class e_form
|
|||||||
$options_on = array('class' => 'e-expandit-on');
|
$options_on = array('class' => 'e-expandit-on');
|
||||||
$options_off = array('class' => 'e-expandit-off');
|
$options_off = array('class' => 'e-expandit-off');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(vartrue($options['reverse'])) // reverse order.
|
||||||
|
{
|
||||||
|
unset($options['reverse']);
|
||||||
|
return $this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0)." ".
|
||||||
|
$this->radio($name, 1, $checked_enabled, $options_on)."".$this->label($label_enabled ? $label_enabled : LAN_ENABLED, $name, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->radio($name, 1, $checked_enabled, $options_on)."".$this->label($label_enabled ? $label_enabled : LAN_ENABLED, $name, 1)."
|
return $this->radio($name, 1, $checked_enabled, $options_on)."".$this->label($label_enabled ? $label_enabled : LAN_ENABLED, $name, 1)."
|
||||||
".$this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0);
|
".$this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0);
|
||||||
|
|
||||||
|
@@ -96,9 +96,7 @@ $COMMENT_TEMPLATE['FORM'] = "
|
|||||||
</div>
|
</div>
|
||||||
<div class='comment-box-right' style='text-align:left'>
|
<div class='comment-box-right' style='text-align:left'>
|
||||||
<div class='P10'>
|
<div class='P10'>
|
||||||
{SUBJECT_INPUT}
|
|
||||||
{AUTHOR_INPUT}
|
{AUTHOR_INPUT}
|
||||||
{RATE_INPUT}
|
|
||||||
{COMMENT_INPUT}
|
{COMMENT_INPUT}
|
||||||
{COMMENT_BUTTON}
|
{COMMENT_BUTTON}
|
||||||
</div>
|
</div>
|
||||||
@@ -120,12 +118,12 @@ $COMMENT_TEMPLATE['ITEM'] = '
|
|||||||
|
|
||||||
<span class="comment-status">{COMMENT_STATUS}</span>
|
<span class="comment-status">{COMMENT_STATUS}</span>
|
||||||
<div class="comment-user-badge-bar">
|
<div class="comment-user-badge-bar">
|
||||||
{COMMENT_RATE}{REPLY}{COMMENTEDIT}
|
{COMMENT_RATE}{REPLY} {COMMENTEDIT} {COMMENT_MODERATE}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear_b H5"><!-- --></div>
|
<div class="clear_b H5"><!-- --></div>
|
||||||
<div id="{COMMENT_ITEMID}-edit">{COMMENT}</div>
|
<div id="{COMMENT_ITEMID}-edit" contentEditable="false">{COMMENT}</div>
|
||||||
{COMMENT_MOD//ERATE}
|
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
@@ -161,7 +161,7 @@ img.comment-avatar { max-width:128px; -webkit-box-shadow:#CCCCCC 0px 0px
|
|||||||
|
|
||||||
a.comment-edit { }
|
a.comment-edit { }
|
||||||
|
|
||||||
.comment-edit { float:right; margin-right:5px; }
|
.comment-edit { float:right; margin:0 5px 0 5px; }
|
||||||
|
|
||||||
.comment-reply { float:right ; margin-right:5px;}
|
.comment-reply { float:right ; margin-right:5px;}
|
||||||
|
|
||||||
@@ -169,6 +169,11 @@ a.comment-edit { }
|
|||||||
|
|
||||||
.comment-rate { text-align:right; float:right; width:100px }
|
.comment-rate { text-align:right; float:right; width:100px }
|
||||||
|
|
||||||
.e-rate-up img { opacity: 0.5 }
|
div.e-comment-edit-save { margin-top:8px; padding: 5px }
|
||||||
.e-rate-down img { opacity: 0.5 }
|
.e-comment-edit-active { -webkit-box-shadow:#CCCCCC 0px 0px 10px; -moz-box-shadow:#CCCCCC 0px 0px 10px; box-shadow:#CCCCCC 0px 0px 10px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px;}
|
||||||
|
.e-comment-edit-success { padding:5px; text-align:center; background-color:#DFFFDF; border: 1px solid #009900; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
|
||||||
|
.e-comment-edit-error { padding:5px; text-align:center; background-color:#FFCECE; border: 1px solid #CC0000; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
|
||||||
|
|
||||||
|
.e-rate-up img { opacity: 0.4 }
|
||||||
|
.e-rate-down img { opacity: 0.4 }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user