public function actionEdit($section, $forum, $thread_id) { if (($section = Sections::findOne(['lang' => $this->lang, 'alias' => $section])) !== null) { if (($forum = $section->getForums()->where(['alias' => $forum])->one()) !== null) { if (($model = $forum->getThreads()->where(['id' => $thread_id])->one()) !== null) { if (!$model->canEdit) { Yii::$app->session->setFlash('error', Yii::t('forum', "You havn't enough right to edit")); return $this->redirect($model->url); } if (Yii::$app->request->isPost) { $model->attachBehavior('ReplaceImagesBehavior', ['class' => \worstinme\jodit\ReplaceImagesBehavior::className(), 'path' => Yii::getAlias('@webroot/images/forum'), 'tempPath' => Yii::getAlias('@webroot/uploads/tmp/' . Yii::$app->user->identity->id), 'subfolder' => true, 'filename_model_suffix' => true, 'attribute' => 'content']); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect($model->url); } } return $this->render('edit', ['lang' => $this->lang, 'model' => $model, 'forum' => $forum, 'section' => $section]); } } } throw new NotFoundHttpException('The requested page does not exist.'); }
public function actionSectionActivate($id) { if (($model = Sections::findOne($id)) === null) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($model->state == $model::STATE_HIDDEN && $model->canEdit) { $model->updateAttributes(['state' => $model::STATE_ACTIVE]); Yii::$app->session->setFlash('success', Yii::t('forum', "Section has been activated.")); return $this->redirect(['index', 'lang' => $this->lang]); } Yii::$app->session->setFlash('error', Yii::t('forum', "Mission impossible")); return $this->redirect($model->url); }