модификация позволяет оценивать сообщения, на основе чего строится репутация пользователя
оригинальная тема: https://www.phpbb-work.ru/posts-rating-t69.html
параметры:
- позволяет оценивать (+/-) либо только первое сообщение, либо любое сообщение в теме.
- имеет настройки в админке
- на основе количества положительных и отрицательных отзывов строится рейтинг (репутация) пользователя.
- мод не даёт возможности редактировать выставленные оценки и удалять их. никому.
ставится довольно просто, багов не замечено.
Итак, поехали:
Скачать модификацию из архива сайта:
Скачать из файлового архива сайта
Распаковать и содержимое папки root загрузить в корень сайта (где файл config.php).
Теперь редактируем файлы:
Открыть memberlist.php
Найти
Вставить после найденного
Код: Выделить всё
$sort_key_sql['m'] = 'u.user_rank';
Вставить после найденного
Код: Выделить всё
if ($config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']))
{
$sort_key_text['r'] = $user->lang['USER_RATING'];
$sort_key_text['o'] = $user->lang['USER_RATED'];
if (!$config['rate_no_negative'] && !$config['rate_no_positive'])
{
$sort_key_sql['r'] = 'CAST(u.user_rating_positive AS SIGNED)-CAST(u.user_rating_negative AS SIGNED)';
$sort_key_sql['o'] = 'CAST(u.user_rated_positive AS SIGNED)-CAST(u.user_rated_negative AS SIGNED)';
}
else if (!$config['rate_no_positive'])
{
$sort_key_sql['r'] = 'u.user_rating_positive';
$sort_key_sql['o'] = 'u.user_rated_positive';
}
else if (!$config['rate_no_negative'])
{
$sort_key_sql['r'] = '-CAST(u.user_rating_negative AS SIGNED)';
$sort_key_sql['o'] = '-CAST(u.user_rated_negative AS SIGNED)';
}
}
Найти
Вставить после найденного
Код: Выделить всё
'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
Вставить после найденного
Код: Выделить всё
'U_SORT_RATING' => ($config['rate_enabled']) ? $sort_url . '&sk=r&sd=' . (($sort_key == 'r' && $sort_dir == 'd') ? 'a' : 'd') : '',
'U_SORT_RATED' => ($config['rate_enabled']) ? $sort_url . '&sk=o&sd=' . (($sort_key == 'o' && $sort_dir == 'd') ? 'a' : 'd') : '',
Найти
Вставить после найденного
Код: Выделить всё
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
Вставить после найденного
Код: Выделить всё
'S_RATING' => $config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']),
'RATING' => ($config['rate_no_positive'] ? 0 : $data['user_rating_positive']) - ($config['rate_no_negative'] ? 0 : $data['user_rating_negative']),
'RATING_POSITIVE' => $data['user_rating_positive'],
'RATING_NEGATIVE' => $data['user_rating_negative'],
'RATED' => ($config['rate_no_positive'] ? 0 : $data['user_rated_positive']) - ($config['rate_no_negative'] ? 0 : $data['user_rated_negative']),
'RATED_POSITIVE' => $data['user_rated_positive'],
'RATED_NEGATIVE' => $data['user_rated_negative'],
Открыть viewtopic.php
Найти
Вставить после найденного
Код: Выделить всё
'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,
Вставить после найденного
Код: Выделить всё
'S_RATE_ENABLED' => $config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']),
Найти
Вставить после найденного
Код: Выделить всё
'post_edit_locked' => $row['post_edit_locked'],
Вставить после найденного
Код: Выделить всё
'post_rating_negative' => $row['post_rating_negative'],
'post_rating_positive' => $row['post_rating_positive'],
Найти
Вставить после найденного
Код: Выделить всё
'from' => '',
Вставить после найденного
Код: Выделить всё
'rating' => 0,
'rating_positive' => 0,
'rating_negative' => 0,
'rated' => 0,
'rated_positive' => 0,
'rated_negative' => 0,
Найти
Вставить после найденного
Код: Выделить всё
'from' => (!empty($row['user_from'])) ? $row['user_from'] : '',
Вставить после найденного
Код: Выделить всё
'rating' => ($config['rate_no_positive'] ? 0 : $row['user_rating_positive']) - ($config['rate_no_negative'] ? 0 : $row['user_rating_negative']),
'rating_positive' => $row['user_rating_positive'],
'rating_negative' => $row['user_rating_negative'],
'rated' => ($config['rate_no_positive'] ? 0 : $row['user_rated_positive']) - ($config['rate_no_negative'] ? 0 : $row['user_rated_negative']),
'rated_positive' => $row['user_rated_positive'],
'rated_negative' => $row['user_rated_negative'],
Найти
Вставить после найденного
Код: Выделить всё
$template->assign_vars(array(
'S_NUM_POSTS' => sizeof($post_list))
);
Вставить после найденного
Код: Выделить всё
// Get user rates
$sql = 'SELECT *
FROM ' . POST_RATES_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
AND ' . $db->sql_in_set('post_id', $post_list);
$result = $db->sql_query($sql);
$user_rates = array();
while ($row = $db->sql_fetchrow($result))
{
$user_rates[$row['post_id']] = $row;
}
Найти
Вставить после найденного
Код: Выделить всё
// we do not want to allow removal of the last post if a moderator locked it!
!$row['post_edit_locked']
)));
Вставить после найденного
Код: Выделить всё
$user_rate = isset($user_rates[$row['post_id']]) ? $user_rates[$row['post_id']] : array('rate' => 0, 'rate_time' => 0);
$rate_time = ($topic_data['topic_first_post_id'] != $row['post_id'] || !isset($config['rate_topic_time']) || $config['rate_topic_time'] == -1) ? $config['rate_time'] : $config['rate_topic_time'];
Найти
Вставить после найденного
Код: Выделить всё
'POSTER_AGE' => $user_cache[$poster_id]['age'],
Вставить после найденного
Код: Выделить всё
'S_POSTER_RATING' => $config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']) && ($poster_id != ANONYMOUS),
'POSTER_RATING' => $user_cache[$poster_id]['rating'],
'POSTER_RATING_POSITIVE' => $user_cache[$poster_id]['rating_positive'],
'POSTER_RATING_NEGATIVE' => $user_cache[$poster_id]['rating_negative'],
'POSTER_RATED' => $user_cache[$poster_id]['rated'],
'POSTER_RATED_POSITIVE' => $user_cache[$poster_id]['rated_positive'],
'POSTER_RATED_NEGATIVE' => $user_cache[$poster_id]['rated_negative'],
Найти
Вставить после найденного
Код: Выделить всё
'POSTER_ID' => $poster_id,
Вставить после найденного
Код: Выделить всё
'POST_RATING_SHOW' => $config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']) && ($row['post_rating_negative'] != 0 || $row['post_rating_positive'] != 0 || (empty($config['rate_only_topics']) || $topic_data['topic_first_post_id'] == $row['post_id']) && ($rate_time > 0 ? $rate_time + $row['post_time'] > time() : true)),
'POST_RATING' => ($config['rate_no_positive'] ? 0 : $row['post_rating_positive']) - ($config['rate_no_negative'] ? 0 : $row['post_rating_negative']),
'POST_RATING_NEGATIVE' => $row['post_rating_negative'],
'POST_RATING_POSITIVE' => $row['post_rating_positive'],
'USER_RATE' => $user_rate['rate'],
'USER_CAN_MINUS' => $config['rate_enabled'] && ($user->data['user_id'] != ANONYMOUS) && ($user->data['user_id'] != $poster_id) && (empty($config['rate_only_topics']) || $topic_data['topic_first_post_id'] == $row['post_id']) && ($rate_time > 0 ? $rate_time + $row['post_time'] > time() : true) && ($user_rate['rate'] >= 0) && ($user_rate['rate'] != 0 && $config['rate_change_time'] > 0 ? $config['rate_change_time'] + $user_rate['rate_time'] > time() : true) && ($config['rate_no_negative'] ? $user_rate['rate'] != 0 : true) && $auth->acl_get('u_canminus'),
'USER_CAN_PLUS' => $config['rate_enabled'] && ($user->data['user_id'] != ANONYMOUS) && ($user->data['user_id'] != $poster_id) && (empty($config['rate_only_topics']) || $topic_data['topic_first_post_id'] == $row['post_id']) && ($rate_time > 0 ? $rate_time + $row['post_time'] > time() : true) && ($user_rate['rate'] <= 0) && ($user_rate['rate'] != 0 && $config['rate_change_time'] > 0 ? $config['rate_change_time'] + $user_rate['rate_time'] > time() : true) && ($config['rate_no_positive'] ? $user_rate['rate'] != 0 : true) && $auth->acl_get('u_canplus'),
Открыть includes/constants.php
Найти
Вставить после найденного
Код: Выделить всё
// Additional tables
Вставить после найденного
Код: Выделить всё
define('POST_RATES_TABLE', $table_prefix . 'post_rates');
Открыть includes/functions.php
Найти
Вставить после найденного
Код: Выделить всё
'BOARD_URL' => $board_url,
Вставить после найденного
Код: Выделить всё
'AJAX_TOKEN' => generate_link_hash('ajax'),
Найти
Вставить перед найденным
Код: Выделить всё
// application/xhtml+xml not used because of IE
header('Content-type: text/html; charset=UTF-8');
Вставить перед найденным
Код: Выделить всё
// Style settings
$settings = array(
'rate_no_positive',
'rate_no_negative',
// miniprofile
'style_mp_show_rating',
'style_mp_show_rating_detailed',
'style_mp_show_rated',
'style_mp_show_rated_detailed',
// profile
'style_p_show_rating',
'style_p_show_rating_detailed',
'style_p_show_rated',
'style_p_show_rated_detailed',
// memberlist
'style_ml_show_rating',
'style_ml_show_rating_detailed',
'style_ml_show_rated',
'style_ml_show_rated_detailed',
);
foreach ($settings as $setting)
{
$template->assign_var(strtoupper($setting), !empty($config[$setting]) ? $config[$setting] : false);
}
Открыть includes/startup.php
Найти
Вставить перед найденным
Код: Выделить всё
// Report all errors, except notices and deprecation messages
Вставить перед найденным
Код: Выделить всё
// Configure autoloader
require(dirname(__FILE__).'/../classes/autoloader.php');
autoloader::init(dirname(__FILE__).'/../classes/');
autoloader::add_path(dirname(__FILE__).'/../modules/', 'module');
Открыть includes/ucp/ucp_pm_viewmessage.php
Найти
Вставить после найденного
Код: Выделить всё
'AUTHOR_FROM' => (!empty($user_info['user_from'])) ? $user_info['user_from'] : '',
Вставить после найденного
Код: Выделить всё
'S_RATE_ENABLED' => $config['rate_enabled'] && (!$config['rate_no_negative'] || !$config['rate_no_positive']) && ($author_id != ANONYMOUS),
'AUTHOR_RATING' => (int) ($config['rate_no_positive'] ? 0 : $user_info['user_rating_positive']) - ($config['rate_no_negative'] ? 0 : $user_info['user_rating_negative']),
'AUTHOR_RATING_POSITIVE' => (int) $user_info['user_rating_positive'],
'AUTHOR_RATING_NEGATIVE' => (int) $user_info['user_rating_negative'],
'AUTHOR_RATED' => (int) ($config['rate_no_positive'] ? 0 : $user_info['user_rated_positive']) - ($config['rate_no_negative'] ? 0 : $user_info['user_rated_negative']),
'AUTHOR_RATED_POSITIVE' => (int) $user_info['user_rated_positive'],
'AUTHOR_RATED_NEGATIVE' => (int) $user_info['user_rated_negative'],
Завершение установки:
теперь необходимого запустить установочный файл.
Код: Выделить всё
http://ваш сайт/install_rate.php
После отработки удалите файл с сервера.
Очистите кэши шаблонов, темы и браузера.
Установите необходимые параметры работы в Администраторском разделе:
на вкладке Модули - работу самого мода,
на вкладка Права Пользователей и Групп - права выставления оценок. (Глобальные права - Права групп - Зарегистрированные пользователи - Разное - Может ставить оценку)
(где что - смотрите на сканах вверху страницы).
Всё. успехов в применении.