Topic: Благодарности за сообщения - Thank For Posts
Расширение Thank For Posts позволяет благодарить пользователей за сообщение. Благодарность в виде кнопки "Спасибо", отображается под аватаркой в каждом посте. Если спасибо не сказано, то отображена кнопка, если посетитель уже благодарил, то появится счетчик благодарностей.
{Тестирование}
Структура расширения Thank For Posts
pan_thanks_for_posts/manifest.xml
pan_thanks_for_posts/img/button_thank.png
pan_thanks_for_posts/lang/English.php
pan_thanks_for_posts/lang/Russian.php
manifest.xml
▼Spoiler
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">
<!--
/**
* Thank For Posts
* @copyright Copyright (C) 2015 PanBB
* @license http://www.gnu.org/licenses/gpl.html GPL
* @package pan_thanks_for_posts
* @website https://punbb.softplaza.net
*/
-->
<extension engine="1.0">
<id>pan_thanks_for_posts</id>
<title>Thank For Posts</title>
<version>1.2</version>
<description>Позволяет благодарить всех посетителей за сообщения (под аватаром).</description>
<author>PunBB</author>
<minversion>1.4.0</minversion>
<maxtestedon>1.4.2</maxtestedon>
<install>
<![CDATA[
$forum_db->add_field('posts', 'thanks_last_ip', 'VARCHAR(39)', false, '0.0.0.0');
$forum_db->add_field('posts', 'thanks_count', 'MEDIUMINT(8) UNSIGNED', false, '0');
]]>
</install>
<uninstall>
<![CDATA[
$forum_db->drop_field('posts', 'thanks_last_ip');
$forum_db->drop_field('posts', 'thanks_count');
]]>
</uninstall>
<hooks>
<hook id="vt_start">
<![CDATA[
if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
else
require $ext_info['path'].'/lang/English.php';
]]>
</hook>
<hook id="vt_qr_get_posts">
<![CDATA[
$query['SELECT'] .= ', p.thanks_last_ip, p.thanks_count';
]]>
</hook>
<hook id="vt_main_output_start">
<![CDATA[
$pan_visitor_ip = $_SERVER['REMOTE_ADDR'];
$thanks_pid = isset($_POST['thanks_pid']) ? intval($_POST['thanks_pid']) : 0;
if (isset($_POST['add_thanks_form_sent']) && $_POST['add_thanks_form_sent'] == 1)
{
$query = array(
'UPDATE' => 'posts',
'SET' => 'thanks_count=thanks_count+1, thanks_last_ip=\''.$forum_db->escape($pan_visitor_ip).'\'',
'WHERE' => 'id=\''.$forum_db->escape($thanks_pid).'\''
);
$forum_db->query_build($query) or error(__FILE__, __LINE__);
echo '<meta http-equiv="Refresh" content="1; URL='.forum_link($forum_url['topic'], $id).'">' ;
}
]]>
</hook>
<hook id="vt_row_pre_post_contacts_merge">
<![CDATA[
$query = array(
'SELECT' => 'SUM(thanks_count)',
'FROM' => 'posts',
'WHERE' => 'poster=poster'
);
$result2 = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$thanks_sum = $forum_db->result($result2);
$pun_add_thanks_form_action = forum_link($forum_url['topic'], $id);
if ($cur_post['thanks_last_ip'] == $pan_visitor_ip)
{
$forum_page['author_info']['thanks_count'] = $lang_pan_thanks_for_posts['Thanks'].' '.$cur_post['thanks_count'].'/'.$thanks_sum['thanks_count'];
} else {
$forum_page['author_info']['thanks_count'] = '
<form class="frm-form" id="frm-addthanks" method="post" action="'.$pun_add_thanks_form_action.'" >
<div class="">
<input type="hidden" name="csrf_token" value="'.generate_form_token($pun_add_thanks_form_action).'" />
<input type="hidden" name="add_thanks_form_sent" value="1" />
<input type="hidden" name="thanks_pid" value="'.$cur_post['id'].'" />
<input type="image" name="submit" src="extensions/pan_thanks_for_posts/img/button_thank1.png" />
</div>
</form>';
}
]]>
</hook>
</hooks>
</extension>
English.php
▼Spoiler
<?php
// Thank For Posts
// @copyright Copyright (C) 2015 PanBB
// @license http://www.gnu.org/licenses/gpl.html GPL
// @package pan_thanks_for_posts
// @website https://punbb.softplaza.net
$lang_pan_thanks_for_posts = array (
'Thanks' => 'Thanks:',
);
Russian.php
▼Spoiler
<?php
// Thank For Posts
// @copyright Copyright (C) 2015 PanBB
// @license http://www.gnu.org/licenses/gpl.html GPL
// @package pan_thanks_for_posts
// @website https://punbb.softplaza.net
$lang_pan_thanks_for_posts = array (
'Thanks' => 'Благодарностей:',
);