forked from trustmaster/cot-thanks
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththanks.comments.query.php
More file actions
34 lines (26 loc) · 968 Bytes
/
thanks.comments.query.php
File metadata and controls
34 lines (26 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=comments.query
[END_COT_EXT]
==================== */
/**
* Thanks comments query
*
* @package thanks
* @copyright Copyright (c) Vladimir Sibirov
* @license BSD
*/
defined('COT_CODE') or die('Wrong URL');
global $db_thanks;
require_once cot_incfile('thanks', 'plug');
$comments_join_columns .= ", (SELECT COUNT(*) FROM `$db_thanks` WHERE th_ext = 'comments' AND th_item = c.com_id) AS thanks_count";
if ($usr['id'] > 0 && cot_auth('plug', 'thanks', 'W'))
{
$comments_join_columns .= ", (SELECT COUNT(*) FROM `$db_thanks` WHERE `th_fromuser` = {$usr['id']} AND `th_touser` = c.com_authorid AND DATE(`th_date`) = DATE(NOW())) AS thanks_touser_today
, (SELECT COUNT(*) FROM `$db_thanks` WHERE `th_fromuser` = {$usr['id']} AND `th_ext` = 'comments' AND `th_item` = c.com_id) AS thanks_toitem";
}
if ($cfg['plugin']['comments']['comorder'])
{
$comments_order = "thanks_count DESC, " . $comments_order;
}