1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Member Avatar & Status [MAS]. An extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2018-forever, Dark❶ [dark1] |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0-only) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace dark1\memberavatarstatus\event; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @ignore |
15
|
|
|
*/ |
16
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
17
|
|
|
use dark1\memberavatarstatus\core\avatar; |
18
|
|
|
use dark1\memberavatarstatus\core\status; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Member Avatar & Status Event listener. |
22
|
|
|
*/ |
23
|
|
|
class review_listener implements EventSubscriberInterface |
24
|
|
|
{ |
25
|
|
|
/** @var avatar*/ |
26
|
|
|
protected $avatar; |
27
|
|
|
|
28
|
|
|
/** @var status*/ |
29
|
|
|
protected $status; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Constructor for listener |
33
|
|
|
* |
34
|
|
|
* @param avatar $avatar dark1 avatar |
35
|
|
|
* @param status $status dark1 status |
36
|
|
|
* @access public |
37
|
|
|
*/ |
38
|
|
|
public function __construct(avatar $avatar, status $status) |
39
|
|
|
{ |
40
|
|
|
$this->avatar = $avatar; |
41
|
|
|
$this->status = $status; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Assign functions defined in this class to event listeners in the core |
46
|
|
|
* |
47
|
|
|
* @return array |
48
|
|
|
* @static |
49
|
|
|
* @access public |
50
|
|
|
*/ |
51
|
|
|
static public function getSubscribedEvents() |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
'core.topic_review_modify_row' => 'mas_posting_topic_review_template', |
55
|
|
|
'core.message_history_modify_template_vars' => 'mas_pm_history_review_template', |
56
|
|
|
'core.mcp_topic_review_modify_row' => 'mas_mcp_topic_review_template', |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* MAS Posting Topic Review Template Setup |
64
|
|
|
* |
65
|
|
|
* @param object $event The event object |
66
|
|
|
* @return null |
67
|
|
|
* @access public |
68
|
|
|
*/ |
69
|
|
|
public function mas_posting_topic_review_template($event) |
70
|
|
|
{ |
71
|
|
|
// Get Event Array `row` & `post_row` |
72
|
|
|
$row = $event['row']; |
73
|
|
|
$post_row = $event['post_row']; |
74
|
|
|
|
75
|
|
|
// Set Avatar |
76
|
|
|
$avatar = $this->avatar->mas_get_avatar('dark1_mas_rv', $row['user_id']); |
77
|
|
|
|
78
|
|
|
// Get Online Status |
79
|
|
|
$online = $this->status->mas_get_online('dark1_mas_rv', $row['user_id']); |
80
|
|
|
|
81
|
|
|
// Add Avatar & Online Status to post_row |
82
|
|
|
$post_row = array_merge($post_row, [ |
83
|
|
|
'AVATAR_IMG' => $avatar, |
84
|
|
|
'S_ONLINE' => $online, |
85
|
|
|
]); |
86
|
|
|
|
87
|
|
|
// Assign post_row to event -> post_row |
88
|
|
|
$event['post_row'] = $post_row; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* MAS PM History Review Template Setup |
95
|
|
|
* |
96
|
|
|
* @param object $event The event object |
97
|
|
|
* @return null |
98
|
|
|
* @access public |
99
|
|
|
*/ |
100
|
|
|
public function mas_pm_history_review_template($event) |
101
|
|
|
{ |
102
|
|
|
// Get Event Array `row` & `template_vars` |
103
|
|
|
$row = $event['row']; |
104
|
|
|
$template_vars = $event['template_vars']; |
105
|
|
|
|
106
|
|
|
// Set Avatar |
107
|
|
|
$avatar = $this->avatar->mas_get_avatar('dark1_mas_rv', $row['user_id']); |
108
|
|
|
|
109
|
|
|
// Get Online Status |
110
|
|
|
$online = $this->status->mas_get_online('dark1_mas_rv', $row['user_id']); |
111
|
|
|
|
112
|
|
|
// Add Avatar & Online Status to template_vars |
113
|
|
|
$template_vars = array_merge($template_vars, [ |
114
|
|
|
'AVATAR_IMG' => $avatar, |
115
|
|
|
'S_ONLINE' => $online, |
116
|
|
|
]); |
117
|
|
|
|
118
|
|
|
// Assign template_vars to event -> template_vars |
119
|
|
|
$event['template_vars'] = $template_vars; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* MAS MCP Topic Review Template Setup |
126
|
|
|
* |
127
|
|
|
* @param object $event The event object |
128
|
|
|
* @return null |
129
|
|
|
* @access public |
130
|
|
|
*/ |
131
|
|
|
public function mas_mcp_topic_review_template($event) |
132
|
|
|
{ |
133
|
|
|
// Get Event Array `row` & `post_row` |
134
|
|
|
$row = $event['row']; |
135
|
|
|
$post_row = $event['post_row']; |
136
|
|
|
|
137
|
|
|
// Set Avatar |
138
|
|
|
$avatar = $this->avatar->mas_get_avatar('dark1_mas_rv', $row['poster_id']); |
139
|
|
|
|
140
|
|
|
// Get Online Status |
141
|
|
|
$online = $this->status->mas_get_online('dark1_mas_rv', $row['poster_id']); |
142
|
|
|
|
143
|
|
|
// Add Avatar & Online Status to post_row |
144
|
|
|
$post_row = array_merge($post_row, [ |
145
|
|
|
'AVATAR_IMG' => $avatar, |
146
|
|
|
'S_ONLINE' => $online, |
147
|
|
|
]); |
148
|
|
|
|
149
|
|
|
// Assign post_row to event -> post_row |
150
|
|
|
$event['post_row'] = $post_row; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
} |
154
|
|
|
|