tiki-view_forum.php 16.8 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 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') {
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
	if ($commentslib->admin_forum($_REQUEST['forumId']))
61
	{
62 63
		$tiki_p_admin_forum = 'y';
	}
64

65 66 67 68 69 70 71 72 73 74 75
	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');
	}
76
}
77

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

80 81 82 83 84 85 86 87 88 89 90 91 92
//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 || ($tsOn && $tsAjax)) {
	$commentslib->forum_add_hit($_REQUEST["forumId"]);
}
pkdille's avatar
pkdille committed
93

94
if (isset($_REQUEST['report']) && $tiki_p_forums_report == 'y') {
95 96
	check_ticket('view-forum');
	$commentslib->report_post($_REQUEST['forumId'], 0, $_REQUEST['report'], $user, '');
97
}
pkdille's avatar
pkdille committed
98

melmut's avatar
melmut committed
99
if ($tiki_p_admin_forum == 'y') {
lindonb's avatar
lindonb committed
100
	//don't see where this is used on tiki-view_forum.tpl - it is used on tiki-view_forum_thread.tpl
101
	if (isset($_REQUEST['remove_attachment'])) {
102
		$access->check_authenticity(tra('Are you sure you want to remove that attachment?'));
103
		$commentslib->remove_thread_attachment($_REQUEST['remove_attachment']);
104
	}
lindonb's avatar
lindonb committed
105
	//locking the entire forum is not fully implemented - only threads can be locked currently
106 107 108 109 110 111 112 113 114 115
	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
116
}
pkdille's avatar
pkdille committed
117

melmut's avatar
melmut committed
118
$smarty->assign_by_ref('forum_info', $forum_info);
119 120
$comments_per_page = $forum_info['topicsPerPage'];
$thread_sort_mode = $forum_info['topicOrdering'];
pkdille's avatar
pkdille committed
121 122
$comments_vars = array('forumId');

melmut's avatar
melmut committed
123 124
$comments_prefix_var = 'forum:';
$comments_object_var = 'forumId';
pkdille's avatar
pkdille committed
125 126 127 128 129

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

melmut's avatar
melmut committed
130
if (!isset($_REQUEST['comments_threshold'])) {
131
	$_REQUEST['comments_threshold'] = 0;
132
}
pkdille's avatar
pkdille committed
133

melmut's avatar
melmut committed
134
$smarty->assign('comments_threshold', $_REQUEST['comments_threshold']);
135 136
if (!isset($_REQUEST['comments_threadId'])) {
	$_REQUEST['comments_threadId'] = 0;
137
}
pkdille's avatar
pkdille committed
138

139
$smarty->assign('comments_threadId', $_REQUEST['comments_threadId']);
melmut's avatar
melmut committed
140
if (!isset($comments_prefix_var)) {
141
	$comments_prefix_var = '';
142
}
pkdille's avatar
pkdille committed
143

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

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

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

153 154 155 156
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
157
			&& $tikilib->page_exists($_REQUEST['comments_title'])) {
158
	$tiki_p_forum_post_topic = 'y';
159
}
pkdille's avatar
pkdille committed
160

161
//Here we either post to a forum or create a new thread
162
if (isset($_REQUEST['comments_postComment'])) {
163 164 165 166
	check_ticket('view-forum');
	$errors = array();
	$feedbacks = array();
	$threadId = $commentslib->post_in_forum($forum_info, $_REQUEST, $feedbacks, $errors);
167 168 169
	if ($threadId && $prefs['feature_freetags'] == 'y') {
		$cat_type = 'forum post';
		$cat_objid = $threadId;
170
		include_once ('freetag_apply.php');
171
	}
172 173
	$smarty->assign_by_ref('errors', $errors);
	$smarty->assign_by_ref('feedbacks', $feedbacks);
changi67's avatar
changi67 committed
174
}
pkdille's avatar
pkdille committed
175

176
// Here we send the user to the right thread/topic if it already exists; this
pkdille's avatar
pkdille committed
177
// is used for the 'discuss' tab. This is done down here because the thread
178
// might have to be created, which happens above.
179
if (isset($_REQUEST['comments_postComment'])) {
180
	// Check if the thread/topic already existis
181
	$threadId = $commentslib->check_for_topic($_REQUEST['comments_title'], $_REQUEST['comments_data']);
182
	// If it does, send the user there with no delay.
183
	if ($threadId && count($errors) === 0) {
184 185 186 187 188 189
		// 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
190
}
pkdille's avatar
pkdille committed
191

melmut's avatar
melmut committed
192
if ($tiki_p_admin_forum == 'y' || $tiki_p_forum_vote == 'y') {
193
	// Process a vote here
194
	if (isset($_REQUEST['comments_vote']) && isset($_REQUEST['comments_threadId'])) {
195 196
		check_ticket('view-forum');
		$comments_show = 'y';
197 198
		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']);
199
		}
200
		$_REQUEST['comments_threadId'] = 0;
201 202
		$smarty->assign('comments_threadId', 0);
	}
changi67's avatar
changi67 committed
203
}
pkdille's avatar
pkdille committed
204

205
if ($user) {
206 207
	$userinfo = $userlib->get_user_info($user);
	$smarty->assign_by_ref('userinfo', $userinfo);
changi67's avatar
changi67 committed
208
}
pkdille's avatar
pkdille committed
209

210
if (isset($_REQUEST['comments_remove']) && isset($_REQUEST['comments_threadId'])) {
211
	if ($tiki_p_admin_forum == 'y'
212 213
			|| ($commentslib->user_can_edit_post($user, $_REQUEST['comments_threadId']) && $tiki_p_forum_post_topic == 'y')
	) {
214
		$access->check_authenticity(tra('Are you sure you want to remove that topic?'));
215
		$comments_show = 'y';
216 217
		$commentslib->remove_comment($_REQUEST['comments_threadId']);
		$commentslib->register_remove_post($_REQUEST['forumId'], 0);
218
	} else { // user can't edit this post
219
		$smarty->assign('msg', tra('You do not have permission to remove someone else\'s post!'));
220
		$smarty->assign('errortype', 'no_redirect_login');
221
		$smarty->display('error.tpl');
222 223
		die;
	}
224
	unset($_REQUEST['comments_threadId']);
225
	$smarty->assign('comments_threadId', 0);
changi67's avatar
changi67 committed
226
}
pkdille's avatar
pkdille committed
227

228 229
if ($_REQUEST['comments_threadId'] > 0) {
	$comment_info = $commentslib->get_comment($_REQUEST['comments_threadId']);
230 231
	$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']);
232
	$smarty->assign(
233 234
		'comment_topictype',
		isset($_REQUEST['comment_topictype']) ? $_REQUEST['comment_topictype'] : $comment_info['type']
235 236
	);
	$smarty->assign(
237 238
		'comment_topicsummary',
		isset($_REQUEST['comment_topicsummary']) ? $_REQUEST['comment_topicsummary'] : $comment_info['summary']
239 240
	);
	$smarty->assign('comment_topicsmiley', $comment_info['smiley']);
241
} else {
242 243 244
	$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'] : '');
245 246 247
	$smarty->assign('comment_topictype', 'n');
	$smarty->assign('comment_topicsummary', '');
	$smarty->assign('comment_topicsmiley', '');
changi67's avatar
changi67 committed
248
}
pkdille's avatar
pkdille committed
249

melmut's avatar
melmut committed
250
$smarty->assign('comment_preview', 'n');
251
if (isset($_REQUEST['comments_previewComment'])) {
252
	check_ticket('view-forum');
253 254 255 256 257 258 259
	$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']);
260 261
	$smarty->assign('openpost', 'y');
	$smarty->assign('comment_preview', 'y');
changi67's avatar
changi67 committed
262
}
pkdille's avatar
pkdille committed
263

264
// Check for settings
265 266
if (!isset($_REQUEST['comments_per_page'])) {
	$_REQUEST['comments_per_page'] = $comments_per_page;
267
}
pkdille's avatar
pkdille committed
268

269 270
if (!isset($_REQUEST['thread_sort_mode'])) {
	$_REQUEST['thread_sort_mode'] = $thread_sort_mode;
271
} else {
272
	$comments_show = 'y';
273
}
pkdille's avatar
pkdille committed
274

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

281 282 283
$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
284

285
// Offset setting for the list of comments
286
if (!isset($_REQUEST['comments_offset'])) {
287
	$comments_offset = 0;
288
} else {
289
	$comments_offset = $_REQUEST['comments_offset'];
290
}
pkdille's avatar
pkdille committed
291

melmut's avatar
melmut committed
292
$smarty->assign('comments_offset', $comments_offset);
293
// Now check if we are displaying top-level comments or a specific comment
294 295
if (!isset($_REQUEST['comments_parentId'])) {
	$_REQUEST['comments_parentId'] = 0;
296
}
pkdille's avatar
pkdille committed
297

298
$smarty->assign('comments_parentId', $_REQUEST['comments_parentId']);
pkdille's avatar
pkdille committed
299 300 301 302
if (!isset($_REQUEST['time_control'])) {
	$_REQUEST['time_control'] = 0;
}

melmut's avatar
melmut committed
303
$commentslib->set_time_control($_REQUEST['time_control']);
304 305
$show_archived = isset($_REQUEST['show_archived']);
$smarty->assign('show_archived', $show_archived);
changi67's avatar
changi67 committed
306
$view_archived_topics = ($show_archived == 'y' && ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_topics_archiving'] == 'n'));
pkdille's avatar
pkdille committed
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324

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'];

325 326 327 328 329 330 331 332 333 334 335 336 337
//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
);

338
$comments_cant = $commentslib->count_forum_topics(
339 340 341 342 343 344 345 346
	$_REQUEST['forumId'],
	$comments_offset,
	$_REQUEST['comments_per_page'],
	$_REQUEST['thread_sort_mode'],
	$view_archived_topics,
	$user_param,
	$type_param,
	$reply_state
347
);
348 349 350 351 352 353 354 355
//initialize tablesorter
if ($tsOn && !$tsAjax) {
	//set tablesorter code
	Table_Factory::build(
		'TikiViewforum',
		array(
			'id' => $ts_tableid,
			'total' => $comments_cant,
356 357 358
			'pager' => array(
				'max' => $_REQUEST['comments_per_page'],
			),
359 360 361 362 363 364 365 366 367
			'ajax' => array(
				'requiredparams' => array(
					'forumId' => $_REQUEST['forumId'],
				),
			),
		)
	);
}

pkdille's avatar
pkdille committed
368

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

changi67's avatar
changi67 committed
371
$smarty->assign_by_ref('last_comments', $last_comments);
melmut's avatar
melmut committed
372
$smarty->assign('comments_cant', $comments_cant);
373
$comments_maxRecords = $_REQUEST["comments_per_page"];
melmut's avatar
melmut committed
374
$smarty->assign_by_ref('comments_coms', $comments_coms);
375

376 377
$cat_type = 'forum';
$cat_objid = $_REQUEST["forumId"];
pkdille's avatar
pkdille committed
378

melmut's avatar
melmut committed
379
include_once ('tiki-section_options.php');
pkdille's avatar
pkdille committed
380

381
if ($prefs['feature_user_watches'] == 'y') {
382 383 384
	if ($user && isset($_REQUEST['watch_event'])) {
		check_ticket('view-forum');
		if ($_REQUEST['watch_action'] == 'add') {
385
			$tikilib->add_user_watch(
386 387 388 389 390 391
				$user,
				$_REQUEST['watch_event'],
				$_REQUEST['watch_object'],
				'forum',
				$forum_info['name'],
				'tiki-view_forum.php?forumId=' . $_REQUEST['forumId']
392
			);
393 394 395 396
		} else {
			$tikilib->remove_user_watch($user, $_REQUEST['watch_event'], $_REQUEST['watch_object'], 'forum');
		}
	}
pkdille's avatar
pkdille committed
397

398
	if ($user && $watch = $tikilib->get_user_event_watches($user, 'forum_post_topic', $_REQUEST['forumId'])) {
399 400 401 402
		$smarty->assign('user_watching_forum', 'y');
	} else {
		$smarty->assign('user_watching_forum', 'n');
	}
pkdille's avatar
pkdille committed
403

404
	if ($user && $watch = $tikilib->get_user_event_watches($user, 'forum_post_topic_and_thread', $_REQUEST['forumId'])) {
405 406 407 408
		$smarty->assign('user_watching_forum_topic_and_thread', 'y');
	} else {
		$smarty->assign('user_watching_forum_topic_and_thread', 'n');
	}
pkdille's avatar
pkdille committed
409

410 411
	// Check, if the user is watching this forum by a category.
	if ($prefs['feature_categories'] == 'y') {
412
		$watching_categories_temp = $categlib->get_watching_categories($_REQUEST['forumId'], 'forum', $user);
413 414 415 416
		$smarty->assign('category_watched', 'n');
		if (count($watching_categories_temp) > 0) {
			$smarty->assign('category_watched', 'y');
			$watching_categories = array();
417
			foreach ($watching_categories_temp as $wct) {
418 419 420 421 422 423 424 425
				$watching_categories[] = array(
					"categId" => $wct,
					"name" => $categlib->get_category_name($wct)
				);
			}
			$smarty->assign('watching_categories', $watching_categories);
		}
	}
changi67's avatar
changi67 committed
426
}
pkdille's avatar
pkdille committed
427

428
if ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_quickjump'] == 'y') {
429
	$all_forums = $commentslib->list_forums(0, -1, 'name_asc', '');
430
	$temp_max = count($all_forums['data']);
431
	for ($i = 0; $i < $temp_max; $i++) {
432
		if ($userlib->object_has_one_permission($all_forums['data'][$i]['forumId'], 'forum')) {
433 434
			if ($tiki_p_admin == 'y'
						|| $userlib->object_has_permission($user, $all_forums['data'][$i]['forumId'], 'forum', 'tiki_p_admin_forum')
435 436
						|| $userlib->object_has_permission($user, $all_forums['data'][$i]['forumId'], 'forum', 'tiki_p_forum_read')) {
				$all_forums['data'][$i]['can_read'] = 'y';
437
			} else {
438
				$all_forums['data'][$i]['can_read'] = 'n';
439 440
			}
		} else {
441
			$all_forums['data'][$i]['can_read'] = 'y';
442 443 444
		}
	}
	$smarty->assign('all_forums', $all_forums['data']);
changi67's avatar
changi67 committed
445
}
pkdille's avatar
pkdille committed
446

melmut's avatar
melmut committed
447
$smarty->assign('unread', 0);
448
if ($user && $prefs['feature_messages'] == 'y' && $tiki_p_messages == 'y') {
449 450
	$unread = $tikilib->user_unread_messages($user);
	$smarty->assign('unread', $unread);
melmut's avatar
melmut committed
451
}
pkdille's avatar
pkdille committed
452

melmut's avatar
melmut committed
453
if ($tiki_p_admin_forum == 'y') {
454 455
	$smarty->assign('queued', $commentslib->get_num_queued($comments_objectId));
	$smarty->assign('reported', $commentslib->get_num_reported($_REQUEST['forumId']));
melmut's avatar
melmut committed
456
}
pkdille's avatar
pkdille committed
457

458
if ($prefs['feature_freetags'] == 'y') {
459
	$cat_type = 'forum post';
460
	$cat_objid = $_REQUEST['comments_threadId'];
461
	$cat_lang = $forum_info['forumLanguage'];
462 463
	include_once ("freetag_list.php");
	//If in preview mode get the tags from the form and not from database
464
	if (isset($_REQUEST['comments_previewComment'])) {
465 466
		$smarty->assign('taglist', $_REQUEST["freetag_string"]);
	}
changi67's avatar
changi67 committed
467
}
pkdille's avatar
pkdille committed
468

469
$defaultRows = $prefs['default_rows_textarea_forum'];
pkdille's avatar
pkdille committed
470

471
if ($prefs['feature_contribution'] == 'y') {
472 473
	$contributionItemId = $_REQUEST['comments_threadId'];
	include_once ('contribution.php');
sylvieg's avatar
sylvieg committed
474
}
pkdille's avatar
pkdille committed
475

476
if ($prefs['feature_forum_parse'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
477
	$wikilib = TikiLib::lib('wiki');
478 479
	$plugins = $wikilib->list_plugins(true, 'editpost');
	$smarty->assign_by_ref('plugins', $plugins);
480
}
pkdille's avatar
pkdille committed
481

482 483
$session = isset($_GET['deleted_parentId']) && !empty($_SESSION['ajaxpost' . $_GET['deleted_parentId']]) ?: false;
if (isset($_POST['ajaxtype']) || $session) {
484 485
	$smarty->assign('ajaxfeedback', 'y');
	$posted = isset($_POST['ajaxtype']) ? $_POST : $_SESSION['ajaxpost' . $_GET['deleted_parentId']];
486 487 488
	if ($session) {
		unset($_SESSION['ajaxpost' . $_GET['deleted_parentId']]);
	}
489 490 491 492 493 494 495 496 497 498 499
	$ajaxpost = array_intersect_key($posted, [
		'ajaxtype' => '',
		'ajaxheading' => '',
		'ajaxitems' => '',
		'ajaxmsg' => '',
		'ajaxtoMsg' => '',
		'ajaxtoList' => '',
	]);
	$smarty->assign($ajaxpost);
}

melmut's avatar
melmut committed
500
ask_ticket('view-forum');
501 502 503 504 505 506
if ($tsAjax) {
	$smarty->display('tiki-view_forum.tpl');
} else {
	$smarty->assign('mid', 'tiki-view_forum.tpl');
	$smarty->display('tiki.tpl');
}