public function actionEdit($pid) { $idu = Yii::$app->user->getId(); $uid = new components\UserId($idu); //die(var_dump($pid)); $post = PostsService::getPostById($pid); $nothing = $post->getAuthor(); $postOwner = $nothing->getId(); if (!Yii::$app->user->can('admin')) { if ($postOwner != $idu) { return $this->redirect('/intouch/accessdenied'); } } // die(var_dump($post)); if (Yii::$app->request->isPost) { try { $id = Yii::$app->request->post('post_id'); $post = PostsService::getPostById($id); $post->changeContent(Yii::$app->request->post('inputContent')); PostsService::savePost($post); } catch (exception $e) { } EventService::createEvent(components\EEvent::ACCOUNT_INFO_CHANGED(), $uid); Yii::$app->session->setFlash('success', 'Post\'s been Succesfuly Updated'); return $this->redirect('/profile'); } return $this->render('edit', ['post' => $post]); }
public function Save() { return PostsService::savePost(this); }