Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	application/config/version.php
	application/controllers/admin/questions.php
	application/core/LsDefaultDataSets.php
	application/extensions/SettingsWidget/SettingsWidget.php
	application/helpers/admin/import_helper.php
	application/helpers/common_helper.php
	application/helpers/expressions/em_manager_helper.php
	application/views/admin/survey/Question/editQuestion_view.php
  • Loading branch information
olleharstedt committed Aug 1, 2018
2 parents d86f838 + 87654a2 commit 3db4a91
Show file tree
Hide file tree
Showing 236 changed files with 3,862 additions and 5,439 deletions.
7 changes: 7 additions & 0 deletions .htaccess
Expand Up @@ -7,6 +7,13 @@

# otherwise forward it to index.php
RewriteRule . index.php

# deny access to hidden files and directories
RewriteRule ^(.*/)?\.+ - [F]
</IfModule>

# deny access to hidden files and directories without mod_rewrite
RedirectMatch 403 ^(.*/)?\.+

# General setting to properly handle LimeSurvey paths
# AcceptPathInfo on
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -53,7 +53,7 @@ before_script:
- sudo service apache2 restart

# Check for syntax errors.
#- find application/ -type f -name "*.php" -exec php -l {} \; | grep -v 'No syntax errors' || true
- find application/ -type f -name "*.php" -exec php -l {} \; | grep -v 'No syntax errors' || true

# Test server.
- wget localhost
Expand Down
2 changes: 1 addition & 1 deletion application/config/packages.php
Expand Up @@ -205,7 +205,7 @@
'css/displayParticipants.css',
),
'js' => array(
'build/adminbasics.js',
'build/adminbasics'.(($debug > 0) ? '' : '.min').'.js',
),
'depends' => array(
'jquery',
Expand Down
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -16,5 +16,5 @@
$config['dbversionnumber'] = 403;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '30050';
$config['assetsversionnumber'] = '30051';
return $config;
3 changes: 0 additions & 3 deletions application/controllers/admin/database.php
Expand Up @@ -1110,9 +1110,6 @@ protected function actionUpdateSurveyLocaleSettingsGeneralSettings($iSurveyID)
$oSurvey->sid
);

if (is_a($currentConfiguration, "TemplateConfiguration")) {
TemplateConfiguration::model()->deleteByPk($currentConfiguration->id);
}
}
$oSurvey->template = $new_template;

Expand Down
11 changes: 1 addition & 10 deletions application/controllers/admin/export.php
Expand Up @@ -1300,16 +1300,7 @@ private function _exporttsv($surveyid)
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public"); // HTTP/1.0

$data = & LimeExpressionManager::TSVSurveyExport($surveyid);

$lines = array();
foreach ($data as $row) {
$lines[] = implode("\t", str_replace(array("\t", "\n", "\r"), array(" ", " ", " "), $row));
}
$output = implode("\n", $lines);
// echo "\xEF\xBB\xBF"; // UTF-8 BOM
echo $output;
return;
tsvSurveyExport($surveyid);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions application/controllers/admin/questions.php
Expand Up @@ -1358,18 +1358,18 @@ public function delete($surveyid, $qid, $ajax = false, $gid = 0)
$oQuestion->delete();
$sMessage = gT("Question was successfully deleted.");
}

$redirectUrl = array('admin/survey/sa/listquestions/', 'surveyid' => $surveyid, 'gid' => $gid_search);
if (!$ajax) {
Yii::app()->session['flashmessage'] = $sMessage;
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/'.$surveyid.'?gid='.$gid_search));
$this->getController()->redirect($redirectUrl);
} else {
return array('status'=>true, 'message'=>$sMessage);
}
} else {
$sMessage = gT("You are not authorized to delete questions.");
if (!$ajax) {
Yii::app()->session['flashmessage'] = $sMessage;
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/'.$surveyid.'?gid='.$gid_search));
$this->getController()->redirect($redirectUrl);
} else {
return array('status'=>false, 'message'=>$sMessage);
}
Expand Down
135 changes: 109 additions & 26 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -278,18 +278,55 @@ public function importsurveyresources()
}

/**
* @todo
* Change survey theme for multiple survey at once.
* Called from survey list massive actions
*/
public function changetemplate($iSurveyID, $template)
public function changeMultipleTheme()
{
if (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveyactivation', 'update')) {
die('No permission');
$sSurveys = $_POST['sItems'];
$aSIDs = json_decode($sSurveys);
$aResults = array();

$sTemplate = App()->request->getPost('theme');

foreach ($aSIDs as $iSurveyID){
$aResults = self::changetemplate($iSurveyID, $sTemplate, $aResults, true);
}

Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults,'successLabel'=>$sTemplate));
}

/**
* Update the theme of a survey
*
* @access public
* @param int $iSurveyID
* @param string $template the survey theme name
* @param array $aResults if the method is called from changeMultipleTheme(), it will update its array of results
* @param boolean $bReturn should the method update and return aResults
* @return mixed null or array
*/
public function changetemplate($iSurveyID, $template, $aResults = null, $bReturn = false)
{

$iSurveyID = sanitize_int($iSurveyID);
$sTemplate = sanitize_dirname($template);

$survey = Survey::model()->findByPk($iSurveyID);


if (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveyactivation', 'update')) {

if (!empty($bReturn)){
$aResults[$iSurveyID]['title'] = $survey->correct_relation_defaultlanguage->surveyls_title;
$aResults[$iSurveyID]['result'] = false;
return $aResults;
}else{
die('No permission');
}
}


$survey->template = $sTemplate;
$survey->save();

Expand All @@ -299,6 +336,12 @@ public function changetemplate($iSurveyID, $template)

// This will force the generation of the entry for survey group
TemplateConfiguration::checkAndcreateSurveyConfig($iSurveyID);

if (!empty($bReturn)){
$aResults[$iSurveyID]['title'] = $survey->correct_relation_defaultlanguage->surveyls_title;
$aResults[$iSurveyID]['result'] = true;
return $aResults;
}
}

/**
Expand Down Expand Up @@ -897,7 +940,7 @@ public function editSurvey_json()
* @uses self::_tabTokens()
* @uses self::_tabPanelIntegration()
* @uses self::_tabResourceManagement()
*
*
* @param int $iSurveyID
* @param string $subaction
* @return void
Expand Down Expand Up @@ -932,10 +975,10 @@ public function rendersidemenulink($iSurveyID, $subaction)
$this->_registerScriptFiles();

// override survey settings if global settings exist
$templateData['showqnumcode'] = getGlobalSetting('showqnumcode') !=='choose'?getGlobalSetting('showqnumcode'):$survey->showqnumcode;
$templateData['shownoanswer'] = getGlobalSetting('shownoanswer') !=='choose'?getGlobalSetting('shownoanswer'):$survey->shownoanswer;
$templateData['showgroupinfo'] = getGlobalSetting('showgroupinfo') !=='2'?getGlobalSetting('showgroupinfo'):$survey->showgroupinfo;
$templateData['showxquestions'] = getGlobalSetting('showxquestions') !=='choose'?getGlobalSetting('showxquestions'):$survey->showxquestions;
$templateData['showqnumcode'] = getGlobalSetting('showqnumcode') !=='choose'?getGlobalSetting('showqnumcode'):$survey->showqnumcode;
$templateData['shownoanswer'] = getGlobalSetting('shownoanswer') !=='choose'?getGlobalSetting('shownoanswer'):$survey->shownoanswer;
$templateData['showgroupinfo'] = getGlobalSetting('showgroupinfo') !=='2'?getGlobalSetting('showgroupinfo'):$survey->showgroupinfo;
$templateData['showxquestions'] = getGlobalSetting('showxquestions') !=='choose'?getGlobalSetting('showxquestions'):$survey->showxquestions;

//Start collecting aData
$aData['surveyid'] = $iSurveyID;
Expand Down Expand Up @@ -1368,6 +1411,46 @@ private function _getGeneralTemplateData($iSurveyID)
return $aData;
}

/**
* @param Survey $survey
* @return array
* tab_edit_view_datasecurity
* editDataSecurityLocalSettings_view
*/
private function _getDataSecurityEditData($survey)
{
Yii::app()->loadHelper("admin/htmleditor");
$aData = $aTabTitles = $aTabContents = array();

$aData['scripts'] = PrepareEditorScript(false, $this->getController());
$aLanguageData = [];

foreach ($survey->allLanguages as $i => $sLang) {
$aLanguageData = $this->_getGeneralTemplateData($survey->sid);
// this one is created to get the right default texts fo each language
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('surveytranslator');

$aSurveyLanguageSettings = SurveyLanguageSetting::model()->findByPk(array('surveyls_survey_id' => $survey->sid, 'surveyls_language' => $sLang))->getAttributes();

$aTabTitles[$sLang] = getLanguageNameFromCode($aSurveyLanguageSettings['surveyls_language'], false);

if ($aSurveyLanguageSettings['surveyls_language'] == $survey->language) {
$aTabTitles[$sLang] .= ' ('.gT("Base language").')';
}

$aLanguageData['aSurveyLanguageSettings'] = $aSurveyLanguageSettings;
$aLanguageData['action'] = "surveygeneralsettings";
$aLanguageData['i'] = $i;
$aLanguageData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat']);
$aLanguageData['oSurvey'] = $survey;
$aTabContents[$sLang] = $this->getController()->renderPartial('/admin/survey/editDataSecurityLocalSettings_view', $aLanguageData, true);
}

$aData['aTabContents'] = $aTabContents;
$aData['aTabTitles'] = $aTabTitles;
return $aData;
}
/**
* @param Survey $survey
* @return array
Expand Down Expand Up @@ -1438,25 +1521,25 @@ private function _generalTabEditSurvey($survey)
return $aData;
}

/**
*
* survey::_pluginTabSurvey()
* Load "Simple Plugin" page in specific survey.
* @param Survey $survey
* @return mixed
*
/**
*
* survey::_pluginTabSurvey()
* Load "Simple Plugin" page in specific survey.
* @param Survey $survey
* @return mixed
*
* This method is called via call_user_func in self::rendersidemenulink()
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
private function _pluginTabSurvey($survey)
{
$aData = array();
$beforeSurveySettings = new PluginEvent('beforeSurveySettings');
$beforeSurveySettings->set('survey', $survey->sid);
App()->getPluginManager()->dispatchEvent($beforeSurveySettings);
$aData['pluginSettings'] = $beforeSurveySettings->get('surveysettings');
return $aData;
}
*/
private function _pluginTabSurvey($survey)
{
$aData = array();
$beforeSurveySettings = new PluginEvent('beforeSurveySettings');
$beforeSurveySettings->set('survey', $survey->sid);
App()->getPluginManager()->dispatchEvent($beforeSurveySettings);
$aData['pluginSettings'] = $beforeSurveySettings->get('surveysettings');
return $aData;
}
/**
* survey::_tabPresentationNavigation()
* Load "Presentation & navigation" tab.
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/tokens.php
Expand Up @@ -2182,8 +2182,8 @@ public function tokenify($iSurveyId)
$this->_renderWrappedTemplate('token', array('message' => array(
'title' => gT("Create tokens"),
'message' => gT("Clicking 'Yes' will generate tokens for all those in this token list that have not been issued one. Continue?")."<br /><br />\n"
. "<input class='btn btn-default btn-lg' type='submit' value='"
. gT("Yes")."' onclick=\"".convertGETtoPOST($this->getController()->createUrl("admin/tokens/sa/tokenify/surveyid/$iSurveyId", array('ok'=>'Y')))."\" />\n"
. "<button class='btn btn-default btn-lg' type='submit' value='"
. gT("Yes")."' onclick='".convertGETtoPOST($this->getController()->createUrl("admin/tokens/sa/tokenify/surveyid/$iSurveyId", array('ok'=>'Y')))."' >".gT("Yes")."</button>\n"
. "<input class='btn btn-default btn-lg' type='submit' value='"
. gT("No")."' onclick=\"window.open('".$this->getController()->createUrl("admin/tokens/sa/index/surveyid/$iSurveyId")."', '_top')\" />\n"
. "<br />\n"
Expand Down

0 comments on commit 3db4a91

Please sign in to comment.