Skip to content

Commit

Permalink
Fixed issue #12555: Settings still buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Aug 18, 2017
1 parent d476d23 commit 3b3654c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 52 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/database.php
Expand Up @@ -1082,7 +1082,7 @@ private function actionUpdateSurveyLocaleSettings($iSurveyID)
$oSurvey->sendconfirmation = $this->_filterEmptyFields($oSurvey,'sendconfirmation');
$oSurvey->tokenanswerspersistence = $this->_filterEmptyFields($oSurvey,'tokenanswerspersistence');
$oSurvey->alloweditaftercompletion = $this->_filterEmptyFields($oSurvey,'alloweditaftercompletion');
$oSurvey->usecaptcha = Survey::transcribeCaptchaOptions();
$oSurvey->usecaptcha = Survey::saveTranscribeCaptchaOptions($oSurvey);
$oSurvey->emailresponseto = $this->_filterEmptyFields($oSurvey,'emailresponseto');
$oSurvey->emailnotificationto = $this->_filterEmptyFields($oSurvey,'emailnotificationto');
$oSurvey->googleanalyticsapikeysetting = $this->_filterEmptyFields($oSurvey,'googleanalyticsapikeysetting');
Expand Down
45 changes: 45 additions & 0 deletions application/models/Survey.php
Expand Up @@ -1504,6 +1504,51 @@ public static function transcribeCaptchaOptions() {
return 'N';
}

/**
* Transcribe from 3 checkboxes to 1 char for captcha usages
* Uses variables from $_POST and transferred Surveyobject
*
* 'A' = All three captcha enabled
* 'B' = All but save and load
* 'C' = All but registration
* 'D' = All but survey access
* 'X' = Only survey access
* 'R' = Only registration
* 'S' = Only save and load
* 'N' = None
*
* @return string One character that corresponds to captcha usage
* @todo Should really be saved as three fields in the database!
*/
public static function saveTranscribeCaptchaOptions(Survey $oSurvey) {

$surveyaccess = App()->request->getPost('usecaptcha_surveyaccess', null);
$registration = App()->request->getPost('usecaptcha_registration', null);
$saveandload = App()->request->getPost('usecaptcha_saveandload', null);

if($surveyaccess === null && $registration === null && $saveandload === null){
return $oSurvey->usecaptcha;
}

if ($surveyaccess && $registration && $saveandload) {
return 'A';
} elseif ($surveyaccess && $registration) {
return 'B';
} elseif ($surveyaccess && $saveandload) {
return 'C';
} elseif ($registration && $saveandload) {
return 'D';
} elseif ($surveyaccess) {
return 'X';
} elseif ($registration) {
return 'R';
} elseif ($saveandload) {
return 'S';
}

return 'N';
}


/**
* Method to make an approximation on how long a survey will last
Expand Down
28 changes: 28 additions & 0 deletions application/views/admin/survey/editLocalSettings_main_view.php
Expand Up @@ -52,4 +52,32 @@
</form>
</div>
</div>
<script type="text/javascript">
$(document).on('ready pjax:complete', function(){
console.log('BOUND SUBMIT TO ',$('#<?=$entryData['name']?>'));

$('#<?=$entryData['name']?>').off('submit');

$('#<?=$entryData['name']?>').on('submit', function(e){
e.preventDefault();
var data = $(this).serializeArray();
var uri = $(this).attr('action');
$.ajax({
url: uri,
method:'POST',
data: data,
success: function(result){
if(result.redirecturl != undefined ){
window.location.href=result.redirecturl;
} else {
window.location.reload();
}
},
error: function(result){
console.log({result: result});
}
});
return false;
});
});
</script>
25 changes: 0 additions & 25 deletions assets/packages/adminpanel/build/lsadminpanel.js
Expand Up @@ -28499,30 +28499,6 @@ if (document.getElementById('vue-app-main-container')) {
});
}

//Add this here for a general correct submit catching
try{
$('#'+formId).on('submit', function(e){
e.preventDefault();
var data = $(this).serializeArray();
var uri = $(this).attr('action');
$.ajax({
url: uri,
method:'POST',
data: data,
success: function(result){
if(result.redirecturl != undefined ){
window.location.href=result.redirecturl;
} else {
window.location.reload();
}
},
error: function(result){
console.log({result: result});
}
});
});
} catch(e){}

$(document).on('pjax:send', () => {
$('#pjax-file-load-container').find('div').css({
'width': '20%',
Expand All @@ -28541,7 +28517,6 @@ $(document).on('pjax:complete', () => {




// const topmenu = new Vue(
// {
// el: '#vue-top-menu-app',
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminpanel/build/lsadminpanel.js.map

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions assets/packages/adminpanel/src/main.js
Expand Up @@ -57,30 +57,6 @@ if (document.getElementById('vue-app-main-container')) {
});
}

//Add this here for a general correct submit catching
try{
$('#'+formId).on('submit', function(e){
e.preventDefault();
var data = $(this).serializeArray();
var uri = $(this).attr('action');
$.ajax({
url: uri,
method:'POST',
data: data,
success: function(result){
if(result.redirecturl != undefined ){
window.location.href=result.redirecturl;
} else {
window.location.reload();
}
},
error: function(result){
console.log({result: result});
}
});
});
} catch(e){}

$(document).on('pjax:send', () => {
$('#pjax-file-load-container').find('div').css({
'width': '20%',
Expand All @@ -99,7 +75,6 @@ $(document).on('pjax:complete', () => {




// const topmenu = new Vue(
// {
// el: '#vue-top-menu-app',
Expand Down

0 comments on commit 3b3654c

Please sign in to comment.