diff --git a/application/controllers/admin/templateoptions.php b/application/controllers/admin/templateoptions.php index 9741dabf9ea..c1e90ae4a74 100644 --- a/application/controllers/admin/templateoptions.php +++ b/application/controllers/admin/templateoptions.php @@ -118,10 +118,11 @@ 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($gsid) + public function updatesurveygroup($id=null, $gsid) { if ( Permission::model()->hasGlobalPermission('templates', 'update')){ - $model = TemplateConfiguration::getInstance(null, $gsid); + $sTemplateName = $id !==null ? TemplateConfiguration::model()->findByPk($id)->template_name : null; + $model = TemplateConfiguration::getInstance($sTemplateName, $gsid); if(isset($_POST['TemplateConfiguration'])){ $model->attributes=$_POST['TemplateConfiguration']; @@ -129,7 +130,7 @@ public function updatesurveygroup($gsid) $this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/",['id'=>$gsid])); } - $this->_updateCommon($model, $sid); + $this->_updateCommon($model); }else{ Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error'); $this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/",['id'=>$gsid])); @@ -241,6 +242,7 @@ private function _updateCommon($model,$sid=null) 'model'=>$model, 'templateOptionPage' => $templateOptionPage ); + if($sid !== null){ $aData['surveyid'] = $sid; $aData['title_bar']['title'] = gT("Survey template options"); diff --git a/application/models/TemplateConfiguration.php b/application/models/TemplateConfiguration.php index d8694b22e18..9e7528dff7f 100644 --- a/application/models/TemplateConfiguration.php +++ b/application/models/TemplateConfiguration.php @@ -431,7 +431,7 @@ public function getButtons() $sEditorUrl = Yii::app()->getController()->createUrl('admin/templates/sa/view', array("templatename"=>$this->template_name)); if (App()->getController()->action->id == "surveysgroups"){ $gisd = Yii::app()->request->getQuery('id', null); - $sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/update', array("id"=>$this->id, "gsid"=>$gisd)); + $sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/updatesurveygroup', array("id"=>$this->id, "gsid"=>$gisd)); }else{ $sOptionUrl = Yii::app()->getController()->createUrl('admin/templateoptions/sa/update', array("id"=>$this->id)); }