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 Feb 26, 2021
2 parents 1d9e111 + a83011d commit dc1bc01
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 22 deletions.
5 changes: 4 additions & 1 deletion application/commands/ResetPasswordCommand.php
Expand Up @@ -21,8 +21,11 @@ public function run($sArgument)
if (isset($sArgument) && isset($sArgument[0]) && isset($sArgument[1])) {
$oUser = User::findByUsername($sArgument[0]);
if ($oUser) {
Yii::import('application.helpers.common_helper', true);
$oUser->setPassword($sArgument[1]);
if ($oUser->save()) {
// Save the model validating only the password, because there may be issues with other attributes
// (like an invalid value for some setting), which the user cannot fix because he doesn't have access.
if ($oUser->save(true, ['password'])) {
echo "Password for user {$sArgument[0]} was set.\n";
return 0;
} else {
Expand Down
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -12,7 +12,7 @@
*/

$config['versionnumber'] = '4.4.10';
$config['dbversionnumber'] = 437;
$config['dbversionnumber'] = 438;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
Expand Down
22 changes: 15 additions & 7 deletions application/controllers/QuestionAdministrationController.php
Expand Up @@ -233,6 +233,12 @@ public function renderFormAux(Question $question)
'core'
);

if (App()->session['questionselectormode'] !== 'default') {
$selectormodeclass = App()->session['questionselectormode'];
} else {
$selectormodeclass = App()->getConfig('defaultquestionselectormode');
}

$viewData = [
'oSurvey' => $question->survey,
'oQuestion' => $question,
Expand All @@ -242,7 +248,8 @@ public function renderFormAux(Question $question)
'generalSettings' => $generalSettings,
'showScriptField' => $showScriptField,
'jsVariablesHtml' => $jsVariablesHtml,
'modalsHtml' => $modalsHtml
'modalsHtml' => $modalsHtml,
'selectormodeclass' => $selectormodeclass,
];

$this->aData = array_merge($this->aData, $viewData);
Expand Down Expand Up @@ -2543,7 +2550,13 @@ private function unparseAndSetGeneralOptions($oQuestion, $dataSet)
* @todo document me
*
* @param Question $oQuestion
* @param array $dataSet
* @param array $dataSet these are the advancedSettings in an array like
* [display]
* [hidden]
* ...
* [logic]
* ...
*
* @return boolean
* @throws CHttpException
*/
Expand Down Expand Up @@ -2934,11 +2947,6 @@ private function getQuestionTypeGroups($aQuestionTypeList)
{
$aQuestionTypeGroups = [];

if (App()->session['questionselectormode'] !== 'default') {
$selectormodeclass = App()->session['questionselectormode'];
} else {
$selectormodeclass = App()->getConfig('defaultquestionselectormode');
}
uasort($aQuestionTypeList, "questionTitleSort");
foreach ($aQuestionTypeList as $questionType) {
$htmlReadyGroup = str_replace(' ', '_', strtolower($questionType['group']));
Expand Down
Expand Up @@ -735,7 +735,7 @@ public function actionSaveQuestionGroupData($sid)

$landOnSideMenuTab = 'structure';
if (empty($sScenario)) {
if (App()->request->getPost('save-and-close', '')) {
if (App()->request->getPost('close-after-save', '')) {
$sScenario = 'save-and-close';
} elseif (App()->request->getPost('saveandnew', '')) {
$sScenario = 'save-and-new';
Expand Down
4 changes: 2 additions & 2 deletions application/core/plugins/AuthLDAP/AuthLDAP.php
Expand Up @@ -366,8 +366,8 @@ public function beforeLogin()
public function newLoginForm()
{
$this->getEvent()->getContent($this)
->addContent(CHtml::tag('span', array(), "<label for='user'>" . gT("Username") . "</label>" . CHtml::textField('user', '', array('size' => 40, 'maxlength' => 40, 'class' => "form-control"))))
->addContent(CHtml::tag('span', array(), "<label for='password'>" . gT("Password") . "</label>" . CHtml::passwordField('password', '', array('size' => 40, 'maxlength' => 40, 'class' => "form-control"))));
->addContent(CHtml::tag('span', array(), "<label for='user'>" . gT("Username") . "</label>" . CHtml::textField('user', '', array('size' => 240, 'maxlength' => 240, 'class' => "form-control"))))
->addContent(CHtml::tag('span', array(), "<label for='password'>" . gT("Password") . "</label>" . CHtml::passwordField('password', '', array('size' => 240, 'maxlength' => 240, 'class' => "form-control"))));
}

/**
Expand Down
Expand Up @@ -123,7 +123,9 @@ if (typeof PreviewModalScript === 'function') {

$('#in_survey_common').off('change.previewModal');
$('#in_survey_common').on('change.previewModal', `#${this.widgetsJsName}`, (e) => {
this.options.onUpdate($(e.currentTarget).val());
var target = $(e.currentTarget);
var option = target.find("option:selected");
this.options.onUpdate(target.val(), option.data('theme'));
});
}

Expand Down
Expand Up @@ -8,11 +8,11 @@
foreach ($this->groupStructureArray as $sGroupTitle => $aGroupArray) {
echo sprintf("<optgroup label='%s'>", $aGroupArray[$this->groupTitleKey]);
foreach ($aGroupArray[$this->groupItemsKey] as $aItemContent) {
$selected = $this->value == $aItemContent['type'] ? 'selected' : '';
$selected = $this->value == $aItemContent['type'] && $this->theme == $aItemContent['name'] ? 'selected' : '';
if(YII_DEBUG) {
echo sprintf("<option value='%s' %s>%s (%s)</option>", $aItemContent['type'], $selected, $aItemContent['title'], $aItemContent['type']);
echo sprintf("<option value='%s' data-theme='%s' %s>%s (%s)</option>", $aItemContent['type'], $aItemContent['name'], $selected, $aItemContent['title'], $aItemContent['type']);
} else {
echo sprintf("<option value='%s' %s>%s</option>", $aItemContent['type'], $selected, $aItemContent['title']);
echo sprintf("<option value='%s' data-theme='%s' %s>%s</option>", $aItemContent['type'], $aItemContent['name'], $selected, $aItemContent['title']);
}
}
echo "</optgroup>";
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/export_helper.php
Expand Up @@ -2768,7 +2768,7 @@ function tsvSurveyExport($surveyid)
$tsv_output['type/scale'] = $group['group_order'];
$tsv_output['name'] = !empty($group['group_name']) ? $group['group_name'] : '';
$tsv_output['text'] = !empty($group['description']) ? str_replace(array("\n", "\r"), '', $group['description']) : '';
$tsv_output['relevance'] = !empty($group['grelevance']) ? $group['grelevance'] : '';
$tsv_output['relevance'] = isset($group['grelevance']) ? $group['grelevance'] : '';
$tsv_output['random_group'] = !empty($group['randomization_group']) ? $group['randomization_group'] : '';
$tsv_output['language'] = $language;
fputcsv($out, array_map('MaskFormula', $tsv_output), chr(9));
Expand All @@ -2782,7 +2782,7 @@ function tsvSurveyExport($surveyid)
$tsv_output['class'] = 'Q';
$tsv_output['type/scale'] = $question['type'];
$tsv_output['name'] = !empty($question['title']) ? $question['title'] : '';
$tsv_output['relevance'] = !empty($question['relevance']) ? $question['relevance'] : '';
$tsv_output['relevance'] = isset($question['relevance']) ? $question['relevance'] : '';
$tsv_output['text'] = !empty($question['question']) ? str_replace(array("\n", "\r"), '', $question['question']) : '';
$tsv_output['help'] = !empty($question['help']) ? str_replace(array("\n", "\r"), '', $question['help']) : '';
$tsv_output['language'] = $question['language'];
Expand Down
77 changes: 77 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -3622,6 +3622,83 @@ function ($v) {
$oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 437), "stg_name='DBVersion'");
$oTransaction->commit();
}
if($iOldDBVersion < 438){
$oTransaction = $oDB->beginTransaction();

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'hidden' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'hidden' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'statistics_showgraph' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'statistics_showgraph' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'public_statistics' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'public_statistics' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'page_break' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'page_break' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'other_numbers_only' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'other_numbers_only' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'other_comment_mandatory' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'other_comment_mandatory' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'hide_tip' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'hide_tip' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'exclude_all_others_auto' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'exclude_all_others_auto' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'commented_checkbox_auto' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'commented_checkbox_auto' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'num_value_int_only' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'num_value_int_only' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'alphasort' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'alphasort' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'use_dropdown' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'use_dropdown' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'num_value_int_only' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'num_value_int_only' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_default_set' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_default_set' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_layout' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_layout' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_middlestart' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_middlestart' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_reset' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_reset' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_reversed' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_reversed' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'slider_showminmax' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'slider_showminmax' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'value_range_allows_missing' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'value_range_allows_missing' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'multiflexible_checkbox' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'multiflexible_checkbox' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'reverse' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'reverse' and value = 'N'");

$oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'input_boxes' and value = 'Y'");
$oDB->createCommand()->update('{{question_attributes}}', array('value' => '0'), "attribute = 'input_boxes' and value = 'N'");


$oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 438), "stg_name='DBVersion'");
$oTransaction->commit();
}

} catch (Exception $e) {
Yii::app()->setConfig('Updating', false);
$oTransaction->rollback();
Expand Down
2 changes: 1 addition & 1 deletion application/models/Question.php
Expand Up @@ -30,7 +30,7 @@
* @property integer $question_order Question order in greoup
* @property integer $parent_qid Questions parent question ID eg for subquestions
* @property integer $scale_id The scale ID
* @property integer $same_default Saves if user set to use the same default value across languages in default options dialog
* @property integer $same_default Saves if user set to use the same default value across languages in default options dialog ('Edit default answers')
* @property string $relevance Questions relevane equation
* @property string $modulename
*
Expand Down
4 changes: 2 additions & 2 deletions application/views/admin/token/tokenform.php
Expand Up @@ -333,13 +333,13 @@
<div id="remind-date-container" data-parent="#remind-switch" class="selector__date-container_hidden date-container" <?php if (!$bRemindSwitchValue){ echo "style='display:none;'"; }?> >

<div id="remind-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="remind-date" type="text" value="<?php echo isset($remindersent) && $remindersent!='N' ? convertToGlobalSettingFormat($remindersent,true) : ''?>" name="remind-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
<input class="YesNoDatePicker form-control" id="remind-date" type="text" value="<?php echo isset($remindersent) && $remindersent!='N' ? $remindersent : ''?>" name="remind-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
</div>
<input class='form-control hidden YesNoDateHidden' type='text' size='20' id='remindersent' name='remindersent' value="<?php if (isset($remindersent) && $remindersent!='N') {echo convertToGlobalSettingFormat($remindersent,true); } else {echo "N"; }?>" />
<input class='form-control hidden YesNoDateHidden' type='text' size='20' id='remindersent' name='remindersent' value="<?php if (isset($remindersent) && $remindersent!='N') {echo $remindersent; } else {echo "N"; }?>" />
</div>

<!-- Reminder count, Uses left -->
Expand Down
3 changes: 2 additions & 1 deletion application/views/questionAdministration/create.php
Expand Up @@ -99,7 +99,8 @@ class="btn navbar-btn button white btn-success"
'aQuestionTypeGroups' => $aQuestionTypeGroups,
'questionThemeTitle' => $questionTheme['title'],
'questionThemeName' => $questionTheme['name'],
'questionThemeClass' => ($questionTheme['settings'])->class
'questionThemeClass' => ($questionTheme['settings'])->class,
'selectormodeclass' => $selectormodeclass,
]
); ?>
</div>
Expand Down

0 comments on commit dc1bc01

Please sign in to comment.