Skip to content

Commit f0a7e0b

Browse files
committed
Move single topic
1 parent aa4a804 commit f0a7e0b

File tree

9 files changed

+379
-169
lines changed

9 files changed

+379
-169
lines changed

featherbb/Controller/Forum.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,24 @@ public function display($fid, $name = null, $page = null)
9292
))->addTemplate('Forum.php')->display();
9393
}
9494

95-
public function markread($id)
95+
public function markread($id, $name = '')
9696
{
9797
$tracked_topics = Track::get_tracked_topics();
9898
$tracked_topics['forums'][$id] = time();
9999
Track::set_tracked_topics($tracked_topics);
100100

101-
Url::redirect($this->feather->urlFor('Forum', array('id' => $id)), __('Mark forum read redirect'));
101+
Url::redirect($this->feather->urlFor('Forum', ['id' => $id, 'name' => $name]), __('Mark forum read redirect'));
102102
}
103103

104-
public function subscribe($id)
104+
public function subscribe($id, $name = '')
105105
{
106106
$this->model->subscribe($id);
107+
Url::redirect($this->feather->urlFor('Forum', ['id' => $forum_id, 'name' => $name]), __('Subscribe redirect'));
107108
}
108109

109-
public function unsubscribe($id)
110+
public function unsubscribe($id, $name = '')
110111
{
111112
$this->model->unsubscribe($id);
113+
Url::redirect($this->feather->urlFor('Forum', ['id' => $forum_id, 'name' => $name]), __('Unsubscribe redirect'));
112114
}
113115
}

featherbb/Controller/Moderate.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,6 @@ public function moderatetopic($id = null, $fid = null, $action = null, $param =
7575

7676
$start_from = $this->user->disp_posts * ($p - 1);
7777

78-
// Move a topic - send a POST after
79-
if ($action == 'move') {
80-
// Check if there are enough forums to move the topic
81-
$this->model->check_move_possible();
82-
83-
$this->feather->template->setPageInfo(array(
84-
'title' => array(Utils::escape($this->config['o_board_title']), __('Moderate')),
85-
'active_page' => 'moderate',
86-
'page' => $p,
87-
'action' => 'single',
88-
'id' => $id,
89-
'topics' => $id,
90-
'list_forums' => $this->model->get_forum_list_move($fid),
91-
)
92-
)->addTemplate('moderate/move_topics.php')->display();
93-
}
9478

9579
// Moderate a topic
9680
if ($action == 'moderate') {

featherbb/Controller/Topic.php

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use FeatherBB\Core\Track;
1313
use FeatherBB\Core\Url;
1414
use FeatherBB\Core\Utils;
15+
use FeatherBB\Core\Error;
1516

1617
class Topic
1718
{
@@ -140,40 +141,63 @@ public function viewpost($pid)
140141
return $this->display($post['topic_id'], null, $post['get_p'], $pid);
141142
}
142143

143-
public function subscribe($id)
144+
public function subscribe($id, $name = '')
144145
{
145146
$this->model->subscribe($id);
146147
}
147148

148-
public function unsubscribe($id)
149+
public function unsubscribe($id, $name = '')
149150
{
150151
$this->model->unsubscribe($id);
151152
}
152153

153-
public function close($id)
154+
public function close($id, $name = '')
154155
{
155156
$topic = $this->model->setClosed($id, 1);
156157
Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Close topic redirect'));
157158
}
158159

159-
public function open($id)
160+
public function open($id, $name = '')
160161
{
161162
$topic = $this->model->setClosed($id, 0);
162163
Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Open topic redirect'));
163164
}
164165

165-
public function stick($id)
166+
public function stick($id, $name = '')
166167
{
167168
$topic = $this->model->setSticky($id, 1);
168169
Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Stick topic redirect'));
169170
}
170171

171-
public function unstick($id)
172+
public function unstick($id, $name = '')
172173
{
173174
$topic = $this->model->setSticky($id, 0);
174175
Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Unstick topic redirect'));
175176
}
176177

178+
// Move a single topic
179+
public function move($tid, $name = '', $fid)
180+
{
181+
if ($new_fid = $this->feather->request->post('move_to_forum')) {
182+
$this->model->move_to($fid, $new_fid, $tid);
183+
Url::redirect($this->feather->urlFor('Topic', array('id' => $tid, 'name' => $name)), __('Move topic redirect'));
184+
}
185+
186+
// Check if there are enough forums to move the topic
187+
if ( !$this->model->check_move_possible() ) {
188+
throw new Error(__('Nowhere to move'), 403);
189+
}
190+
191+
$this->feather->template->setPageInfo(array(
192+
'title' => array(Utils::escape($this->feather->config['o_board_title']), __('Moderate')),
193+
'active_page' => 'moderate',
194+
'action' => 'single',
195+
'topics' => $tid,
196+
'list_forums' => $this->model->get_forum_list_move($fid),
197+
)
198+
)->addTemplate('moderate/move_topics.php')->display();
199+
}
200+
177201
public function action($id, $action)
178202
{
179203
$this->model->handle_actions($id, $action);

featherbb/Model/Forum.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,7 @@ public function unsubscribe($forum_id)
343343
->where('user_id', $this->user->id)
344344
->where('forum_id', $forum_id);
345345
$delete = $this->hook->fireDB('unsubscribe_forum_query', $delete);
346-
$delete = $delete->delete_many();
347-
348-
Url::redirect($this->feather->urlFor('Forum', ['id' => $forum_id]), __('Unsubscribe redirect'));
346+
$delete->delete_many();
349347
}
350348

351349
public function subscribe($forum_id)
@@ -394,8 +392,6 @@ public function subscribe($forum_id)
394392
->create()
395393
->set($subscription['insert']);
396394
$subscription = $this->hook->fireDB('subscribe_forum_query', $subscription);
397-
$subscription = $subscription->save();
398-
399-
Url::redirect($this->feather->urlFor('Forum', ['id' => $forum_id]), __('Subscribe redirect'));
395+
$subscription->save();
400396
}
401397
}

0 commit comments

Comments
 (0)