|
12 | 12 | use FeatherBB\Core\Track; |
13 | 13 | use FeatherBB\Core\Url; |
14 | 14 | use FeatherBB\Core\Utils; |
| 15 | +use FeatherBB\Core\Error; |
15 | 16 |
|
16 | 17 | class Topic |
17 | 18 | { |
@@ -140,40 +141,63 @@ public function viewpost($pid) |
140 | 141 | return $this->display($post['topic_id'], null, $post['get_p'], $pid); |
141 | 142 | } |
142 | 143 |
|
143 | | - public function subscribe($id) |
| 144 | + public function subscribe($id, $name = '') |
144 | 145 | { |
145 | 146 | $this->model->subscribe($id); |
146 | 147 | } |
147 | 148 |
|
148 | | - public function unsubscribe($id) |
| 149 | + public function unsubscribe($id, $name = '') |
149 | 150 | { |
150 | 151 | $this->model->unsubscribe($id); |
151 | 152 | } |
152 | 153 |
|
153 | | - public function close($id) |
| 154 | + public function close($id, $name = '') |
154 | 155 | { |
155 | 156 | $topic = $this->model->setClosed($id, 1); |
156 | 157 | Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Close topic redirect')); |
157 | 158 | } |
158 | 159 |
|
159 | | - public function open($id) |
| 160 | + public function open($id, $name = '') |
160 | 161 | { |
161 | 162 | $topic = $this->model->setClosed($id, 0); |
162 | 163 | Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Open topic redirect')); |
163 | 164 | } |
164 | 165 |
|
165 | | - public function stick($id) |
| 166 | + public function stick($id, $name = '') |
166 | 167 | { |
167 | 168 | $topic = $this->model->setSticky($id, 1); |
168 | 169 | Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Stick topic redirect')); |
169 | 170 | } |
170 | 171 |
|
171 | | - public function unstick($id) |
| 172 | + public function unstick($id, $name = '') |
172 | 173 | { |
173 | 174 | $topic = $this->model->setSticky($id, 0); |
174 | 175 | Url::redirect($this->feather->urlFor('Topic', ['id' => $id, 'name' => Url::url_friendly($topic['subject'])]), __('Unstick topic redirect')); |
175 | 176 | } |
176 | 177 |
|
| 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 | + |
177 | 201 | public function action($id, $action) |
178 | 202 | { |
179 | 203 | $this->model->handle_actions($id, $action); |
|
0 commit comments