diff --git a/application/controllers/admin/themeoptions.php b/application/controllers/admin/themeoptions.php index c34a72e64f3..478e6998884 100644 --- a/application/controllers/admin/themeoptions.php +++ b/application/controllers/admin/themeoptions.php @@ -126,12 +126,17 @@ public function updatesurvey($sid) * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ - public function updatesurveygroup($id = null, $gsid) + public function updatesurveygroup($id = null, $gsid, $l=null) { if (Permission::model()->hasGlobalPermission('templates', 'update')) { + $sTemplateName = $id !== null ? TemplateConfiguration::model()->findByPk($id)->template_name : null; $model = TemplateConfiguration::getInstance($sTemplateName, $gsid); + if ($model->bJustCreated === true && $l === null ){ + $this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions/sa/updatesurveygroup/", ['id'=>$id, 'gsid'=>$gsid, 'l'=>1])); + } + if (isset($_POST['TemplateConfiguration'])) { $model = TemplateConfiguration::getInstance($_POST['TemplateConfiguration']['template_name'], $gsid); $model->attributes = $_POST['TemplateConfiguration']; diff --git a/application/models/TemplateConfiguration.php b/application/models/TemplateConfiguration.php index ddc2e66ba99..72d0e552efd 100755 --- a/application/models/TemplateConfiguration.php +++ b/application/models/TemplateConfiguration.php @@ -54,6 +54,9 @@ class TemplateConfiguration extends TemplateConfig /**@var boolean Should the magic getters automatically retreives the parent value when field is set to inherit. Only turn to on for template rendering */ public $bUseMagicInherit = false; + /**@var boolean Indicate if this entry in DB get created on the fly. If yes, because of Cache, it can need a page redirect */ + public $bJustCreated = false; + // Caches /** @var string $sPreviewImgTag the template preview image tag for the template list*/ @@ -195,6 +198,8 @@ public static function getInstanceFromSurveyGroup($iSurveyGroupId, $sTemplateNam $oTemplateConfigurationModel->gsid = $iSurveyGroupId; $oTemplateConfigurationModel->setToInherit(); $oTemplateConfigurationModel->save(); + + $oTemplateConfigurationModel->bJustCreated = true; } return $oTemplateConfigurationModel; @@ -608,8 +613,7 @@ protected function getOptionPageAttributes() public function getOptionPage() { - $oTemplate = $this->prepareTemplateRendering(); - + $oTemplate = $this->prepareTemplateRendering($this->template->name); $renderArray = array('templateConfiguration' => $oTemplate->getOptionPageAttributes()); $oTemplate->setOptions();