Skip to content

Commit 9fb09b7

Browse files
committed
Draft API new topic
1 parent d57f0d4 commit 9fb09b7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

featherbb/Controller/Api/Topic.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function newTopic($req, $res, $args)
3232

3333
$is_admmod = $this->model->checkPermissions($cur_posting, null, $args['id']);
3434

35-
if (is_bool($is_admmod)) {
35+
if (!is_bool($is_admmod)) {
3636
return $is_admmod;
3737
}
3838

@@ -78,5 +78,9 @@ public function newTopic($req, $res, $args)
7878

7979
return Router::redirect(Router::pathFor('postApi', ['id' => $new['pid']]));
8080
}
81+
else {
82+
die(var_dump($errors));
83+
return json_encode($errors, JSON_PRETTY_PRINT);
84+
}
8185
}
8286
}

featherbb/Model/Api/Topic.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use FeatherBB\Core\Database as DB;
1313
use FeatherBB\Core\Error;
14+
use FeatherBB\Core\Track;
1415
use FeatherBB\Core\Utils;
1516

1617
class Topic extends Api
@@ -110,6 +111,7 @@ public function check_errors_before_post($fid, $errors)
110111

111112
// If it's a new topic
112113
if ($fid) {
114+
// todo: can't get req_subject
113115
$subject = Utils::trim(Input::post('req_subject'));
114116

115117
if (ForumSettings::get('o_censoring') == '1') {
@@ -307,9 +309,11 @@ public function insert_topic($post, $fid)
307309
->set($topic['update']);
308310
$topic = $topic->save();
309311

310-
$this->search->update_search_index('post', $new['pid'], $post['message'], $post['subject']);
312+
$search = new \FeatherBB\Core\Search();
311313

312-
Forum::update($fid);
314+
$search->update_search_index('post', $new['pid'], $post['message'], $post['subject']);
315+
316+
\FeatherBB\Model\Forum::update($fid);
313317

314318
return $new;
315319
}

featherbb/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
Route::get('/user/{id:\d+}', '\FeatherBB\Controller\Api\User:display')->setName('userApi');
187187
Route::get('/forum/{id:\d+}', '\FeatherBB\Controller\Api\Forum:display')->setName('forumApi');
188188
Route::get('/topic/{id:\d+}', '\FeatherBB\Controller\Api\Topic:display')->setName('topicApi');
189-
Route::post('/new/topic/forum-id/{id:\d+}', '\FeatherBB\Controller\Api\Topic:newTopic')->setName('newTopicApi');
189+
Route::post('/topic/{id:\d+}', '\FeatherBB\Controller\Api\Topic:newTopic')->setName('newTopicApi');
190190
Route::get('/post/{id:\d+}', '\FeatherBB\Controller\Api\Post:display')->setName('postApi');
191191
})->add(new JsonHeader);
192192

0 commit comments

Comments
 (0)