예제 #1
0
 /**
  * Listing the contents.
  * @param string $name content name
  * @return string|\yii\web\Response
  */
 public function actionContents($name = '')
 {
     if (empty(Content::defaultContent($name))) {
         $name = Content::TERMS_AND_CONDS;
     }
     $model = Content::fill($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
 /**
  * Adds default Content.
  * @return string result message.
  */
 protected function _addContent()
 {
     try {
         $default = Content::defaultContent();
         $this->db->createCommand()->batchInsert('{{%podium_content}}', ['name', 'topic', 'content'], [[Content::TERMS_AND_CONDS, $default[Content::TERMS_AND_CONDS]['topic'], $default[Content::TERMS_AND_CONDS]['content']], [Content::EMAIL_REGISTRATION, $default[Content::EMAIL_REGISTRATION]['topic'], $default[Content::EMAIL_REGISTRATION]['content']], [Content::EMAIL_PASSWORD, $default[Content::EMAIL_PASSWORD]['topic'], $default[Content::EMAIL_PASSWORD]['content']], [Content::EMAIL_REACTIVATION, $default[Content::EMAIL_REACTIVATION]['topic'], $default[Content::EMAIL_REACTIVATION]['content']], [Content::EMAIL_NEW, $default[Content::EMAIL_NEW]['topic'], $default[Content::EMAIL_NEW]['content']], [Content::EMAIL_SUBSCRIPTION, $default[Content::EMAIL_SUBSCRIPTION]['topic'], $default[Content::EMAIL_SUBSCRIPTION]['content']]])->execute();
         return $this->outputSuccess(Yii::t('podium/flash', 'Default Content has been added.'));
     } catch (Exception $e) {
         Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
         $this->setError(true);
         return $this->outputDanger(Yii::t('podium/flash', 'Error during content adding') . ': ' . Html::tag('pre', $e->getMessage()));
     }
 }