Posted comments will require approval before being visible to others
diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php
index 88c69c4df..7d01ea4a2 100644
--- a/e107_core/shortcodes/batch/comment_shortcodes.php
+++ b/e107_core/shortcodes/batch/comment_shortcodes.php
@@ -182,6 +182,12 @@ class comment_shortcodes extends e_shortcode
return;
}
+ // TODO put into a
drop-down format.
+ $text = "Delete ";
+ $text .= "Approve ";
+
+ return $text;
+
$url = e_PAGE."?".e_QUERY;
$unblock = "[".COMLAN_1."] ";
@@ -281,17 +287,19 @@ class comment_shortcodes extends e_shortcode
switch ($this->var['comment_blocked'])
{
case 2:
- return "Pending Approval"; // TODO LAN
+ $text = "Pending Approval"; // TODO LAN
break;
case 1:
- return COMLAN_0;
+ $text = COMLAN_0;
break;
default:
-
+ return;
break;
}
+
+ return "".$text."";
}
@@ -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?
if (strstr(e_QUERY, "&"))
{
- return "{$adop_icon}";
+ return "{$adop_icon}";
}
else
{
// return "";
- return "".$adop_icon."";
+ return "".$adop_icon."";
}
}
else
diff --git a/e107_files/jslib/core/all.jquery.js b/e107_files/jslib/core/all.jquery.js
index b4fc02c69..07ee65717 100644
--- a/e107_files/jslib/core/all.jquery.js
+++ b/e107_files/jslib/core/all.jquery.js
@@ -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;
- });
-
})
diff --git a/e107_files/jslib/core/front.jquery.js b/e107_files/jslib/core/front.jquery.js
index 87fbd70bd..e7389d0d6 100644
--- a/e107_files/jslib/core/front.jquery.js
+++ b/e107_files/jslib/core/front.jquery.js
@@ -2,7 +2,230 @@
$(document).ready(function()
{
- $(":input").tipsy({gravity: 'w',fade: true});
- $(".e-tip").tipsy({gravity: 'sw',fade: true});
+ $(":input").tipsy({gravity: 'w',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.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;
+ });
+
});
\ No newline at end of file
diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php
index 6dc0d5544..7abc1b5b7 100644
--- a/e107_handlers/comment_class.php
+++ b/e107_handlers/comment_class.php
@@ -246,9 +246,10 @@ class comment
$text .= (isset($action) && $action == "reply" ? "" : '');
$text .=(isset($eaction) && $eaction == "edit" ? "" : "");
$text .=(isset($content_type) && $content_type ? "" : '');
- $text .= (!$pref['nested_comments']) ? "\n" : "";
+ // $text .= (!$pref['nested_comments']) ? "\n" : "";
$text .= "
+
\n
\n
\n
@@ -441,6 +442,42 @@ class comment
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
* e-token POST value should be always valid when using this method.
@@ -496,6 +533,7 @@ class comment
$subject = $tp->toDB($subject);
$cuser_id = 0;
$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 ($_POST['comment'])
@@ -506,8 +544,8 @@ class comment
$cuser_name = USERNAME;
$cuser_mail = USEREMAIL;
}
- elseif ($_POST['author_name'] != '')
- { // See if author name is registered user
+ elseif ($_POST['author_name'] != '') // 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'])."' AND user_ip='".$tp->toDB($ip, true)."' "))
@@ -523,8 +561,8 @@ class comment
define("emessage", COMLAN_310);
}
}
- else
- { // User not on-line, so can't be entering comments
+ else // User not on-line, so can't be entering comments
+ {
$cuser_name = $tp->toDB($author_name);
}
}
@@ -585,6 +623,10 @@ class comment
if (!($inserted_id = $sql->db_Insert("comments", $edata_li)))
{
//echo "".COMLAN_323." ".COMLAN_11;
+ if(e_AJAX_REQUEST)
+ {
+ return "Error";
+ }
e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
}
@@ -630,6 +672,12 @@ class comment
if (defined("emessage"))
{
+ if(e_AJAX_REQUEST)
+ {
+ return emessage;
+ }
+
+
message_handler("ALERT", emessage);
}
return false;
@@ -870,7 +918,7 @@ class comment
if ($tablerender)
{
- echo $ns->tablerender($this->totalComments." ".COMLAN_99, $TEMPL, 'comment', TRUE);
+ echo $ns->tablerender("".$this->totalComments." ".COMLAN_99, $TEMPL, 'comment', TRUE);
}
else
{
diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php
index f218449b5..6b9569691 100644
--- a/e107_handlers/form_handler.php
+++ b/e107_handlers/form_handler.php
@@ -745,7 +745,14 @@ class e_form
$options_on = array('class' => 'e-expandit-on');
$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)."
".$this->radio($name, 0, !$checked_enabled, $options_off)."".$this->label($label_disabled ? $label_disabled : LAN_DISABLED, $name, 0);
diff --git a/e107_themes/templates/comment_template.php b/e107_themes/templates/comment_template.php
index 9142dd327..28e932188 100644
--- a/e107_themes/templates/comment_template.php
+++ b/e107_themes/templates/comment_template.php
@@ -96,9 +96,7 @@ $COMMENT_TEMPLATE['FORM'] = "