tiki-view_forum.php 17.4 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
6
//
melmut's avatar
melmut committed
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9
// $Id$
changi67's avatar
changi67 committed
10

mose's avatar
mose committed
11
$section = 'forums';
melmut's avatar
melmut committed
12
require_once ('tiki-setup.php');
13
if ($prefs['feature_categories'] == 'y') {
14
	$categlib = TikiLib::lib('categ');
15
}
16
if ($prefs['feature_freetags'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
17
	$freetaglib = TikiLib::lib('freetag');
18
}
19 20 21

$access->check_feature('feature_forums');

changi67's avatar
changi67 committed
22
$auto_query_args = array(
23 24 25 26 27 28 29 30 31 32
	'forumId',
	'comment_threadId',
	'comment_offset',
	'comment_threshold',
	'thread_sort_mode',
	'time_control',
	'show_archived',
	'poster',
	'filter_type',
	'reply_state'
changi67's avatar
changi67 committed
33
);
pkdille's avatar
pkdille committed
34

35
$commentslib = TikiLib::lib('comments');
pkdille's avatar
pkdille committed
36

37
if (!isset($_REQUEST['forumId']) || !($forum_info = $commentslib->get_forum($_REQUEST['forumId']))) {
38
	$smarty->assign('errortype', 'no_redirect_login');
39 40
	$smarty->assign('msg', tra('No forum indicated'));
	$smarty->display('error.tpl');
41
	die;
42
}
pkdille's avatar
pkdille committed
43

44 45 46 47
if (isset($_REQUEST['comments_postCancel'])) {
	unset($_REQUEST['comments_threadId']);
	unset($_REQUEST['comments_title']);
	unset($_REQUEST['openpost']);
48
}
pkdille's avatar
pkdille committed
49

50
if (isset($_REQUEST['openpost'])) {
51
	$smarty->assign('openpost', 'y');
52
} else {
53
	$smarty->assign('openpost', 'n');
54
}
55
$smarty->assign('forumId', $_REQUEST['forumId']);
56
$tikilib->get_perm_object($_REQUEST['forumId'], 'forum', $forum_info, true);
pkdille's avatar
pkdille committed
57

58 59
// Now if the user is the moderator then give him forum admin privs -. SHOULD BE IN get_perm_object
if ($tiki_p_admin_forum != 'y' && $user) {
60 61 62 63
	if ($forum_info['moderator'] == $user
		|| in_array($forum_info['moderator_group'], $userlib->get_user_groups($user))
		|| Perms::get('forum', $_REQUEST['forumId'])->admin_forum)
	{
64 65
		$tiki_p_admin_forum = 'y';
	}
66

67 68 69 70 71 72 73 74 75 76 77
	if ($tiki_p_admin_forum == 'y') {
		$smarty->assign('tiki_p_admin_forum', 'y');
		$tiki_p_forum_post = 'y';
		$smarty->assign('tiki_p_forum_post', 'y');
		$tiki_p_forum_read = 'y';
		$smarty->assign('tiki_p_forum_read', 'y');
		$tiki_p_forum_vote = 'y';
		$smarty->assign('tiki_p_forum_vote', 'y');
		$tiki_p_forum_post_topic = 'y';
		$smarty->assign('tiki_p_forum_post_topic', 'y');
	}
78
}
79

80
$access->check_permission(array('tiki_p_forum_read'), '', 'forum', $_REQUEST['forumId']);
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
//add tablesorter sorting and filtering
$tsOn = Table_Check::isEnabled(true);
$smarty->assign('tsOn', $tsOn);
$tsAjax = Table_Check::isAjaxCall();
$smarty->assign('tsAjax', $tsAjax);
static $iid = 0;
++$iid;
$ts_tableid = 'viewforum' . $_REQUEST['forumId'] . '-' . $iid;
$smarty->assign('ts_tableid', $ts_tableid);
if ($tsOn) {
	$ts_countid = $ts_tableid . '-count';
	$ts_offsetid = $ts_tableid . '-offset';
	$smarty->assign('ts_countid', $ts_countid);
	$smarty->assign('ts_offsetid', $ts_offsetid);
}

if (!$tsOn || ($tsOn && $tsAjax)) {
	$commentslib->forum_add_hit($_REQUEST["forumId"]);
}
pkdille's avatar
pkdille committed
101

102
if (isset($_REQUEST['report']) && $tiki_p_forums_report == 'y') {
103 104
	check_ticket('view-forum');
	$commentslib->report_post($_REQUEST['forumId'], 0, $_REQUEST['report'], $user, '');
105
}
pkdille's avatar
pkdille committed
106

melmut's avatar
melmut committed
107
if ($tiki_p_admin_forum == 'y') {
lindonb's avatar
lindonb committed
108
	//don't see where this is used on tiki-view_forum.tpl - it is used on tiki-view_forum_thread.tpl
109
	if (isset($_REQUEST['remove_attachment'])) {
110
		$access->check_authenticity(tra('Are you sure you want to remove that attachment?'));
111
		$commentslib->remove_thread_attachment($_REQUEST['remove_attachment']);
112
	}
lindonb's avatar
lindonb committed
113
	//locking the entire forum is not fully implemented - only threads can be locked currently
114 115 116 117 118 119 120 121 122 123
	if (isset($_REQUEST['lock']) && isset($_REQUEST['forumId'])) {
		check_ticket('view-forum');
		if ($_REQUEST['lock'] == 'y') {
			$commentslib->lock_object_thread('forum:' . ((int)$_REQUEST['forumId']));
			$forum_info['is_locked'] = 'y';
		} elseif ($_REQUEST['lock'] == 'n') {
			$commentslib->unlock_object_thread('forum:' . ((int)$_REQUEST['forumId']));
			$forum_info['is_locked'] = 'n';
		}
	}
changi67's avatar
changi67 committed
124
}
pkdille's avatar
pkdille committed
125

melmut's avatar
melmut committed
126
$smarty->assign_by_ref('forum_info', $forum_info);
127 128
$comments_per_page = $forum_info['topicsPerPage'];
$thread_sort_mode = $forum_info['topicOrdering'];
pkdille's avatar
pkdille committed
129 130
$comments_vars = array('forumId');

melmut's avatar
melmut committed
131 132
$comments_prefix_var = 'forum:';
$comments_object_var = 'forumId';
pkdille's avatar
pkdille committed
133 134 135 136 137

if (isset($forum_info['inbound_pop_server']) && !empty($forum_info['inbound_pop_server'])) {
	$commentslib->process_inbound_mail($_REQUEST['forumId']);
}

melmut's avatar
melmut committed
138
if (!isset($_REQUEST['comments_threshold'])) {
139
	$_REQUEST['comments_threshold'] = 0;
140
}
pkdille's avatar
pkdille committed
141

melmut's avatar
melmut committed
142
$smarty->assign('comments_threshold', $_REQUEST['comments_threshold']);
143 144
if (!isset($_REQUEST['comments_threadId'])) {
	$_REQUEST['comments_threadId'] = 0;
145
}
pkdille's avatar
pkdille committed
146

147
$smarty->assign('comments_threadId', $_REQUEST['comments_threadId']);
melmut's avatar
melmut committed
148
if (!isset($comments_prefix_var)) {
149
	$comments_prefix_var = '';
150
}
pkdille's avatar
pkdille committed
151

melmut's avatar
melmut committed
152
if (!isset($comments_object_var) || (!$comments_object_var) || !isset($_REQUEST[$comments_object_var])) {
153
	die('the comments_object_var variable is not set or cannot be found as a REQUEST variable');
154
}
pkdille's avatar
pkdille committed
155

changi67's avatar
changi67 committed
156
$comments_objectId = $comments_prefix_var . $_REQUEST["$comments_object_var"];
pkdille's avatar
pkdille committed
157

changi67's avatar
changi67 committed
158
// Process a post form here
melmut's avatar
melmut committed
159
$smarty->assign('warning', 'n');
pkdille's avatar
pkdille committed
160

161 162 163 164
if ($tiki_p_forum_post_topic == 'n'
			&& isset($_REQUEST['comments_postComment'])
			&& isset($_REQUEST['comments_title'])
			&& $_REQUEST['forumId'] == $prefs['wiki_forum_id']
pkdille's avatar
pkdille committed
165
			&& $tikilib->page_exists($_REQUEST['comments_title'])) {
166
	$tiki_p_forum_post_topic = 'y';
167
}
pkdille's avatar
pkdille committed
168

169
//Here we either post to a forum or create a new thread
170
if (isset($_REQUEST['comments_postComment'])) {
171 172 173 174
	check_ticket('view-forum');
	$errors = array();
	$feedbacks = array();
	$threadId = $commentslib->post_in_forum($forum_info, $_REQUEST, $feedbacks, $errors);
175 176 177
	if ($threadId && $prefs['feature_freetags'] == 'y') {
		$cat_type = 'forum post';
		$cat_objid = $threadId;
178
		include_once ('freetag_apply.php');
179
	}
180 181
	$smarty->assign_by_ref('errors', $errors);
	$smarty->assign_by_ref('feedbacks', $feedbacks);
changi67's avatar
changi67 committed
182
}
pkdille's avatar
pkdille committed
183

184
// Here we send the user to the right thread/topic if it already exists; this
pkdille's avatar
pkdille committed
185
// is used for the 'discuss' tab. This is done down here because the thread
186
// might have to be created, which happens above.
187
if (isset($_REQUEST['comments_postComment'])) {
188
	// Check if the thread/topic already existis
189
	$threadId = $commentslib->check_for_topic($_REQUEST['comments_title'], $_REQUEST['comments_data']);
190
	// If it does, send the user there with no delay.
191
	if ($threadId && count($errors) === 0) {
192 193 194 195 196 197
		// If the samely titled comment already
		// exists, go straight to it.
		$url = 'tiki-view_forum_thread.php?comments_parentId=' . urlencode($threadId) . '&forumId=' . urlencode($_REQUEST["forumId"]);
		header('location: ' . $url);
		exit;
	}
changi67's avatar
changi67 committed
198
}
pkdille's avatar
pkdille committed
199

melmut's avatar
melmut committed
200
if ($tiki_p_admin_forum == 'y' || $tiki_p_forum_vote == 'y') {
201
	// Process a vote here
202
	if (isset($_REQUEST['comments_vote']) && isset($_REQUEST['comments_threadId'])) {
203 204
		check_ticket('view-forum');
		$comments_show = 'y';
205 206
		if ($tikilib->register_user_vote($user, 'comment' . $_REQUEST['comments_threadId'], $_REQUEST['comments_vote'], range(1, 5))) {
			$commentslib->vote_comment($_REQUEST['comments_threadId'], $user, $_REQUEST['comments_vote']);
207
		}
208
		$_REQUEST['comments_threadId'] = 0;
209 210
		$smarty->assign('comments_threadId', 0);
	}
changi67's avatar
changi67 committed
211
}
pkdille's avatar
pkdille committed
212

213
if ($user) {
214 215
	$userinfo = $userlib->get_user_info($user);
	$smarty->assign_by_ref('userinfo', $userinfo);
changi67's avatar
changi67 committed
216
}
pkdille's avatar
pkdille committed
217

218
if (isset($_REQUEST['comments_remove']) && isset($_REQUEST['comments_threadId'])) {
219
	if ($tiki_p_admin_forum == 'y'
220 221
			|| ($commentslib->user_can_edit_post($user, $_REQUEST['comments_threadId']) && $tiki_p_forum_post_topic == 'y')
	) {
222
		$access->check_authenticity(tra('Are you sure you want to remove that topic?'));
223
		$comments_show = 'y';
224 225
		$commentslib->remove_comment($_REQUEST['comments_threadId']);
		$commentslib->register_remove_post($_REQUEST['forumId'], 0);
226 227 228
	} else { // user can't edit this post
		$smarty->assign('msg', tra('You are not permitted to remove someone else\'s post!'));
		$smarty->assign('errortype', 'no_redirect_login');
229
		$smarty->display('error.tpl');
230 231
		die;
	}
232
	unset($_REQUEST['comments_threadId']);
233
	$smarty->assign('comments_threadId', 0);
changi67's avatar
changi67 committed
234
}
pkdille's avatar
pkdille committed
235

236 237
if ($_REQUEST['comments_threadId'] > 0) {
	$comment_info = $commentslib->get_comment($_REQUEST['comments_threadId']);
238 239
	$smarty->assign('comment_title', isset($_REQUEST['comments_title']) ? $_REQUEST['comments_title'] : $comment_info['title']);
	$smarty->assign('comment_data', isset($_REQUEST['comments_data']) ? $_REQUEST['comments_data'] : $comment_info['data']);
240
	$smarty->assign(
241 242
		'comment_topictype',
		isset($_REQUEST['comment_topictype']) ? $_REQUEST['comment_topictype'] : $comment_info['type']
243 244
	);
	$smarty->assign(
245 246
		'comment_topicsummary',
		isset($_REQUEST['comment_topicsummary']) ? $_REQUEST['comment_topicsummary'] : $comment_info['summary']
247 248
	);
	$smarty->assign('comment_topicsmiley', $comment_info['smiley']);
249
} else {
250 251 252
	$smarty->assign('comment_title', isset($_REQUEST['comments_title']) ? $_REQUEST['comments_title'] : '');
	$smarty->assign('comment_data', isset($_REQUEST['comments_data']) ? $_REQUEST['comments_data'] : '');
	$smarty->assign('comment_topictype', isset($_REQUEST['comment_topictype']) ? $_REQUEST['comment_topictype'] : '');
253 254 255
	$smarty->assign('comment_topictype', 'n');
	$smarty->assign('comment_topicsummary', '');
	$smarty->assign('comment_topicsmiley', '');
changi67's avatar
changi67 committed
256
}
pkdille's avatar
pkdille committed
257

melmut's avatar
melmut committed
258
$smarty->assign('comment_preview', 'n');
259
if (isset($_REQUEST['comments_previewComment'])) {
260
	check_ticket('view-forum');
261 262 263 264 265 266 267
	$smarty->assign('comments_preview_title', $_REQUEST['comments_title']);
	$smarty->assign('comments_preview_data', ($commentslib->parse_comment_data($_REQUEST['comments_data'])));
	$smarty->assign('comment_title', $_REQUEST['comments_title']);
	$smarty->assign('comment_data', $_REQUEST['comments_data']);
	$smarty->assign('comment_topictype', $_REQUEST['comment_topictype']);
	if ($forum_info['topic_summary'] == 'y') $smarty->assign('comment_topicsummary', $_REQUEST['comment_topicsummary']);
	if ($forum_info['topic_smileys'] == 'y') $smarty->assign('comment_topicsmiley', $_REQUEST['comment_topicsmiley']);
268 269
	$smarty->assign('openpost', 'y');
	$smarty->assign('comment_preview', 'y');
changi67's avatar
changi67 committed
270
}
pkdille's avatar
pkdille committed
271

272
// Check for settings
273 274
if (!isset($_REQUEST['comments_per_page'])) {
	$_REQUEST['comments_per_page'] = $comments_per_page;
275
}
pkdille's avatar
pkdille committed
276

277 278
if (!isset($_REQUEST['thread_sort_mode'])) {
	$_REQUEST['thread_sort_mode'] = $thread_sort_mode;
279
} else {
280
	$comments_show = 'y';
281
}
pkdille's avatar
pkdille committed
282

283 284
if (!isset($_REQUEST['comments_commentFind'])) {
	$_REQUEST['comments_commentFind'] = '';
285
} else {
286
	$comments_show = 'y';
287
}
pkdille's avatar
pkdille committed
288

289 290 291
$smarty->assign('comments_per_page', $_REQUEST['comments_per_page']);
$smarty->assign('thread_sort_mode', $_REQUEST['thread_sort_mode']);
$smarty->assign('comments_commentFind', $_REQUEST['comments_commentFind']);
pkdille's avatar
pkdille committed
292

293
// Offset setting for the list of comments
294
if (!isset($_REQUEST['comments_offset'])) {
295
	$comments_offset = 0;
296
} else {
297
	$comments_offset = $_REQUEST['comments_offset'];
298
}
pkdille's avatar
pkdille committed
299

melmut's avatar
melmut committed
300
$smarty->assign('comments_offset', $comments_offset);
301
// Now check if we are displaying top-level comments or a specific comment
302 303
if (!isset($_REQUEST['comments_parentId'])) {
	$_REQUEST['comments_parentId'] = 0;
304
}
pkdille's avatar
pkdille committed
305

306
$smarty->assign('comments_parentId', $_REQUEST['comments_parentId']);
pkdille's avatar
pkdille committed
307 308 309 310
if (!isset($_REQUEST['time_control'])) {
	$_REQUEST['time_control'] = 0;
}

melmut's avatar
melmut committed
311
$commentslib->set_time_control($_REQUEST['time_control']);
312 313
$show_archived = isset($_REQUEST['show_archived']);
$smarty->assign('show_archived', $show_archived);
changi67's avatar
changi67 committed
314
$view_archived_topics = ($show_archived == 'y' && ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_topics_archiving'] == 'n'));
pkdille's avatar
pkdille committed
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332

if (!isset($_REQUEST['poster']) || $_REQUEST['poster'] == '')
	$user_param = '';
elseif ($_REQUEST['poster'] == '_me')
	$user_param = $user;
else
	$user_param = $_REQUEST['poster'];

if (!isset($_REQUEST['filter_type']))
	$type_param = '';
else
	$type_param = $_REQUEST['filter_type'];

if (!isset($_REQUEST['reply_state']))
	$reply_state = '';
else
	$reply_state = $_REQUEST['reply_state'];

333 334 335 336 337 338 339 340 341 342 343 344 345
//need the info on all threads so leave this even on initial non-ajax load
$comments_coms = $commentslib->get_forum_topics(
	$_REQUEST['forumId'],
	$comments_offset,
	$_REQUEST['comments_per_page'],
	$_REQUEST['thread_sort_mode'],
	$view_archived_topics,
	$user_param,
	$type_param,
	$reply_state,
	$forum_info
);

346
$comments_cant = $commentslib->count_forum_topics(
347 348 349 350 351 352 353 354
	$_REQUEST['forumId'],
	$comments_offset,
	$_REQUEST['comments_per_page'],
	$_REQUEST['thread_sort_mode'],
	$view_archived_topics,
	$user_param,
	$type_param,
	$reply_state
355
);
356 357 358 359 360 361 362 363
//initialize tablesorter
if ($tsOn && !$tsAjax) {
	//set tablesorter code
	Table_Factory::build(
		'TikiViewforum',
		array(
			'id' => $ts_tableid,
			'total' => $comments_cant,
364 365 366
			'pager' => array(
				'max' => $_REQUEST['comments_per_page'],
			),
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
			'ajax' => array(
				'requiredparams' => array(
					'forumId' => $_REQUEST['forumId'],
				),
				'servercount' => array(
					'id' => $ts_countid,
				),
				'serveroffset' => array(
					'id' => $ts_offsetid,
				),
			),
		)
	);
}

pkdille's avatar
pkdille committed
382

changi67's avatar
changi67 committed
383
$last_comments = $commentslib->get_last_forum_posts($_REQUEST['forumId'], $forum_info['forum_last_n']);
pkdille's avatar
pkdille committed
384

changi67's avatar
changi67 committed
385
$smarty->assign_by_ref('last_comments', $last_comments);
melmut's avatar
melmut committed
386
$smarty->assign('comments_cant', $comments_cant);
387
$comments_maxRecords = $_REQUEST["comments_per_page"];
melmut's avatar
melmut committed
388
$smarty->assign_by_ref('comments_coms', $comments_coms);
389 390 391 392 393

$all_coms = $commentslib->get_forum_topics($_REQUEST['forumId'], 0, -1);
$all_coms = array_column($all_coms, 'title', 'threadId');
$smarty->assign('all_coms_encoded', json_encode($all_coms));

394 395
$cat_type = 'forum';
$cat_objid = $_REQUEST["forumId"];
pkdille's avatar
pkdille committed
396

melmut's avatar
melmut committed
397
include_once ('tiki-section_options.php');
pkdille's avatar
pkdille committed
398

399
if ($prefs['feature_user_watches'] == 'y') {
400 401 402
	if ($user && isset($_REQUEST['watch_event'])) {
		check_ticket('view-forum');
		if ($_REQUEST['watch_action'] == 'add') {
403
			$tikilib->add_user_watch(
404 405 406 407 408 409
				$user,
				$_REQUEST['watch_event'],
				$_REQUEST['watch_object'],
				'forum',
				$forum_info['name'],
				'tiki-view_forum.php?forumId=' . $_REQUEST['forumId']
410
			);
411 412 413 414
		} else {
			$tikilib->remove_user_watch($user, $_REQUEST['watch_event'], $_REQUEST['watch_object'], 'forum');
		}
	}
pkdille's avatar
pkdille committed
415

416 417 418 419 420
	if ($user && $watch = $tikilib->user_watches($user, 'forum_post_topic', $_REQUEST['forumId'], 'forum')) {
		$smarty->assign('user_watching_forum', 'y');
	} else {
		$smarty->assign('user_watching_forum', 'n');
	}
pkdille's avatar
pkdille committed
421

422 423 424 425 426
	if ($user && $watch = $tikilib->user_watches($user, 'forum_post_topic_and_thread', $_REQUEST['forumId'], 'forum')) {
		$smarty->assign('user_watching_forum_topic_and_thread', 'y');
	} else {
		$smarty->assign('user_watching_forum_topic_and_thread', 'n');
	}
pkdille's avatar
pkdille committed
427

428 429
	// Check, if the user is watching this forum by a category.
	if ($prefs['feature_categories'] == 'y') {
430
		$watching_categories_temp = $categlib->get_watching_categories($_REQUEST['forumId'], 'forum', $user);
431 432 433 434
		$smarty->assign('category_watched', 'n');
		if (count($watching_categories_temp) > 0) {
			$smarty->assign('category_watched', 'y');
			$watching_categories = array();
435
			foreach ($watching_categories_temp as $wct) {
436 437 438 439 440 441 442 443
				$watching_categories[] = array(
					"categId" => $wct,
					"name" => $categlib->get_category_name($wct)
				);
			}
			$smarty->assign('watching_categories', $watching_categories);
		}
	}
changi67's avatar
changi67 committed
444
}
pkdille's avatar
pkdille committed
445

446
if ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_quickjump'] == 'y') {
447
	$all_forums = $commentslib->list_forums(0, -1, 'name_asc', '');
448
	$temp_max = count($all_forums['data']);
449
	for ($i = 0; $i < $temp_max; $i++) {
450
		if ($userlib->object_has_one_permission($all_forums['data'][$i]['forumId'], 'forum')) {
451 452
			if ($tiki_p_admin == 'y'
						|| $userlib->object_has_permission($user, $all_forums['data'][$i]['forumId'], 'forum', 'tiki_p_admin_forum')
453 454
						|| $userlib->object_has_permission($user, $all_forums['data'][$i]['forumId'], 'forum', 'tiki_p_forum_read')) {
				$all_forums['data'][$i]['can_read'] = 'y';
455
			} else {
456
				$all_forums['data'][$i]['can_read'] = 'n';
457 458
			}
		} else {
459
			$all_forums['data'][$i]['can_read'] = 'y';
460 461 462
		}
	}
	$smarty->assign('all_forums', $all_forums['data']);
463 464
	$all_names = array_column($all_forums['data'], 'name', 'forumId');
	$smarty->assign('all_forums_encoded', json_encode($all_names));
changi67's avatar
changi67 committed
465
}
pkdille's avatar
pkdille committed
466

melmut's avatar
melmut committed
467
$smarty->assign('unread', 0);
468
if ($user && $prefs['feature_messages'] == 'y' && $tiki_p_messages == 'y') {
469 470
	$unread = $tikilib->user_unread_messages($user);
	$smarty->assign('unread', $unread);
melmut's avatar
melmut committed
471
}
pkdille's avatar
pkdille committed
472

melmut's avatar
melmut committed
473
if ($tiki_p_admin_forum == 'y') {
474 475
	$smarty->assign('queued', $commentslib->get_num_queued($comments_objectId));
	$smarty->assign('reported', $commentslib->get_num_reported($_REQUEST['forumId']));
melmut's avatar
melmut committed
476
}
pkdille's avatar
pkdille committed
477

478
if ($prefs['feature_freetags'] == 'y') {
479
	$cat_type = 'forum post';
480
	$cat_objid = $_REQUEST['comments_threadId'];
481
	$cat_lang = $forum_info['forumLanguage'];
482 483
	include_once ("freetag_list.php");
	//If in preview mode get the tags from the form and not from database
484
	if (isset($_REQUEST['comments_previewComment'])) {
485 486
		$smarty->assign('taglist', $_REQUEST["freetag_string"]);
	}
changi67's avatar
changi67 committed
487
}
pkdille's avatar
pkdille committed
488

489
$defaultRows = $prefs['default_rows_textarea_forum'];
pkdille's avatar
pkdille committed
490

491
if ($prefs['feature_contribution'] == 'y') {
492 493
	$contributionItemId = $_REQUEST['comments_threadId'];
	include_once ('contribution.php');
sylvieg's avatar
sylvieg committed
494
}
pkdille's avatar
pkdille committed
495

496
if ($prefs['feature_forum_parse'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
497
	$wikilib = TikiLib::lib('wiki');
498 499
	$plugins = $wikilib->list_plugins(true, 'editpost');
	$smarty->assign_by_ref('plugins', $plugins);
500
}
pkdille's avatar
pkdille committed
501

502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
if (isset($_POST['ajaxtype']) || !empty($_SESSION['ajaxpost' . $_GET['deleted_parentId']])) {
	$smarty->assign('ajaxfeedback', 'y');
	$posted = isset($_POST['ajaxtype']) ? $_POST : $_SESSION['ajaxpost' . $_GET['deleted_parentId']];
	unset($_SESSION['ajaxpost' . $_GET['deleted_parentId']]);
	$ajaxpost = array_intersect_key($posted, [
		'ajaxtype' => '',
		'ajaxheading' => '',
		'ajaxitems' => '',
		'ajaxmsg' => '',
		'ajaxtoMsg' => '',
		'ajaxtoList' => '',
	]);
	$smarty->assign($ajaxpost);
}

melmut's avatar
melmut committed
517
ask_ticket('view-forum');
518 519 520 521 522 523
if ($tsAjax) {
	$smarty->display('tiki-view_forum.tpl');
} else {
	$smarty->assign('mid', 'tiki-view_forum.tpl');
	$smarty->display('tiki.tpl');
}