Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into task/zoho-L41-T491-…
Browse files Browse the repository at this point in the history
…checkbox-layout-not_shown-in-overview

# Conflicts:
#	application/views/questionAdministration/summary.php
  • Loading branch information
Trischi80 committed Mar 15, 2021
2 parents 488656e + cf8ddff commit b3e4d3b
Show file tree
Hide file tree
Showing 36 changed files with 673 additions and 532 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -12,7 +12,7 @@
*/

$config['versionnumber'] = '4.4.12';
$config['dbversionnumber'] = 440;
$config['dbversionnumber'] = 441;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
Expand Down
Expand Up @@ -119,7 +119,7 @@ public function actionEdit($questionId, $tabOverviewEditor = 'overview')
{
$questionId = (int) $questionId;

/** @var Question|null */
/** @var $question Question|null */
$question = Question::model()->findByPk($questionId);
if (empty($question)) {
throw new CHttpException(404, gT("Invalid question id"));
Expand Down
22 changes: 18 additions & 4 deletions application/controllers/SurveyAdministrationController.php
Expand Up @@ -366,6 +366,12 @@ public function actionNewSurvey()
'N' => gT('Off', 'unescaped'),
);

$aData['optionsAdmin'] = array(
'default' => gT('Default', 'unescaped'),
'owner' => gT('Current user', 'unescaped'),
'custom' => gT('Custom', 'unescaped'),
);

//Prepare the edition panes
// $aData['edittextdata'] = array_merge($aData, $this->getTextEditData($survey));

Expand Down Expand Up @@ -437,15 +443,23 @@ public function actionInsert($iSurveyID = null)
if ($baseLanguage === null) {
$baseLanguage = 'en'; //shoulb be const somewhere ... or get chosen language from user
}
$simpleSurveyValues->setBaseLanguage($baseLanguage);
$simpleSurveyValues->setSurveyGroupId((int) App()->request->getPost('gsid', '1'));
$simpleSurveyValues->setTitle($surveyTitle);
$simpleSurveyValues->baseLanguage = $baseLanguage;
$simpleSurveyValues->surveyGroupId = (int) App()->request->getPost('gsid', '1');
$simpleSurveyValues->title = $surveyTitle;

$administrator = Yii::app()->request->getPost('administrator');
if ($administrator == 'custom') {
$simpleSurveyValues->admin = Yii::app()->request->getPost('admin');
$simpleSurveyValues->adminEmail = Yii::app()->request->getPost('adminemail');
}
$overrideAdministrator = ($administrator != 'owner');

$surveyCreator = new \LimeSurvey\Models\Services\CreateSurvey(new Survey(), new SurveyLanguageSetting());
$newSurvey = $surveyCreator->createSimple(
$simpleSurveyValues,
(int)Yii::app()->user->getId(),
Permission::model()
Permission::model(),
$overrideAdministrator
);
if (!$newSurvey) {
Yii::app()->setFlashMessage(gT("Survey could not be created."), 'error');
Expand Down
12 changes: 12 additions & 0 deletions application/controllers/admin/export.php
Expand Up @@ -554,6 +554,18 @@ public function exportspss()
}
}

// Add instructions to change variable type and recode 'Other' option.
// This is needed when all answer option codes are numeric but the question has 'Other' enabled,
// because the variable is initialy set as alphanumeric in order to hold the '-oth-' value. See issue #16939
foreach ($fields as $field) {
if (isset($field['needsAlterType'])) {
echo "RECODE {$field['id']} (\"-oth-\" = \"666666\").\n";
echo "EXECUTE.\n";
echo "ADD VALUE LABELS {$field['id']} 666666 \"other\".\n";
echo "ALTER TYPE {$field['id']} (F6.0).\n";
}
}

foreach ($fields as $field) {
if ($field['scale'] !== '') {
switch ($field['scale']) {
Expand Down
18 changes: 7 additions & 11 deletions application/controllers/admin/responses.php
Expand Up @@ -967,11 +967,6 @@ public function time($iSurveyID)
*/
private function _zipFiles($iSurveyID, $responseIds, $zipfilename)
{
/**
* @todo Move this to model.
*/
App()->loadLibrary('admin/pclzip');

$tmpdir = App()->getConfig('uploaddir') . DIRECTORY_SEPARATOR . "surveys" . DIRECTORY_SEPARATOR . $iSurveyID . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR;

$filelist = array();
Expand All @@ -987,19 +982,20 @@ private function _zipFiles($iSurveyID, $responseIds, $zipfilename)
*/
if (file_exists($tmpdir . basename($fileInfo['filename']))) {
$filelist[] = array(
PCLZIP_ATT_FILE_NAME => $tmpdir . basename($fileInfo['filename']),
PCLZIP_ATT_FILE_NEW_FULL_NAME => sprintf("%05s_%02s-%s_%02s-%s", $response->id, $filecount, $fileInfo['question']['title'], $fileInfo['index'], sanitize_filename(rawurldecode($fileInfo['name'])))
$tmpdir . basename($fileInfo['filename']),
sprintf("%05s_%02s-%s_%02s-%s", $response->id, $filecount, $fileInfo['question']['title'], $fileInfo['index'], sanitize_filename(rawurldecode($fileInfo['name'])))
);
}
}
}

if (count($filelist) > 0) {
$zip = new PclZip($tmpdir . $zipfilename);
if ($zip->create($filelist) === 0) {
//Oops something has gone wrong!
$zip = new ZipArchive();
$zip->open($tmpdir.$zipfilename,ZipArchive::CREATE);
foreach($filelist as $aFile) {
$zip->addFile($aFile[0],$aFile[1]);
}

$zip->close();
if (file_exists($tmpdir . '/' . $zipfilename)) {
@ob_clean();
header('Content-Description: File Transfer');
Expand Down
Expand Up @@ -429,6 +429,12 @@ public function render($sCoreClasses = '')

$this->registerAssets();
$this->inputnames[] = $this->sSGQA;

if (!Yii::app()->getClientScript()->isScriptFileRegistered(Yii::app()->getConfig('generalscripts') . "dualscale.js", LSYii_ClientScript::POS_BEGIN)) {
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "dualscale.js", LSYii_ClientScript::POS_BEGIN);
}
Yii::app()->getClientScript()->registerScript('doDualScaleFunction' . $this->oQuestion->qid, "{$this->doDualScaleFunction}({$this->oQuestion->qid});", LSYii_ClientScript::POS_POSTSCRIPT);

return array($answer, $this->inputnames);
}
}
56 changes: 7 additions & 49 deletions application/datavalueobjects/SimpleSurveyValues.php
Expand Up @@ -17,59 +17,17 @@ class SimpleSurveyValues
{

/** @var string language selected by user */
private $baseLanguage;
public $baseLanguage;

/** @var string title of the survey */
private $title;
public $title;

/** @var int the surveygroup from which the new survey will inherit values */
private $surveyGroupId;
public $surveyGroupId;

/**
* @return string
*/
public function getBaseLanguage(): string
{
return $this->baseLanguage;
}
/** @var string administrator name */
public $admin = 'inherit';

/**
* @param string $baseLanguage
*/
public function setBaseLanguage(string $baseLanguage)
{
$this->baseLanguage = $baseLanguage;
}

/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}

/**
* @param string $title
*/
public function setTitle(string $title)
{
$this->title = $title;
}

/**
* @return int
*/
public function getSurveyGroupId(): int
{
return $this->surveyGroupId;
}

/**
* @param int $surveyGroupId
*/
public function setSurveyGroupId(int $surveyGroupId)
{
$this->surveyGroupId = $surveyGroupId;
}
/** @var string administrator email */
public $adminEmail = 'inherit';
}
Expand Up @@ -13,6 +13,13 @@ public function run()
if ($this->generalOption->inputType === 'buttongroup') {
//echo '<pre>';print_r($this->generalOption->formElement->options);die;
}

//workaround if inputType is text, then take out "" in the middle of the string and replace every " inside the string
//with '
if($this->generalOption->inputType === 'text'){
$this->generalOption->formElement->value = str_replace('"', "'",$this->generalOption->formElement->value);
}

$content = $this->render($this->generalOption->inputType, null, true);
$this->render('layout', ['content' => $content]);
}
Expand Down
25 changes: 21 additions & 4 deletions application/helpers/export_helper.php
Expand Up @@ -17,12 +17,15 @@
* Strips html tags and replaces new lines
*
* @param $string
* @param $removeOther if 'true', removes '-oth-' from the string.
* @return string
*/
function stripTagsFull($string)
function stripTagsFull($string, $removeOther = true)
{
$string = flattenText($string, false, true); // stripo whole + html_entities
$string = str_replace('-oth', '', $string);// Why ?
if ($removeOther) {
$string = str_replace('-oth-', '', $string);
}
//The backslashes must be escaped twice, once for php, and again for the regexp
$string = str_replace("'|\\\\'", "&apos;", $string);
return $string;
Expand Down Expand Up @@ -252,7 +255,7 @@ function SPSSExportData($iSurveyID, $iLength, $na = '', $sEmptyAnswerValue = '',
break; // Break inside if : comment and other are string to be filtered
} // else do default action
default:
$strTmp = mb_substr(stripTagsFull($row[$fieldno]), 0, $iLength);
$strTmp = mb_substr(stripTagsFull($row[$fieldno], false), 0, $iLength);
if (trim($strTmp) != '') {
echo quoteSPSS($strTmp, $q, $field);
} elseif ($row[$fieldno] === '') {
Expand Down Expand Up @@ -314,7 +317,7 @@ function SPSSGetValues($field = array(), $qidattributes = null, $language)
foreach ($result as $row) {
$answers[] = array(
'code' => $row['code'],
'value' => mb_substr(stripTagsFull($row["answer"]), 0, $length_vallabel),
'value' => mb_substr(stripTagsFull($row["answer"], false), 0, $length_vallabel),
);
}
}
Expand Down Expand Up @@ -408,8 +411,18 @@ function SPSSGetValues($field = array(), $qidattributes = null, $language)
$spsstype = 'A';
}
}
// For questions types with answer options, if all answer codes are numeric but "Other" option is enabled,
// field should be exported as SPSS type 'A', size 6. See issue #16939
if (strpos("!LORFH1", $field['LStype']) !== false && $spsstype == 'F') {
$oQuestion = Question::model()->findByPk($field["qid"]);
if ($oQuestion->other == 'Y') {
$spsstype = 'A';
$size = 6;
}
}
$answers['SPSStype'] = $spsstype;
$answers['size'] = $size;
$answers['needsAlterType'] = true;
return $answers;
} else {
/* Not managed (currently): url, IP, … */
Expand Down Expand Up @@ -649,6 +662,10 @@ function SPSSFieldMap($iSurveyID, $prefix = 'V', $sLanguage = '')
$tempArray['SPSStype'] = $answers['SPSStype'];
unset($answers['SPSStype']);
}
if (isset($answers['needsAlterType'])) {
$tempArray['needsAlterType'] = $answers['needsAlterType'];
unset($answers['needsAlterType']);
}
if (!empty($answers)) {
$tempArray['answers'] = $answers;
}
Expand Down
9 changes: 7 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -3948,13 +3948,18 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid, $forc

$token = Token::model($surveyid)->findByToken($_SESSION[$this->sessid]['token']);
if ($token) {
$tokenEncryptionOptions = $survey->getTokenEncryptionOptions();
foreach ($token as $key => $val) {
$this->knownVars["TOKEN:" . strtoupper($key)] = array(
// Decrypt encrypted token attributes
if (isset($tokenEncryptionOptions['columns'][$key]) && $tokenEncryptionOptions['columns'][$key] === 'Y'){
$val = $token->decrypt($val);
}
$this->knownVars["TOKEN:" . strtoupper($key)] = [
'code' => $anonymized ? '' : $val,
'jsName_on' => '',
'jsName' => '',
'readWrite' => 'N',
);
];
}
}
} else {
Expand Down
36 changes: 22 additions & 14 deletions application/helpers/twig_translation_helper.php
@@ -1,31 +1,39 @@
<?php

/*
* LimeSurvey
* Copyright (C) 2007-2020 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
* LimeSurvey
* Copyright (C) 2007-2020 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/


/**
* Dummy helper intended to facilitate "twig only" strings to be picked by Translations Bot.
*
*
* Since twig files are not scanned by the bot, translatable strings that only appear in twig
* files can be placed here in order to be scanned.
*
* @return void
*/


function dummy_twig_translation_helper() {
function dummy_twig_translation_helper()
{
return;

gT("Your survey responses have not been recorded. This survey is not yet active."); // From themes/survey/vanilla/views/subviews/content/submit_preview.twig:23 (2020/11/16)
gT("Search (3 characters minimum)"); // From application/views/survey/questions/answer/shortfreetext/location_mapservice/item_100.twig:29 (2021/02/19)
gT("Restrict search place to map extent"); // From application/views/survey/questions/answer/shortfreetext/location_mapservice/item_100.twig:40 (2021/02/19)
gT("Latitude:"); // From application/views/survey/questions/answer/shortfreetext/location_mapservice/item_100.twig:66 (2021/02/19)
gT("Longitude:"); // From application/views/survey/questions/answer/shortfreetext/location_mapservice/item_100.twig:80 (2021/02/19)
gt("Some example answer option"); // From application/views/questionAdministration/answerOptionRow.twig
gT("Drag to sort"); // From application/views/questionAdministration/answerOptionRow.twig
gT("Insert a new answer option after this"); // From application/views/questionAdministration/answerOptionRow.twig
gT("Predefined label sets..."); // From application/views/questionAdministration/subquestions.twig
gT("Save as label set"); // From application/views/questionAdministration/answerOptions.twig
gT("Short Free Text"); // From application/views/survey/questions/answer/shortfreetext/config.xml
}
35 changes: 35 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -3721,6 +3721,41 @@ function ($v) {
$oTransaction->commit();
}

if ($iOldDBVersion < 441) {
$oTransaction = $oDB->beginTransaction();
// Convert old html editor modes if present in global settings
$oDB->createCommand()->update(
'{{settings_global}}',
array(
'stg_value' => 'inline',
),
"stg_name='defaulthtmleditormode' AND stg_value='wysiwyg'"
);
$oDB->createCommand()->update(
'{{settings_global}}',
array(
'stg_value' => 'none',
),
"stg_name='defaulthtmleditormode' AND stg_value='source'"
);
// Convert old html editor modes if present in profile settings
$oDB->createCommand()->update(
'{{users}}',
array(
'htmleditormode' => 'inline',
),
"htmleditormode='wysiwyg'"
);
$oDB->createCommand()->update(
'{{users}}',
array(
'htmleditormode' => 'none',
),
"htmleditormode='source'"
);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 441), "stg_name='DBVersion'");
$oTransaction->commit();
}
} catch (Exception $e) {
Yii::app()->setConfig('Updating', false);
$oTransaction->rollback();
Expand Down

0 comments on commit b3e4d3b

Please sign in to comment.