예제 #1
0
 /**
  * Listing the contents.
  * @param string $name content name
  * @return string|\yii\web\Response
  */
 public function actionContents($name = '')
 {
     $allowed = ['terms', 'email-reg', 'email-new', 'email-react', 'email-pass', 'email-sub'];
     if ($name == '' || !in_array($name, $allowed)) {
         $name = 'terms';
     }
     $model = Content::find()->where(['name' => $name])->limit(1)->one();
     if (!$model) {
         $model = new Content();
         $model->name = $name;
     }
     if ($model->load(Yii::$app->request->post())) {
         if (User::can(Rbac::PERM_CHANGE_SETTINGS)) {
             if ($model->save()) {
                 $this->success(Yii::t('podium/flash', 'Content has been saved.'));
             } else {
                 $this->error(Yii::t('podium/flash', 'Sorry! There was some error while saving the content.'));
             }
         } else {
             $this->error(Yii::t('podium/flash', 'You are not allowed to perform this action.'));
         }
         return $this->refresh();
     }
     return $this->render('contents', ['model' => $model]);
 }
예제 #2
0
 /**
  * Listing the contents.
  * @param string $name content name
  * @return string|\yii\web\Response
  */
 public function actionContents($name = '')
 {
     $allowed = ['terms', 'email-reg', 'email-new', 'email-react', 'email-pass', 'email-sub'];
     if ($name == '' || !in_array($name, $allowed)) {
         $name = 'terms';
     }
     $model = Content::find()->where(['name' => $name])->one();
     if (!$model) {
         $model = new Content();
         $model->name = $name;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $this->success('Content has been saved.');
         return $this->refresh();
     }
     return $this->render('contents', ['model' => $model]);
 }