ADDED : Basic Comment Moderation in Admin Area

This commit is contained in:
Fawaz 2010-03-19 11:39:18 +00:00
parent 330be098df
commit a41a50508c
9 changed files with 476 additions and 22 deletions

View file

@ -30,5 +30,103 @@ switch($mode)
$myquery->delete_note($id);
}
break;
case 'delete_comment':
{
$type = $_POST['type'];
switch($type)
{
case 'v':
case 'video':
default:
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$cbvid->update_comments_count($type_id);
}
break;
case 'u':
case 'c':
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$userquery->update_comments_count($type_id);
}
break;
case 't':
case 'topic':
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$cbgroup->update_comments_count($type_id);
}
break;
}
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
case 'spam_comment':
{
$cid = mysql_clean($_POST['cid']);
$rating = $myquery->spam_comment($cid);
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
case 'remove_spam':
{
$cid = mysql_clean($_POST['cid']);
$rating = $myquery->remove_spam($cid);
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
}
?>

View file

@ -0,0 +1,56 @@
<?php
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
$mode = $_GET['mode'];
$cid = $_GET['cid'];
$comment = array();
$comment['order'] = " comment_id DESC";
/* By default only video comments list but when you change this is used list video comments */
if(isset($_GET['filter'])) {
$comment['type'] = $_GET['filter'];
assign('filters',$_GET['filter']);
}
/* Used to list topic posts */
if(isset($_GET['filter'])) {
$comment['type'] = $_GET['filter'];
assign('filters',$_GET['filter']);
}
/* Used to list topic posts */
if(isset($_GET['filter'])) {
$comment['type'] = $_GET['filter'];
assign('filters',$_GET['filter']);
}
/* Used to update a comment */
if($cid) {
if(isset($_POST['update_comment'])) {
$updated_comment = $_POST['comment'];
$cbvid->update_comment($cid,$updated_comment);
}
}
/* Getting comments and assigning smarty variables */
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,RESULTS);
$comment['limit'] = $get_limit;
$comments = $cbvideo->get_comments($comment);
assign("comments",$comments);
if($mode) {
assign('mode',$mode);
}
/* Pagination */
$ccount = $comment;
$ccount['count_only'] = true;
$total_rows = $cbvideo->get_comments($ccount);
$total_pages = count_pages($total_rows,RESULTS);
$pages->paginate($total_pages,$page);
subtitle("Comments");
template_files('comments.html');
display_it();
?>

View file

@ -0,0 +1,120 @@
<span class="page_title">Comments Manager</span>
<br />
{if $mode == '' || $mode == "list_comments"}
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="40" align="center" valign="middle" class="left_head">
<input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/></td>
<td width="50" class="head">CID</td>
<td class="head">Comment</td>
<td width="50" class="right_head">&nbsp;</td>
</tr>
</table>
<div style="clear:both; height:5px;"></div>
<a href="?filter=v" title="View Video Comments">View Video Comments</a> | <a href="?filter=t">View Topic Posts</a> | <a href="?filter=c">View Channel Comments</a>
{if $comments}
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
{foreach from=$comments item=comment}
{if $comment.anonym_name != ""}
{assign var=comment_owner value=$comment.anonym_name}
{else}
{assign var=comment_owner value=$userquery->get_user_details($comment.userid)}
{/if}
<tr class="video_opt_td" id="comment_{$comment.comment_id}" style="background-color:{if $comment.spam_votes > 0} #ffd7d7{else}{$bgcolor}{/if}">
<td width="40" align="center" valign="top" class="video_opt_td"><input name="check_comments[]" type="checkbox" id="check_comments" value="{$comment.comment_id}" /></td>
<td width="50" align="left" valign="top" class="video_opt_td">{$comment.comment_id}</td>
<td valign="top" class="video_opt_td" onmouseover="$('#comm_opt-{$comment.comment_id}').show()" onmouseout="$('#comm_opt-{$comment.comment_id}').hide()" >
{if $filters == '' || $filters == 'v'}
<span class="vdo_sets">
{if is_array($comment_owner)} <a href="{$userquery->profile_link($comment_owner)}"><strong>{$comment_owner.username}</strong></a> {else} <strong>{$comment_owner}</strong> {/if} commented on <strong>{$comment.date_added|date_format}</strong> on a video named <span style="text-transform:none"><a href="{videoLink vdetails=$comment}" title="{$comment.title}">{$comment.title|truncate:40}</a></span>
</span>
<div style="height:5px; clear:both;"></div>
<span style="font-size:11px;">{$comment.comment|truncate:150}</span><br />
<div id="comm_opt-{$comment.comment_id}" class="vid_opts" style="display:none">
<a href="{videoLink vdetails=$comment}#{if $comment.spam_votes > 0}spam_{/if}comment_{$comment.comment_id}" target="_blank">{lang code='view'} {lang code='comment'}</a> |
<a href="?mode=edit_comment&cid={$comment.comment_id}">{lang code='edit'|capitalize} {lang code='comment'}</a> |
<a href="#" id="spam_comment_{$comment.comment_id}" onclick="admin_spam_comment({$comment.comment_id}); return false;"{if $comment.spam_votes ==0} style="display:inline"{else} style="display:none;"{/if}>Mark {lang code='spam'}</a> <a href="#" id="remove_spam_comment_{$comment.comment_id}" onclick="admin_remove_spam({$comment.comment_id}); return false;"
{if $comment.spam_votes !=0} style="display:inline"{else} style="display:none;"{/if}>{lang code='remove'} {lang code='spam'}</a> |
<a href="#" onclick="delete_comment('{$comment.comment_id}','v'); return false;">{lang code='delete'}</a>
</div>
</td>
<td width="50" valign="top" class="video_opt_td">&nbsp;</td>
</tr>
{/if}
{if $filters == 't'}
<span class="vdo_sets">
{if is_array($comment_owner)} <a href="{$userquery->profile_link($comment_owner)}"><strong>{$comment_owner.username}</strong></a> {else} <strong>{$comment_owner}</strong> {/if} commented on <strong>{$comment.date_added|date_format}</strong> on a topic named <span style="text-transform:none"><a href="{$cbgroup->topic_link($comment)}" title="{$comment.topic_title}">{$comment.topic_title|truncate:40}</a></span>
</span>
<div style="height:5px; clear:both;"></div>
<span style="font-size:11px;">{$comment.comment|truncate:150}</span><br />
<div id="comm_opt-{$comment.comment_id}" class="vid_opts" style="display:none">
<a href="{$cbgroup->topic_link($comment)}#{if $comment.spam_votes > 0}spam_{/if}comment_{$comment.comment_id}" target="_blank">{lang code='view'} {lang code='comment'}</a> |
<a href="?mode=edit_comment&cid={$comment.comment_id}">{lang code='edit'|capitalize} {lang code='comment'}</a> |
<a href="#" id="spam_comment_{$comment.comment_id}" onclick="admin_spam_comment({$comment.comment_id}); return false;"{if $comment.spam_votes ==0} style="display:inline"{else} style="display:none;"{/if}>Mark {lang code='spam'}</a> <a href="#" id="remove_spam_comment_{$comment.comment_id}" onclick="admin_remove_spam({$comment.comment_id}); return false;"
{if $comment.spam_votes !=0} style="display:inline"{else} style="display:none;"{/if}>{lang code='remove'} {lang code='spam'}</a> |
<a href="#" onclick="delete_comment('{$comment.comment_id}','v'); return false;">{lang code='delete'}</a>
</div>
{/if}
{if $filters == 'c'}
<span class="vdo_sets">
{if is_array($comment_owner)} <a href="{$userquery->profile_link($comment_owner)}"><strong>{$comment_owner.username}</strong></a> {else} <strong>{$comment_owner}</strong> {/if} commented on <strong>{$comment.date_added|date_format}</strong> on a channel named <span style="text-transform:none"><a href="{$userquery->profile_link($comment)}" title="{$comment.username}">{$comment.username|truncate:40}</a></span>
</span>
<div style="height:5px; clear:both;"></div>
<span style="font-size:11px;">{$comment.comment|truncate:150}</span><br />
<div id="comm_opt-{$comment.comment_id}" class="vid_opts" style="display:none">
<a href="{$userquery->profile_link($comment)}#{if $comment.spam_votes > 0}spam_{/if}comment_{$comment.comment_id}" target="_blank">{lang code='view'} {lang code='comment'}</a> |
<a href="?mode=edit_comment&cid={$comment.comment_id}">{lang code='edit'|capitalize} {lang code='comment'}</a> |
<a href="#" id="spam_comment_{$comment.comment_id}" onclick="admin_spam_comment({$comment.comment_id}); return false;"{if $comment.spam_votes ==0} style="display:inline"{else} style="display:none;"{/if}>Mark {lang code='spam'}</a> <a href="#" id="remove_spam_comment_{$comment.comment_id}" onclick="admin_remove_spam({$comment.comment_id}); return false;"
{if $comment.spam_votes !=0} style="display:inline"{else} style="display:none;"{/if}>{lang code='remove'} {lang code='spam'}</a> |
<a href="#" onclick="delete_comment('{$comment.comment_id}','v'); return false;">{lang code='delete'}</a>
</div>
{/if}
{if $bgcolor == ""}
{assign var = bgcolor value = "#EEE"}
{else}
{assign var = bgcolor value = ""}
{/if}
{/foreach}
</table>
{/if}
<div style="height:10px; clear:both"></div>
{include file="$style_dir/blocks/pagination.html" }
{/if}
{if $mode == 'edit_comment'}
{assign var=cid value=$smarty.get.cid}
{assign var=comment value=$cbvid->get_comment($cid)}
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="5" valign="middle" class="left_head"></td>
<td width="10" class="head">&nbsp;</td>
<td class="head">Edit Comment</td>
<td width="50" class="right_head">&nbsp;</td>
</tr>
</table>
<div style="clear:both; height:5px;"></div>
<div></div>
<form action="" name="comment_moderation" id="comment_moderation" method="post">
{ANCHOR place='before_compose_box'}
<textarea name="comment" id="comment" style="padding:5px; font-size:11px; font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; background:#F0F0F0; border:1px solid #ccc; width:50%"rows="5" cols="45">{$comment.comment}</textarea>
<div style="height:10px;"></div>
<input type="submit" name="update_comment" id="update_comment" class="button" value="Update Comment" />
</form>
{/if}

View file

@ -210,6 +210,31 @@ class myquery {
return false;
}
/**
* Function used to set comment as spam
*/
function remove_spam($cid) {
global $db;
$comment = $this->get_comment($cid);
$vote = '0';
$none = '';
if($comment) {
$votes = $comment['spam_votes'];
if(!$votes) {
e(lang('Comment is not a spam'));
} elseif(!userid()) {
e(lang('login_to_mark_as_spam'));
} else {
$db->update(tbl('comments'),array('spam_votes','spam_voters'),array($vote,$none)," comment_id='$cid'");
e(lang('Spam removed from comment.'),"m");
}
} else {
e(lang('no_comment_exists'));
}
}
/**
* Function used to delete all comments of particlar object
*/
@ -751,7 +776,7 @@ class myquery {
case "u":
case "c":
{
if($obj['allow_comments'] == 'yes' && config('channel_comments')==1)
if($obj['allow_comments'] == 'Yes' && config('channel_comments')==1)
return true;
}
}

View file

@ -1077,24 +1077,107 @@ class CBvideo extends CBCategory
/**
* Function used get comments of videos
*/
function get_comments($type=NULL)
function get_comments($params=NULL)
{
global $db;
$cond = "";
$comtbl = tbl("comments");
$limit = $params['limit'];
$order = $params['order'];
$type = $params['type'];
if($type) {
$cond = " ".tbl("comments").".type='$type'";
}
$result = $db->select(tbl("comments"),"*",$cond);
if($result) {
return $result;
} else {
return false;
}
}
if($type)
$cond = " $comtbl.type = '$type'";
else
$cond = '';
switch($type) {
case 'v':
{
$sectbl = tbl('video');
$sectblName = 'video';
$secfields = $sectbl.".videokey,".$sectbl.".videoid,".$sectbl.".file_name,".$sectbl.".title";
if($cond) {
$cond .= " AND";
}
$cond .= " $comtbl.type_id = $sectbl.videoid";
}
break;
case 't':
{
$sectbl = tbl('group_topics');
$sectblName = 'group_topics';
$secfields = $sectbl.".topic_title,".$sectbl.".topic_id,".$sectbl.".topic_title";
if($cond) {
$cond .= " AND";
}
$cond .= " $comtbl.type_id = $sectbl.topic_id";
}
break;
case 'c':
{
$sectbl = tbl('users');
$sectblName = 'users';
$secfields = $sectbl.".username,".$sectbl.".userid";
if($cond) {
$cond .= " AND";
}
$cond .= " $comtbl.type_id = $sectbl.userid";
}
break;
default:
{
$sectbl = tbl('video');
$sectblName = 'video';
$secfields = $sectbl.".videokey,".$sectbl.".videoid,".$sectbl.".file_name,".$sectbl.".title";
if($cond) {
$cond .= " AND";
}
$cond .= " $comtbl.type_id = $sectbl.videoid";
}
}
if(!$params['count_only']) {
$result = $db->select(tbl("comments,".$sectblName.""),
"$comtbl.*,$secfields",
$cond,$limit,$order);
echo $db->db_query;
}
if($params['count_only'])
return $result = $db->count(tbl("comments,video"),"*",$cond);
else
return $result;
}
/**
* Function used get single comment
*/
function get_comment($cid) {
global $db;
$result = $db->select(tbl("comments"),"*", " comment_id = $cid");
if($result)
return $result[0];
else
return false;
}
/**
* Function used update comment
*/
function update_comment($cid,$comment) {
global $db;
if(!$comment) {
e(lang('usr_cmt_err1'),e);
} else {
$db->update(tbl("comments"),array("comment"),array($comment)," comment_id = $cid");
e(lang("Comment Updated"),m);
}
}
}
?>

View file

@ -3717,6 +3717,7 @@
$path = get_binaries($path);
$array = array();
$result = shell_output($path." -version");
if($result)
{
if($params['assign'])
@ -3750,8 +3751,12 @@
{
case 'ffmpeg':
{
preg_match("/svn-r([0-9]+)/i",$result,$matches);
return $matches[1];
preg_match("/svn-([0-9]+)/i",$result,$matches);
if(is_numeric($matches[1])) {
return $matches[1];
} else {
return false;
}
}
break;
case 'php':
@ -3762,13 +3767,21 @@
case 'flvtool2':
{
preg_match("/flvtool2 ([0-9\.]+)/i",$result,$matches);
return $matches[1];
if(is_numeric($matches[1])){
return $matches[1];
} else {
return false;
}
}
break;
case 'mp4box':
{
preg_match("/version ([0-9\.]+)/i",$result,$matches);
return $matches[1];
if(is_numeric($matches[1])){
return $matches[1];
} else {
return false;
}
}
}
}

View file

@ -75,4 +75,63 @@ function toggle_menu()
$.cookie("admin_menu","show");
}
}
}
function admin_spam_comment(cid)
{
$.post(page,
{
mode : 'spam_comment',
cid : cid
},
function(data)
{
if(!data)
alert("No data");
else
{
if(data.msg)
{
$("#comment_"+cid).css({'backgroundColor' : '#ffd7d7'});
$("#spam_comment_"+cid).fadeOut(350, function() {
$("#remove_spam_comment_"+cid).fadeIn(350);
});
}
if(data.err)
{
alert(data.err)
}
}
},'json');
}
function admin_remove_spam(cid)
{
$.post(page,
{
mode : 'remove_spam',
cid : cid
},
function(data)
{
if(!data)
alert("No data");
else
{
if(data.msg)
{
$("#comment_"+cid).css({'backgroundColor' : '#f3f3f3'});
$("#remove_spam_comment_"+cid).fadeOut(350, function() {
$("#spam_comment_"+cid).fadeIn(350);
});
}
if(data.err)
{
alert(data.err)
}
}
},'json');
}

View file

@ -7,7 +7,7 @@ function install_global_announcement()
{
global $db;
$db->Execute(
'CREATE TABLE IF NOT EXISTS `'.tbl("global_announcement").'` (
'CREATE TABLE IF NOT EXISTS '.tbl("global_announcement").' (
`announcement` text NOT NULL
) ENGINE=MyISAM;'
);

View file

@ -4,7 +4,7 @@
{
global $db;
$db->Execute(
'DROP TABLE `'.tbl("global_announcement").'`'
'DROP TABLE '.tbl("global_announcement").''
);
}