Skip to content

Commit

Permalink
Fixed issue #09344: AND rules with ATTRIBUTE disappear when modify an…
Browse files Browse the repository at this point in the history
…d importing the survey

Dev : importing : bad order for getConditionsForEM : with $qid set : it work
Dev : modify : debug to 2 show Notice, surely broke before
Dev : reset the relevance equation when show condition (if needed)
Dev : TODO : use Yii on getConditionsForEM, but big request here
  • Loading branch information
Shnoulle committed Nov 25, 2014
1 parent bedcc30 commit 605b8f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
49 changes: 30 additions & 19 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -204,12 +204,15 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)

if (isset($p_subaction) && $p_subaction == "insertcondition")
{
if (( !isset($p_canswers) &&
!isset($_POST['ConditionConst']) &&
!isset($_POST['prevQuestionSGQA']) &&
!isset($_POST['tokenAttr']) &&
!isset($_POST['ConditionRegexp'])) ||
(!isset($p_cquestions) && !isset($p_csrctoken))
if (
(
!isset($p_canswers) &&
!isset($_POST['ConditionConst']) &&
!isset($_POST['prevQuestionSGQA']) &&
!isset($_POST['tokenAttr']) &&
!isset($_POST['ConditionRegexp'])
) ||
(!isset($p_cquestions) && !isset($p_csrctoken))
)
{
$conditionsoutput_action_error .= CHtml::script("\n<!--\n alert(\"".gT("Your condition could not be added! It did not include the question and/or answer upon which the condition was based. Please ensure you have selected a question and an answer.","js")."\")\n //-->\n");
Expand Down Expand Up @@ -413,7 +416,6 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
// COPY CONDITIONS IF THIS IS COPY
if ( isset($p_subaction) && $p_subaction == "copyconditions" )
{

$qid = returnGlobal('qid');
$copyconditionsfrom = returnGlobal('copyconditionsfrom');
$copyconditionsto = returnGlobal('copyconditionsto');
Expand Down Expand Up @@ -1147,13 +1149,14 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$aViewUrls['conditionshead_view'][] = $aData;

//BEGIN DISPLAY CONDITIONS FOR THIS QUESTION
if ( $subaction == 'index' ||
$subaction == 'editconditionsform' || $subaction == 'insertcondition' ||
$subaction == "editthiscondition" || $subaction == "delete" ||
$subaction == "updatecondition" || $subaction == "deletescenario" ||
$subaction == "renumberscenarios" || $subaction == "deleteallconditions" ||
$subaction == "updatescenario" ||
$subaction == 'copyconditionsform' || $subaction == 'copyconditions' || $subaction == 'conditions'
if (
$subaction == 'index' ||
$subaction == 'editconditionsform' || $subaction == 'insertcondition' ||
$subaction == "editthiscondition" || $subaction == "delete" ||
$subaction == "updatecondition" || $subaction == "deletescenario" ||
$subaction == "renumberscenarios" || $subaction == "deleteallconditions" ||
$subaction == "updatescenario" ||
$subaction == 'copyconditionsform' || $subaction == 'copyconditions' || $subaction == 'conditions'
)
{

Expand Down Expand Up @@ -1375,13 +1378,21 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
{
$leftOperandType = 'tokenattr';
$aTokenAttrNames=getTokenFieldsAndNames($iSurveyID);
if (count($aTokenAttrNames) != 0)
if(isset($aTokenAttrNames[strtolower($extractedTokenAttr[1])]))
{
$thisAttrName=HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description'])." [".gT("From token table")."]";
$thisAttrName=HTMLEscape($aTokenAttrNames[strtolower($extractedTokenAttr[1])]['description']);
}
else
{
$thisAttrName=HTMLEscape($extractedTokenAttr[1])." [".gT("Inexistant token table")."]";
$thisAttrName=HTMLEscape($extractedTokenAttr[1]);
}
if(tableExists("{{tokens_$iSurveyID}}"))
{
$thisAttrName.= " [".gT("From token table")."]";
}
else
{
$thisAttrName.= " [".gT("Inexistant token table")."]";
}
$aViewUrls['output'] .= "\t$thisAttrName\n";
// TIBO not sure this is used anymore !!
Expand Down Expand Up @@ -1565,10 +1576,10 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
}

}


$s++;
}
// If we have a condition, allways reset the condition, this can fix old import (see #09344)
LimeExpressionManager::UpgradeConditionsToRelevance(NULL,$qid);
}
else
{ // no condition ==> disable delete all conditions button, and display a simple comment
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -8065,11 +8065,11 @@ private static function getConditionsForEM($surveyid=NULL, $qid=NULL)
$databasetype = Yii::app()->db->getDriverName();
if ($databasetype=='mssql' || $databasetype=='dblib')
{
$query .= " order by sid, c.qid, scenario, cqid, cfieldname, value";
$query .= " order by c.qid, sid, scenario, cqid, cfieldname, value";
}
else
{
$query .= " order by sid, qid, scenario, cqid, cfieldname, value";
$query .= " order by qid, sid, scenario, cqid, cfieldname, value";
}

return Yii::app()->db->createCommand($query)->query();
Expand Down

0 comments on commit 605b8f5

Please sign in to comment.