Skip to content

Commit

Permalink
Fixed issue: notice when editing for the first time theme options at …
Browse files Browse the repository at this point in the history
…survey group level
  • Loading branch information
LouisGac committed Dec 22, 2017
1 parent 42e7f69 commit 0da997d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion application/controllers/admin/themeoptions.php
Expand Up @@ -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'];
Expand Down
8 changes: 6 additions & 2 deletions application/models/TemplateConfiguration.php
Expand Up @@ -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*/
Expand Down Expand Up @@ -195,6 +198,8 @@ public static function getInstanceFromSurveyGroup($iSurveyGroupId, $sTemplateNam
$oTemplateConfigurationModel->gsid = $iSurveyGroupId;
$oTemplateConfigurationModel->setToInherit();
$oTemplateConfigurationModel->save();

$oTemplateConfigurationModel->bJustCreated = true;
}

return $oTemplateConfigurationModel;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0da997d

Please sign in to comment.