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 4, 2021
2 parents 76a2989 + 1a013ec commit 8882b70
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions application/config/config-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@

// Preselected Question Type
$config['preselectquestiontype'] = 'T';
$config['preselectquestiontheme'] = 'core';

// theme editor mode
$config['defaultthemeteeditormode'] = 'default';
Expand Down
8 changes: 7 additions & 1 deletion application/controllers/QuestionAdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ public function renderFormAux(Question $question)
App()->session['FileManagerContext'] = "edit:survey:{$question->sid}";
initKcfinder();

$questionTemplate = 'core';
$questionTemplate = SettingsUser::getUserSettingValue(
'preselectquestiontheme',
null,
null,
null,
App()->getConfig('preselectquestiontheme')
);
if ($question->qid !== 0) {
$questionTemplate = QuestionAttribute::getQuestionTemplateValue($question->qid);
}
Expand Down
5 changes: 4 additions & 1 deletion application/controllers/admin/useraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public function personalsettings()
Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat');

SettingsUser::setUserSetting('preselectquestiontype', Yii::app()->request->getPost('preselectquestiontype'));
SettingsUser::setUserSetting('preselectquestiontheme', Yii::app()->request->getPost('preselectquestiontheme'));
SettingsUser::setUserSetting('showScriptEdit', Yii::app()->request->getPost('showScriptEdit'));
SettingsUser::setUserSetting('noViewMode', Yii::app()->request->getPost('noViewMode'));
SettingsUser::setUserSetting('answeroptionprefix', Yii::app()->request->getPost('answeroptionprefix'));
Expand Down Expand Up @@ -728,11 +729,13 @@ public function personalsettings()
});

$currentPreselectedQuestiontype = array_key_exists('preselectquestiontype', $aUserSettings) ? $aUserSettings['preselectquestiontype'] : App()->getConfig('preselectquestiontype');
$currentPreselectedQuestionTheme = array_key_exists('preselectquestiontheme', $aUserSettings) ? $aUserSettings['preselectquestiontheme'] : App()->getConfig('preselectquestiontheme');

$aData['currentPreselectedQuestiontype'] = $currentPreselectedQuestiontype;
$aData['currentPreselectedQuestionTheme'] = $currentPreselectedQuestionTheme;
$aData['aUserSettings'] = $aUserSettings;
$aData['aQuestionTypeList'] = QuestionTheme::findAllQuestionMetaDataForSelector();
$aData['selectedQuestion'] = QuestionTheme::findQuestionMetaData($currentPreselectedQuestiontype);
$aData['selectedQuestion'] = QuestionTheme::findQuestionMetaData($currentPreselectedQuestiontype, $currentPreselectedQuestionTheme);

$aData['surveymenu_data']['model'] = $oSurveymenu;
$aData['surveymenuentry_data']['model'] = $oSurveymenuEntries;
Expand Down
10 changes: 5 additions & 5 deletions application/core/LSSodium.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function init()
$this->checkIfKeyExists();
}
}

/**
* Check if Sodium library is installed
* @return bool
Expand Down Expand Up @@ -84,7 +84,7 @@ protected function getEncryptionSecretKey()
{
return ParagonIE_Sodium_Compat::hex2bin(Yii::app()->getConfig('encryptionsecretkey'));
}

/**
* Encrypt input data using AES256 CBC encryption
* @param unknown_type $sDataToEncrypt Data to encrypt. Could be a string or a serializable PHP object
Expand All @@ -103,7 +103,7 @@ public function encrypt($sDataToEncrypt)
return $sDataToEncrypt;
}
}

/**
*
* Decrypt encrypted string.
Expand All @@ -126,7 +126,7 @@ public function decrypt($sEncryptedString, $bReturnFalseIfError = false)
return $sEncryptedString;
}
}

/**
*
* Write encryption key to version.php config file
Expand All @@ -145,7 +145,7 @@ protected function generateEncryptionKeys()
if (empty($sEncryptionKeypair)) {
return false;
}

$sConfig = "<?php if (!defined('BASEPATH')) exit('No direct script access allowed');" . "\n"
. "/*" . "\n"
. " * LimeSurvey" . "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ if (typeof PreviewModalScript === 'function') {
});
} else {

$('#in_survey_common').off('change.previewModal');
$('#in_survey_common').on('change.previewModal', `#${this.widgetsJsName}`, (e) => {
$('#in_survey_common, #in_survey_common_action').off('change.previewModal');
$('#in_survey_common, #in_survey_common_action').on('change.previewModal', `#${this.widgetsJsName}`, (e) => {
var target = $(e.currentTarget);
var option = target.find("option:selected");
this.options.onUpdate(target.val(), option.data('theme'));
Expand Down
1 change: 1 addition & 0 deletions application/models/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Question extends LSActiveRecord

const START_SORTING_VALUE = 1; //this is the start value for question_order

const DEFAULT_QUESTION_THEME = 'core'; // The question theme name to use when no theme is specified

/** @var string $group_name Stock the active group_name for questions list filtering */
public $group_name;
Expand Down
8 changes: 2 additions & 6 deletions application/models/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,8 @@ public function getContentForScreen($sScreen)
foreach ($filesFromXML as $file) {
if ($file->attributes()->role == "content") {
// The path of the file is defined inside the theme itself.
$aExplodedFile = explode(DIRECTORY_SEPARATOR, $file);
$sFormatedFile = end($aExplodedFile);

// The file extension (.twig) is defined inside the theme itself.
$aExplodedFile = explode('.', $sFormatedFile);
$sFormatedFile = $aExplodedFile[0];
$aExplodedFile = pathinfo($file);
$sFormatedFile = $aExplodedFile['filename'];
return (string) $sFormatedFile;
}
}
Expand Down
9 changes: 8 additions & 1 deletion application/views/admin/user/personalsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
$aQuestionTypeGroups[$htmlReadyGroup]['questionTypes'][] = $questionType;
}
$currentPreselectedQuestiontype = array_key_exists('preselectquestiontype', $aUserSettings) ? $aUserSettings['preselectquestiontype'] : Yii::app()->getConfig('preselectquestiontype');

$oQuestionSelector = $this->beginWidget('ext.admin.PreviewModalWidget.PreviewModalWidget', array(
'widgetsJsName' => "preselectquestiontype",
'renderType' => "group-simple",
Expand All @@ -59,11 +59,17 @@
'previewWindowTitle' => gT("Preview question type"),
'groupStructureArray' => $aQuestionTypeGroups,
'value' => $currentPreselectedQuestiontype,
'theme' => $currentPreselectedQuestionTheme,
'debug' => YII_DEBUG,
'currentSelected' => $selectedQuestion['title'] ?? gT('Invalid question'),
'buttonClasses' => ['btn-primary'],
'optionArray' => [
'selectedClass' => $selectedQuestion['settings']->class ?? 'invalid_question',
'onUpdate' => [
'value',
'theme',
"$('#preselectquestiontheme').val(theme);"
],
]
));

Expand Down Expand Up @@ -244,6 +250,7 @@
<?php echo TbHtml::label(gT("Preselected question type:"), 'preselectquestiontype', array('class'=>" control-label")); ?>
<?=$oQuestionSelector->getButtonOrSelect(true)?>
<?php $this->endWidget('ext.admin.PreviewModalWidget.PreviewModalWidget'); ?>
<?php echo TbHtml::hiddenField('preselectquestiontheme', $currentPreselectedQuestionTheme); ?>
</div>
</div>
<div class="col-sm-12 col-md-6">
Expand Down

0 comments on commit 8882b70

Please sign in to comment.