@@ 101-119 (lines=19) @@ | ||
98 | * update comment |
|
99 | * |
|
100 | */ |
|
101 | public function update(){ |
|
102 | ||
103 | $commentId = Encryption::decryptIdWithDash($this->request->data("comment_id")); |
|
104 | $content = $this->request->data("content"); |
|
105 | ||
106 | if(!$this->comment->exists($commentId)){ |
|
107 | return $this->error(404); |
|
108 | } |
|
109 | ||
110 | $comment = $this->comment->update($commentId, $content); |
|
111 | ||
112 | if(!$comment){ |
|
113 | $this->view->renderErrors($this->comment->errors()); |
|
114 | }else{ |
|
115 | ||
116 | $html = $this->view->render(Config::get('VIEWS_PATH') . 'posts/comments.php', array("comments" => $comment)); |
|
117 | $this->view->renderJson(array("data" => $html)); |
|
118 | } |
|
119 | } |
|
120 | ||
121 | /** |
|
122 | * get comment by Id |
@@ 79-97 (lines=19) @@ | ||
76 | $this->view->renderJson(array("data" => $html)); |
|
77 | } |
|
78 | ||
79 | public function update(){ |
|
80 | ||
81 | // Remember? each news feed has an id that looks like this: feed-51b2cfa |
|
82 | $newsfeedId = Encryption::decryptIdWithDash($this->request->data("newsfeed_id")); |
|
83 | $content = $this->request->data("content"); |
|
84 | ||
85 | if(!$this->newsfeed->exists($newsfeedId)){ |
|
86 | return $this->error(404); |
|
87 | } |
|
88 | ||
89 | $newsfeed = $this->newsfeed->update($newsfeedId, $content); |
|
90 | if(!$newsfeed){ |
|
91 | $this->view->renderErrors($this->newsfeed->errors()); |
|
92 | }else{ |
|
93 | ||
94 | $html = $this->view->render(Config::get('VIEWS_PATH') . 'newsfeed/newsfeed.php', array("newsfeed" => $newsfeed)); |
|
95 | $this->view->renderJson(array("data" => $html)); |
|
96 | } |
|
97 | } |
|
98 | ||
99 | public function getById(){ |
|
100 |