Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cint
Browse files Browse the repository at this point in the history
Conflicts:
	application/libraries/PluginManager/LimesurveyApi.php
  • Loading branch information
olleharstedt committed Aug 1, 2016
2 parents a892e87 + 2c08600 commit f08d076
Show file tree
Hide file tree
Showing 26 changed files with 3,658 additions and 3,816 deletions.
26 changes: 9 additions & 17 deletions application/controllers/admin/database.php
Expand Up @@ -659,8 +659,7 @@ function index($sa = null)
}
}
} else {
$qattributes = questionAttributes();
$validAttributes = $qattributes[Yii::app()->request->getPost('type')];
$validAttributes=\ls\helpers\questionHelper::getQuestionAttributesSettings(Yii::app()->request->getPost('type'));
$aLanguages=array_merge(array(Survey::model()->findByPk($iSurveyID)->language),Survey::model()->findByPk($iSurveyID)->additionalLanguages);

foreach ($validAttributes as $validAttribute)
Expand Down Expand Up @@ -773,25 +772,18 @@ function index($sa = null)


// Remove invalid question attributes on saving
$qattributes=questionAttributes();


$criteria = new CDbCriteria;
$criteria->compare('qid',$iQuestionID);
if (isset($qattributes[$sQuestionType])){
$validAttributes=$qattributes[$sQuestionType];
foreach ($validAttributes as $validAttribute)
{
$criteria->compare('attribute', '<>'.$validAttribute['name']);
}
$validAttributes=\ls\helpers\questionHelper::getQuestionAttributesSettings($sQuestionType);
foreach ($validAttributes as $validAttribute)
{
$criteria->compare('attribute', '<>'.$validAttribute['name']);
}
QuestionAttribute::model()->deleteAll($criteria);
$aLanguages=array_merge(array(Survey::model()->findByPk($iSurveyID)->language),Survey::model()->findByPk($iSurveyID)->additionalLanguages);


//now save all valid attributes
// eg: other_replace_text ; other_replace_text_en
$validAttributes=$qattributes[$sQuestionType];

foreach ($validAttributes as $validAttribute)
{
if ($validAttribute['i18n'])
Expand Down Expand Up @@ -1239,15 +1231,15 @@ function index($sa = null)
if( $oSurvey->googleanalyticsapikeysetting == "Y")
{
$oSurvey->googleanalyticsapikey = App()->request->getPost('googleanalyticsapikey');
}
}
else if( $oSurvey->googleanalyticsapikeysetting == "G")
{
$oSurvey->googleanalyticsapikey = "9999useGlobal9999";
}
}
else if( $oSurvey->googleanalyticsapikeysetting == "N")
{
$oSurvey->googleanalyticsapikey = "";
}
}

$oSurvey->googleanalyticsstyle = App()->request->getPost('googleanalyticsstyle');
$oSurvey->tokenlength = (App()->request->getPost('tokenlength')<5 || App()->request->getPost('tokenlength')>36)?15:App()->request->getPost('tokenlength');
Expand Down
16 changes: 10 additions & 6 deletions application/controllers/admin/questions.php
Expand Up @@ -915,7 +915,7 @@ public function getSubquestionRow( $surveyid, $gid, $qid, $codes, $language, $fi
{
// index.php/admin/questions/sa/getSubquestionRow/position/1/scale_id/1/surveyid/691948/gid/76/qid/1611/language/en/first/true
$stringCodes = json_decode($codes); // All the codes of the displayed subquestions

// TODO: calcul correct value
$oldCode = false;

Expand Down Expand Up @@ -1357,10 +1357,13 @@ public function index($sa, $surveyid, $gid, $qid=null)
$aData['selectormodeclass'] = $selectormodeclass;
}

if (!$adding)
$qattributes = questionAttributes();
else
$qattributes = array();
/**
* Since is moved via ajax call only : it's not needed, when we have time : readd it for no-js solution
*/
//~ if (!$adding)
//~ $qattributes = \ls\helpers\questionHelper::getQuestionAttributesSettings(($aqresult->type); //(or Question::getAdvancedSettingsWithValues )
//~ else
//~ $qattributes = array();

if ($adding)
{
Expand Down Expand Up @@ -1718,14 +1721,15 @@ public function ajaxReloadPositionWidget($gid, $classes='')
*/
public function ajaxquestionattributes()
{

$surveyid = (int) Yii::app()->request->getParam('sid',0);
$qid = (int) Yii::app()->request->getParam('qid',0);
$type = Yii::app()->request->getParam('question_type');
$thissurvey = getSurveyInfo($surveyid);
if(!$thissurvey) die();
$aLanguages = array_merge(array(Survey::model()->findByPk($surveyid)->language), Survey::model()->findByPk($surveyid)->additionalLanguages);

$aAttributesWithValues = Question::model()->getAdvancedSettingsWithValues($qid, $type, $surveyid);

uasort($aAttributesWithValues, 'categorySort');

$aAttributesPrepared = array();
Expand Down
29 changes: 0 additions & 29 deletions application/controllers/admin/tokens.php
Expand Up @@ -694,11 +694,6 @@ public function editToken($iSurveyId)
foreach ($aData as $k => $v)
$token->$k = $v;

$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$iSurveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);

echo $token->update();
}
// if add it will insert a new row
Expand Down Expand Up @@ -728,10 +723,6 @@ public function editToken($iSurveyId)
}
$token = Token::create($surveyId);
$token->setAttributes($aData, false);
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$surveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
echo $token->save();
}
elseif ($sOperation == 'del' && Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update'))
Expand Down Expand Up @@ -836,10 +827,6 @@ public function addnew($iSurveyId)
// AutoExecute
$token = Token::create($iSurveyId);
$token->setAttributes($aData, false);
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$iSurveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
$inresult = $token->save();
$aData['success'] = true;
}
Expand Down Expand Up @@ -948,10 +935,6 @@ public function edit($iSurveyId, $iTokenId, $ajax=false)
$token = Token::model($iSurveyId)->findByPk($iTokenId);
foreach ($aTokenData as $k => $v)
$token->$k = $v;
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$iSurveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
$token->save();

$aData['sidemenu']['state'] = false;
Expand Down Expand Up @@ -1132,10 +1115,6 @@ public function addDummies($iSurveyId, $subaction = '')
}

$existingtokens[$token->token] = true;
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$iSurveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
$token->save();
$newDummyToken++;
}
Expand Down Expand Up @@ -1702,10 +1681,6 @@ public function email($iSurveyId, $tokenids = null)
$token->remindersent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
$token->remindercount++;
}
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$token );
$beforeTokenSave->set('iSurveyID',$iSurveyId );
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
$token->save();

//Update central participant survey_links
Expand Down Expand Up @@ -2454,10 +2429,6 @@ public function import($iSurveyId)
}
else
{
$beforeTokenSave = new PluginEvent('beforeTokenSave');
$beforeTokenSave->set('model',$oToken );
$beforeTokenSave->set('iSurveyID',$iSurveyId);
App()->getPluginManager()->dispatchEvent($beforeTokenSave);
$iRecordImported++;
}
}
Expand Down
11 changes: 6 additions & 5 deletions application/helpers/admin/import_helper.php
Expand Up @@ -220,7 +220,7 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
{


$aAllAttributes=questionAttributes(true);
$aAllAttributes=\ls\helpers\questionHelper::getAttributesDefinitions();

foreach ($xml->question_attributes->rows->row as $row)
{
Expand Down Expand Up @@ -518,7 +518,7 @@ function XMLImportQuestion($sFullFilePath, $iNewSID, $newgid)
{


$aAllAttributes=questionAttributes(true);
$aAllAttributes=\ls\helpers\questionHelper::getAttributesDefinitions();
foreach ($xml->question_attributes->rows->row as $row)
{
$insertdata=array();
Expand Down Expand Up @@ -1266,7 +1266,7 @@ function XMLImportSurvey($sFullFilePath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
// Import questionattributes -------------------------------------------------
if(isset($xml->question_attributes))
{
$aAllAttributes=questionAttributes(true);
$aAllAttributes=\ls\helpers\questionHelper::getAttributesDefinitions();
foreach ($xml->question_attributes->rows->row as $row)
{
$insertdata=array();
Expand Down Expand Up @@ -2074,7 +2074,7 @@ function TSVImportSurvey($sFullFilePath)
$handle = fopen($sFullFilePath, 'r');
$bom = fread($handle, 2);
rewind($handle);
$aAttributeList = questionAttributes();
$aAttributeList = array(); //QuestionAttribute::getQuestionAttributesSettings();

// Excel tends to save CSV as UTF-16, which PHP does not properly detect
if($bom === chr(0xff).chr(0xfe) || $bom === chr(0xfe).chr(0xff)){
Expand Down Expand Up @@ -2358,7 +2358,8 @@ function TSVImportSurvey($sFullFilePath)
$insertdata = array();
$insertdata['qid'] = $qid;
// check if attribute is a i18n attribute. If yes, set language, else set language to null in attribute table
if (isset($aAttributeList[$qtype][$key]['i18n']) && $aAttributeList[$qtype][$key]['i18n']==1)
$aAttributeList[$qtype]=\ls\helpers\questionHelper::getQuestionAttributesSettings($qtype);
if ($aAttributeList[$qtype][$key]['i18n'])
{
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
}
Expand Down

0 comments on commit f08d076

Please sign in to comment.