diff --git a/ground/controllers/ArticleController.php b/ground/controllers/ArticleController.php
index cfab6ba..dd9789b 100644
--- a/ground/controllers/ArticleController.php
+++ b/ground/controllers/ArticleController.php
@@ -192,41 +192,6 @@ class ArticleController extends Controller
App::redirect('/user/');
}
- static function actionAddComment()
- {
- if (!App::$user ||
- !isset($_POST['parentType']) ||
- !isset($_POST['parentId']) ||
- !isset($_POST['answerTo']) ||
- !isset($_POST['text']))
- {
- App::error404();
- }
-
- if (trim($_POST['text']) == '') {
- App::redirect('/'.$_POST['parentType'].'/'.$_POST['parentId']);
- }
-
- $text = str_replace(array('<','>'), array('<','>'), $_POST['text']);
-
- $html = strip_tags($_POST['text']);
- $html = str_replace(array('<','>',"'"), array('<','>','′'), $html);
- $html = Markdown::liteProcessing($html);
- $html = nl2br($html);
-
- $comment = new Comment(array(
- 'userId' => App::$user->id,
- 'parentType' => ($_POST['parentType'] == 'article') ? 'article' : 'point',
- 'parentId' => (int)$_POST['parentId'],
- 'answerTo' => (int)$_POST['answerTo'],
- 'addDate' => time(),
- 'text' => $text,
- 'html' => $html,
- ));
- $comment->save();
- App::redirect('/'.$_POST['parentType'].'/'.$_POST['parentId'].'#comment'.$comment->id);
- }
-
static function actionMarkdown()
{
if (isset($_POST['text']) ){
diff --git a/ground/controllers/CommentsController.php b/ground/controllers/CommentsController.php
new file mode 100644
index 0000000..7ee30c6
--- /dev/null
+++ b/ground/controllers/CommentsController.php
@@ -0,0 +1,55 @@
+'), array('<', '>'), $_POST['text']);
+
+ $html = strip_tags($_POST['text']);
+ $html = str_replace(array('<', '>', "'"), array('<', '>', '′'), $html);
+ $html = Markdown::liteProcessing($html);
+ $html = nl2br($html);
+
+ $comment = new Comment(array(
+ 'userId' => App::$user->id,
+ 'parentType' => ($_POST['parentType'] == 'article') ? 'article' : 'point',
+ 'parentId' => (int) $_POST['parentId'],
+ 'answerTo' => (int) $_POST['answerTo'],
+ 'addDate' => time(),
+ 'text' => $text,
+ 'html' => $html,
+ ));
+ $comment->save();
+ App::redirect('/' . $_POST['parentType'] . '/' . $_POST['parentId'] . '#comment' . $comment->id);
+ }
+
+ static function actionDel()
+ {
+ if (!App::$user || !(int)App::getParam('id')) {
+ App::error404();
+ }
+
+ $id = (int)App::getParam('id');
+ $comment = Comment::model()->getByPK($id);
+
+ if($comment->id && $comment->userId == App::$user->id) {
+ $comment->delete($id);
+ }
+
+ App::redirect('/'.$comment->parentType.'/'.$comment->parentId);
+ }
+}
diff --git a/ground/views/comments/comment.php b/ground/views/comments/comment.php
index 78aa378..b46815f 100644
--- a/ground/views/comments/comment.php
+++ b/ground/views/comments/comment.php
@@ -2,9 +2,12 @@