Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jun 21, 2018
2 parents 2ea4fae + f392f4d commit b13f86c
Show file tree
Hide file tree
Showing 6 changed files with 464 additions and 9 deletions.
2 changes: 1 addition & 1 deletion application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
$aTHemes = TemplateConfiguration::model()->findAll();

foreach ($aTHemes as $oTheme){
$oTheme->setGlobalOptionOn("ajaxmode");
$oTheme->setGlobalOption("ajaxmode", "on");
}

$oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>351], "stg_name='DBVersion'");
Expand Down
3 changes: 2 additions & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ public function relations()
'quotas' => array(self::HAS_MANY, 'Quota', 'sid', 'order'=>'name ASC'),
'surveymenus' => array(self::HAS_MANY, 'Surveymenu', array('survey_id' => 'sid')),
'surveygroup' => array(self::BELONGS_TO, 'SurveysGroups', array('gsid' => 'gsid')),
'templateModel' => array(self::HAS_ONE, 'Template', array('name' => 'template'))
'templateModel' => array(self::HAS_ONE, 'Template', array('name' => 'template')),
'templateConfiguration' => array(self::HAS_ONE, 'TemplateConfiguration', array('sid' => 'sid'))
);
}

Expand Down
44 changes: 39 additions & 5 deletions application/models/TemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,24 +616,45 @@ public function getHasOptionPage()
}

/**
* Turn ON a given option at global setting level (survey level not affected)
* Set a value on a given option at global setting level (survey level not affected).
* Will be used to turn ON ajax mode on update.
*
* @param string $name
* @param mixed $value
* @return void
*/
public function setGlobalOptionOn($optionName="ajaxmode")
public function setGlobalOption($name, $value)
{

if ($this->options != 'inherit') {
$oOptions = json_decode($this->options);

if ($oOptions->$optionName === "off" && empty($this->sid)){
$oOptions->$optionName = "on";
if (empty($this->sid)) {
$oOptions->$name = $value;
$sOptions = json_encode($oOptions);
$this->options = $sOptions;
$this->save();
}
}
}

/**
* Set option (unless if options is set to "inherit").
* @param string $name
* @param mixed $value
* @return void
*/
public function setOption($name, $value)
{
if ($this->options != 'inherit') {
$oOptions = json_decode($this->options);

$oOptions->$name = $value;
$sOptions = json_encode($oOptions);
$this->options = $sOptions;
$this->save();
}
}

private function _filterImages($file)
{
$imagePath = (file_exists($this->filesPath.$file['name']))
Expand Down Expand Up @@ -1090,4 +1111,17 @@ public function getTemplateAndMotherNames()

return $sTemplateNames;
}

/**
* Get the global template configuration with same name as $this.
* The global config has no sid, no gsid and no uid.
* @return TemplateConfiguration
*/
public function getGlobalParent()
{
return self::model()->find(
'sid IS NULL AND uid IS NULL and gsid IS NULL AND template_name = :template_name',
[':template_name'=>$this->template_name]
);
}
}

0 comments on commit b13f86c

Please sign in to comment.