summaryrefslogtreecommitdiff
path: root/handler/admin/PostAdd.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /handler/admin/PostAdd.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'handler/admin/PostAdd.php')
-rw-r--r--handler/admin/PostAdd.php68
1 files changed, 0 insertions, 68 deletions
diff --git a/handler/admin/PostAdd.php b/handler/admin/PostAdd.php
deleted file mode 100644
index c21a239..0000000
--- a/handler/admin/PostAdd.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-namespace handler\admin;
-
-use csrf;
-use posts;
-use RedirectResponse;
-use Response;
-
-class PostAdd extends AutoAddOrEdit {
-
- public function get(): Response {
- return $this->_get_postAdd();
- }
-
- public function post(): Response {
- csrf::check('addpost');
-
- list($text, $title, $tags, $visible, $short_name)
- = $this->input('text, title, tags, b:visible, short_name');
- $tags = posts::splitStringToTags($tags);
-
- $error_code = null;
-
- if (!$title) {
- $error_code = 'no_title';
- } else if (!$text) {
- $error_code = 'no_text';
- } else if (empty($tags)) {
- $error_code = 'no_tags';
- } else if (empty($short_name)) {
- $error_code = 'no_short_name';
- }
-
- if ($error_code)
- return $this->_get_postAdd(
- text: $text,
- title: $title,
- tags: $tags,
- short_name: $short_name,
- error_code: $error_code
- );
-
- $id = posts::add([
- 'title' => $title,
- 'md' => $text,
- 'visible' => (int)$visible,
- 'short_name' => $short_name,
- ]);
-
- if (!$id)
- $this->_get_postAdd(
- text: $text,
- title: $title,
- tags: $tags,
- short_name: $short_name,
- error_code: 'db_err'
- );
-
- // set tags
- $post = posts::get($id);
- $tag_ids = posts::getTagIds($tags);
- $post->setTagIds($tag_ids);
-
- return new RedirectResponse($post->getUrl());
- }
-
-} \ No newline at end of file