helper::get_mcp_queue_url()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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&amp;f={$topic_data['forum_id']}&amp;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') . "&amp;f={$post_data['forum_id']}&amp;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&amp;f={$topic_data['forum_id']}&amp;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']}&amp;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&amp;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}&amp;" . urlencode('fid[]') . "=$forum_id&amp;sc=0&amp;sf=titleonly&amp;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&amp;mode=post_details&amp;f=$forum_id&amp;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&amp;p={$post_data['post_id']}&amp;f={$post_data['forum_id']}&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url . '&amp;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&amp;f={$topic_data['forum_id']}&amp;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&amp;mode=report_details&amp;f=' . $post_data['forum_id'] . '&amp;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&amp;mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&amp;f=' . $post_data['forum_id'] . '&amp;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&amp;mode=user_notes&amp;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&amp;mode=warn_post&amp;f=' . $post_data['forum_id'] . '&amp;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&amp;mode=unapproved_posts&amp;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&amp;mode=content&amp;do=view&amp;type=$content_type&amp;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&amp;mode=topic_view&amp;f=$forum_id&amp;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&amp;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) ? '&amp;redirect=' . urlencode($url) : '';
240
	}
241
}
242