Only allow friends to chat see #5264

skala
Julio Montoya 13 years ago
parent df6d9821e8
commit 3fb5d2fe6c
  1. 8
      main/inc/lib/chat.lib.php
  2. 13
      main/inc/lib/social.lib.php

@ -173,6 +173,10 @@ class Chat extends Model {
* @return void Prints "1"
*/
function send($from_user_id, $to_user_id, $message) {
$user_friend_relation = SocialManager::get_relation_between_contacts($from_user_id, $to_user_id);
if ($user_friend_relation == USER_RELATION_TYPE_FRIEND) {
$user_info = api_get_user_info($to_user_id, true);
$this->save_window($to_user_id);
@ -205,6 +209,10 @@ class Chat extends Model {
//print_r($_SESSION['chatHistory']);
echo "1";
exit;
} else {
echo "0";
exit;
}
}
/**
* Close a specific chat box (user ID taken from $_POST['chatbox'])

@ -49,8 +49,8 @@ class SocialManager extends UserManager {
} else {
return $friend_relation_list;
}
}
/**
* Get relation type contact by name
* @param string names of the kind of relation
@ -58,14 +58,14 @@ class SocialManager extends UserManager {
* @author isaac flores paz
*/
public static function get_relation_type_by_name ($relation_type_name) {
$list_type_friend=array();
$list_type_friend=self::show_list_type_friends();
$list_type_friend = self::show_list_type_friends();
foreach ($list_type_friend as $value_type_friend) {
if (strtolower($value_type_friend['title'])==$relation_type_name) {
return $value_type_friend['id'];
}
}
}
/**
* Get the kind of relation between contacts
* @param int user id
@ -80,7 +80,7 @@ class SocialManager extends UserManager {
'WHERE rt.id=(SELECT uf.relation_type FROM '.$tbl_my_friend.' uf WHERE user_id='.((int)$user_id).' AND friend_user_id='.((int)$user_friend).' AND uf.relation_type <> '.USER_RELATION_TYPE_RRHH.' )';
$res=Database::query($sql);
if (Database::num_rows($res)>0) {
$row=Database::fetch_array($res,'ASSOC');
$row = Database::fetch_array($res,'ASSOC');
return $row['id'];
} else {
return USER_UNKNOW;
@ -531,6 +531,9 @@ class SocialManager extends UserManager {
}
$user_info = api_get_user_info($user_id, true);
$current_user_id = api_get_user_id();
$user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
$show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
//$show_messages = array('messages', 'messages_inbox', 'messages_outbox', 'messages_compose');
@ -655,7 +658,7 @@ class SocialManager extends UserManager {
}
//@todo check if user is online and if it's a friend to show the chat link
if (api_get_setting('allow_global_chat') == 'true' && $show_full_profile) {
if (api_get_setting('allow_global_chat') == 'true' && $user_friend_relation == USER_RELATION_TYPE_FRIEND) {
if ($user_id != api_get_user_id()) {
$user_name = $user_info['complete_name'];

Loading…
Cancel
Save