Skip to content

Commit

Permalink
Dev: Fixed small issue with templateOptions and surveygroups
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Oct 19, 2017
1 parent a8bf8d6 commit 589a318
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions application/controllers/admin/templateoptions.php
Expand Up @@ -118,18 +118,19 @@ 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'];
if($model->save())
$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]));
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateConfiguration.php
Expand Up @@ -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));
}
Expand Down

0 comments on commit 589a318

Please sign in to comment.