-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.php
100 lines (89 loc) · 2.81 KB
/
main.php
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
*
* @package Who Visited This Topic
* @copyright (c) 2015 BruninoIt
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace bruninoit\wvtt\controller;
class main
{
protected $auth;
protected $template;
protected $db;
protected $wvtt_table;
protected $user;
protected $helper;
public function __construct(\phpbb\template\template $template, \phpbb\db\driver\driver_interface $db, $wvtt_table, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\controller\helper $helper)
{
$this->template = $template;
$this->db = $db;
$this->wvtt_table = $wvtt_table;
$this->auth = $auth;
$this->user = $user;
$this->helper = $helper;
}
public function handle($topic_id)
{
$page_name=$this->user->lang['WVTT_TITLE'];
//content start
//topic title
$topic_query = "SELECT topic_title
FROM " . TOPICS_TABLE . "
WHERE topic_id = " . $topic_id . "";
$topic_query_g = $this->db->sql_query($topic_query);
$topic_query_arr = $this->db->sql_fetchrow($topic_query_g);
$topic_title = $topic_query_arr['topic_title'];
$this->template->assign_var('TOPIC_TITLE', $topic_title);
//list
$query = "SELECT w.*, u.*
FROM " . $this->wvtt_table . " w, " . USERS_TABLE . " u
WHERE w.topic_id = " . $topic_id . "
AND w.user_id=u.user_id
GROUP BY w.user_id";
$list_query = $this->db->sql_query($query);
while($list = $this->db->sql_fetchrow($list_query))
{
$username = $list['username'];
$user_colour = ($list['user_colour']) ? ' style="color:#' . $list['user_colour'] . '" class="username-coloured"' : '';
$user_id = $list['user_id'];
if($this->auth->acl_get('u_wvtt_count'))
{
$cont = "SELECT COUNT(user_id) AS total
FROM " . $this->wvtt_table . "
WHERE topic_id = " . $topic_id . "
AND user_id = " . $user_id . "";
$result = $this->db->sql_query($cont);
$visits = (int) $this->db->sql_fetchfield('total');
}else{
$visits = null;
}
$date = "SELECT date
FROM " . $this->wvtt_table . "
WHERE topic_id = " . $topic_id . "
AND user_id = " . $user_id . "
ORDER BY date DESC";
$date_query = $this->db->sql_query($date);
$date_array = $this->db->sql_fetchrow($date_query);
$date = $date_array['date'];
$date = $this->user->format_date($date);
$this->template->assign_block_vars('wvtt_list',array(
'USERNAME' => $username,
'USERNAME_COLOUR' => $user_colour,
'VISITS' => $visits,
'DATE' => $date
));
}
if($this->auth->acl_get('u_wvtt_popup'))
{
$this->template->assign_var('PERMISSION_VIEW', true);
}
if($this->auth->acl_get('u_wvtt_count'))
{
$this->template->assign_var('PERMISSION_COUNT', true);
}
//content end
return $this->helper->render('wvtt_popup.html', $page_name);
}
}