|
|
|
@ -2736,36 +2736,12 @@ class MessageManager |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Execute the SQL necessary to know the number of messages in the database. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param int $userId The user for which we need the unread messages count |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return int The number of unread messages in the database for the given user |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static function getCountNewMessagesFromDB($userId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MESSAGE); |
|
|
|
|
|
|
|
$sql = "SELECT COUNT(id) as count |
|
|
|
|
|
|
|
FROM $table |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
user_receiver_id=".api_get_user_id()." AND |
|
|
|
|
|
|
|
msg_status = ".MESSAGE_STATUS_UNREAD; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
$row = Database::fetch_assoc($result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $row['count']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $messageId |
|
|
|
* @param int $messageId |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @throws \Doctrine\ORM\Query\QueryException |
|
|
|
* @throws \Doctrine\ORM\Query\QueryException |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function countLikesAndDislikes($messageId, $userId) |
|
|
|
public static function countLikesAndDislikes($messageId, $userId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -2800,8 +2776,9 @@ class MessageManager |
|
|
|
* @param int $userId |
|
|
|
* @param int $userId |
|
|
|
* @param int $groupId Optional. |
|
|
|
* @param int $groupId Optional. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return string |
|
|
|
|
|
|
|
* @throws \Doctrine\ORM\Query\QueryException |
|
|
|
* @throws \Doctrine\ORM\Query\QueryException |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function getLikesButton($messageId, $userId, $groupId = 0) |
|
|
|
public static function getLikesButton($messageId, $userId, $groupId = 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -2834,4 +2811,28 @@ class MessageManager |
|
|
|
|
|
|
|
|
|
|
|
return $btnLike.PHP_EOL.$btnDislike; |
|
|
|
return $btnLike.PHP_EOL.$btnDislike; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Execute the SQL necessary to know the number of messages in the database. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param int $userId The user for which we need the unread messages count |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return int The number of unread messages in the database for the given user |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static function getCountNewMessagesFromDB($userId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MESSAGE); |
|
|
|
|
|
|
|
$sql = "SELECT COUNT(id) as count |
|
|
|
|
|
|
|
FROM $table |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
user_receiver_id=".api_get_user_id()." AND |
|
|
|
|
|
|
|
msg_status = ".MESSAGE_STATUS_UNREAD; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
$row = Database::fetch_assoc($result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $row['count']; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|