Модераторский комментарий/предупреждение в постах. (Вместо модераторского тега) Запросы к существующей БД: ALTER TABLE `bb_posts` ADD `post_mod_comment` TEXT NOT NULL DEFAULT ''; ALTER TABLE `bb_posts` ADD `post_mod_comment_type` TINYINT( 1 ) NOT NULL DEFAULT '0'; ALTER TABLE `bb_posts` ADD `post_mc_mod_id` mediumint(8) NOT NULL; ALTER TABLE `bb_posts` ADD `post_mc_mod_name` varchar(25) NOT NULL DEFAULT ''; git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@458 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
fly.dvorkin 2012-09-25 17:46:21 +00:00
commit b301f3672a
10 changed files with 133 additions and 4 deletions

View file

@ -947,6 +947,10 @@ CREATE TABLE IF NOT EXISTS `bb_posts` (
`post_attachment` tinyint(1) NOT NULL DEFAULT '0', `post_attachment` tinyint(1) NOT NULL DEFAULT '0',
`post_reported` tinyint(1) NOT NULL DEFAULT '0', `post_reported` tinyint(1) NOT NULL DEFAULT '0',
`user_post` tinyint(1) NOT NULL DEFAULT '1', `user_post` tinyint(1) NOT NULL DEFAULT '1',
`post_mod_comment` TEXT NOT NULL DEFAULT '',
`post_mod_comment_type` TINYINT( 1 ) NOT NULL DEFAULT '0',
`post_mc_mod_id` mediumint(8) NOT NULL,
`post_mc_mod_name` varchar(25) NOT NULL DEFAULT '',
PRIMARY KEY (`post_id`), PRIMARY KEY (`post_id`),
KEY `topic_id` (`topic_id`), KEY `topic_id` (`topic_id`),
KEY `poster_id` (`poster_id`), KEY `poster_id` (`poster_id`),

View file

@ -21,6 +21,7 @@ switch ($ajax->action)
break; break;
case 'posts': case 'posts':
case 'post_mod_comment':
require(INC_DIR .'bbcode.php'); require(INC_DIR .'bbcode.php');
require(INC_DIR .'functions_post.php'); require(INC_DIR .'functions_post.php');
require(INC_DIR .'functions_admin.php'); require(INC_DIR .'functions_admin.php');
@ -87,6 +88,7 @@ class ajax_common
'posts' => array('guest'), 'posts' => array('guest'),
'index_data' => array('guest'), 'index_data' => array('guest'),
'post_mod_comment' => array('mod'),
); );
var $action = null; var $action = null;
@ -447,6 +449,31 @@ class ajax_common
} }
} }
function post_mod_comment ()
{
global $lang, $user;
$post_id = (int) $this->request['post_id'];
$post = DB()->fetch_row("SELECT t.*, f.*, p.*, pt.post_text
FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f, ". BB_POSTS ." p, ". BB_POSTS_TEXT ." pt
WHERE p.post_id = $post_id
AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
AND p.post_id = pt.post_id
LIMIT 1");
if(!$post) $this->ajax_die('not post');
$type = (int) $this->request['mc_type'];
$text = (string) $this->request['mc_text'];
$text = prepare_message($text);
if (!$text) $this->ajax_die('no text');
DB()->query("UPDATE ". BB_POSTS ." SET post_mod_comment = '". DB()->escape($text) ."', post_mod_comment_type = $type, post_mc_mod_id = ". $user->id .", post_mc_mod_name = '". $user->data['username'] ."' WHERE post_id = $post_id LIMIT 1");
$this->response['type'] = $type;
$this->response['post_id'] = $post_id;
if ($type == 0) $this->response['html'] = '';
else if ($type == 1) $this->response['html'] = '<div class="mcBlock"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="mcTd1C">K</td><td class="mcTd2C"><a href="profile.php?mode=viewprofile&u='. $user->id .'">'. $user->data['username'] .'</a> '. $lang['WROTE'] .':<br /><br />'. bbcode2html($text) .'</td></tr></table></div>';
else if ($type == 2) $this->response['html'] = '<div class="mcBlock"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="mcTd1W">!</td><td class="mcTd2W"><a href="profile.php?mode=viewprofile&u='. $user->id .'">'. $user->data['username'] .'</a> '. $lang['WROTE'] .':<br /><br />'. bbcode2html($text) .'</td></tr></table></div>';
}
function view_post () function view_post ()
{ {
require(AJAX_DIR .'view_post.php'); require(AJAX_DIR .'view_post.php');

View file

@ -1740,5 +1740,7 @@ $lang['INDEX_RETURN'] = 'Back to home page';
$lang['FORUM_RETURN'] = 'Back to Forum'; $lang['FORUM_RETURN'] = 'Back to Forum';
$lang['TOPIC_RETURN'] = 'Back to the topic'; $lang['TOPIC_RETURN'] = 'Back to the topic';
$lang['POST_RETURN'] = 'Go to post'; $lang['POST_RETURN'] = 'Go to post';
$lang['PROFILE_EDIT_RETURN'] = 'Return to editing'; $lang['PROFILE_EDIT_RETURN'] = 'Return to editing';
$lang['PROFILE_RETURN'] = 'Go to the Profile'; $lang['PROFILE_RETURN'] = 'Go to the Profile';
$lang['WARNING'] = 'Warning';

View file

@ -1749,5 +1749,7 @@ $lang['INDEX_RETURN'] = 'Вернуться на главную';
$lang['FORUM_RETURN'] = 'Вернуться в форум'; $lang['FORUM_RETURN'] = 'Вернуться в форум';
$lang['TOPIC_RETURN'] = 'Вернуться в тему'; $lang['TOPIC_RETURN'] = 'Вернуться в тему';
$lang['POST_RETURN'] = 'Перейти к сообщению'; $lang['POST_RETURN'] = 'Перейти к сообщению';
$lang['PROFILE_EDIT_RETURN'] = 'Вернуться к редактированию'; $lang['PROFILE_EDIT_RETURN'] = 'Вернуться к редактированию';
$lang['PROFILE_RETURN'] = 'Перейти к просмотру профиля'; $lang['PROFILE_RETURN'] = 'Перейти к просмотру профиля';
$lang['WARNING'] = 'Предупреждение';

View file

@ -918,6 +918,11 @@ a.menu-root, a.menu-root:visited, a.menu-root:hover {
.menu-a { background: #FFFFFF; border: 1px solid #92A3A4; } .menu-a { background: #FFFFFF; border: 1px solid #92A3A4; }
.menu-a a { color: #0000A0; background: #E7E7E7; padding: 4px 10px 5px; margin: 1px; display: block; text-decoration: none !important; } .menu-a a { color: #0000A0; background: #E7E7E7; padding: 4px 10px 5px; margin: 1px; display: block; text-decoration: none !important; }
.menu-a a:hover { color: #0000FF; background: #D1D7DC; text-decoration: none !important; } .menu-a a:hover { color: #0000FF; background: #D1D7DC; text-decoration: none !important; }
.mc{ background:#E7E7E7; padding:5px; font-size:11px;}
.mc-bord{ background:#fff; padding:1px; border:1px solid #92A3A4;}
.mc-th{ background:#71869F; color:#F0F8FF; padding:4px; border-bottom:1px solid #fff; font-weight:bold; font-size:11px; text-align:center;}
.mc-but{ background:#B5BEC3; padding:4px; border-top:1px solid #fff; text-align:center;}
/* ================================================================ * /* ================================================================ *
Ajax Ajax
* ================================================================ */ * ================================================================ */
@ -1332,3 +1337,26 @@ span.YTLink a.postLink{
color:white; color:white;
float:left; float:left;
} }
/* Mod comment */
.mcBlock{
border:1px solid #92a3a4; width:90%; margin:30px 0 0 30px; padding:4px;
border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px;
box-shadow:0px 0px 5px #999; -moz-box-shadow:0px 0px 5px #999; -webkit-box-shadow:0px 0px 5px #999;
}
.mcBlock table{ width:100%;}
.mcTd1C, .mcTd1W{
width:50px;
font:45px Georgia, serif; color:#e7e7e7; font-weight:bold;
border:1px solid #eff0f3;
padding:2px 0 0;
text-align:center;
}
.mcTd2C, .mcTd2W{ background:#e7e7e7 !important; border:1px solid #e1e1e1; padding:10px;}
.mcTd1C{ background:#71869f !important; border:1px solid #536479; text-shadow:0 0 10px #1d232c;}
.mcTd2C{ color:#262e37;}
.mcTd1W{ background:#751717 !important; border:1px solid #5e0000; text-shadow:0 0 10px #200000;}
.mcTd2W{ color:#3e0000;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -22,6 +22,8 @@ $images['icon_mod'] = $_main .'icon_mod.gif';
$images['icon_www'] = $_lang .'icon_www.gif'; $images['icon_www'] = $_lang .'icon_www.gif';
$images['icon_icq'] = $_lang .'icon_icq_add.gif'; $images['icon_icq'] = $_lang .'icon_icq_add.gif';
$images['icon_mc'] = $_lang .'icon_mc.gif';
$images['icon_birthday'] = $_main .'icon_birthday.gif'; $images['icon_birthday'] = $_main .'icon_birthday.gif';
$images['icon_male'] = $_main .'icon_male.gif'; $images['icon_male'] = $_main .'icon_male.gif';
$images['icon_female'] = $_main .'icon_female.gif'; $images['icon_female'] = $_main .'icon_female.gif';
@ -142,6 +144,7 @@ if (!empty($page_cfg['load_tpl_vars']) AND $vars = array_flip($page_cfg['load_tp
'DELETE_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['DELETE_POST_TXTB'] : '<img src="'. $images['icon_delpost'] .'" alt="'.$lang['DELETE_POST_TXTB'].'" title="'. $lang['DELETE_POST'] .'" />', 'DELETE_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['DELETE_POST_TXTB'] : '<img src="'. $images['icon_delpost'] .'" alt="'.$lang['DELETE_POST_TXTB'].'" title="'. $lang['DELETE_POST'] .'" />',
'IP_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['VIEW_IP_TXTB'] : '<img src="'. $images['icon_ip'] .'" alt="'.$lang['VIEW_IP_TXTB'].'" title="'. $lang['VIEW_IP'] .'" />', 'IP_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['VIEW_IP_TXTB'] : '<img src="'. $images['icon_ip'] .'" alt="'.$lang['VIEW_IP_TXTB'].'" title="'. $lang['VIEW_IP'] .'" />',
'MOD_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['MODERATE_POST_TXTB'] : '<img src="'. $images['icon_mod'] .'" alt="'.$lang['MODERATE_POST_TXTB'].'" title="'. $lang['MODERATE_POST'] .'" />', 'MOD_POST_IMG' => ($bb_cfg['text_buttons']) ? $lang['MODERATE_POST_TXTB'] : '<img src="'. $images['icon_mod'] .'" alt="'.$lang['MODERATE_POST_TXTB'].'" title="'. $lang['MODERATE_POST'] .'" />',
'MC_IMG' => ($bb_cfg['text_buttons']) ? 'Comment' : '<img src="'. $images['icon_mc'] .'" alt="Comment" title="Comment" />',
'QUOTE_URL' => BB_ROOT ."posting.php?mode=quote&amp;p=", 'QUOTE_URL' => BB_ROOT ."posting.php?mode=quote&amp;p=",
'EDIT_POST_URL' => BB_ROOT ."posting.php?mode=editpost&amp;p=", 'EDIT_POST_URL' => BB_ROOT ."posting.php?mode=editpost&amp;p=",

View file

@ -118,6 +118,34 @@ ajax.callback.mod_action = function(data) {
$tt_td.html(ajax.tte_orig_html); $tt_td.html(ajax.tte_orig_html);
$('.tt-text', $tt_td).html(data.topic_title); $('.tt-text', $tt_td).html(data.topic_title);
} }
ajax.post_mod_comment = function(post_id, mc_text) {
if ($('#mc_type_'+post_id+'_0').attr('checked') == 'checked') {
var mc_type = 0;
}
else if ($('#mc_type_'+post_id+'_1').attr('checked') == 'checked') {
var mc_type = 1;
}
else if ($('#mc_type_'+post_id+'_2').attr('checked') == 'checked') {
var mc_type = 2;
}
ajax.exec({
action : 'post_mod_comment',
post_id : post_id,
mc_type : mc_type,
mc_text : mc_text
});
}
ajax.callback.post_mod_comment = function(data) {
if (data.type == 0) {
$('#pc_'+ data.post_id).html('');
}
else if (data.type == 1) {
$('#pc_'+ data.post_id).html(data.html);
}
else if (data.type == 2) {
$('#pc_'+ data.post_id).html(data.html);
}
}
</script> </script>
<a style="cursor: help; color: #800000;" title="{L_EDIT_TOPIC_TITLE}" onclick="edit_topic_title('edit'); return false" href="#">&para;</a> <a style="cursor: help; color: #800000;" title="{L_EDIT_TOPIC_TITLE}" onclick="edit_topic_title('edit'); return false" href="#">&para;</a>
@ -267,6 +295,25 @@ ajax.callback.mod_action = function(data) {
</tr> </tr>
<!-- BEGIN postrow --> <!-- BEGIN postrow -->
<!-- IF AUTH_MOD -->
<div class="menu-sub" id="mc_{postrow.POST_ID}">
<div class="nowrap mc-bord">
<p class="mc-th">{L_COMMENT}</p>
<div class="nowrap mc">
<input type="radio" name="mc_type_{postrow.POST_ID}" id="mc_type_{postrow.POST_ID}_0" value="0" <!-- IF postrow.POST_MC_TYPE == 0 -->checked="checked"<!-- ENDIF --> /> {L_DELETE} {L_COMMENT} <br />
<input type="radio" name="mc_type_{postrow.POST_ID}" id="mc_type_{postrow.POST_ID}_1" value="1" <!-- IF postrow.POST_MC_TYPE == 1 -->checked="checked"<!-- ENDIF --> /> {L_COMMENT} <br />
<input type="radio" name="mc_type_{postrow.POST_ID}" id="mc_type_{postrow.POST_ID}_2" value="2" <!-- IF postrow.POST_MC_TYPE == 2 -->checked="checked"<!-- ENDIF --> /> {L_WARNING} <br />
<textarea name="mc_text_{postrow.POST_ID}" cols="40" rows="3" id="mc_text_{postrow.POST_ID}"></textarea>
<script type="text/javascript">
$('#mc_text_{postrow.POST_ID}').val("{postrow.POST_MC_BBCODE}");
</script>
</div>
<div class="mc-but">
<input type="button" style="width:100px; cursor:pointer;" value="{L_SUBMIT}" onclick="ajax.post_mod_comment({postrow.POST_ID}, $('#mc_text_{postrow.POST_ID}').val());" />
</div>
</div>
</div>
<!-- ENDIF -->
<tbody id="post_{postrow.POST_ID}" class="{postrow.ROW_CLASS}"> <tbody id="post_{postrow.POST_ID}" class="{postrow.ROW_CLASS}">
<tr> <tr>
<td class="poster_info td1"><a name="{postrow.POST_ID}"></a><!-- IF postrow.IS_NEWEST --><a name="newest"></a><!-- ENDIF --> <td class="poster_info td1"><a name="{postrow.POST_ID}"></a><!-- IF postrow.IS_NEWEST --><a name="newest"></a><!-- ENDIF -->
@ -311,6 +358,7 @@ ajax.callback.mod_action = function(data) {
<!-- IF postrow.MOD_CHECKBOX --><input type="checkbox" class="select_post" onclick="set_hid_chbox('{postrow.POST_ID}');"><!-- ENDIF --> <!-- IF postrow.MOD_CHECKBOX --><input type="checkbox" class="select_post" onclick="set_hid_chbox('{postrow.POST_ID}');"><!-- ENDIF -->
<p style="float: right;<!-- IF TEXT_BUTTONS --> padding: 3px 2px 4px;<!-- ELSE --> padding: 1px 6px 2px;<!-- ENDIF -->" class="post_btn_1"> <p style="float: right;<!-- IF TEXT_BUTTONS --> padding: 3px 2px 4px;<!-- ELSE --> padding: 1px 6px 2px;<!-- ENDIF -->" class="post_btn_1">
<!-- IF AUTH_MOD --><a class="txtb menu-root" href="#mc_{postrow.POST_ID}">{MC_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF -->
<!-- IF postrow.QUOTE --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="ajax.exec({ action: 'posts', post_id: {postrow.POST_ID}, type: 'reply'}); return false;<!-- ELSE -->{QUOTE_URL}{postrow.POST_ID}<!-- ENDIF -->">{QUOTE_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF --> <!-- IF postrow.QUOTE --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="ajax.exec({ action: 'posts', post_id: {postrow.POST_ID}, type: 'reply'}); return false;<!-- ELSE -->{QUOTE_URL}{postrow.POST_ID}<!-- ENDIF -->">{QUOTE_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF -->
<!-- IF postrow.EDIT --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="edit_post({postrow.POST_ID}, 'edit'); return false;<!-- ELSE -->{EDIT_POST_URL}{postrow.POST_ID}<!-- ENDIF -->">{EDIT_POST_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF --> <!-- IF postrow.EDIT --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="edit_post({postrow.POST_ID}, 'edit'); return false;<!-- ELSE -->{EDIT_POST_URL}{postrow.POST_ID}<!-- ENDIF -->">{EDIT_POST_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF -->
<!-- IF postrow.DELETE --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="ajax.exec({ action: 'posts', post_id: {postrow.POST_ID}, type: 'delete'}); return false;<!-- ELSE -->{DELETE_POST_URL}{postrow.POST_ID}<!-- ENDIF -->">{DELETE_POST_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF --> <!-- IF postrow.DELETE --><a class="txtb" href="<!-- IF $bb_cfg['use_ajax_posts'] -->" onclick="ajax.exec({ action: 'posts', post_id: {postrow.POST_ID}, type: 'delete'}); return false;<!-- ELSE -->{DELETE_POST_URL}{postrow.POST_ID}<!-- ENDIF -->">{DELETE_POST_IMG}</a>{POST_BTN_SPACER}<!-- ENDIF -->
@ -326,6 +374,7 @@ ajax.callback.mod_action = function(data) {
<div class="post_body"> <div class="post_body">
<div class="post_wrap"> <div class="post_wrap">
<span id="pp_{postrow.POST_ID}">{postrow.MESSAGE}</span> <span id="pp_{postrow.POST_ID}">{postrow.MESSAGE}</span>
<div id="pc_{postrow.POST_ID}">{postrow.POST_MOD_COMMENT}</div>
<span id="pe_{postrow.POST_ID}"></span> <span id="pe_{postrow.POST_ID}"></span>
{postrow.ATTACHMENTS} {postrow.ATTACHMENTS}
</div><!--/post_wrap--> </div><!--/post_wrap-->

View file

@ -988,6 +988,16 @@ for($i = 0; $i < $total_posts; $i++)
break; break;
} }
$post_mod_comment_html = '';
if ($postrow[$i]['post_mod_comment_type'] == 1)
{
$post_mod_comment_html = '<div class="mcBlock"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="mcTd1C">K</td><td class="mcTd2C"><a href="profile.php?mode=viewprofile&u='. $postrow[$i]['post_mc_mod_id'] .'">'. $postrow[$i]['post_mc_mod_name'] .'</a> '. $lang['WROTE'] .':<br /><br />'. bbcode2html($postrow[$i]['post_mod_comment']) .'</td></tr></table></div>';
}
else if ($postrow[$i]['post_mod_comment_type'] == 2)
{
$post_mod_comment_html = '<div class="mcBlock"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="mcTd1W">!</td><td class="mcTd2W"><a href="profile.php?mode=viewprofile&u='. $postrow[$i]['post_mc_mod_id'] .'">'. $postrow[$i]['post_mc_mod_name'] .'</a> '. $lang['WROTE'] .':<br /><br />'. bbcode2html($postrow[$i]['post_mod_comment']) .'</td></tr></table></div>';
}
$template->assign_block_vars('postrow', array( $template->assign_block_vars('postrow', array(
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POST_ID' => $postrow[$i]['post_id'], 'POST_ID' => $postrow[$i]['post_id'],
@ -1026,6 +1036,10 @@ for($i = 0; $i < $total_posts; $i++)
'REPORT' => ($bb_cfg['text_buttons']) ? $report : $report_img, 'REPORT' => ($bb_cfg['text_buttons']) ? $report : $report_img,
'POSTER_BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $this_date == $poster_birthday) ? '<img src="'. $images['icon_birthday'] .'" alt="" title="'. $lang['HAPPY_BIRTHDAY'] .'" border="0" />' : '', 'POSTER_BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $this_date == $poster_birthday) ? '<img src="'. $images['icon_birthday'] .'" alt="" title="'. $lang['HAPPY_BIRTHDAY'] .'" border="0" />' : '',
'POST_MOD_COMMENT' => ($postrow[$i]['post_mod_comment'] && $postrow[$i]['post_mod_comment_type']) ? $post_mod_comment_html : '',
'POST_MC_BBCODE' => str_replace("\n", '\n', $postrow[$i]['post_mod_comment']),
'POST_MC_TYPE' => $postrow[$i]['post_mod_comment_type'],
)); ));
if ($postrow[$i]['post_attachment'] && $is_auth['auth_download'] && function_exists('display_post_attachments')) if ($postrow[$i]['post_attachment'] && $is_auth['auth_download'] && function_exists('display_post_attachments'))