Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:LimeSurvey/LimeSurvey.git int…
Browse files Browse the repository at this point in the history
…o develop

Dev: leave bug for another commit
# Conflicts:
#	application/config/version.php
#	application/controllers/admin/database.php
  • Loading branch information
Shnoulle committed Dec 6, 2016
2 parents fbf2ff1 + 54a2cce commit e407444
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 92 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;

?>
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 e407444

Please sign in to comment.