Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/LimeSurvey/LimeSurvey in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
Shnoulle committed Dec 6, 2016
2 parents 0587c97 + 2de852b commit 830c8b1
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 124 deletions.
4 changes: 2 additions & 2 deletions application/config/version.php
Expand Up @@ -11,11 +11,11 @@
* See COPYRIGHT.php for copyright notices and details.
*/

$config['versionnumber'] = '3.0.0 alpha (2.57 merged)'; /* I don't found actually a better way to have : 'master verion + info it'a develop : ,someone have another idea ? */
$config['versionnumber'] = '3.0.0 alpha (2.57.1 merged)'; /* I don't found actually a better way to have : 'master verion + info it'a develop : ,someone have another idea ? */
$config['dbversionnumber'] = 261;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '44';
$config['assetsversionnumber'] = '45';
return $config;

?>
43 changes: 11 additions & 32 deletions application/controllers/admin/database.php
Expand Up @@ -556,8 +556,6 @@ private function actionUpdateQuestion($iSurveyID)


// Remove invalid question attributes on saving


$criteria = new CDbCriteria;
$criteria->compare('qid',$this->iQuestionID);
$validAttributes=\ls\helpers\questionHelper::getQuestionAttributesSettings($sQuestionType);
Expand All @@ -566,6 +564,7 @@ private function actionUpdateQuestion($iSurveyID)
$criteria->compare('attribute', '<>'.$validAttribute['name']);
}
QuestionAttribute::model()->deleteAll($criteria);

$aLanguages=array_merge(array(Survey::model()->findByPk($iSurveyID)->language),Survey::model()->findByPk($iSurveyID)->additionalLanguages);
foreach ($validAttributes as $validAttribute)
{
Expand All @@ -577,21 +576,17 @@ private function actionUpdateQuestion($iSurveyID)
$langCriteria->compare('attribute',$validAttribute['name']);
$langCriteria->addNotInCondition('language',$aLanguages);
QuestionAttribute::model()->deleteAll($langCriteria);
/* But not in don't work for null value in mysql ? */
/* delete IS NULL too*/
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language IS NULL',array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID));

foreach ($aLanguages as $sLanguage)
{// TODO sanitise XSS
$value=Yii::app()->request->getPost($validAttribute['name'].'_'.$sLanguage);
$iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute'=>$validAttribute['name'], 'qid'=>$this->iQuestionID, 'language'=>$sLanguage));
if (count($iInsertCount)>0)
{
if ($value!='')
{
$iInsertCount = QuestionAttribute::model()->countByAttributes(array('attribute'=>$validAttribute['name'], 'qid'=>$this->iQuestionID, 'language'=>$sLanguage));
if ($iInsertCount>0){
if ($value!=''){
QuestionAttribute::model()->updateAll(array('value'=>$value), 'attribute=:attribute AND qid=:qid AND language=:language', array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID, ':language'=>$sLanguage));
}
else
{
}else{
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid AND language=:language', array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID, ':language'=>$sLanguage));
}
}
Expand All @@ -608,27 +603,11 @@ private function actionUpdateQuestion($iSurveyID)
}
else
{
$value=Yii::app()->request->getPost($validAttribute['name']);

if ($validAttribute['name']=='multiflexible_step' && trim($value)!='') {
$value=floatval($value);
if ($value==0) $value=1;
};

$iInsertCount = QuestionAttribute::model()->findAllByAttributes(array('attribute'=>$validAttribute['name'], 'qid'=>$this->iQuestionID));
if (count($iInsertCount)>0)
{
if($value!=$validAttribute['default'] && trim($value)!="")
{
QuestionAttribute::model()->updateAll(array('value'=>$value),'attribute=:attribute AND qid=:qid', array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID));
}
else
{
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid', array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID));
}
}
elseif($value!=$validAttribute['default'] && trim($value)!="")
{
$value=Yii::app()->request->getPost($validAttribute['name'],'');
/* we must have only one element, and this element must be null, then reset always (see #11980)*/
/* We can update, but : this happen only for admin and not a lot, then : delete + add */
QuestionAttribute::model()->deleteAll('attribute=:attribute AND qid=:qid', array(':attribute'=>$validAttribute['name'], ':qid'=>$this->iQuestionID));
if($value!=$validAttribute['default'] && trim($value)!==""){
$attribute = new QuestionAttribute;
$attribute->qid = $this->iQuestionID;
$attribute->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion application/core/LSYii_Application.php
Expand Up @@ -84,7 +84,7 @@ public function __construct($aApplicationConfig = null)
{
$this->setConfig($key, $value);
}
App()->getAssetManager()->linkAssets = true;
/* Don't touch to linkAssets : you can set it in config.php */
// Asset manager path can only be set after App was constructed because it relies on App()
App()->getAssetManager()->setBaseUrl($settings['tempurl']. '/assets');
App()->getAssetManager()->setBasePath($settings['tempdir'] . '/assets');
Expand Down
7 changes: 2 additions & 5 deletions application/models/Question.php
Expand Up @@ -220,11 +220,7 @@ public function getAdvancedSettingsWithValues($iQuestionID, $sQuestionType, $iSu
{
$aLanguages = array($sLanguage);
}

if ($iQuestionID)
{
$aAttributeValues=QuestionAttribute::model()->getQuestionAttributes($iQuestionID);
}
$aAttributeValues=QuestionAttribute::model()->getQuestionAttributes($iQuestionID,$sLanguage);
$aAttributeNames = \ls\helpers\questionHelper::getQuestionAttributesSettings($sQuestionType);
uasort($aAttributeNames, 'categorySort');
foreach ($aAttributeNames as $iKey => $aAttribute)
Expand Down Expand Up @@ -255,6 +251,7 @@ public function getAdvancedSettingsWithValues($iQuestionID, $sQuestionType, $iSu
}
}
}

return $aAttributeNames;
}

Expand Down
47 changes: 30 additions & 17 deletions application/models/QuestionAttribute.php
Expand Up @@ -165,10 +165,12 @@ public function setMultiple($iSid, $aQidsAndLang, $aAttributesToUpdate, $aValidQ
*
* @access public
* @param int $iQuestionID
* @param string $sLanguage restrict to this language (@todo : add it in qanda)
* @return array
*/
public function getQuestionAttributes($iQuestionID)
public function getQuestionAttributes($iQuestionID,$sLanguage=null)
{

$iQuestionID=(int)$iQuestionID;
static $aQuestionAttributesStatic=array();// TODO : replace by Yii::app()->cache
// Limit the size of the attribute cache due to memory usage
Expand All @@ -181,8 +183,11 @@ public function getQuestionAttributes($iQuestionID)
$oQuestion = Question::model()->find("qid=:qid",array('qid'=>$iQuestionID)); // Maybe take parent_qid attribute before this qid attribute
if ($oQuestion)
{
$aLanguages = array_merge(array(Survey::model()->findByPk($oQuestion->sid)->language), Survey::model()->findByPk($oQuestion->sid)->additionalLanguages);

if($sLanguage){
$aLanguages = array($sLanguage);
}else{
$aLanguages = array_merge(array(Survey::model()->findByPk($oQuestion->sid)->language), Survey::model()->findByPk($oQuestion->sid)->additionalLanguages);
}
// Get all atribute set for this question
$sType=$oQuestion->type;

Expand All @@ -194,33 +199,41 @@ public function getQuestionAttributes($iQuestionID)

$aAttributeNames = \ls\helpers\questionHelper::getQuestionAttributesSettings($sType);

/* Get whole existing attribute for this question in an array*/
$oAttributeValues = QuestionAttribute::model()->findAll("qid=:qid",array('qid'=>$iQuestionID));
$aAttributeValues=array();
foreach($oAttributeValues as $oAttributeValue)
{
if($oAttributeValue->language){
$aAttributeValues[$oAttributeValue->attribute][$oAttributeValue->language]=$oAttributeValue->value;
}else{
/* Don't replace existing language, use '' for null key (and for empty string) */
$aAttributeValues[$oAttributeValue->attribute]['']=$oAttributeValue->value;
}
}
// Fill with aQuestionAttributes with default attribute or with aAttributeValues
// Can not use array_replace due to i18n
foreach($aAttributeNames as $aAttribute)
{
$oAttributeNameValues = QuestionAttribute::model()->findAll("qid=:qid and attribute=:attribute",array(':qid'=>$iQuestionID,':attribute'=>$aAttribute['name']));
/* listData do an array with key language : get really all value : null key is set to empty string */
/* this allow to set an attribute to i18n without loose old value */
$aAttributeNameValues=CHtml::listData($oAttributeNameValues,'language','value');

if ($aAttribute['i18n'] == false)
{
if(isset($aAttributeNameValues['']))
{
$aQuestionAttributes[$aAttribute['name']]=$aAttributeNameValues[''];
}
else
{
if(isset($aAttributeValues[$aAttribute['name']][''])){
$aQuestionAttributes[$aAttribute['name']]=$aAttributeValues[$aAttribute['name']][''];
}elseif(isset($aAttributeValues[$aAttribute['name']])){ /* Some survey have language is set for attribute without language (see #11980). This must fix for public survey and not only for admin. */
$aQuestionAttributes[$aAttribute['name']]=reset($aAttributeValues[$aAttribute['name']]);
}else{
$aQuestionAttributes[$aAttribute['name']]=$aAttribute['default'];
}
}
else
{
foreach ($aLanguages as $sLanguage)
{
if (isset($aAttributeNameValues[$sLanguage])){
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttributeNameValues[$sLanguage];
}elseif(isset($aAttributeNameValues[''])){
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttributeNameValues[''];
if (isset($aAttributeValues[$aAttribute['name']][$sLanguage])){
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttributeValues[$aAttribute['name']][$sLanguage];
}elseif(isset($aAttributeValues[$aAttribute['name']][''])){
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttributeValues[$aAttribute['name']][''];
}else{
$aQuestionAttributes[$aAttribute['name']][$sLanguage] = $aAttribute['default'];
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/Session.php
Expand Up @@ -69,7 +69,7 @@ public function afterFind()
private function hexToStr($hex){
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
$string .= chr( hexdec( $hex[$i].$hex[$i+1] ) );
}
return $string;
}
Expand Down
11 changes: 10 additions & 1 deletion docs/release_notes.txt
Expand Up @@ -35,7 +35,16 @@ Thank you to everyone who helped with this new release!
CHANGE LOG
------------------------------------------------------

Changes from 2.56.1 (build 161117) to 2.57 (build 161202) Dec 2 2016
Changes from 2.57.0 (build 161202) to 2.57.1 (build 161205) Dec 5 2016
-Fixed issue #11947: Session.php is a false positive under ASL/clamav (Bert Hankes)
-Fixed issue #11974: Very slow rendering of first page (Denis Chenu)
-Fixed issue #11976: Relevance based on array-dual-scale not working properly (Denis Chenu)
#Updated translation: Kyrgyz by kmaksat
#Updated translation: Norwegian (Bokmål) by pmonstad
#Updated translation: Norwegian (Nynorsk) by pmonstad
#Updated translation: Spanish (Spain) by c_schmitz, aesteban

Changes from 2.56.1 (build 161117) to 2.57.0 (build 161202) Dec 2 2016
-New feature: Single table PDF export in statistics
-Fixed issue #11609: Participant panel lists participants in duplicate, and does't list others for non-superadmins (Olle Haerstedt)
-Fixed issue #11851: Unstyled HTML when editing default answer options for yes-no question (Olle Haerstedt)
Expand Down

0 comments on commit 830c8b1

Please sign in to comment.