Completed
Push — develop-3.2.x ( 3829e8...a269e9 )
by Matt
02:35
created

similar_topics::is_viewable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
/**
3
*
4
* Precise Similar Topics
5
*
6
* @copyright (c) 2013 Matt Friedman
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace vse\similartopics\core;
12
13
class similar_topics
14
{
15
	/** @var \phpbb\auth\auth */
16
	protected $auth;
17
18
	/** @var \phpbb\cache\service */
19
	protected $cache;
20
21
	/** @var \phpbb\config\config */
22
	protected $config;
23
24
	/** @var \phpbb\db\driver\driver_interface */
25
	protected $db;
26
27
	/** @var \phpbb\event\dispatcher_interface */
28
	protected $dispatcher;
29
30
	/** @var \phpbb\language\language */
31
	protected $langauge;
32
33
	/** @var \phpbb\pagination */
34
	protected $pagination;
35
36
	/** @var \phpbb\request\request */
37
	protected $request;
38
39
	/** @var \phpbb\template\template */
40
	protected $template;
41
42
	/** @var \phpbb\user */
43
	protected $user;
44
45
	/** @var \phpbb\content_visibility */
46
	protected $content_visibility;
47
48
	/** @var string phpBB root path  */
49
	protected $root_path;
50
51
	/** @var string PHP file extension */
52
	protected $php_ext;
53
54
	/**
55
	 * Constructor
56
	 *
57
	 * @param \phpbb\auth\auth                  $auth
58
	 * @param \phpbb\cache\service              $cache
59
	 * @param \phpbb\config\config              $config
60
	 * @param \phpbb\db\driver\driver_interface $db
61
	 * @param \phpbb\event\dispatcher_interface $dispatcher
62
	 * @param \phpbb\language\language          $language
63
	 * @param \phpbb\pagination                 $pagination
64
	 * @param \phpbb\request\request            $request
65
	 * @param \phpbb\template\template          $template
66
	 * @param \phpbb\user                       $user
67
	 * @param \phpbb\content_visibility         $content_visibility
68
	 * @param string                            $root_path
69
	 * @param string                            $php_ext
70
	 * @access public
71
	 */
72
	public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\language\language $language, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\content_visibility $content_visibility, $root_path, $php_ext)
73
	{
74
		$this->auth = $auth;
75
		$this->cache = $cache;
76
		$this->config = $config;
77
		$this->db = $db;
78
		$this->dispatcher = $dispatcher;
79
		$this->language = $language;
0 ignored issues
show
Bug introduced by
The property language does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
80
		$this->pagination = $pagination;
81
		$this->request = $request;
82
		$this->template = $template;
83
		$this->user = $user;
84
		$this->content_visibility = $content_visibility;
85
		$this->root_path = $root_path;
86
		$this->php_ext = $php_ext;
87
	}
88
89
	/**
90
	* Is similar topics available?
91
	*
92
	* @return bool True if available, false otherwise
93
	* @access public
94
	*/
95
	public function is_available()
96
	{
97
		return $this->is_enabled() && $this->is_viewable() && $this->is_mysql();
98
	}
99
100
	/**
101
	 * Is similar topics configured?
102
	 *
103
	 * @return bool True if configured, false otherwise
104
	 * @access public
105
	 */
106
	public function is_enabled()
107
	{
108
		return !empty($this->config['similar_topics']) && !empty($this->config['similar_topics_limit']);
109
	}
110
111
	/**
112
	 * Is similar topics viewable bu the user?
113
	 *
114
	 * @return bool True if viewable, false otherwise
115
	 * @access public
116
	 */
117
	public function is_viewable()
118
	{
119
		return !empty($this->user->data['user_similar_topics']) && $this->auth->acl_get('u_similar_topics');
120
	}
121
122
	/**
123
	* Is the forum available for displaying similar topics
124
	*
125
	* @param int $forum_id A forum identifier
126
	* @return bool True if available, false otherwise
127
	* @access public
128
	*/
129
	public function forum_available($forum_id)
130
	{
131
		return !in_array($forum_id, explode(',', $this->config['similar_topics_hide']));
132
	}
133
134
	/**
135
	* Get similar topics by matching topic titles
136
	*
137
	* NOTE: Currently requires MySQL due to the use of FULLTEXT indexes
138
	* and MATCH and AGAINST and UNIX_TIMESTAMP. MySQL FULLTEXT has built-in
139
	* English ignore words. We use phpBB's ignore words for non-English
140
	* languages. We also remove any admin-defined special ignore words.
141
	*
142
	* @param	array	$topic_data	Array with topic data
143
	* @return 	null
144
	* @access	public
145
	*/
146
	public function display_similar_topics($topic_data)
147
	{
148
		$topic_title = $this->clean_topic_title($topic_data['topic_title']);
149
150
		// If the cleaned up topic_title is empty, no need to continue
151
		if (empty($topic_title))
152
		{
153
			return;
154
		}
155
156
		// Similar Topics query
157
		$sql_array = array(
158
			'SELECT'	=> "f.forum_id, f.forum_name, t.*,
159
				MATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') AS score",
160
161
			'FROM'		=> array(
162
				TOPICS_TABLE	=> 't',
163
			),
164
			'LEFT_JOIN'	=> array(
165
				array(
166
					'FROM'	=>	array(FORUMS_TABLE	=> 'f'),
167
					'ON'	=> 'f.forum_id = t.forum_id',
168
				),
169
			),
170
			'WHERE'		=> "MATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') >= 0.5
171
				AND t.topic_status <> " . ITEM_MOVED . '
172
				AND t.topic_visibility = ' . ITEM_APPROVED . '
173
				AND t.topic_time > (UNIX_TIMESTAMP() - ' . $this->config['similar_topics_time'] . ')
174
				AND t.topic_id <> ' . (int) $topic_data['topic_id'],
175
			//'GROUP_BY'	=> 't.topic_id',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
176
			//'ORDER_BY'	=> 'score DESC', // this is done automatically by MySQL when not using IN BOOLEAN MODE
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
177
		);
178
179
		// Add topic tracking data to the query (only if query caching is off)
180
		if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache'])
181
		{
182
			$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $this->user->data['user_id']);
183
			$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = f.forum_id AND ft.user_id = ' . $this->user->data['user_id']);
184
			$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as f_mark_time';
185
		}
186
		else if ($this->config['load_anon_lastread'] || $this->user->data['is_registered'])
187
		{
188
			// Cookie based tracking copied from search.php
189
			$tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
190
			$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
191
		}
192
193
		// We need to exclude passworded forums so we do not leak the topic title
194
		$passworded_forums = $this->user->get_passworded_forums();
195
196
		// See if the admin set this forum to only search a specific group of other forums, and include them
197
		if (!empty($topic_data['similar_topic_forums']))
198
		{
199
			// Remove any passworded forums from this group of forums we will be searching
200
			$included_forums = array_diff(explode(',', $topic_data['similar_topic_forums']), $passworded_forums);
201
			// if there's nothing left to display (user has no access to the forums we want to search)
202
			if (empty($included_forums))
203
			{
204
				return;
205
			}
206
207
			$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $included_forums);
208
		}
209
		// Otherwise, see what forums are not allowed to be searched, and exclude them
210
		else if (!empty($this->config['similar_topics_ignore']))
211
		{
212
			// Add passworded forums to the exlude array
213
			$excluded_forums = array_unique(array_merge(explode(',', $this->config['similar_topics_ignore']), $passworded_forums));
214
			$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $excluded_forums, true);
215
		}
216
		// In all other cases, exclude any passworded forums the user is not allowed to view
217
		else if (!empty($passworded_forums))
218
		{
219
			$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $passworded_forums, true);
220
		}
221
222
		/**
223
		* Event to modify the sql_array for similar topics
224
		*
225
		* @event vse.similartopics.get_topic_data
226
		* @var	array	sql_array	SQL array to get similar topics data
227
		* @since 1.3.0
228
		*/
229
		$vars = array('sql_array');
230
		extract($this->dispatcher->trigger_event('vse.similartopics.get_topic_data', compact($vars)));
0 ignored issues
show
Bug introduced by
$this->dispatcher->trigg..._data', compact($vars)) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
231
232
		$sql = $this->db->sql_build_query('SELECT', $sql_array);
233
		$result = $this->db->sql_query_limit($sql, $this->config['similar_topics_limit'], 0, $this->config['similar_topics_cache']);
234
235
		// Grab icons
236
		$icons = $this->cache->obtain_icons();
237
238
		$rowset = array();
239
240
		while ($row = $this->db->sql_fetchrow($result))
241
		{
242
			$similar_forum_id = (int) $row['forum_id'];
243
			$similar_topic_id = (int) $row['topic_id'];
244
			$rowset[$similar_topic_id] = $row;
245
246
			if ($this->auth->acl_get('f_read', $similar_forum_id))
247
			{
248
				// Get topic tracking info
249
				if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache'])
250
				{
251
					$topic_tracking_info = get_topic_tracking($similar_forum_id, $similar_topic_id, $rowset, array($similar_forum_id => $row['f_mark_time']));
252
				}
253
				else if ($this->config['load_anon_lastread'] || $this->user->data['is_registered'])
254
				{
255
					$topic_tracking_info = get_complete_topic_tracking($similar_forum_id, $similar_topic_id);
256
257
					if (!$this->user->data['is_registered'])
258
					{
259
						$this->user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $this->config['board_startdate']) : 0;
260
					}
261
				}
262
263
				// Replies
264
				$replies = $this->content_visibility->get_count('topic_posts', $row, $similar_forum_id) - 1;
265
266
				// Get folder img, topic status/type related information
267
				$folder_img = $folder_alt = $topic_type = '';
268
				$unread_topic = (isset($topic_tracking_info[$similar_topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$similar_topic_id]) ? true : false;
269
				topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
270
271
				$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $this->auth->acl_get('m_approve', $similar_forum_id)) ? true : false;
272
				$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $this->auth->acl_get('m_approve', $similar_forum_id)) ? true : false;
273
				//$topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
274
				$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$similar_topic_id", true, $this->user->session_id) : '';
275
				//$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "i=queue&amp;mode=deleted_topics&amp;t=$similar_topic_id", true, $this->user->session_id) : $u_mcp_queue;
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
276
277
				$base_url = append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&amp;t=' . $similar_topic_id);
278
279
				$topic_row = array(
280
					'TOPIC_AUTHOR_FULL'		=> get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
281
					'FIRST_POST_TIME'		=> $this->user->format_date($row['topic_time']),
282
					'LAST_POST_TIME'		=> $this->user->format_date($row['topic_last_post_time']),
283
					'LAST_POST_AUTHOR_FULL'	=> get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
284
285
					'TOPIC_REPLIES'			=> $replies,
286
					'TOPIC_VIEWS'			=> $row['topic_views'],
287
					'TOPIC_TITLE'			=> censor_text($row['topic_title']),
288
					'FORUM_TITLE'			=> $row['forum_name'],
289
290
					'TOPIC_IMG_STYLE'		=> $folder_img,
291
					'TOPIC_FOLDER_IMG'		=> $this->user->img($folder_img, $folder_alt),
292
					'TOPIC_FOLDER_IMG_ALT'	=> $this->language->lang($folder_alt),
293
294
					'TOPIC_ICON_IMG'		=> (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
295
					'TOPIC_ICON_IMG_WIDTH'	=> (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
296
					'TOPIC_ICON_IMG_HEIGHT'	=> (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
297
					'ATTACH_ICON_IMG'		=> ($this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $similar_forum_id) && $row['topic_attachment']) ? $this->user->img('icon_topic_attach', $this->language->lang('TOTAL_ATTACHMENTS')) : '',
298
					'UNAPPROVED_IMG'		=> ($topic_unapproved || $posts_unapproved) ? $this->user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
299
300
					'S_UNREAD_TOPIC'		=> $unread_topic,
301
					'S_TOPIC_REPORTED'		=> (!empty($row['topic_reported']) && $this->auth->acl_get('m_report', $similar_forum_id)) ? true : false,
302
					'S_TOPIC_UNAPPROVED'	=> $topic_unapproved,
303
					'S_POSTS_UNAPPROVED'	=> $posts_unapproved,
304
					//'S_TOPIC_DELETED'		=> $topic_deleted,
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
305
					'S_HAS_POLL'			=> ($row['poll_start']) ? true : false,
306
307
					'U_NEWEST_POST'			=> append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&amp;t=' . $similar_topic_id . '&amp;view=unread') . '#unread',
308
					'U_LAST_POST'			=> append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&amp;t=' . $similar_topic_id . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
309
					'U_VIEW_TOPIC'			=> append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&amp;t=' . $similar_topic_id),
310
					'U_VIEW_FORUM'			=> append_sid("{$this->root_path}viewforum.{$this->php_ext}", 'f=' . $similar_forum_id),
311
					'U_MCP_REPORT'			=> append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=reports&amp;mode=reports&amp;f=' . $similar_forum_id . '&amp;t=' . $similar_topic_id, true, $this->user->session_id),
312
					'U_MCP_QUEUE'			=> $u_mcp_queue,
313
				);
314
315
				/**
316
				* Event to modify the similar topics template block
317
				*
318
				* @event vse.similartopics.modify_topicrow
319
				* @var	array	row			Array with similar topic data
320
				* @var	array	topic_row	Template block array
321
				* @since 1.3.0
322
				*/
323
				$vars = array('row', 'topic_row');
324
				extract($this->dispatcher->trigger_event('vse.similartopics.modify_topicrow', compact($vars)));
0 ignored issues
show
Bug introduced by
$this->dispatcher->trigg...icrow', compact($vars)) cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
325
326
				$this->template->assign_block_vars('similar', $topic_row);
327
328
				$this->pagination->generate_template_pagination($base_url, 'similar.pagination', 'start', $replies + 1, $this->config['posts_per_page'], 1, true, true);
329
			}
330
		}
331
332
		$this->db->sql_freeresult($result);
333
334
		$this->language->add_lang('similar_topics', 'vse/similartopics');
335
336
		$this->template->assign_vars(array(
337
			'L_SIMILAR_TOPICS'	=> $this->language->lang('SIMILAR_TOPICS'),
338
			'NEWEST_POST_IMG'	=> $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
339
			'LAST_POST_IMG'		=> $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
340
			'REPORTED_IMG'		=> $this->user->img('icon_topic_reported', 'TOPIC_REPORTED'),
341
			//'DELETED_IMG'		=> $this->user->img('icon_topic_deleted', 'TOPIC_DELETED'),
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
342
			'POLL_IMG'			=> $this->user->img('icon_topic_poll', 'TOPIC_POLL'),
343
		));
344
	}
345
346
	/**
347
	* Clean topic title (and if needed, ignore-words)
348
	*
349
	* @param	string	$text	The topic title
350
	* @return	string	The topic title
351
	* @access	public
352
	*/
353
	public function clean_topic_title($text)
354
	{
355
		// Strip quotes, ampersands
356
		$text = str_replace(array('&quot;', '&amp;'), '', $text);
357
358
		if (!$this->english_lang() || $this->has_ignore_words())
359
		{
360
			$text = $this->strip_stop_words($text);
361
		}
362
363
		return $text;
364
	}
365
366
	/**
367
	* Remove any non-english and/or custom defined ignore-words
368
	*
369
	* @param	string	$text			The topic title
370
	* @return	string	The topic title
371
	* @access	protected
372
	*/
373
	protected function strip_stop_words($text)
374
	{
375
		$words = array();
376
377
		// Retrieve a language dependent list of words to be ignored (method copied from search.php)
378
		$search_ignore_words = "{$this->user->lang_path}{$this->user->lang_name}/search_ignore_words.{$this->php_ext}";
379
		if (!$this->english_lang() && file_exists($search_ignore_words))
380
		{
381
			include($search_ignore_words);
382
		}
383
384
		if ($this->has_ignore_words())
385
		{
386
			// Merge any custom defined ignore words from the ACP to the stop-words array
387
			$words = array_merge($this->make_word_array($this->config['similar_topics_words']), $words);
388
		}
389
390
		// Remove stop-words from the topic title text
391
		$words = array_diff($this->make_word_array($text), $words);
392
393
		// Convert our words array back to a string
394
		$text = (!empty($words)) ? implode(' ', $words) : '';
395
396
		return $text;
397
	}
398
399
	/**
400
	* Helper function to split string into an array of words
401
	*
402
	* @param	string	$text	String of plain text words
403
	* @return	array	Array of plaintext words
404
	* @access	protected
405
	*/
406
	protected function make_word_array($text)
407
	{
408
		// Strip out any non-alpha-numeric characters using PCRE regex syntax
409
		$text = trim(preg_replace('#[^\p{L}\p{N}]+#u', ' ', $text));
410
411
		$words = explode(' ', utf8_strtolower($text));
412
		foreach ($words as $key => $word)
413
		{
414
			// Strip words of 2 characters or less
415
			if (utf8_strlen(trim($word)) < 3)
416
			{
417
				unset($words[$key]);
418
			}
419
		}
420
421
		return $words;
422
	}
423
424
	/**
425
	* Check if English is the current user's language
426
	*
427
	* @return	bool	True if lang is 'en' or 'en_us', false otherwise
428
	* @access	protected
429
	*/
430
	protected function english_lang()
431
	{
432
		return ($this->user->lang_name == 'en' || $this->user->lang_name == 'en_us');
433
	}
434
435
	/**
436
	* Check if custom ignore words have been defined for similar topics
437
	*
438
	* @return	bool	True or false
439
	* @access	protected
440
	*/
441
	protected function has_ignore_words()
442
	{
443
		return !empty($this->config['similar_topics_words']);
444
	}
445
446
	/**
447
	* Check if the database layer is MySQL4 or later
448
	*
449
	* @return	bool	True is MySQL4 or later, false otherwise
450
	* @access	protected
451
	*/
452
	protected function is_mysql()
453
	{
454
		return ($this->db->get_sql_layer() == 'mysql4' || $this->db->get_sql_layer() == 'mysqli');
455
	}
456
}
457