Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jun 22, 2018
2 parents b13f86c + 59cbcfb commit 0ba08bd
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 91 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
$config['dbversionnumber'] = 403;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '30041';
$config['assetsversionnumber'] = '30042';
return $config;
8 changes: 8 additions & 0 deletions application/controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,14 @@ private function display($iSurveyId, $iTokenId = null, $registerContent)

$aData['aSurveyInfo'] = array_merge($aSurveyInfo, $aData['aSurveyInfo']);

$aData['aSurveyInfo']['alanguageChanger']['show'] = false;
$alanguageChangerDatas = getLanguageChangerDatas(App()->language);

if ($alanguageChangerDatas) {
$aData['aSurveyInfo']['alanguageChanger']['show'] = true;
$aData['aSurveyInfo']['alanguageChanger']['datas'] = $alanguageChangerDatas;
}

Yii::app()->twigRenderer->renderTemplateFromFile('layout_global.twig', $aData, false);

}
Expand Down
20 changes: 19 additions & 1 deletion application/core/LSHttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,32 @@ protected function normalizeRequest()

$route = Yii::app()->getUrlManager()->parseUrl($this);
if ($this->enableCsrfValidation) {
foreach ($this->noCsrfValidationRoutes as $cr) {

$beforeUrlCheck = new PluginEvent('beforeUrlCheck');
$beforeUrlCheck->set('routes', $this->noCsrfValidationRoutes);
$beforeUrlCheck->set('params', []);
App()->getPluginManager()->dispatchEvent($beforeUrlCheck);
$validationRoutes = $beforeUrlCheck->get('routes');
$validationParams = $beforeUrlCheck->get('params');

foreach ($validationRoutes as $cr) {
if (preg_match('#'.$cr.'#', $route)) {
Yii::app()->detachEventHandler('onBeginRequest',
array($this, 'validateCsrfToken'));
Yii::trace('Route "'.$route.' passed without CSRF validation');
break; // found first route and break
}
}

foreach ($validationParams as $key => $value) {
if (isset($_GET[$key]) && $_GET[$key] === $value) {
Yii::app()->detachEventHandler('onBeginRequest',
array($this, 'validateCsrfToken'));
Yii::trace('Route "'.$route.' passed without CSRF validation');
break; // found first param and break
}
}

}
}

Expand Down
40 changes: 22 additions & 18 deletions application/helpers/remotecontrol/remotecontrol_handle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,9 @@ public function remind_participants($sSessionKey, $iSurveyID, $iMinDaysBetween =
* @param string $sSessionKey Auth credentials
* @param int $iSurveyID ID of the Survey to insert responses
* @param array $aResponseData The actual response
* @return int|array The response ID
* @return int|array The response ID or an array with status message (can include result_id)
* @todo Need to clean up return array, especially the case when response was added but file not uploaded.
* @todo See discussion: https://bugs.limesurvey.org/view.php?id=13794
*/
public function add_response($sSessionKey, $iSurveyID, $aResponseData)
{
Expand All @@ -2566,31 +2568,31 @@ public function add_response($sSessionKey, $iSurveyID, $aResponseData)

if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'create')) {
if (!Yii::app()->db->schema->getTable($oSurvey->responsesTableName)) {
return array('status' => 'No survey response table');
return array('status' => 'No survey response table');
}

//set required values if not set

// @todo: Some of this is part of the validation and should be done in the model instead
if (array_key_exists('submitdate', $aResponseData) && empty($aResponseData['submitdate'])) {
unset($aResponseData['submitdate']);
} else if (!isset($aResponseData['submitdate'])) {
$aResponseData['submitdate'] = date("Y-m-d H:i:s");
unset($aResponseData['submitdate']);
} elseif (!isset($aResponseData['submitdate'])) {
$aResponseData['submitdate'] = date("Y-m-d H:i:s");
}
if (!isset($aResponseData['startlanguage'])) {
$aResponseData['startlanguage'] = $oSurvey->language;
}
if (!isset($aResponseData['startlanguage'])) {
$aResponseData['startlanguage'] = $oSurvey->language;
}

if ($oSurvey->isDateStamp) {
if (array_key_exists('datestamp', $aResponseData) && empty($aResponseData['datestamp'])) {
unset($aResponseData['datestamp']);
} else if (!isset($aResponseData['datestamp'])) {
$aResponseData['datestamp'] = date("Y-m-d H:i:s");
unset($aResponseData['datestamp']);
} elseif (!isset($aResponseData['datestamp'])) {
$aResponseData['datestamp'] = date("Y-m-d H:i:s");
}
if (array_key_exists('startdate', $aResponseData) && empty($aResponseData['startdate'])) {
unset($aResponseData['startdate']);
} else if (!isset($aResponseData['startdate'])) {
$aResponseData['startdate'] = date("Y-m-d H:i:s");
if (array_key_exists('startdate', $aResponseData) && empty($aResponseData['startdate'])) {
unset($aResponseData['startdate']);
} elseif (!isset($aResponseData['startdate'])) {
$aResponseData['startdate'] = date("Y-m-d H:i:s");
}
}

Expand All @@ -2613,7 +2615,10 @@ public function add_response($sSessionKey, $iSurveyID, $aResponseData)
}

if (!rename($sFileTempName, $sFileRealName)) {
return array('status' => 'Unable to move files '.$sFileTempName.' '.$sFileRealName);
return array(
'status' => 'Unable to move files '.$sFileTempName.' '.$sFileRealName,
'result_id' => $result_id
);
}
}

Expand All @@ -2624,9 +2629,8 @@ public function add_response($sSessionKey, $iSurveyID, $aResponseData)
return array('status' => 'Unable to add response');
}
} else {
return array('status' => 'No permission');
return array('status' => 'No permission');
}

}

/**
Expand Down
1 change: 1 addition & 0 deletions application/models/TemplateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ public function getClassAndAttributes()
$aClassAndAttributes['attr']['clearalllinks'] = $aClassAndAttributes['attr']['clearalllink'] = ' ';
// Clearall Buttons
$aClassAndAttributes['class']['clearallwrapper'] = $aClassAndAttributes['class']['clearallconfirm'] = ""; // No need, adding it if need something after
$aClassAndAttributes['class']['clearalllabel'] = "ls-js-hidden";
$aClassAndAttributes['attr']['clearallconfirm'] = 'value="confirm" name="confirm-clearall" type="checkbox"';
$aClassAndAttributes['attr']['clearallbutton'] = 'type="submit" value="clearall" name="move" data-confirmedby="confirm-clearall"';
$aClassAndAttributes['class']['clearallbutton'] = "ls-clearaction ls-clearall"; // Not needed, keep it (and adding to twig to be most compatible in future)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
'selectedClass' => Question::getQuestionClass($oQuestion->type),
'onUpdate' => [
'value',
"console.ls.log(value); $('#question_type').val(value);"
"console.ls.log(value); $('#question_type').val(value); updatequestionattributes(''); updateQuestionTemplateOptions();"
]
]
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ul>

<!-- Editors for each languages -->
<div class="tab-content">
<div class="tab-content" v-pre>

<!-- Base Language tab-pane -->
<div id="<?php echo $oSurvey->language; ?>" class="tab-pane fade in active">
Expand Down
24 changes: 12 additions & 12 deletions application/views/admin/survey/surveybar_displayexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<p>".gT("It will include the following data in a ZIP file ending with '.lsa'.")."</p>
<ul>
<li>".gT("Survey structure")."</li>
<li>".gT("Response data (Files uploaded in a file upload question have to exported separately)")."</li>
<li>".gT("Token data (if activated)")."</li>
<li>".gT("Response data (Attention: Doesn't include files uploaded in a file upload question. These have to be exported separately.)")."</li>
<li>".gT("Survey participant data (if available)")."</li>
<li>".gT("Timings (if activated)")."</li>
</ul>
",
Expand All @@ -44,7 +44,7 @@
]
: [
"key" => "surveyarchive",
"description" => "".gT("Survey archive - only in active surveys"),
"description" => "".gT("Survey archive - only available for active surveys"),
"detailpage" => "",
"href" => '#',
"htmlclasses" => 'disabled',
Expand All @@ -61,7 +61,7 @@
<p>".gT("queXML is an XML description of a questionnaire.")."</p>
<p>".gT("It is not suitable for backing up a LimeSurvey survey as it cannot export conditions, and isn't able to export all question types.")."</p>
<p>".gT("Exporting a questionnaire to queXML allows you to create PDF documents that can be printed, filled then scanned and processed using queXF software.")."</p>
<p>".gT("To get to know more about queXML check this page:")." <a href=\"https://quexml.acspri.org.au/\" target=\"_blank\">quexml.acspri.org.au <i class=\"fa fa-external-link\"></i></a>.</p>",
<p>".gT("To find out more about queXML check out this page:")." <a href=\"https://quexml.acspri.org.au/\" target=\"_blank\">quexml.acspri.org.au <i class=\"fa fa-external-link\"></i></a>.</p>",
"href" => $this->createUrl("admin/export/sa/survey/action/exportstructurequexml/surveyid/".$oSurvey->sid),
"download" => true
];
Expand Down Expand Up @@ -97,8 +97,8 @@
"description" => gT("Printable survey (*.html)"),
"detailpage" => "
<p>".gT("This will download a .zip file containing the survey in all languages.")."</p>
<p>".gT("It will also contain the necessary stylesheets to put it up on any HTML-ready devices or browsers")."</p>
<p>".gT("It will not contain any logic, or EM-functionalities, you will have to calculate that yourself.")."</p>
<p>".gT("It will also contain the necessary stylesheets to put it up on any HTML-ready devices or browsers.")."</p>
<p>".gT("It will not contain any logic or EM-functionality, you'll have to take that into account yourself.")."</p>
",
"href" => $this->createUrl("admin/export/sa/survey/action/exportprintables/surveyid/".$oSurvey->sid),
"download" => true,
Expand All @@ -110,9 +110,9 @@
"key" => "printablesurvey",
"description" => gT("Printable survey"),
"detailpage" => "
<p>".gT("This will open the survey as a printable page in another window.")."</p>
<p>".gT("All necessary styles will be loaded, to print it just press Ctrl/Cmd+p or select print from your browsers menu.")."</p>
<p>".gT("It will not contain any logic, or EM-functionalities, you will have to calculate that yourself.")."</p>
<p>".gT("This will open the survey as a printable page in new window.")."</p>
<p>".gT("All necessary styles will be loaded, to print it just press Ctrl/Cmd+p or select print from your browser menu.")."</p>
<p>".gT("It will not contain any logic or EM-functionality, you'll have to take that into account yourself.")."</p>
",
"href" => $this->createUrl("admin/printablesurvey/sa/index/surveyid/$oSurvey->sid"),
"download" => false,
Expand All @@ -135,9 +135,9 @@
"key" => "printablesurvey_".$tmp_lang,
"description" => gT("Printable survey").' ('.getLanguageNameFromCode($tmp_lang, false).')',
"detailpage" => "
<p>".sprintf(gT("This will open the survey in %s as a printable page in another window."), getLanguageNameFromCode($tmp_lang, false))."</p>
<p>".gT("All necessary styles will be loaded, to print it just press Ctrl/Cmd+p or select print from your browsers menu.")."</p>
<p>".gT("It will not contain any logic, or EM-functionalities, you will have to calculate that yourself.")."</p>
<p>".sprintf(gT("This will open the survey in %s as a printable page in new window."), getLanguageNameFromCode($tmp_lang, false))."</p>
<p>".gT("All necessary styles will be loaded, to print it just press Ctrl/Cmd+p or select print from your browser menu.")."</p>
<p>".gT("It will not contain any logic or EM-functionality, you'll have to take that into account yourself.")."</p>
",
"href" => $this->createUrl("admin/printablesurvey/sa/index/surveyid/".$oSurvey->sid."/lang/".$tmp_lang),
"external" => true,
Expand Down
28 changes: 9 additions & 19 deletions assets/scripts/admin/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ var QuestionFunctions = function () {
});

$('#question_type').on('change', function(){
updatequestionattributes('');
updateQuestionTemplatePreview();
OtherSelection(this.value);
});

$(document).on('change', '#question_template', function(){
updatequestionattributes($('#question_template').val());
updateQuestionTemplatePreview();
updateQuestionTemplateOptions('question_template');
});

/**
Expand Down Expand Up @@ -206,22 +204,7 @@ function updatequestionattributes(question_template_name) {
});
}

function updateQuestionTemplateOptions() {
var type = $('#question_type').val();
$.ajax({
url: get_question_template_options_url,
data: {'type': type},
method: 'POST',
success: function (data) {
$("#question_template").html("");
$.each(data, function (key, value) {
$("#question_template").append("<option value="+key+">"+value.title+"</option>");
});
}
});
}

function updateQuestionTemplatePreview() {
function updateQuestionTemplateOptions(selector = '') { // selector is only set when this function is called from #question_template
var type = $('#question_type').val();
var template = $('#question_template').val();
$.ajax({
Expand All @@ -234,6 +217,13 @@ function updateQuestionTemplatePreview() {
} else {
$("#QuestionTemplatePreview img").attr('src', data['core']['preview']);
}

if (selector === ''){ // selector is not called from #question_template
$("#question_template").html("");
$.each(data, function (key, value) {
$("#question_template").append("<option value="+key+">"+value.title+"</option>");
});
}
}
});
}
Expand Down

0 comments on commit 0ba08bd

Please sign in to comment.