|
|
|
@ -91,6 +91,35 @@ class SocialManager extends UserManager |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get count of friends from user |
|
|
|
|
* |
|
|
|
|
* @param int $userId |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function getCountFriends($userId) |
|
|
|
|
{ |
|
|
|
|
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER); |
|
|
|
|
$userId = (int) $userId; |
|
|
|
|
if (empty($userId)) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = 'SELECT count(friend_user_id) count |
|
|
|
|
FROM '.$tbl_my_friend.' |
|
|
|
|
WHERE |
|
|
|
|
relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND |
|
|
|
|
friend_user_id<>'.($userId).' AND |
|
|
|
|
user_id='.($userId); |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
if (Database::num_rows($res)) { |
|
|
|
|
$row = Database::fetch_array($res, 'ASSOC'); |
|
|
|
|
return (int) $row['count']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets friends id list |
|
|
|
|
* @param int user id |
|
|
|
@ -350,7 +379,6 @@ class SocialManager extends UserManager |
|
|
|
|
*/ |
|
|
|
|
public static function get_list_invitation_sent_by_user_id($user_id) |
|
|
|
|
{ |
|
|
|
|
$list_friend_invitation = array(); |
|
|
|
|
$tbl_message = Database::get_main_table(TABLE_MESSAGE); |
|
|
|
|
$sql = 'SELECT user_receiver_id, send_date,title,content |
|
|
|
|
FROM '.$tbl_message.' |
|
|
|
@ -358,11 +386,35 @@ class SocialManager extends UserManager |
|
|
|
|
user_sender_id = '.intval($user_id).' AND |
|
|
|
|
msg_status = '.MESSAGE_STATUS_INVITATION_PENDING; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$list = array(); |
|
|
|
|
while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
|
|
|
$list_friend_invitation[$row['user_receiver_id']] = $row; |
|
|
|
|
$list[$row['user_receiver_id']] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $list_friend_invitation; |
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get count invitation sent by user |
|
|
|
|
* @author Julio Montoya <gugli100@gmail.com> |
|
|
|
|
* @param int user id |
|
|
|
|
* @return array() |
|
|
|
|
*/ |
|
|
|
|
public static function getCountInvitationSent($user_id) |
|
|
|
|
{ |
|
|
|
|
$tbl_message = Database::get_main_table(TABLE_MESSAGE); |
|
|
|
|
$sql = 'SELECT count(user_receiver_id) count |
|
|
|
|
FROM '.$tbl_message.' |
|
|
|
|
WHERE |
|
|
|
|
user_sender_id = '.intval($user_id).' AND |
|
|
|
|
msg_status = '.MESSAGE_STATUS_INVITATION_PENDING; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
if (Database::num_rows($res)) { |
|
|
|
|
$row = Database::fetch_array($res, 'ASSOC'); |
|
|
|
|
return (int) $row['count']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|