1<?php
2/*
3 * e107 website system
4 *
5 * Copyright (C) 2008-2013 e107 Inc (e107.org)
6 * Released under the terms and conditions of the
7 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
8 *
9 */
10
11require_once('../../class2.php');
12$e107 = e107::getInstance();
13if (!$e107->isInstalled('forum'))
14{
15	e107::redirect('admin');
16	exit;
17}
18
19$ns = e107::getRender();
20$tp = e107::getParser();
21
22require_once(e_PLUGIN.'forum/forum_class.php');
23$forum = new e107forum;
24
25e107::lan('forum', 'admin');
26//include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_conf.php');
27
28$e_sub_cat = 'forum';
29
30if(!USER || !isset($_GET['f']) || !isset($_GET['id']))
31{
32	header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1));
33	exit;
34}
35
36$id = (int)$_GET['id'];
37$action = $_GET['f'];
38
39$qry = "
40SELECT t.*, f.*, fp.forum_id AS forum_parent_id FROM #forum_thread as t
41LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id
42LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
43WHERE t.thread_id = {$thread_id}
44";
45
46$threadInfo = $forum->threadGet($id);
47$modList = $forum->forumGetMods($threadInfo->forum_moderators);
48
49//var_dump($threadInfo);
50//var_dump($modList);
51
52//If user is not a moderator of indicated forum, redirect to index page
53if(!in_array(USERID, array_keys($modList)))
54{
55	header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1));
56	exit;
57}
58
59require_once(HEADERF);
60
61if (isset($_POST['deletepollconfirm']))
62{
63	$sql->delete("poll", "poll_id='".intval($thread_parent)."' ");
64	$sql->select("forum_thread", "*", "thread_id='".$thread_id."' ");
65	$row = $sql->fetch();
66	 extract($row);
67	$thread_name = str_replace("[poll] ", "", $thread_name);
68	$sql->update("forum_thread", "thread_name='$thread_name' WHERE thread_id='$thread_id' ");
69	$message = LAN_FORUM_5001;
70	$url = e_PLUGIN."forum/forum_viewtopic.php?".$thread_id;
71}
72
73
74
75// Moved to forum_post.php
76/*
77if (isset($_POST['move']))
78{
79//	print_a($_POST);
80	require_once(e_PLUGIN.'forum/forum_class.php');
81	$forum = new e107forum;
82
83	$newThreadTitle = '';
84	if($_POST['rename_thread'] == 'add')
85	{
86		$newThreadTitle = '['.LAN_FORUM_5021.']';
87		$newThreadTitleType = 0;
88	}
89	elseif($_POST['rename_thread'] == 'rename' && trim($_POST['newtitle']) != '')
90	{
91		$newThreadTitle = $tp->toDB($_POST['newtitle']);
92		$newThreadTitleType = 1;
93	}
94
95	$threadId = $_GET['id'];
96	$toForum = $_POST['forum_move'];
97
98	$forum->threadMove($threadId, $toForum, $newThreadTitle, $newThreadTitleType);
99
100	$message = LAN_FORUM_5005;// XXX _URL_ thread name
101	$url = $e107::getUrl()->create('forum/thread/view', 'id='.$threadId);
102}
103
104if (isset($_POST['movecancel']))
105{
106	require_once(e_PLUGIN.'forum/forum_class.php');
107	$forum = new e107forum;
108	$postInfo = $forum->postGet($id, 0, 1);
109
110	$message = LAN_FORUM_5006;
111//	$url = e_PLUGIN."forum/forum_viewforum.php?".$info['forum_id'];
112	$url = $e107::getUrl()->create('forum/forum/view', 'id='.$postInfo[0]['post_forum']);// XXX _URL_ thread name
113}
114
115
116
117*/
118
119
120
121if ($message)
122{
123	$text = "<div style='text-align:center'>".$message."
124		<br />
125		<a href='$url'>".LAN_FORUM_5007.'</a>
126		</div>';
127	$ns->tablerender(LAN_FORUM_5008, $text);
128	require_once(FOOTERF);
129	exit;
130}
131
132if ($action == "delete_poll")
133{
134	$text = "<div style='text-align:center'>
135		".LAN_FORUM_5009."
136		<br /><br />
137		<form method='post' action='".e_SELF."?".e_QUERY."'>
138		<input class='btn btn-default btn-secondary button' type='submit' name='deletecancel' value='".LAN_CANCEL."' />
139		<input class='btn btn-default btn-secondary button' type='submit' name='deletepollconfirm' value='".LAN_FORUM_5010."' />
140		</form>
141		</div>";
142	$ns->tablerender(LAN_UI_DELETE_LABEL, $text);
143	require_once(FOOTERF);
144	exit;
145}
146/*
147if ($action == 'move')
148{
149	$postInfo = $forum->postGet($id, 0, 1);
150
151	$frm = e107::getForm();
152
153	$qry = "
154	SELECT f.forum_id, f.forum_name, fp.forum_name AS forum_parent, sp.forum_name AS sub_parent
155	FROM `#forum` AS f
156	LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id
157	LEFT JOIN `#forum` AS sp ON f.forum_sub = sp.forum_id
158	WHERE f.forum_parent != 0
159	AND f.forum_id != ".(int)$threadInfo['thread_forum_id']."
160	ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
161	";
162
163	$sql->gen($qry);
164	$fList = $sql->db_getList();
165
166	$text = "
167		<form class='forum-horizontal' method='post' action='".e_SELF.'?'.e_QUERY."'>
168		<div style='text-align:center'>
169		<table class='table table-striped' style='".ADMIN_WIDTH."'>
170		<tr>
171		<td>".LAN_FORUM_5019.": </td>
172		<td>
173		<select name='forum_move' class='tbox'>";
174
175
176	foreach($fList as $f)
177	{
178		if(substr($f['forum_name'], 0, 1) != '*')
179		{
180			$f['sub_parent'] = ltrim($f['sub_parent'], '*');
181			$for_name = $f['forum_parent'].' > ';
182			$for_name .= ($f['sub_parent'] ? $f['sub_parent'].' > ' : '');
183			$for_name .= $f['forum_name'];
184			$text .= "<option value='{$f['forum_id']}'>".$for_name."</option>";
185		}
186	}
187	$text .= "</select>
188		</td>
189		</tr>
190		<tr>
191		<td >".LAN_FORUM_5026."</td>
192		<td><div class='radio'>
193		".$frm->radio('rename_thread','none',true, 'label='.LAN_FORUM_5022)."
194		".$frm->radio('rename_thread', 'add', false, array('label'=> LAN_ADD.' ['.LAN_FORUM_5021.'] '.LAN_FORUM_5024)). "
195		<div class='form-inline'>".$frm->radio('rename_thread','rename', false, array('label'=>LAN_FORUM_5025))."
196		".$frm->text('newtitle', $tp->toForm($threadInfo['thread_name']), 250)."
197		</div>
198		</div></td>
199		</tr>
200		</table>
201		<div class='center'>
202		<input class='btn btn-primary button' type='submit' name='move' value='".LAN_FORUM_5019."' />
203		<input class='btn btn-default button' type='submit' name='movecancel' value='".LAN_CANCEL."' />
204		</div>
205
206		</div>
207		</form>";
208
209
210		$threadName = $tp->toHTML($threadInfo['thread_name'], true);
211		$threadText = $tp->toHTML($postInfo[0]['post_entry'], true);
212
213	$text .= "<h3>".$threadName."</h3><div>".$threadText."</div>"; // $e107->ns->tablerender(, ), '', true).$ns->tablerender('', $text, '', true);
214	$ns->tablerender(LAN_FORUM_5019, $text);
215
216}
217*/
218
219
220
221
222require_once(FOOTERF);
223