1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2016 Daniel A. (blitze) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace blitze\content\services; |
11
|
|
|
|
12
|
|
|
class helper extends permissions |
13
|
|
|
{ |
14
|
|
|
/** @var string */ |
15
|
|
|
protected $phpbb_root_path; |
16
|
|
|
|
17
|
|
|
/** @var string */ |
18
|
|
|
protected $php_ext; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Constructor |
22
|
|
|
* |
23
|
|
|
* @param \phpbb\auth\auth $auth Auth object |
24
|
|
|
* @param \phpbb\config\db $config Config object |
25
|
|
|
* @param \phpbb\user $user User object |
26
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
27
|
|
|
* @param string $php_ext php file extension |
28
|
|
|
*/ |
29
|
|
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\db $config, \phpbb\user $user, $phpbb_root_path, $php_ext) |
30
|
|
|
{ |
31
|
|
|
parent::__construct($auth, $config, $user); |
32
|
|
|
|
33
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
34
|
|
|
$this->php_ext = $php_ext; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param array $post_data |
39
|
|
|
* @param array $topic_data |
40
|
|
|
* @param string $redirect_url |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
public function get_edit_url(array $post_data, array $topic_data, $redirect_url) |
44
|
|
|
{ |
45
|
|
|
return ($this->edit_allowed($post_data, $topic_data)) |
46
|
|
|
? append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=edit&f={$topic_data['forum_id']}&p={$post_data['post_id']}" . $this->get_redirect_url($redirect_url)) |
47
|
|
|
: ''; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param array $post_data |
52
|
|
|
* @param array $topic_data |
53
|
|
|
* @param string $redirect_url |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function get_delete_url(array $post_data, array $topic_data, $redirect_url) |
57
|
|
|
{ |
58
|
|
|
return ($this->delete_allowed($post_data, $topic_data)) |
59
|
|
|
? append_sid("{$this->phpbb_root_path}posting.$this->php_ext", 'mode=' . (($this->softdelete_allowed($post_data)) ? 'soft_delete' : 'delete') . "&f={$post_data['forum_id']}&p={$post_data['post_id']}" . $this->get_redirect_url($redirect_url)) |
60
|
|
|
: ''; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param array $post_data |
65
|
|
|
* @param array $topic_data |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function get_quote_url(array $post_data, array $topic_data) |
69
|
|
|
{ |
70
|
|
|
return ($this->post_is_quotable($post_data, $topic_data) && $this->quote_allowed($topic_data)) |
71
|
|
|
? append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=quote&f={$topic_data['forum_id']}&p={$post_data['post_id']}") |
72
|
|
|
: ''; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param array $topic_data |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function get_viewtopic_url(array $topic_data) |
80
|
|
|
{ |
81
|
|
|
return append_sid("{$this->phpbb_root_path}viewtopic.$this->php_ext", "f={$topic_data['forum_id']}&t={$topic_data['topic_id']}"); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param array $topic_data |
86
|
|
|
* @return string |
87
|
|
|
*/ |
88
|
|
|
public function get_print_topic_url(array $topic_data) |
89
|
|
|
{ |
90
|
|
|
return ($this->auth->acl_get('f_print', $topic_data['forum_id'])) ? $topic_data['topic_url'] . '?view=print' : ''; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param array $topic_data |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function get_email_topic_url(array $topic_data) |
98
|
|
|
{ |
99
|
|
|
return ($this->auth->acl_get('f_email', $topic_data['forum_id']) && $this->config['email_enable']) |
100
|
|
|
? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=email&t=' . $topic_data['topic_id']) |
101
|
|
|
: ''; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param int $forum_id |
106
|
|
|
* @param string $username |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
|
|
public function get_search_users_posts_url($forum_id, $username) |
110
|
|
|
{ |
111
|
|
|
return append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", "author={$username}&" . urlencode('fid[]') . "=$forum_id&sc=0&sf=titleonly&sr=topics"); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param array $post_data |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
public function get_info_url(array $post_data) |
119
|
|
|
{ |
120
|
|
|
$forum_id = $post_data['forum_id']; |
121
|
|
|
return ($this->auth->acl_get('m_info', $forum_id)) |
122
|
|
|
? append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", "i=main&mode=post_details&f=$forum_id&p=" . $post_data['post_id'], true, $this->user->session_id) |
123
|
|
|
: ''; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param array $post_data |
128
|
|
|
* @param string $viewtopic_url |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function get_approve_url(array $post_data, $viewtopic_url) |
132
|
|
|
{ |
133
|
|
|
return append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", "i=queue&p={$post_data['post_id']}&f={$post_data['forum_id']}&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $post_data['post_id'] . '#p' . $post_data['post_id']))); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param array $post_data |
138
|
|
|
* @param array $topic_data |
139
|
|
|
* @param string $redirect_url |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
public function get_mcp_edit_url(array $post_data, array $topic_data, $redirect_url) |
143
|
|
|
{ |
144
|
|
|
return append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=edit&f={$topic_data['forum_id']}&p={$post_data['post_id']}" . $this->get_redirect_url($redirect_url)); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param array $post_data |
149
|
|
|
* @return string |
150
|
|
|
*/ |
151
|
|
|
public function get_mcp_report_url(array $post_data) |
152
|
|
|
{ |
153
|
|
|
return ($this->auth->acl_get('m_report', $post_data['forum_id'])) |
154
|
|
|
? append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=reports&mode=report_details&f=' . $post_data['forum_id'] . '&p=' . $post_data['post_id'], true, $this->user->session_id) |
155
|
|
|
: ''; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param array $post_data |
160
|
|
|
* @param array $topic_data |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
|
|
public function get_mcp_restore_url(array $post_data, array $topic_data) |
164
|
|
|
{ |
165
|
|
|
return ($this->auth->acl_get('m_approve', $post_data['forum_id'])) |
166
|
|
|
? append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=queue&mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&f=' . $post_data['forum_id'] . '&p=' . $post_data['post_id'], true, $this->user->session_id) |
167
|
|
|
: ''; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param array $post_data |
172
|
|
|
* @return string |
173
|
|
|
*/ |
174
|
|
|
public function get_notes_url(array $post_data) |
175
|
|
|
{ |
176
|
|
|
return ($this->auth->acl_getf_global('m_')) |
177
|
|
|
? append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=notes&mode=user_notes&u=' . $post_data['poster_id'], true, $this->user->session_id) |
178
|
|
|
: ''; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param array $post_data |
183
|
|
|
* @return string |
184
|
|
|
*/ |
185
|
|
|
public function get_warning_url(array $post_data) |
186
|
|
|
{ |
187
|
|
|
return ($this->auth->acl_get('m_warn') && !$this->user_is_poster($post_data['poster_id']) && $post_data['poster_id'] != ANONYMOUS) |
188
|
|
|
? append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=warn&mode=warn_post&f=' . $post_data['forum_id'] . '&p=' . $post_data['post_id'], true, $this->user->session_id) |
189
|
|
|
: ''; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param int $topic_id |
194
|
|
|
* @return string |
195
|
|
|
*/ |
196
|
|
|
public function get_mcp_queue_url($topic_id) |
197
|
|
|
{ |
198
|
|
|
return append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", "i=queue&mode=unapproved_posts&t=$topic_id", true, $this->user->session_id); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @param string $content_type |
203
|
|
|
* @param int $topic_id |
204
|
|
|
* @return string |
205
|
|
|
*/ |
206
|
|
|
public function get_mcp_review_url($content_type, $topic_id) |
207
|
|
|
{ |
208
|
|
|
return append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", "i=-blitze-content-mcp-content_module&mode=content&do=view&type=$content_type&t=$topic_id"); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param int $forum_id |
213
|
|
|
* @param int $topic_id |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
public function get_mcp_url($forum_id, $topic_id) |
217
|
|
|
{ |
218
|
|
|
$u_mcp = ''; |
219
|
|
|
if ($this->auth->acl_get('m_', $forum_id)) |
220
|
|
|
{ |
221
|
|
|
if ($topic_id) |
222
|
|
|
{ |
223
|
|
|
$u_mcp = append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", "i=mcp_main&mode=topic_view&f=$forum_id&t=$topic_id", true, $this->user->session_id); |
224
|
|
|
} |
225
|
|
|
else |
226
|
|
|
{ |
227
|
|
|
$u_mcp = append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=-blitze-content-mcp-content_module&mode=content', true, $this->user->session_id); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
return $u_mcp; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @param string $url |
235
|
|
|
* @return string |
236
|
|
|
*/ |
237
|
|
|
protected function get_redirect_url($url) |
238
|
|
|
{ |
239
|
|
|
return ($url) ? '&redirect=' . urlencode($url) : ''; |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
|