Don't show link to start chat with non-friend users

1.10.x
Angel Fernando Quiroz Campos 9 years ago
parent 18caca0130
commit 5315a2cc37
  1. 14
      main/inc/lib/social.lib.php
  2. 15
      main/template/default/social/user_block.tpl

@ -1649,6 +1649,10 @@ class SocialManager extends UserManager
return '';
}
$currentUserId = api_get_user_id();
$userId = intval($userId);
$userRelationType = 0;
$socialAvatarBlock = SocialManager::show_social_avatar_block(
$groupBlock,
$groupId,
@ -1656,8 +1660,14 @@ class SocialManager extends UserManager
);
$profileEditionLink = null;
if (api_get_user_id() == $userId) {
if ($currentUserId === $userId) {
$profileEditionLink = Display::getProfileEditionLink($userId);
} else {
$userRelationType = SocialManager::get_relation_between_contacts(
$currentUserId,
$userId
);
}
$vCardUserLink = Display::getVCardUserLink($userId);
@ -1684,6 +1694,8 @@ class SocialManager extends UserManager
}
$chatEnabled = api_is_global_chat_enabled();
$template->assign('chat_enabled', $chatEnabled);
$template->assign('user_relation', $userRelationType);
$template->assign('user_relation_type_friend', USER_RELATION_TYPE_FRIEND);
$templateName = $template->get_template('social/user_block.tpl');
if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) {

@ -32,20 +32,19 @@
</li>
{% endif %}
{% if chat_enabled == 1 %}
{% if user.user_is_online_in_chat != 0 %}
{% if user_relation == user_relation_type_friend %}
<li class="item">
{% if user.id == _u.id %}
<img src="{{ "online.png" | icon }}" alt="{{ "Online" | get_lang }}">
{{ "Chat" | get_lang }} ({{ "Online" | get_lang }})
{% elseif user.user_is_online_in_chat != 0 %}
<a onclick="javascript:chatWith('{{ user.id }}', '{{ user.complete_name }}', '{{ user.user_is_online }}','{{ user.avatar_small }}')" href="javascript:void(0);">
<img src="{{ "online.png" | icon }}" alt="{{ "Online" | get_lang }}">
{{ "Chat" | get_lang }} ({{ "Online" | get_lang }})
</a>
{% else %}
<img src="{{ "offline.png" | icon }}" alt="{{ "Online" | get_lang }}">
{{ "Chat" | get_lang }} ({{ "Offline" | get_lang }})
{% endif %}
</li>
{# else #}
{# <img src="{{ "offline.png" | icon }}" alt="{{ "Online" | get_lang }}"> #}
{# {{ "Chat" | get_lang }} ({{ "Offline" | get_lang }}) #}
{% endif %}
{% endif %}
{% endif %}
{% if not profile_edition_link is empty %}

Loading…
Cancel
Save