Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into task/zoho-L41-T388-…
Browse files Browse the repository at this point in the history
…check-all-switches-for-int-in-db
  • Loading branch information
Trischi80 committed Feb 26, 2021
2 parents 890d0f8 + 5f2cb1e commit a83011d
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 23 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
14 changes: 8 additions & 6 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 @@ -2940,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 @@ -2769,7 +2769,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 @@ -2783,7 +2783,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
Expand Up @@ -59,8 +59,10 @@ public function move($destdir)
throw new Exception(gT('Temporary folder does not exist.'));
}

// NB: mkdir() always applies the set umask to 0777. See https://www.php.net/manual/en/function.mkdir
mkdir($destdir, 0777, true);
if (!file_exists($destdir)) {
// NB: mkdir() always applies the set umask to 0777. See https://www.php.net/manual/en/function.mkdir
mkdir($destdir, 0777, true);
}

if (!is_writable(dirname($destdir))) {
throw new Exception(gT('Cannot move files due to permission problem. ' . $destdir));
Expand Down
11 changes: 9 additions & 2 deletions application/libraries/PluginManager/Storage/DbStorage.php
Expand Up @@ -6,6 +6,13 @@

class DbStorage implements iPluginStorage
{
/**
* NB: Needed even if empty.
*/
public function __construct()
{
}

/**
* @param iPlugin $plugin
* @param string $key Key for the setting; passing null will return all keys.
Expand Down Expand Up @@ -43,7 +50,7 @@ protected function getGeneric(iPlugin $plugin, $key, $model, $id, $default)
if ($key != null) {
$attributes['key'] = $key;
}

$records = \PluginSetting::model()->findAllByAttributes($attributes);
if (count($records) > 1) {
foreach ($records as $record) {
Expand Down Expand Up @@ -104,7 +111,7 @@ protected function setGeneric(iPlugin $plugin, $key, $data, $model, $id, $langua
}
$record->value = json_encode($data);
$result = $record->save();

return $result;
}
}
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
27 changes: 27 additions & 0 deletions tests/TestBaseClassWeb.php
Expand Up @@ -19,6 +19,7 @@
use Facebook\WebDriver\WebDriverExpectedCondition;
use Facebook\WebDriver\Exception\TimeOutException;
use Facebook\WebDriver\Exception\NoSuchElementException;
use Facebook\WebDriver\Exception\UnrecognizedExceptionException;

/**
* Class TestBaseClassWeb
Expand Down Expand Up @@ -169,6 +170,10 @@ public static function adminLogin($userName, $password)

$submit = self::$webDriver->findElement(WebDriverBy::name('login_submit'));
$submit->click();

self::ignoreAdminNotification();
self::ignoreAdminNotification();

/*
try {
sleep(1);
Expand Down Expand Up @@ -220,4 +225,26 @@ protected function waitForElementShim(&$driver, $CSSelementSelectorString, $time

return $element;
}

/**
* @return void
*/
protected static function ignoreAdminNotification()
{
// Ignore password warning.
try {
$button = self::$webDriver->wait(1)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('#admin-notification-modal button.btn-default')
)
);
$button->click();
} catch (TimeOutException $ex) {
// Do nothing.
} catch (NoSuchElementException $ex) {
// Do nothing.
} catch (UnrecognizedExceptionException $ex) {
// Do nothing.
}
}
}
2 changes: 2 additions & 0 deletions tests/functional/backend/NoGreenBarTest.php
Expand Up @@ -52,6 +52,8 @@ public function setup()
$input = $web->findById('firstname');
$input->sendKeys('dummy name');
sleep(1);
self::ignoreAdminNotification();
self::ignoreAdminNotification();
$savebutton = $web->findById('save-button');
$savebutton->click();
sleep(1);
Expand Down

0 comments on commit a83011d

Please sign in to comment.