1. Добавляем BBcod. Идем в Администраторский раздел -> вкладка Сообщения -> BBCodes -> Добавить BBCode
При создании BBCode не отмечайте опцию Показывать на странице ответа (что бы пользователи не видели эти кнопки), от использования вручную написанного кода это не спасет . Решение этой проблемы опишу ниже
Сообщение Администратора:
Использование BBCode
Код: Выделить всё
[am={TEXT1}]{TEXT2}[/am]
Код: Выделить всё
<table cellspacing='0px' cellpadding='0px' style='width: 100%; border: 1px solid #0084FF; border-left: 4px solid #0084FF; vertical-align: middle;'>
<tr style='height: 40px; line-height: 40px;'>
<td style='background-color: #e7eef7; padding-left:10px; font-size: 10px;' width='95%'>Сообщение Администратора: <b><a class="postauthor" style="color: #aa0000;" href="memberlist.php?mode=viewprofile&un={TEXT1}">{TEXT1}</a></b></td>
<td style='max-width: 40px; width: 40px; text-align: center; background-color: #0084FF;; font-size: 36px; color: white;'>
A</td>
</tr>
<tr style='line-height: 40px;'>
<td colspan='2' style='padding-left:10px; background-color: #f4f4f4; color: #0084FF; font-size: 12px; font-weight: bold;'>{TEXT2}</td>
</tr>
</table>
Предупреждение Администратора:
Использование BBCode
Код: Выделить всё
[aw={TEXT1}]{TEXT2}[/aw]
Код: Выделить всё
<table cellspacing='0px' cellpadding='0px' style='width: 100%; border: 1px solid red; border-left: 4px solid red; vertical-align: middle;'>
<tr style='height: 40px; line-height: 40px;'>
<td style='background-color: #f7eee7; padding-left:10px; font-size: 10px;' width='95%'>Предупреждение от Администратора: <b><a class="postauthor" style="color: #aa0000" href="memberlist.php?mode=viewprofile&un={TEXT1}">{TEXT1}</a></b></td>
<td style='max-width: 40px; width: 40px; text-align: center; background-color: red; font-size: 36px; color: white;'>!!</td>
</tr>
<tr style='line-height: 40px;'>
<td colspan='2' style='padding-left:10px; background-color: #f4f4f4; color: red; font-size: 12px; font-weight: bold;'>{TEXT2}</td>
</tr>
</table>
Сообщение модератора:
Использование BBCode
Код: Выделить всё
[mm={TEXT1}]{TEXT2}[/mm]
Код: Выделить всё
<table cellspacing='0px' cellpadding='0px' style='width: 100%; border: 1px solid #0084FF; border-left: 4px solid #0084FF; vertical-align: middle;'>
<tr style='height: 40px; line-height: 40px;'>
<td style='background-color: #e7eef7; padding-left:10px; font-size: 10px;' width='95%'>Сообщение модератора: <b><a class="postauthor" style="color: #663333" href="memberlist.php?mode=viewprofile&un={TEXT1}">{TEXT1}</a></b></td>
<td style='max-width: 40px; width: 40px; text-align: center; background-color: #0084FF;; font-size: 36px; color: white;'>
М</td>
</tr>
<tr style='line-height: 40px;'>
<td colspan='2' style='padding-left:10px; background-color: #f4f4f4; color: #0084FF; font-size: 12px; font-weight: bold;'>{TEXT2}</td>
</tr>
</table>
Предупреждение модератора:
Использование BBCode
Код: Выделить всё
[mw={TEXT1}]{TEXT2}[/mw]
Код: Выделить всё
<table cellspacing='0px' cellpadding='0px' style='width: 100%; border: 1px solid red; border-left: 4px solid red; vertical-align: middle;'>
<tr style='height: 40px; line-height: 40px;'>
<td style='background-color: #f7eee7; padding-left:10px; font-size: 10px;' width='95%'>Предупреждение от модератора: <b><a class="postauthor" style="color: #663333" href="memberlist.php?mode=viewprofile&un={TEXT1}">{TEXT1}</a></b></td>
<td style='max-width: 40px; width: 40px; text-align: center; background-color: red; font-size: 36px; color: white;'>!</td>
</tr>
<tr style='line-height: 40px;'>
<td colspan='2' style='padding-left:10px; background-color: #f4f4f4; color: red; font-size: 12px; font-weight: bold;'>{TEXT2}</td>
</tr>
</table>
2. Делаем видимыми кнопки для администраторов и модератов
Открыть ./styles/prosilver (subsilver2)/template/posting_buttons.html
Найти:
Код: Выделить всё
var imageTag = false;
Код: Выделить всё
// admin/moderator messages
function BBaw()
{
var FoundErrors = '';
var enterUsername = prompt("Введите ваш ник", "");
var enterText = prompt("Введите ваше сообщение", "Text");
if (!enterUsername) {
FoundErrors += "Вы не ввели свой ник.";
}
if (!enterText)
{
FoundErrors += " Вы не ввели сообщение.";
}
if (FoundErrors)
{
alert("Error : "+FoundErrors);
return;
}
var bbtags = "[aw="+enterUsername+"]"+enterText+"[/aw]";
document.forms[form_name].elements[text_name].value+=bbtags;
document.forms[form_name].elements[text_name].focus();
}
function BBam()
{
var FoundErrors = '';
var enterUsername = prompt("Введите ваш ник", "");
var enterText = prompt("Введите ваше сообщение", "Text");
if (!enterUsername) {
FoundErrors += "Вы не ввели свой ник.";
}
if (!enterText)
{
FoundErrors += " Вы не ввели сообщение.";
}
if (FoundErrors)
{
alert("Error : "+FoundErrors);
return;
}
var bbtags = "[am="+enterUsername+"]"+enterText+"[/am]";
document.forms[form_name].elements[text_name].value+=bbtags;
document.forms[form_name].elements[text_name].focus();
}
function BBmm()
{
var FoundErrors = '';
var enterUsername = prompt("Введите ваш ник", "");
var enterText = prompt("Введите ваше сообщение", "Text");
if (!enterUsername) {
FoundErrors += "Вы не ввели свой ник.";
}
if (!enterText)
{
FoundErrors += " Вы не ввели сообщение.";
}
if (FoundErrors)
{
alert("Error : "+FoundErrors);
return;
}
var bbtags = "[mm="+enterUsername+"]"+enterText+"[/mm]";
document.forms[form_name].elements[text_name].value+=bbtags;
document.forms[form_name].elements[text_name].focus();
}
function BBmw()
{
var FoundErrors = '';
var enterUsername = prompt("Введите ваш ник", "");
var enterText = prompt("Введите ваше сообщение", "Text");
if (!enterUsername) {
FoundErrors += "Вы не ввели свой ник.";
}
if (!enterText)
{
FoundErrors += " Вы не ввели сообщение.";
}
if (FoundErrors)
{
alert("Error : "+FoundErrors);
return;
}
var bbtags = "[mw="+enterUsername+"]"+enterText+"[/mw]";
document.forms[form_name].elements[text_name].value+=bbtags;
document.forms[form_name].elements[text_name].focus();
}
Код: Выделить всё
<!-- IF S_BBCODE_FLASH -->
<input type="button" class="btnbbcode" accesskey="d" name="addbbcode18" value="Flash" onclick="bbstyle(18)" onmouseover="helpline('d')" onmouseout="helpline('tip')" />
<!-- ENDIF -->
Код: Выделить всё
<!-- IF U_ACP -->
<span><a href="#" title="Администраторские теги" onclick="
obj=this.parentNode.childNodes[1].style;
tmp=(obj.display!='block') ? 'block' : 'none';
obj.display=tmp;
return false;"><input type="button" class="btnbbcode" value="Admin_tags"></a><div style="display: none">
<br>
<input type="button" class="btnbbcode" value="am=" onmouseover="helpline('g')" style="text-decoration: underline; width: 40px" onclick="BBam()" title="Сообщение администратора" />
<input type="button" class="btnbbcode" value="aw=" onmouseover="helpline('h')" style="text-decoration: underline; width: 40px" onclick="BBaw()" title="Предупреждение администратора" />
<br><br>
</div></span>
<!-- ENDIF -->
<!-- IF U_MCP -->
<span><a href="#" title="Модераторские теги" onclick="
obj=this.parentNode.childNodes[1].style;
tmp=(obj.display!='block') ? 'block' : 'none';
obj.display=tmp;
return false;"><input type="button" class="btnbbcode" value="Moder_tags"></a><div style="display: none">
<br>
<input type="button" class="btnbbcode" value="mm=" onmouseover="helpline('k')" style="text-decoration: underline; width: 40px" onclick="BBmm()" title="Сообщение модератора" />
<input type="button" class="btnbbcode" value="mw=" onmouseover="helpline('j')" style="text-decoration: underline; width: 40px" onclick="BBmw()" title="Предупреждение модератора" />
</div></span>
<!-- ENDIF -->
Кнопки добавлены, выглядит это так
3. Запрещаем использовать ббкод всем кроме определенных групп
т.е. если пользователь или кто либо другой кому запрещено использовать ббкод, наберет в сообщении его вручную и нажмет отправить
появится предупреждение "Вы не можете использовать некоторые BBCode:"
Открыть includes / message_parser.php
Найти
Код: Выделить всё
// Parse smilies
if ($allow_smilies)
{
$this->smilies($config['max_' . $mode . '_smilies']);
}
Код: Выделить всё
// Custom BBCode Rights
global $phpbb_root_path, $phpEx, $template;
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// ------------------------
$group_id = array(5,32);
// -----------------------
$users_id = $user->data['user_id'];
$group_in = group_memberships($group_id, $users_id , true);
if ($group_in !== true){
// ------------------------------------
$forbid = array('am=', 'aw=', 'mm=', 'mw=');
// -------------------------------------
foreach ($forbid as $not_allowed){
$this->bbcodes[$not_allowed]['disabled'] = true;}
$template->assign_vars(array('S_NO_BBCODE_BUTTON' => true));}
// Custom BBCode Rights
в $forbid = array('am=', 'aw=', 'mm=', 'mw='); можно при желании добавить свои ббкоды, к примеру: $forbid = array('am=', 'aw=', 'mm=', 'mw=', 'center');
4. Вырезаем наш ббкод при цитировании поста
Открыть posting.php
Найти
Код: Выделить всё
$post_data['post_text'] = $message_parser->message;
Заменить
Код: Выделить всё
// Custom BBCode Rights
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// ----------------------
$group_id = array(5,32);
// ----------------------
$users_id = $user->data['user_id'];
$group_in = group_memberships($group_id, $users_id , true);
if ($group_in !== true){
if ($mode == 'quote' or $mode == 'reply'){
// -----------------------------------
$forbid = array('mw', 'mm', 'am', 'aw');
// -----------------------------------
foreach ($forbid as $forbid_bb){
if (preg_match("/\[$forbid_bb\b(.*?)\](.*?)\[\/$forbid_bb\b(.*?)\]/s", $message_parser->message)){
$forbid_show = implode(",", $forbid);
$error[] = $user->lang['BBCODE_EXTRACTED'] . " $forbid_show1";}
$search_bb[] = "/\[$forbid_bb\b(.*?)\](.*?)\[\/$forbid_bb\b(.*?)\]/s";
$replac_bb[] = '';
$custom_lite = preg_replace($search_bb, $replac_bb, $message_parser->message);
$post_data['post_text'] = $custom_lite;}}
else{$post_data['post_text'] = $message_parser->message;}}
else{$post_data['post_text'] = $message_parser->message;}
// Custom BBCode Rights
в $group_id = array(5,32); вносим или изменяем ID групп
Вроде бы все , теоретически вполне хватит запрета на использование ббкода п.3, но лучше его еще вырезать при цитировании сообщения с нашим ббкодом, что бы не было всяких лишних и не нужных кодов.
Все это выглядит так
что не получилось сделать, а хотелось бы , при вставке кода автоматически добавлялся ник и время того кто добавляет сообщение пример http://www.ppkbb3cker.ru/viewtopic.php?t=91, но там для PHPBB2, может кто знает как сделать для PHPBB3?, пытался сделать на основе "кто редактировал сообщение", в includes/functions_posting.php
есть
Код: Выделить всё
case 'edit_topic':
// If edit reason is given always display edit info
// If editing last post then display no edit info
// If m_edit permission then display no edit info
// If normal edit display edit info
// Display edit info if edit reason given or user is editing his post, which is not the last within the topic.
if ($data['post_edit_reason'] || (!$auth->acl_get('m_edit', $data['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post')))
{
$data['post_edit_reason'] = truncate_string($data['post_edit_reason'], 255, 255, false);
$sql_data[POSTS_TABLE]['sql'] = array(
'post_edit_time' => $current_time,
'post_edit_reason' => $data['post_edit_reason'],
'post_edit_user' => (int) $data['post_edit_user'],
);
$sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1';
}
else if (!$data['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data['forum_id']))
{
$sql_data[POSTS_TABLE]['sql'] = array(
'post_edit_reason' => '',
);
}