mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Infopanel comment-approval now fully functional.
This commit is contained in:
@@ -62,16 +62,16 @@ if(e_AJAX_REQUEST) // TODO improve security
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']))
|
if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']) && ADMIN)
|
||||||
{
|
{
|
||||||
$status = e107::getComment()->deleteComment($_POST['itemid']);
|
$status = e107::getComment()->deleteComment($_POST['itemid']);
|
||||||
$ret['msg'] = COMLAN_332;
|
$ret['msg'] = ($status) ? 'Ok' : COMLAN_332;
|
||||||
$ret['error'] = ($status) ? false : true;
|
$ret['error'] = ($status) ? false : true;
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']))
|
if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']) && ADMIN)
|
||||||
{
|
{
|
||||||
$status = e107::getComment()->approveComment($_POST['itemid']);
|
$status = e107::getComment()->approveComment($_POST['itemid']);
|
||||||
$ret['msg'] = ($status) ? COMLAN_333 : COMLAN_334;
|
$ret['msg'] = ($status) ? COMLAN_333 : COMLAN_334;
|
||||||
|
@@ -482,31 +482,30 @@ EOF;
|
|||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$rows = $sql->retrieve('comments','*','comment_blocked=2 ORDER BY comment_id DESC LIMIT 5',true) )
|
if(!$rows = $sql->retrieve('comments','*','comment_blocked=2 ORDER BY comment_id DESC LIMIT 25',true) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sc = e107::getScBatch('comment');
|
$sc = e107::getScBatch('comment');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$text = '
|
$text = '
|
||||||
<ul class="media-list unstyled">';
|
<ul class="media-list unstyled">';
|
||||||
// <button class='btn btn-mini'><i class='icon-pencil'></i> Edit</button>
|
// <button class='btn btn-mini'><i class='icon-pencil'></i> Edit</button>
|
||||||
foreach($rows as $row)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
//XXX Always keep template hardcoded here - heavy use of ajax and ids.
|
||||||
|
$count = 1;
|
||||||
|
foreach($rows as $row)
|
||||||
|
{
|
||||||
|
$hide = ($count > 3) ? ' hide' : '';
|
||||||
|
|
||||||
$TEMPLATE = "{SETIMAGE: w=40}
|
$TEMPLATE = "{SETIMAGE: w=40}
|
||||||
<li class='media'>
|
<li id='comment-".$row['comment_id']."' class='media".$hide."'>
|
||||||
<span class='media-object pull-left'>{USER_AVATAR=".$row['comment_author_id']."}</span>
|
<span class='media-object pull-left'>{USER_AVATAR=".$row['comment_author_id']."}</span>
|
||||||
<div class='btn-group pull-right'>
|
<div class='btn-group pull-right'>
|
||||||
|
<button data-target='".e_BASE."comment.php' data-comment-id='".$row['comment_id']."' data-comment-action='delete' class='btn btn-mini btn-danger'><i class='icon-remove'></i> Delete</button>
|
||||||
<button class='btn btn-mini btn-danger'><i class='icon-remove'></i> Delete</button>
|
<button data-target='".e_BASE."comment.php' data-comment-id='".$row['comment_id']."' data-comment-action='approve' class='btn btn-mini btn-success'><i class='icon-ok'></i> Approve</button>
|
||||||
<button class='btn btn-mini btn-success'><i class='icon-ok'></i> Approve</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class='media-body'><small class='muted smalltext'>Posted by {USERNAME} {TIMEDATE=relative}</small><br />
|
<div class='media-body'><small class='muted smalltext'>Posted by {USERNAME} {TIMEDATE=relative}</small><br />
|
||||||
<p>{COMMENT}</p>
|
<p>{COMMENT}</p>
|
||||||
@@ -516,16 +515,17 @@ EOF;
|
|||||||
|
|
||||||
$sc->setVars($row);
|
$sc->setVars($row);
|
||||||
$text .= $tp->parseTemplate($TEMPLATE,true,$sc);
|
$text .= $tp->parseTemplate($TEMPLATE,true,$sc);
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$text .= '
|
$text .= '
|
||||||
|
</ul>
|
||||||
<li class="separator" style="text-align: center">
|
<div class="right">
|
||||||
<a class="btn btn-mini btn-primary pull-right" href="'.e_ADMIN.'comment.php?searchquery=&filter_options=comment_blocked__2">View all</a>
|
<a class="btn btn-mini btn-primary text-right" href="'.e_ADMIN.'comment.php?searchquery=&filter_options=comment_blocked__2">View all</a>
|
||||||
</li>
|
</div>
|
||||||
</ul>';
|
';
|
||||||
$text .= "<small class='text-center text-warning'>Note: Not fully functional at the moment.</small>";
|
// $text .= "<small class='text-center text-warning'>Note: Not fully functional at the moment.</small>";
|
||||||
|
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
return $ns->tablerender("Latest Comments",$text,'core-infopanel_online',true);
|
return $ns->tablerender("Latest Comments",$text,'core-infopanel_online',true);
|
||||||
|
@@ -529,7 +529,7 @@ class comment
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return e107::getDb()->db_Delete("comments","comment_id = ".intval($id)." LIMIT 1");
|
return e107::getDb()->update("comments","comment_blocked=1 WHERE comment_id = ".intval($id)." LIMIT 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function approveComment($id) // appropve a single comment by comment id.
|
function approveComment($id) // appropve a single comment by comment id.
|
||||||
@@ -539,7 +539,7 @@ class comment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return e107::getDb()->db_Update("comments","comment_blocked=0 WHERE comment_id = ".intval($id)." LIMIT 1");
|
return e107::getDb()->update("comments","comment_blocked=0 WHERE comment_id = ".intval($id)." LIMIT 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ class comment
|
|||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
if(!e107::getDb()->db_Update("comments","comment_comment=\"".$tp->toDB($comment)."\" WHERE comment_id = ".intval($id)." LIMIT 1"))
|
if(!e107::getDb()->update("comments","comment_comment=\"".$tp->toDB($comment)."\" WHERE comment_id = ".intval($id)." LIMIT 1"))
|
||||||
{
|
{
|
||||||
return "Update Failed"; // trigger ajax error message.
|
return "Update Failed"; // trigger ajax error message.
|
||||||
}
|
}
|
||||||
|
@@ -143,6 +143,49 @@ $(document).ready(function()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/* InfoPanel Comment approval and deletion */
|
||||||
|
$("button[data-comment-action]").live("click", function(){
|
||||||
|
|
||||||
|
var url = $(this).attr("data-target");
|
||||||
|
var action = $(this).attr('data-comment-action');
|
||||||
|
var id = $(this).attr("data-comment-id");
|
||||||
|
var next = $('#comment-'+ id).nextAll('.hide').attr("id");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url + '?ajax_used=1&mode='+action,
|
||||||
|
data: { itemid: id },
|
||||||
|
success: function(data) {
|
||||||
|
var a = $.parseJSON(data);
|
||||||
|
// alert(data);
|
||||||
|
if(!a.error)
|
||||||
|
{
|
||||||
|
$('#comment-'+ id).hide(800, function () {
|
||||||
|
$('#'+next).show('slow');
|
||||||
|
$('#'+next).removeClass('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Bootstrap Modal window within an iFrame */
|
/* Bootstrap Modal window within an iFrame */
|
||||||
|
Reference in New Issue
Block a user