Доработка вывода аватарки текущего пользователя на главной

Проблемы с установкой или работой phpBB 3.0.x? Получите помощь здесь!
С 1 января 2017 года phpBB Group прекращает поддержку phpBB версии 3.0.
Сайт официальной русской поддержки phpBB Guru продолжит поддержку phpBB 3.0 до 1 июля 2017 года.
Подробнее: Окончание поддержки phpBB 3.0.
Правила форума
Местная Конституция | Шаблон запроса | Документация (phpBB3) | Переход на 3.0.6 и выше | FAQ-3 (phpbb3) | Как задавать вопросы | Как устанавливать моды

Ваш вопрос может быть удален без объяснения причин, если на него есть ответы по приведённым ссылкам (а вы рискуете получить предупреждение ;) ).
snvck
phpBB 1.2.0
Сообщения: 12
Стаж: 13 лет 6 месяцев
Благодарил (а): 2 раза

Доработка вывода аватарки текущего пользователя на главной

Сообщение snvck »

Доброго времени!
На форуме под названием ppkbb3cker от пользователя PPK была представлена инстукция по выводу аватары текущего пользователя на главной. Все установилось хорошо и корректно работает. Однако мною были выявлены некоторые ошибки.
А именно:
Fatal error: Call to undefined function get_user_rank() in S:\home\localhost\www\phpBB3\includes\mcp\mcp_warn.php on line 311
и
Fatal error: Call to undefined function get_user_rank() in S:\home\localhost\www\phpBB3\includes\ucp\ucp_pm_viewmessage.php on line 313
более подробно смотрим здесь

Очень надеюсь на вашу помощь, ибо моих знаний очень сильно не хватает пока((((

Итак, сама инструкция:
/includes/functions_display.php заменить

Код: Выделить всё

function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
   global $user, $config, $phpbb_root_path, $phpEx;
 
   if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
   {
      return '';
   }
 
   $avatar_img = '';
 
   switch ($avatar_type)
   {
      case AVATAR_UPLOAD:
         if (!$config['allow_avatar_upload'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
      break;
 
      case AVATAR_GALLERY:
         if (!$config['allow_avatar_local'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
      break;
 
      case AVATAR_REMOTE:
         if (!$config['allow_avatar_remote'] && !$ignore_config)
         {
            return '';
         }
      break;
   }
 
   $avatar_img .= $avatar;
   return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
на

Код: Выделить всё

if (!function_exists('get_user_avatar'))
{
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
   global $user, $config, $phpbb_root_path, $phpEx;
 
   if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
   {
      return '';
   }
 
   $avatar_img = '';
 
   switch ($avatar_type)
   {
      case AVATAR_UPLOAD:
         if (!$config['allow_avatar_upload'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
      break;
 
      case AVATAR_GALLERY:
         if (!$config['allow_avatar_local'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
      break;
 
      case AVATAR_REMOTE:
         if (!$config['allow_avatar_remote'] && !$ignore_config)
         {
            return '';
         }
      break;
   }
 
   $avatar_img .= $avatar;
   return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
}
/includes/functions.php перед добавить

Код: Выделить всё

if (!function_exists('get_user_avatar'))
{
   function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
   {
      global $user, $config, $phpbb_root_path, $phpEx;
 
      if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
      {
         return '';
      }
 
      $avatar_img = '';
 
      switch ($avatar_type)
      {
         case AVATAR_UPLOAD:
            if (!$config['allow_avatar_upload'] && !$ignore_config)
            {
               return '';
            }
            $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
         break;
 
         case AVATAR_GALLERY:
            if (!$config['allow_avatar_local'] && !$ignore_config)
            {
               return '';
            }
            $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
         break;
 
         case AVATAR_REMOTE:
            if (!$config['allow_avatar_remote'] && !$ignore_config)
            {
               return '';
            }
         break;
      }
 
      $avatar_img .= $avatar;
      return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
   }
}
после

Код: Выделить всё

// The following assigns all _common_ variables that may be used at any point in a template.
   $template->assign_vars(array(
добавить

Код: Выделить всё

  'U_AVATAR_IMG'               => $user->data['is_registered'] ? get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']) : false,
для вывода аватары использовать в шаблоне код

Код: Выделить всё

<!-- IF not S_IS_BOT and S_USER_LOGGED_IN -->
<!-- IF U_AVATAR_IMG -->
<a href="{U_PROFILE}">{U_AVATAR_IMG}</a>
<!-- ELSE -->
<a href="{U_PROFILE}"><img src="{T_THEME_PATH}/images/no_avatar.png" alt=""></a>
<!-- ENDIF -->
<!-- ENDIF -->
Аватара пользователя
Татьяна5
Поддержка
Поддержка
Сообщения: 13159
Стаж: 15 лет 1 месяц
Благодарил (а): 236 раз
Поблагодарили: 3750 раз

Re: Доработка вывода аватарки текущего пользователя на главн

Сообщение Татьяна5 »

ucp_pm_viewmessage.php перед вызовом user_rank

Код: Выделить всё

if (!function_exists('get_user_avatar'))
	{
		include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
	}
Условие не срабатывает, т.к. функция get_user_avatar уже задана в functions.php.

-----------------------------------------------------------------------

1. Удалить правки, указанные в предыдущем посте
2.
/includes/functions.php
Найти

Код: Выделить всё

// The following assigns all _common_ variables that may be used at any point in a template.
   $template->assign_vars(array(
Добавить после:

Код: Выделить всё

'U_AVATAR_IMG'                  => $user->data['is_registered'] ? get_user_avatar_2($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']) : false,
Найти: Добавить перед:

Код: Выделить всё

function get_user_avatar_2($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
   {
      global $user, $config, $phpbb_root_path, $phpEx;
 
      if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
      {
         return '';
      }
 
      $avatar_img = '';
 
      switch ($avatar_type)
      {
         case AVATAR_UPLOAD:
            if (!$config['allow_avatar_upload'] && !$ignore_config)
            {
               return '';
            }
            $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
         break;
 
         case AVATAR_GALLERY:
            if (!$config['allow_avatar_local'] && !$ignore_config)
            {
               return '';
            }
            $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
         break;
 
         case AVATAR_REMOTE:
            if (!$config['allow_avatar_remote'] && !$ignore_config)
            {
               return '';
            }
         break;
      }
 
      $avatar_img .= $avatar;
      return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
   }
Вывод в шаблон - без изменений

Код: Выделить всё

<!-- IF not S_IS_BOT and S_USER_LOGGED_IN -->
<!-- IF U_AVATAR_IMG -->
<a href="{U_PROFILE}">{U_AVATAR_IMG}</a>
<!-- ELSE -->
<a href="{U_PROFILE}"><img src="{T_THEME_PATH}/images/no_avatar.png" alt=""></a>
<!-- ENDIF -->
<!-- ENDIF -->

Вернуться в «Поддержка phpBB 3.0.х»