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
|
|
|
abstract class urls |
13
|
|
|
{ |
14
|
|
|
/** @var \phpbb\auth\auth */ |
15
|
|
|
protected $auth; |
16
|
|
|
|
17
|
|
|
/** @var \phpbb\config\db */ |
18
|
|
|
protected $config; |
19
|
|
|
|
20
|
|
|
/** @var \phpbb\user */ |
21
|
|
|
protected $user; |
22
|
|
|
|
23
|
|
|
/** @var string */ |
24
|
|
|
protected $phpbb_root_path; |
25
|
|
|
|
26
|
|
|
/** @var string */ |
27
|
|
|
protected $php_ext; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Constructor |
31
|
|
|
* |
32
|
|
|
* @param \phpbb\auth\auth $auth Auth object |
33
|
|
|
* @param \phpbb\config\db $config Config object |
34
|
|
|
* @param \phpbb\user $user User object |
35
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
36
|
|
|
* @param string $php_ext php file extension |
37
|
|
|
*/ |
38
|
|
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\db $config, \phpbb\user $user, $phpbb_root_path, $php_ext) |
39
|
|
|
{ |
40
|
|
|
$this->auth = $auth; |
41
|
|
|
$this->config = $config; |
42
|
|
|
$this->user = $user; |
43
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
44
|
|
|
$this->php_ext = $php_ext; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param array $post_data |
49
|
|
|
* @param array $topic_data |
50
|
|
|
* @param string $cp_mode |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function get_edit_url(array $post_data, array $topic_data, $cp_mode = '') |
54
|
|
|
{ |
55
|
|
|
$cp_param = $this->get_cp_param($post_data, $topic_data, $cp_mode); |
56
|
|
|
return ($this->edit_allowed($post_data, $topic_data)) ? append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=edit&f={$topic_data['forum_id']}&p={$post_data['post_id']}" . $cp_param) : ''; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param array $post_data |
61
|
|
|
* @param array $topic_data |
62
|
|
|
* @param string $cp_mode |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function get_delete_url(array $post_data, array $topic_data, $cp_mode = '') |
66
|
|
|
{ |
67
|
|
|
$cp_param = $this->get_cp_param($post_data, $topic_data, $cp_mode); |
68
|
|
|
return ($this->delete_allowed($post_data, $topic_data)) ? 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']}" . $cp_param) : ''; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param array $post_data |
73
|
|
|
* @param array $topic_data |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function get_quote_url(array $post_data, array $topic_data) |
77
|
|
|
{ |
78
|
|
|
return ($this->post_is_quotable($post_data, $topic_data) && $this->quote_allowed($topic_data)) ? append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=quote&f={$topic_data['forum_id']}&p={$post_data['post_id']}") : ''; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param array $topic_data |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function get_viewtopic_url(array $topic_data) |
86
|
|
|
{ |
87
|
|
|
return append_sid("{$this->phpbb_root_path}viewtopic.$this->php_ext", "f={$topic_data['forum_id']}&t={$topic_data['topic_id']}"); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param array $topic_data |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function get_print_topic_url(array $topic_data) |
95
|
|
|
{ |
96
|
|
|
return ($this->auth->acl_get('f_print', $topic_data['forum_id'])) ? $topic_data['topic_url'] . '?view=print' : ''; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param array $topic_data |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function get_email_topic_url(array $topic_data) |
104
|
|
|
{ |
105
|
|
|
return ($this->auth->acl_get('f_email', $topic_data['forum_id']) && $this->config['email_enable']) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=email&t=' . $topic_data['topic_id']) : ''; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param int $forum_id |
110
|
|
|
* @param string $username |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
public function get_search_users_posts_url($forum_id, $username) |
114
|
|
|
{ |
115
|
|
|
return append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", "author={$username}&" . urlencode('fid[]') . "=$forum_id&sc=0&sf=titleonly&sr=topics"); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param array $post_data |
120
|
|
|
* @return string |
121
|
|
|
*/ |
122
|
|
|
public function get_info_url(array $post_data) |
123
|
|
|
{ |
124
|
|
|
$forum_id = $post_data['forum_id']; |
125
|
|
|
return ($this->auth->acl_get('m_info', $forum_id)) ? 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) : ''; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param array $post_data |
130
|
|
|
* @param string $viewtopic_url |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
public function get_approve_url(array $post_data, $viewtopic_url) |
134
|
|
|
{ |
135
|
|
|
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']))); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param array $post_data |
140
|
|
|
* @param array $topic_data |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
public function get_mcp_edit_url(array $post_data, array $topic_data) |
144
|
|
|
{ |
145
|
|
|
return append_sid("{$this->phpbb_root_path}posting.$this->php_ext", "mode=edit&f={$topic_data['forum_id']}&p={$post_data['post_id']}&cp=mcp"); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param array $post_data |
150
|
|
|
* @return string |
151
|
|
|
* |
152
|
|
|
public function get_mcp_approve_url(array $post_data) |
153
|
|
|
{ |
154
|
|
|
return append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", 'i=queue&mode=approve_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
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
|
|
public function get_mcp_report_url(array $post_data) |
163
|
|
|
{ |
164
|
|
|
return ($this->auth->acl_get('m_report', $post_data['forum_id'])) ? 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) : ''; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param array $post_data |
169
|
|
|
* @param array $topic_data |
170
|
|
|
* @return string |
171
|
|
|
*/ |
172
|
|
|
public function get_mcp_restore_url(array $post_data, array $topic_data) |
173
|
|
|
{ |
174
|
|
|
return ($this->auth->acl_get('m_approve', $post_data['forum_id'])) ? 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) : ''; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param array $post_data |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
|
|
public function get_notes_url(array $post_data) |
182
|
|
|
{ |
183
|
|
|
return ($this->auth->acl_getf_global('m_')) ? 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) : ''; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param array $post_data |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
|
|
public function get_warning_url(array $post_data) |
191
|
|
|
{ |
192
|
|
|
return ($this->auth->acl_get('m_warn') && !$this->user_is_poster($post_data['poster_id']) && $post_data['poster_id'] != ANONYMOUS) ? 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) : ''; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param int $topic_id |
197
|
|
|
* @return string |
198
|
|
|
*/ |
199
|
|
|
public function get_mcp_queue_url($topic_id) |
200
|
|
|
{ |
201
|
|
|
return append_sid("{$this->phpbb_root_path}mcp.$this->php_ext", "i=queue&mode=unapproved_posts&t=$topic_id", true, $this->user->session_id); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param string $content_type |
206
|
|
|
* @param int $topic_id |
207
|
|
|
* @return string |
208
|
|
|
*/ |
209
|
|
|
public function get_mcp_review_url($content_type, $topic_id) |
210
|
|
|
{ |
211
|
|
|
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"); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return string |
216
|
|
|
*/ |
217
|
|
|
public function get_mcp_url($forum_id, $topic_id) |
218
|
|
|
{ |
219
|
|
|
$u_mcp = ''; |
220
|
|
|
if ($this->auth->acl_get('m_', $forum_id)) |
221
|
|
|
{ |
222
|
|
|
if ($topic_id) |
223
|
|
|
{ |
224
|
|
|
$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); |
225
|
|
|
} |
226
|
|
|
else |
227
|
|
|
{ |
228
|
|
|
$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); |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
return $u_mcp; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @param array $post_data |
236
|
|
|
* @param array $topic_data |
237
|
|
|
* @param string $cp_mode |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
protected function get_cp_param(array $post_data, array $topic_data, $cp_mode) |
241
|
|
|
{ |
242
|
|
|
$cp_param = ''; |
243
|
|
|
if ($topic_data['topic_first_post_id'] == $post_data['post_id']) |
244
|
|
|
{ |
245
|
|
|
$cp_param = '&cp=' . ((!$cp_mode) ? (($this->user_is_poster($post_data['poster_id'])) ? 'ucp' : 'mcp') : $cp_mode); |
246
|
|
|
} |
247
|
|
|
return $cp_param; |
248
|
|
|
} |
249
|
|
|
} |
250
|
|
|
|