мод добавляет на главную страницу, напротив каждого подфорума, аватар того, кто последним ответил в темах конкретных подфорумов, а так же на странице просмотра подфорумов выводится аватар автора темы и последнего ответившего.
Выглядеть будет примерно так:


[dombelk]index.php[/dombelk]
Если заинтересовало - ставим:
Скачать мод из архива сайта:
Скачать из файлового архива сайта
распаковать, содержимое папки root скопировать в корень сайта (где файл config.php).
Перед редактированием файлов необходимо провести SQL - запрос для создания таблиц в базе:
Код: Выделить всё
ALTER TABLE phpbb_forums ADD forum_last_poster_avatar VARCHAR( 255 ) COLLATE utf8_bin NOT NULL default '';
ALTER TABLE phpbb_forums ADD forum_last_poster_avatar_type tinyint(2) NOT NULL default '0';
ALTER TABLE phpbb_forums ADD forum_last_poster_avatar_width smallint(4) unsigned NOT NULL default '0';
ALTER TABLE phpbb_forums ADD forum_last_poster_avatar_height smallint(4) unsigned NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_first_poster_avatar VARCHAR( 255 ) COLLATE utf8_bin NOT NULL default '';
ALTER TABLE phpbb_topics ADD topic_first_poster_avatar_type tinyint(2) NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_first_poster_avatar_width smallint(4) unsigned NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_first_poster_avatar_height smallint(4) unsigned NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_last_poster_avatar VARCHAR( 255 ) COLLATE utf8_bin NOT NULL default '';
ALTER TABLE phpbb_topics ADD topic_last_poster_avatar_type tinyint(2) NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_last_poster_avatar_width smallint(4) unsigned NOT NULL default '0';
ALTER TABLE phpbb_topics ADD topic_last_poster_avatar_height smallint(4) unsigned NOT NULL default '0';
INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_avatar_index', '1');
скачать, распаковать, загрузить файл db_update.php в корень форума и запустить его по адресу
Код: Выделить всё
http://ваш форум/db_update.php
после отработки скрипта удалить его с сервера.
Теперь редактируем файлы форума:
Код: Выделить всё
avatar_delete('user', $user_row);
Вставить после найденного
Код: Выделить всё
user_update_avatar($user_row['user_id'], '', 0, 0, 0);
Код: Выделить всё
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true)
Заменить найденное на
Код: Выделить всё
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
'enable_avatar_index' => array('lang' => 'ENABLE_AVATAR_INDEX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true)
Код: Выделить всё
$forum_data[$forum_id]['last_poster_colour'] = '';
Вставить после найденного
Код: Выделить всё
$forum_data[$forum_id]['last_poster_avatar'] = '';
$forum_data[$forum_id]['last_poster_avatar_type'] = 0;
$forum_data[$forum_id]['last_poster_avatar_width'] = 0;
$forum_data[$forum_id]['last_poster_avatar_height'] = 0;
Код: Выделить всё
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Добавить после неё
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$forum_data[$forum_id]['last_poster_colour'] = $post_info[$data['last_post_id']]['user_colour'];
Вставить после найденного
Код: Выделить всё
$forum_data[$forum_id]['last_poster_avatar'] = $post_info[$data['last_post_id']]['user_avatar'];
$forum_data[$forum_id]['last_poster_avatar_type'] = $post_info[$data['last_post_id']]['user_avatar_type'];
$forum_data[$forum_id]['last_poster_avatar_width'] = $post_info[$data['last_post_id']]['user_avatar_width'];
$forum_data[$forum_id]['last_poster_avatar_height'] = $post_info[$data['last_post_id']]['user_avatar_height'];
Код: Выделить всё
$forum_data[$forum_id]['last_poster_colour'] = '';
Вставить после найденного
Код: Выделить всё
$forum_data[$forum_id]['last_poster_avatar'] = '';
$forum_data[$forum_id]['last_poster_avatar_type'] = 0;
$forum_data[$forum_id]['last_poster_avatar_width'] = 0;
$forum_data[$forum_id]['last_poster_avatar_height'] = 0;
Код: Выделить всё
$fieldnames = array('last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'
В часть строки найденного
Код: Выделить всё
'last_poster_colour'
Добавить после
Код: Выделить всё
, 'last_poster_avatar', 'last_poster_avatar_type', 'last_poster_avatar_width', 'last_poster_avatar_height'
Код: Выделить всё
if (preg_match('#(name|colour|subject
К части строки найденного
Код: Выделить всё
|subject
Добавить после
Код: Выделить всё
|avatar
Код: Выделить всё
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour
В часть строки найденного
Код: Выделить всё
t.topic_first_poster_colour
Добавить после
Код: Выделить всё
, t.topic_first_poster_avatar, t.topic_first_poster_avatar_type, t.topic_first_poster_avatar_width, t.topic_first_poster_avatar_height, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_poster_avatar, t.topic_last_poster_avatar_type, t.topic_last_poster_avatar_width, t.topic_last_poster_avatar_height
Код: Выделить всё
$sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Добавить после следующий код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$topic_data[$topic_id]['first_poster_colour'] = $row['user_colour'];
Вставить после найденного
Код: Выделить всё
$topic_data[$topic_id]['first_poster_avatar'] = $row['user_avatar'];
$topic_data[$topic_id]['first_poster_avatar_type'] = $row['user_avatar_type'];
$topic_data[$topic_id]['first_poster_avatar_width'] = $row['user_avatar_width'];
$topic_data[$topic_id]['first_poster_avatar_height'] = $row['user_avatar_height'];
Код: Выделить всё
$topic_data[$topic_id]['last_poster_colour'] = $row['user_colour'];
Вставить после найденного
Код: Выделить всё
$topic_data[$topic_id]['last_poster_avatar'] = $row['user_avatar'];
$topic_data[$topic_id]['last_poster_avatar_type'] = $row['user_avatar_type'];
$topic_data[$topic_id]['last_poster_avatar_width'] = $row['user_avatar_width'];
$topic_data[$topic_id]['last_poster_avatar_height'] = $row['user_avatar_height'];
Код: Выделить всё
$sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sync_shadow_topics[$orig_topic_id]['topic_first_poster_colour'] = $row['user_colour'];
Вставить после найденного
Код: Выделить всё
$sync_shadow_topics[$orig_topic_id]['topic_first_poster_avatar'] = $row['user_avatar'];
$sync_shadow_topics[$orig_topic_id]['topic_first_poster_avatar_type'] = $row['user_avatar_type'];
$sync_shadow_topics[$orig_topic_id]['topic_first_poster_avatar_width'] = $row['user_avatar_width'];
$sync_shadow_topics[$orig_topic_id]['topic_first_poster_avatar_height'] = $row['user_avatar_height'];
Код: Выделить всё
$sync_shadow_topics[$orig_topic_id]['topic_last_poster_colour'] = $row['user_colour'];
Вставить после найденного
Код: Выделить всё
$sync_shadow_topics[$orig_topic_id]['topic_last_poster_avatar'] = $row['user_avatar'];
$sync_shadow_topics[$orig_topic_id]['topic_last_poster_avatar_type'] = $row['user_avatar_type'];
$sync_shadow_topics[$orig_topic_id]['topic_last_poster_avatar_width'] = $row['user_avatar_width'];
$sync_shadow_topics[$orig_topic_id]['topic_last_poster_avatar_height'] = $row['user_avatar_height'];
Код: Выделить всё
$fieldnames = array('time', 'replies', 'replies_real', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour'
В часть строки найденного
Код: Выделить всё
'first_poster_colour'
Добавить после следующий код
Код: Выделить всё
, 'first_poster_avatar', 'first_poster_avatar_type', 'first_poster_avatar_width', 'first_poster_avatar_height', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour', 'last_poster_avatar', 'last_poster_avatar_type', 'last_poster_avatar_width', 'last_poster_avatar_height'
Код: Выделить всё
$forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
Вставить после найденного
Код: Выделить всё
$forum_rows[$parent_id]['forum_last_poster_avatar'] = $row['forum_last_poster_avatar'];
$forum_rows[$parent_id]['forum_last_poster_avatar_type'] = $row['forum_last_poster_avatar_type'];
$forum_rows[$parent_id]['forum_last_poster_avatar_width'] = $row['forum_last_poster_avatar_width'];
$forum_rows[$parent_id]['forum_last_poster_avatar_height'] = $row['forum_last_poster_avatar_height'];
Код: Выделить всё
$template->assign_block_vars('forumrow', array(
'S_IS_CAT' => false,
Вставить перед найденным
Код: Выделить всё
$avatar_max_dimensions = $avatar_width = $avatar_height = '';
if ( !empty($row['forum_last_poster_avatar']) )
{
$avatar_max_dimensions = 40; // here you can change the max-width you would like to have the avatars displayed
if ( $row['forum_last_poster_avatar_width'] >= $row['forum_last_poster_avatar_height'] )
{
$avatar_width = ( $row['forum_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['forum_last_poster_avatar_width'] ;
$avatar_height = ( $avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['forum_last_poster_avatar_width'] * $row['forum_last_poster_avatar_height']) : $row['forum_last_poster_avatar_height'] ;
}
else
{
$avatar_height = ( $row['forum_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['forum_last_poster_avatar_height'] ;
$avatar_width = ( $avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['forum_last_poster_avatar_height'] * $row['forum_last_poster_avatar_width']) : $row['forum_last_poster_avatar_width'] ;
}
}
Код: Выделить всё
'LAST_POSTER_FULL'
Вставить после найденного
Код: Выделить всё
'LAST_POSTER_AVATAR' => ($config['enable_avatar_index']) ? get_user_avatar($row['forum_last_poster_avatar'], $row['forum_last_poster_avatar_type'], $avatar_width, $avatar_height) : false,
'LAST_POSTER_AVATAR_MARGIN' => ( $avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $avatar_width + 5 ),
'AVATAR_WIDTH' => $avatar_max_dimensions,
Код: Выделить всё
$update_sql[$forum_id][] = "forum_last_poster_colour = ''";
Вставить после найденного
Код: Выделить всё
$update_sql[$forum_id][] = "forum_last_poster_avatar = ''";
$update_sql[$forum_id][] = 'forum_last_poster_avatar_type = 0';
$update_sql[$forum_id][] = 'forum_last_poster_avatar_width = 0';
$update_sql[$forum_id][] = 'forum_last_poster_avatar_height = 0';
Код: Выделить всё
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после следующий код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
Вставить после найденного
Код: Выделить всё
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "'";
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_avatar_type = ' . (int) $row['user_avatar_type'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_avatar_width = ' . (int) $row['user_avatar_width'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
case 'delete_first_post':
$sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sql_data[TOPICS_TABLE] = '
Часть строки найденного
Код: Выделить всё
$db->sql_escape($row['username'])) . "'";
Заменить на следующий код
Код: Выделить всё
$db->sql_escape($row['username'])) . "', topic_first_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "', topic_first_poster_avatar_type = " . (int) $row['user_avatar_type'] . ', topic_first_poster_avatar_width = ' . (int) $row['user_avatar_width'] . ', topic_first_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
'topic_first_poster_colour' => $user->data['user_colour'],
Вставить после найденного
Код: Выделить всё
'topic_first_poster_avatar' => $user->data['user_avatar'],
'topic_first_poster_avatar_type' => $user->data['user_avatar_type'],
'topic_first_poster_avatar_width' => $user->data['user_avatar_width'],
'topic_first_poster_avatar_height' => $user->data['user_avatar_height'],
Код: Выделить всё
'topic_last_poster_colour' => $user->data['user_colour'],
Вставить после найденного
Код: Выделить всё
'topic_last_poster_avatar' => $user->data['user_avatar'],
'topic_last_poster_avatar_type' => $user->data['user_avatar_type'],
'topic_last_poster_avatar_width' => $user->data['user_avatar_width'],
'topic_last_poster_avatar_height' => $user->data['user_avatar_height'],
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = '" . $db->sql_escape($user->data['user_avatar']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = ' . (int) $user->data['user_avatar_type'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = ' . (int) $user->data['user_avatar_width'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = ' . (int) $user->data['user_avatar_height'];
Код: Выделить всё
// any posts left in this forum?
if (!empty($row['last_post_id']))
{
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после следующий код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = ' . (int) $row['user_avatar_type'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = ' . (int) $row['user_avatar_width'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = ''";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = 0';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = 0';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = 0';
Код: Выделить всё
// any posts left in this forum?
if (!empty($row['last_post_id']))
{
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после следующий код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = ' . (int) $row['user_avatar_type'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = ' . (int) $row['user_avatar_width'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = ''";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = 0';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = 0';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = 0';
Код: Выделить всё
// this post has a higher id, it is newer
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Добавить после следующий код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
Вставить после найденного
Код: Выделить всё
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_type = ' . (int) $row['user_avatar_type'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_width = ' . (int) $row['user_avatar_width'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $current_time;
Вставить после найденного
Код: Выделить всё
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_avatar = '" . $db->sql_escape($user->data['user_avatar']) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_type = ' . (int) $user->data['user_avatar_type'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_width = ' . (int) $user->data['user_avatar_width'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_height = ' . (int) $user->data['user_avatar_height'];
Код: Выделить всё
// any posts left in this forum?
if (!empty($row['last_post_id']))
{
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
В часть строки найденного
Код: Выделить всё
u.user_colour
Вставить после код
Код: Выделить всё
, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height
Код: Выделить всё
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'";
Вставить после найденного
Код: Выделить всё
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_avatar = '" . $db->sql_escape($row['user_avatar']) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_type = ' . (int) $row['user_avatar_type'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_width = ' . (int) $row['user_avatar_width'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_avatar_height = ' . (int) $row['user_avatar_height'];
Код: Выделить всё
/**
* Adds an user
Вставить перед найденным
Код: Выделить всё
/**
* Updates a user_avatar across all relevant tables/fields
*/
function user_update_avatar($user_id, $new_avatar, $new_avatar_type, $new_avatar_width, $new_avatar_height)
{
global $config, $db, $cache;
$sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_last_poster_avatar = '" . $db->sql_escape($new_avatar) . "', forum_last_poster_avatar_type = " . (int) $new_avatar_type . ', forum_last_poster_avatar_width = ' . (int) $new_avatar_width . ', forum_last_poster_avatar_height = ' . (int) $new_avatar_height . '
WHERE forum_last_poster_id = ' . (int)$user_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_poster_avatar = '" . $db->sql_escape($new_avatar) . "', topic_last_poster_avatar_type = " . (int) $new_avatar_type . ', topic_last_poster_avatar_width = ' . (int)$new_avatar_width . ', topic_last_poster_avatar_height = ' . (int) $new_avatar_height . '
WHERE topic_last_poster_id = ' . (int) $user_id;
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_first_poster_avatar = '" . $db->sql_escape($new_avatar) . "', topic_first_poster_avatar_type = " . (int) $new_avatar_type . ', topic_first_poster_avatar_width = ' . (int) $new_avatar_width . ', topic_first_poster_avatar_height = ' . (int) $new_avatar_height . '
WHERE topic_poster = ' . (int) $user_id;
$db->sql_query($sql);
}
Код: Выделить всё
avatar_delete('user', $userdata);
}
}
Вставить после найденного
Код: Выделить всё
$user_id = (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']);
user_update_avatar($user_id, $sql_ary['user_avatar'], $sql_ary['user_avatar_type'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']);
Код: Выделить всё
// Send vars to template
$template->assign_block_vars('topicrow', array(
Вставить перед найденным
Код: Выделить всё
$avatar_img = $avatar_max_dimensions = $topic_last_poster_avatar_height = $topic_last_poster_avatar_width = $topic_first_poster_avatar_width = $topic_first_poster_avatar_height = '';
if ( !empty($row['topic_first_poster_avatar']) || !empty($row['topic_last_poster_avatar']))
{
$avatar_max_dimensions = 40; // here you can change the max-width you would like to have the avatars displayed
if ( $row['topic_first_poster_avatar_width'] >= $row['topic_first_poster_avatar_height'] )
{
$topic_first_poster_avatar_width = ( $row['topic_first_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_width'] ;
$topic_first_poster_avatar_height = ( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_width'] * $row['topic_first_poster_avatar_height']) : $row['topic_first_poster_avatar_height'] ;
}
else
{
$topic_first_poster_avatar_height = ( $row['topic_first_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_height'] ;
$topic_first_poster_avatar_width = ( $topic_first_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_height'] * $row['topic_first_poster_avatar_width']) : $row['topic_first_poster_avatar_width'] ;
}
if ( $row['topic_last_poster_avatar_width'] >= $row['topic_last_poster_avatar_height'] )
{
$topic_last_poster_avatar_width = ( $row['topic_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_width'] ;
$topic_last_poster_avatar_height = ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_width'] * $row['topic_last_poster_avatar_height']) : $row['topic_last_poster_avatar_height'] ;
}
else
{
$topic_last_poster_avatar_height = ( $row['topic_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_height'] ;
$topic_last_poster_avatar_width = ( $topic_last_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_height'] * $row['topic_last_poster_avatar_width']) : $row['topic_last_poster_avatar_width'] ;
}
}
Код: Выделить всё
'TOPIC_AUTHOR_FULL'
Вставить после найденного
Код: Выделить всё
'TOPIC_AUTHOR_AVATAR' => ($config['enable_avatar_index']) ? get_user_avatar($row['topic_first_poster_avatar'], $row['topic_first_poster_avatar_type'], $topic_first_poster_avatar_width, $topic_first_poster_avatar_height) : false,
'TOPIC_AUTHOR_AVATAR_MARGIN' => ( $topic_first_poster_avatar_width == '' ) ? '' : (( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $topic_first_poster_avatar_width + 5 )),
'AVATAR_WIDTH' => $avatar_max_dimensions ,
Код: Выделить всё
'LAST_POST_AUTHOR_FULL'
Вставить после найденного
Код: Выделить всё
'LAST_POST_AUTHOR_AVATAR' => ($config['enable_avatar_index']) ? get_user_avatar($row['topic_last_poster_avatar'], $row['topic_last_poster_avatar_type'], $topic_last_poster_avatar_width, $topic_last_poster_avatar_height) : false,
'LAST_POST_AUTHOR_AVATAR_MARGIN'=> ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $topic_last_poster_avatar_width + 5 ),
Код: Выделить всё
?>
Вставить перед найденным
Код: Выделить всё
// Avatar on Index and viewforum
$lang = array_merge($lang, array(
'ENABLE_AVATAR_INDEX' => 'Включить мод Avatar on Index and Viewforum Mod',
'ENABLE_AVATAR_INDEX_EXPLAIN' => 'вкл/выкл мода вывода аватара на главной и в списке тем',
));
Код: Выделить всё
?>
Вставить перед найденным
Код: Выделить всё
// Avatar on Index and viewforum
$lang = array_merge($lang, array(
'ENABLE_AVATAR_INDEX' => 'Enable Avatar on Index and Viewforum Mod',
'ENABLE_AVATAR_INDEX_EXPLAIN' => 'Turns on/off the Avatar on Index and Viewforum Mod.',
));
Код: Выделить всё
<dd class="posts">{forumrow.POSTS} <dfn>{L_POSTS}</dfn></dd>
<dd class="lastpost"><span>
В часть строки найденного
Код: Выделить всё
<dd class="lastpost">
Вставить после следующий код
Код: Выделить всё
<!-- IF forumrow.LAST_POSTER_AVATAR --><div style="float: left; padding-top: 0px; margin-left: 5px; margin-right: {forumrow.LAST_POSTER_AVATAR_MARGIN}px;">{forumrow.LAST_POSTER_AVATAR}</div><!-- ENDIF -->
Код: Выделить всё
<dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
В часть строки найденного
Код: Выделить всё
"{topicrow.TOPIC_FOLDER_IMG_ALT}">
Вставить следующий код
Код: Выделить всё
<!-- IF topicrow.TOPIC_AUTHOR_AVATAR --><span style="float: left; padding-top: 3px; margin-right: {topicrow.TOPIC_AUTHOR_AVATAR_MARGIN}px;">{topicrow.TOPIC_AUTHOR_AVATAR}</span><!-- ENDIF-->
Код: Выделить всё
<dd class="lastpost">
В часть строки найденного
Код: Выделить всё
<dd class="lastpost">
Вставить после код
Код: Выделить всё
<!-- IF topicrow.LAST_POST_AUTHOR_AVATAR --><div style="float: left; padding-top: 0px; margin-left: 5px; margin-right: {topicrow.LAST_POST_AUTHOR_AVATAR_MARGIN}px;">{topicrow.LAST_POST_AUTHOR_AVATAR}</div><!-- ENDIF -->
Код: Выделить всё
<p class="topicdetails"><!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a> <!-- ENDIF -->{forumrow.LAST_POST_TIME}</p>
<p class="topicdetails">{forumrow.LAST_POSTER_FULL}
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a><!-- ENDIF -->
</p>
Заменить найденное на
Код: Выделить всё
<table>
<tr>
<!-- IF forumrow.LAST_POSTER_AVATAR --><td width="{forumrow.AVATAR_WIDTH}">{forumrow.LAST_POSTER_AVATAR}</td><!-- ENDIF -->
<td align="center" nowrap="nowrap">
<p class="topicdetails"><!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a> <!-- ENDIF -->{forumrow.LAST_POST_TIME}</p>
<p class="topicdetails">{forumrow.LAST_POSTER_FULL}
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a><!-- ENDIF -->
</p>
</td>
</tr>
</table>
Код: Выделить всё
<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
Заменить найденное на
Код: Выделить всё
<td class="row2" width="130" align="center">
<table>
<tr>
<!-- IF topicrow.TOPIC_AUTHOR_AVATAR --><td align="center" width="{topicrow.AVATAR_WIDTH}" >{topicrow.TOPIC_AUTHOR_AVATAR}</td><!-- ENDIF -->
<td align="center">
<p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
</tr>
</table>
</td>
Код: Выделить всё
<td class="row1" width="140" align="center">
<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
<a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a>
</p>
</td>
Заменить найденное на
Код: Выделить всё
<td class="row1" width="140" align="center">
<table>
<tr>
<!-- IF topicrow.LAST_POST_AUTHOR_AVATAR --> <td width="{topicrow.AVATAR_WIDTH}">{topicrow.LAST_POST_AUTHOR_AVATAR}</td><!-- ENDIF -->
<td align="center">
<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
<a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a>
</p>
</td>
</tr>
</table>
</td>
Код: Выделить всё
<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
Заменить найденное на
Код: Выделить всё
<td class="row2" width="130" align="center">
<table>
<tr>
<!-- IF topicrow.TOPIC_AUTHOR_AVATAR --><td align="center" width="{topicrow.AVATAR_WIDTH}" >{topicrow.TOPIC_AUTHOR_AVATAR}</td><!-- ENDIF -->
<td align="center">
<p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
</tr>
</table>
</td>
Код: Выделить всё
<td class="row1" width="140" align="center">
<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
<a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a>
</p>
</td>
Заменить найденное на
Код: Выделить всё
<td class="row1" width="140" align="center">
<table>
<tr>
<!-- IF topicrow.LAST_POST_AUTHOR_AVATAR --> <td width="{topicrow.AVATAR_WIDTH}">{topicrow.LAST_POST_AUTHOR_AVATAR}</td><!-- ENDIF -->
<td align="center">
<p class="topicdetails" style="white-space: nowrap;">{topicrow.LAST_POST_TIME}</p>
<p class="topicdetails">{topicrow.LAST_POST_AUTHOR_FULL}
<a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a>
</p>
</td>
</tr>
</table>
</td>
Для завершения установки запустите файл avatar_update.php через браузер
Код: Выделить всё
http://ваш сайт/avatar_update.php
после отработки скрипта установки удалите с сервера файл avatar_update.php и его языковой файл по адресу language/en/avatar_update.php.
Почистите кэш и всё. Настройка мода находятся Админка - Общие - Аватары.
Небольшая информация по проблемам установки (если выводятся аватарки больших размеров):
Код: Выделить всё
$avatar_img = $avatar_max_dimensions = $topic_last_poster_avatar_height = $topic_last_poster_avatar_width = $topic_first_poster_avatar_width = $topic_first_poster_avatar_height = '';
if ( !empty($row['topic_first_poster_avatar']) || !empty($row['topic_last_poster_avatar']))
{
$avatar_max_dimensions = 40; // here you can change the max-width you would like to have the avatars displayed
if ( $row['topic_first_poster_avatar_width'] >= $row['topic_first_poster_avatar_height'] )
{
$topic_first_poster_avatar_width = ( $row['topic_first_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_width'] ;
$topic_first_poster_avatar_height = ( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_width'] * $row['topic_first_poster_avatar_height']) : $row['topic_first_poster_avatar_height'] ;
}
else
{
$topic_first_poster_avatar_height = ( $row['topic_first_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_height'] ;
$topic_first_poster_avatar_width = ( $topic_first_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_height'] * $row['topic_first_poster_avatar_width']) : $row['topic_first_poster_avatar_width'] ;
}
if ( $row['topic_last_poster_avatar_width'] >= $row['topic_last_poster_avatar_height'] )
{
$topic_last_poster_avatar_width = ( $row['topic_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_width'] ;
$topic_last_poster_avatar_height = ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_width'] * $row['topic_last_poster_avatar_height']) : $row['topic_last_poster_avatar_height'] ;
}
else
{
$topic_last_poster_avatar_height = ( $row['topic_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_height'] ;
$topic_last_poster_avatar_width = ( $topic_last_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_height'] * $row['topic_last_poster_avatar_width']) : $row['topic_last_poster_avatar_width'] ;
}
}
Заменить на :
Код: Выделить всё
$avatar_img = $avatar_max_dimensions = $topic_last_poster_avatar_height = $topic_last_poster_avatar_width = $topic_first_poster_avatar_width = $topic_first_poster_avatar_height = 40;
if ( !empty($row['topic_first_poster_avatar']) || !empty($row['topic_last_poster_avatar']))
{
$avatar_max_dimensions = $avatar_width = $avatar_height = 40; // here you can change the max-width you would like to have the avatars displayed
if ( !empty($row['topic_first_poster_avatar']))
{
if ( $row['topic_first_poster_avatar_width'] >= $row['topic_first_poster_avatar_height'] )
{
$topic_first_poster_avatar_width = ( $row['topic_first_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_width'] ;
$topic_first_poster_avatar_height = ( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_width'] * $row['topic_first_poster_avatar_height']) : $row['topic_first_poster_avatar_height'] ;
}
else
{
$topic_first_poster_avatar_height = ( $row['topic_first_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_height'] ;
$topic_first_poster_avatar_width = ( $topic_first_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_height'] * $row['topic_first_poster_avatar_width']) : $row['topic_first_poster_avatar_width'] ;
}
}
if ( !empty($row['topic_last_poster_avatar']))
{
if ( $row['topic_last_poster_avatar_width'] >= $row['topic_last_poster_avatar_height'] )
{
$topic_last_poster_avatar_width = ( $row['topic_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_width'] ;
$topic_last_poster_avatar_height = ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_width'] * $row['topic_last_poster_avatar_height']) : $row['topic_last_poster_avatar_height'] ;
}
else
{
$topic_last_poster_avatar_height = ( $row['topic_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_height'] ;
$topic_last_poster_avatar_width = ( $topic_last_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_height'] * $row['topic_last_poster_avatar_width']) : $row['topic_last_poster_avatar_width'] ;
}
}
}
Код: Выделить всё
$avatar_max_dimensions = $avatar_width = $avatar_height = '';
Заменить на:
Код: Выделить всё
$avatar_max_dimensions = $avatar_width = $avatar_height = 40;
у меня лично эта правка прописана, но, так как проблема вылезает не у всех - сделано как дополнение
Никаким образом убрать это не получилось, хотя всё остальное и работает.
В результате применил "жёсткую прописку аватара":
В файле includes/functions_display.php строку
Код: Выделить всё
'LAST_POSTER_AVATAR' => ($config['enable_avatar_index']) ? get_user_avatar($row['forum_last_poster_avatar'], $row['forum_last_poster_avatar_type'], $avatar_width, $avatar_height) : false,
надо прописать так:
Код: Выделить всё
'LAST_POSTER_AVATAR' => ($config['enable_avatar_index']) ? get_user_avatar($row['forum_last_poster_avatar'], $row['forum_last_poster_avatar_type'], $avatar_width = '40', $avatar_height = '40') : false,
где
Код: Выделить всё
$avatar_width = '40', $avatar_height = '40'
и есть размеры.
После таких правок всё нормализовалось.
Код: Выделить всё
General Error
SQL ERROR [ mysqli ]
Field 'forum_last_poster_avatar' doesn't have a default value [1364]
SQL
INSERT INTO phpbb_forums (parent_id, forum_type, forum_status, forum_parents, forum_name, forum_link, forum_desc, forum_desc_uid, forum_desc_options, forum_desc_bitfield, forum_rules, forum_rules_uid, forum_rules_options, forum_rules_bitfield, forum_rules_link, forum_image, forum_style, display_subforum_list, display_on_index, forum_topics_per_page, enable_indexing, enable_icons, enable_prune, prune_days, prune_viewed, prune_freq, forum_options, forum_flags, left_id, right_id) VALUES (0, 1, 0, '', 'Test', '', '', '', 7, '', '', '', 7, '', '', '', 0, 1, 0, 0, 1, 0, 0, 7, 7, 1, 0, 48, 39, 40)
BACKTRACE
FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()
FILE: [ROOT]/includes/db/dbal.php
LINE: 757
CALL: trigger_error()
FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()
FILE: [ROOT]/includes/acp/acp_forums.php
LINE: 1019
CALL: dbal_mysqli->sql_query()
FILE: [ROOT]/includes/acp/acp_forums.php
LINE: 188
CALL: acp_forums->update_forum_data()
FILE: [ROOT]/includes/functions_module.php
LINE: 507
CALL: acp_forums->main()
FILE: [ROOT]/adm/index.php
LINE: 74
CALL: p_master->load_active()
согласно которой получается, что поле forum_last_poster_avatar не имеет в базе значения по умолчанию (это поле как раз и относится к этому моду), то решается эта проблема так:
Код: Выделить всё
// On add, add empty forum_options... else do not consider it (not updating it)
Вставить перед найденным
Код: Выделить всё
//-- mod : apiv ----------------------------------------------------------------
//-- add
$forum_data += array('forum_last_poster_avatar' => '');
//-- fin mod : apiv ------------------------------------------------------------
после этого всё нормализуется.
(нашли решение здесь: https://www.phpbb.com/customise/db/mod/ ... 02197)) )
Успехов. Мод опробован в работе и 100% рабочий.
2 марта 2023 года проверил мод установкой на тест-форум. правок, конечно, много, но мод встал сразу и заработал. проблем нет.