1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Infopanel comment-approval now fully functional.

This commit is contained in:
Cameron 2013-05-20 13:37:39 -07:00
parent 5034dc0e49
commit de808f74d5
4 changed files with 67 additions and 24 deletions

View File

@ -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']);
$ret['msg'] = COMLAN_332;
$ret['msg'] = ($status) ? 'Ok' : COMLAN_332;
$ret['error'] = ($status) ? false : true;
echo json_encode($ret);
exit;
}
if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']))
if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']) && ADMIN)
{
$status = e107::getComment()->approveComment($_POST['itemid']);
$ret['msg'] = ($status) ? COMLAN_333 : COMLAN_334;

View File

@ -482,31 +482,30 @@ EOF;
// 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;
}
$sc = e107::getScBatch('comment');
$text = '
<ul class="media-list unstyled">';
// <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}
<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>
<div class='btn-group pull-right'>
<button class='btn btn-mini btn-danger'><i class='icon-remove'></i> Delete</button>
<button class='btn btn-mini btn-success'><i class='icon-ok'></i> Approve</button>
<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 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>
</div>
<div class='media-body'><small class='muted smalltext'>Posted by {USERNAME} {TIMEDATE=relative}</small><br />
<p>{COMMENT}</p>
@ -516,16 +515,17 @@ EOF;
$sc->setVars($row);
$text .= $tp->parseTemplate($TEMPLATE,true,$sc);
$count++;
}
$text .= '
<li class="separator" style="text-align: center">
<a class="btn btn-mini btn-primary pull-right" href="'.e_ADMIN.'comment.php?searchquery=&filter_options=comment_blocked__2">View all</a>
</li>
</ul>';
$text .= "<small class='text-center text-warning'>Note: Not fully functional at the moment.</small>";
</ul>
<div class="right">
<a class="btn btn-mini btn-primary text-right" href="'.e_ADMIN.'comment.php?searchquery=&filter_options=comment_blocked__2">View all</a>
</div>
';
// $text .= "<small class='text-center text-warning'>Note: Not fully functional at the moment.</small>";
$ns = e107::getRender();
return $ns->tablerender("Latest Comments",$text,'core-infopanel_online',true);

View File

@ -529,7 +529,7 @@ class comment
{
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.
@ -539,7 +539,7 @@ class comment
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();
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.
}

View File

@ -143,6 +143,49 @@ $(document).ready(function()
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 */