diff --git a/application/controllers/admin/conditions.php b/application/controllers/admin/conditions.php index e34e4d28c84..6c9fa9f8407 100644 --- a/application/controllers/admin/conditions.php +++ b/application/controllers/admin/conditions.php @@ -9,9 +9,9 @@ * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. - * + * * $Id$ - * + * */ /** @@ -23,7 +23,7 @@ * @subpackage Backend */ class conditions extends SurveyCommonController { - + /** * Constructor */ @@ -31,23 +31,23 @@ function __construct() { parent::__construct(); } - + public function _remap($method, $params = array()) { array_unshift($params, $method); return call_user_func_array(array($this, "action"), $params); } - + function action($subaction, $surveyid=null, $gid=null, $qid=null) { - + //Compatibility variables for CI $_POST = $this->input->post(); $clang = $this->limesurvey_lang; $dbprefix = $this->db->dbprefix; $imageurl=$this->config->item("imageurl"); $this->load->helper("database"); - + if($this->input->post("subaction")) $subaction=$this->input->post("subaction"); //BEGIN Sanitizing POSTed data @@ -55,7 +55,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) if (!isset($qid)) {$qid=returnglobal('qid');} if (!isset($gid)) {$gid=returnglobal('gid');} if (!isset($p_scenario)) {$p_scenario=returnglobal('scenario');} - if (!isset($p_cqid)) + if (!isset($p_cqid)) { $p_cqid=returnglobal('cqid'); if ($p_cqid == '') $p_cqid=0; // we are not using another question as source of condition @@ -65,10 +65,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) if (!isset($p_cquestions)) {$p_cquestions=returnglobal('cquestions');} if (!isset($p_csrctoken)) {$p_csrctoken=returnglobal('csrctoken');} if (!isset($p_prevquestionsgqa)) {$p_prevquestionsgqa=returnglobal('prevQuestionSGQA');} - + if (!isset($p_canswers)) { - + if (isset($_POST['canswers']) && is_array($_POST['canswers'])) { foreach ($_POST['canswers'] as $key => $val) @@ -77,12 +77,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + // this array will be used soon, // to explain wich conditions is used to evaluate the question if (isset($stringcomparizonoperators) && $stringcomparizonoperators == 1) { - $method = array( + $method = array( "<" => $clang->gT("Less than"), "<=" => $clang->gT("Less than or equal to"), "==" => $clang->gT("equals"), @@ -98,7 +98,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } else { - $method = array( + $method = array( "<" => $clang->gT("Less than"), "<=" => $clang->gT("Less than or equal to"), "==" => $clang->gT("equals"), @@ -108,7 +108,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) "RX" => $clang->gT("Regular expression") ); } - + if (isset($_POST['method'])) { if (!in_array($_POST['method'], array_keys($method))) @@ -120,20 +120,20 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $p_method = trim ($_POST['method']); } } - - + + if (isset($_POST['newscenarionum'])) { $p_newscenarionum = sanitize_int($_POST['newscenarionum']); } //END Sanitizing POSTed data - + //include_once("login_check.php"); //include_once("database.php"); // Caution (lemeur): database.php uses auto_unescape on all entries in $_POST // Take care to not use auto_unescape on $_POST variables after this - - + + //MAKE SURE THAT THERE IS A SID if (!isset($surveyid) || !$surveyid) { @@ -142,7 +142,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) show_error($conditionsoutput); return; } - + //MAKE SURE THAT THERE IS A QID if (!isset($qid) || !$qid) { @@ -151,28 +151,28 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) show_error($conditionsoutput); return; } - - + + // If we made it this far, then lets develop the menu items // add the conditions container table - + $extraGetParams =""; if (isset($qid) && isset($gid)) { $extraGetParams="/$gid/$qid/"; } - + $conditionsoutput_action_error = ""; // defined during the actions $conditionsoutput_main_content = ""; // everything after the menubar - + $markcidarray=Array(); if (isset($_GET['markcid'])) { $markcidarray=explode("-",$_GET['markcid']); } - - + + //BEGIN PROCESS ACTIONS // ADD NEW ENTRY IF THIS IS AN ADD if (isset($p_subaction) && $p_subaction == "insertcondition") @@ -196,7 +196,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $conditionCfieldname=$p_csrctoken; } - + if (isset($p_canswers)) { foreach ($p_canswers as $ca) @@ -211,7 +211,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND value='".$ca."'"; $result = db_execute_assoc($query) or safe_die("Couldn't check for existing condition
$query
".$connect->ErrorMsg()); $count_caseinsensitivedupes = $result->num_rows(); - + if ($count_caseinsensitivedupes == 0) { $query = "INSERT INTO {$dbprefix}conditions (qid, scenario, cqid, cfieldname, method, value) VALUES " @@ -220,7 +220,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + unset($posted_condition_value); // Please note that auto_unescape is already applied in database.php included above // so we only need to db_quote _POST variables @@ -240,7 +240,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $posted_condition_value = db_quote($_POST['ConditionRegexp']); } - + if (isset($posted_condition_value)) { $query = "INSERT INTO {$dbprefix}conditions (qid, scenario, cqid, cfieldname, method, value) VALUES " @@ -249,7 +249,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + // UPDATE ENTRY IF THIS IS AN EDIT if (isset($p_subaction) && $p_subaction == "updatecondition") { @@ -272,7 +272,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $conditionCfieldname=$p_csrctoken; } - + if (isset($p_canswers)) { foreach ($p_canswers as $ca) @@ -282,7 +282,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $result = db_execute_assoc($query) or safe_die ("Couldn't update condition
$query
".$connect->ErrorMsg()); } } - + unset($posted_condition_value); // Please note that auto_unescape is already applied in database.php included above // so we only need to db_quote _POST variables @@ -302,7 +302,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $posted_condition_value = db_quote($_POST['ConditionRegexp']); } - + if (isset($posted_condition_value)) { $query = "UPDATE {$dbprefix}conditions SET qid='{$qid}', scenario='{$p_scenario}' , cqid='{$p_cqid}', cfieldname='{$conditionCfieldname}', method='{$p_method}', value='".$posted_condition_value."' " @@ -311,35 +311,35 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + // DELETE ENTRY IF THIS IS DELETE if (isset($p_subaction) && $p_subaction == "delete") { $query = "DELETE FROM {$dbprefix}conditions WHERE cid={$p_cid}"; $result = db_execute_assoc($query) or safe_die ("Couldn't delete condition
$query
".$connect->ErrorMsg()); } - + // DELETE ALL CONDITIONS IN THIS SCENARIO if (isset($p_subaction) && $p_subaction == "deletescenario") { $query = "DELETE FROM {$dbprefix}conditions WHERE qid={$qid} AND scenario={$p_scenario}"; $result = db_execute_assoc($query) or safe_die ("Couldn't delete scenario
$query
".$connect->ErrorMsg()); } - + // UPDATE SCENARIO if (isset($p_subaction) && $p_subaction == "updatescenario" && isset($p_newscenarionum)) { $query = "UPDATE {$dbprefix}conditions SET scenario=$p_newscenarionum WHERE qid={$qid} AND scenario={$p_scenario}"; $result = db_execute_assoc($query) or safe_die ("Couldn't delete scenario
$query
".$connect->ErrorMsg()); } - + // DELETE ALL CONDITIONS FOR THIS QUESTION if (isset($p_subaction) && $p_subaction == "deleteallconditions") { $query = "DELETE FROM {$dbprefix}conditions WHERE qid={$qid}"; $result = db_execute_assoc($query) or safe_die ("Couldn't delete scenario
$query
".$connect->ErrorMsg()); } - + // RENUMBER SCENARIOS if (isset($p_subaction) && $p_subaction == "renumberscenarios") { @@ -352,9 +352,9 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $result2 = db_execute_assoc($query2) or safe_die ("Couldn't renumber scenario
$query
".$connect->ErrorMsg()); $newindex++; } - + } - + // COPY CONDITIONS IF THIS IS COPY if (isset($p_subaction) && $p_subaction == "copyconditions") { @@ -392,7 +392,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND value='".$pfc['value']."'"; $result = db_execute_assoc($query) or safe_die("Couldn't check for existing condition
$query
".$connect->ErrorMsg()); $count_caseinsensitivedupes = $result->num_rows(); - + $countduplicates = 0; if ($count_caseinsensitivedupes != 0) { @@ -401,7 +401,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) if ($ccrow['value'] == $pfc['value']) $countduplicates++; } } - + if ($countduplicates == 0) //If there is no match, add the condition. { $query = "INSERT INTO {$dbprefix}conditions ( qid,scenario,cqid,cfieldname,method,value) \n" @@ -433,23 +433,23 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $CopyConditionsMessage = "
(".$clang->gT("No conditions could be copied (due to duplicates)").")
"; } } - + } //END PROCESS ACTIONS - - - + + + $cquestions=Array(); $canswers=Array(); - - - + + + //BEGIN: GATHER INFORMATION // 1: Get information for this question if (!isset($qid)) {$qid=returnglobal('qid');} if (!isset($surveyid)) {$surveyid=returnglobal('sid');} $thissurvey=getSurveyInfo($surveyid); - + $query = "SELECT * " ."FROM {$dbprefix}questions, " ."{$dbprefix}groups " @@ -465,9 +465,9 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $questiontext=$rows['question']; $questiontype=$rows['type']; } - + // 2: Get all other questions that occur before this question that are pre-determined answer types - + // To avoid natural sort order issues, // first get all questions in natural sort order // , and find out which number in that order this question is @@ -479,12 +479,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND {$dbprefix}questions.sid=$surveyid " ."AND {$dbprefix}questions.language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."AND {$dbprefix}groups.language='".GetBaseLanguageFromSurveyID($surveyid)."' " ; - + $qresult = db_execute_assoc($qquery) or safe_die ("$qquery
".$connect->ErrorMsg()); $qrows = $qresult->result_array(); // Perform a case insensitive natural sort on group name then question title (known as "code" in the form) of a multidimensional array usort($qrows, 'GroupOrderThenQuestionOrder'); - + $position="before"; // Go through each question until we reach the current one foreach ($qrows as $qrow) @@ -500,7 +500,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) break; } } - + // Now, using the same array which is now properly sorted by group then question // Create an array of all the questions that appear AFTER the current one $position = "before"; @@ -516,10 +516,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $postquestionlist[]=$qrow['qid']; } } - + $theserows=array(); $postrows=array(); - + if (isset($questionlist) && is_array($questionlist)) { foreach ($questionlist as $ql) @@ -539,11 +539,11 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND {$dbprefix}questions.qid=$ql " ."AND {$dbprefix}questions.language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."AND {$dbprefix}groups.language='".GetBaseLanguageFromSurveyID($surveyid)."'" ; - + $result=db_execute_assoc($query) or die("Couldn't get question $qid"); - + $thiscount=$result->num_rows(); - + // And store again these questions in this array... foreach ($result->result_array() as $myrows) { //key => value @@ -558,7 +558,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + if (isset($postquestionlist) && is_array($postquestionlist)) { foreach ($postquestionlist as $pq) @@ -578,12 +578,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."q.qid=$pq AND " ."q.language='".GetBaseLanguageFromSurveyID($surveyid)."' AND " ."g.language='".GetBaseLanguageFromSurveyID($surveyid)."'"; - - + + $result = db_execute_assoc($query) or safe_die("Couldn't get postquestions $qid
$query
".$connect->ErrorMsg()); - + $postcount=$result->num_rows(); - + foreach ($result->result_array() as $myrows) { $postrows[]=array("qid"=>$myrows['qid'], @@ -598,9 +598,9 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } $postquestionscount=count($postrows); } - + $questionscount=count($theserows); - + if (isset($postquestionscount) && $postquestionscount > 0) { //Build the array used for the questionNav and copyTo select boxes foreach ($postrows as $pr) @@ -609,16 +609,16 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) "fieldname"=>$pr['sid']."X".$pr['gid']."X".$pr['qid']); } } - + // Previous question parsing ==> building cquestions[] and canswers[] if ($questionscount > 0) { $X="X"; - + foreach($theserows as $rows) { $shortquestion=$rows['title'].": ".strip_tags($rows['question']); - + if ($rows['type'] == "A" || $rows['type'] == "B" || $rows['type'] == "C" || @@ -631,15 +631,15 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."WHERE parent_qid={$rows['qid']} " ."AND language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."ORDER BY question_order"; - + $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to Array questions
$aquery
".$connect->ErrorMsg()); - + foreach ($aresult->result_array() as $arows) { $shortanswer = "{$arows['title']}: [" . FlattenText($arows['question']) . "]"; $shortquestion=$rows['title'].":$shortanswer ".FlattenText($rows['question']); $cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']); - + switch ($rows['type']) { case "A": //Array 5 buttons @@ -684,12 +684,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title'], "", $clang->gT("No answer")); } - + } //while } elseif ($rows['type'] == ":" || $rows['type'] == ";") { // Multiflexi - + //Get question attribute for $canswers $qidattributes=getQuestionAttributes($rows['qid'], $rows['type']); if (isset($qidattributes['multiflexible_max']) && trim($qidattributes['multiflexible_max'])!='') { @@ -707,14 +707,14 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } else { $stepvalue=1; } - + if (isset($qidattributes['multiflexible_checkbox']) && $qidattributes['multiflexible_checkbox']!=0) { $minvalue=0; $maxvalue=1; $stepvalue=1; } // Get the Y-Axis - + $fquery = "SELECT sq.*, q.other" ." FROM ".$this->db->dbprefix('questions')." sq, ".$this->db->dbprefix('questions')." q" ." WHERE sq.sid=$surveyid AND sq.parent_qid=q.qid " @@ -723,34 +723,34 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ." AND q.qid={$rows['qid']} AND sq.scale_id=0 ORDER BY sq.question_order"; - + $y_axis_db = db_execute_assoc($fquery); - - // Get the X-Axis + + // Get the X-Axis $aquery = "SELECT sq.* - FROM ".$this->db->dbprefix('questions')." q, ".$this->db->dbprefix('questions')." sq - WHERE q.sid=$surveyid + FROM ".$this->db->dbprefix('questions')." q, ".$this->db->dbprefix('questions')." sq + WHERE q.sid=$surveyid AND sq.parent_qid=q.qid AND q.language='".GetBaseLanguageFromSurveyID($surveyid)."' AND sq.language='".GetBaseLanguageFromSurveyID($surveyid)."' AND q.qid=".$rows['qid']." AND sq.scale_id=1 ORDER BY sq.question_order"; - + $x_axis_db=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to Array questions
$aquery
".$connect->ErrorMsg()); - + foreach ($x_axis_db->result_array() as $frow) { $x_axis[$frow['title']]=$frow['question']; } - + foreach ($y_axis_db->result_array() as $arow) { foreach($x_axis as $key=>$val) { $shortquestion=$rows['title'].":{$arows['title']}:$key: [".strip_tags($arows['question']). "][" .strip_tags($val). "] " . FlattenText($rows['question']); $cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."_".$key); - + if ($rows['type'] == ":") { for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue) @@ -770,7 +770,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."ORDER BY question_order"; $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to Array questions
$aquery
".$connect->ErrorMsg()); - + foreach ($aresult->result_array() as $arows) { $attr = getQuestionAttributes($rows['qid']); @@ -779,11 +779,11 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $shortanswer = "{$arows['title']}: [" . strip_tags($arows['question']) . "][$label1]"; $shortquestion=$rows['title'].":$shortanswer ".strip_tags($rows['question']); $cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."#0"); - + $shortanswer = "{$arows['title']}: [" . strip_tags($arows['question']) . "][$label2]"; $shortquestion=$rows['title'].":$shortanswer ".strip_tags($rows['question']); $cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."#1"); - + // first label $lquery="SELECT * " ."FROM {$dbprefix}answers " @@ -796,7 +796,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."#0", "{$lrows['code']}", "{$lrows['code']}"); } - + // second label $lquery="SELECT * " ."FROM {$dbprefix}answers " @@ -809,7 +809,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']."#1", "{$lrows['code']}", "{$lrows['code']}"); } - + // Only Show No-Answer if question is not mandatory if ($rows['mandatory'] != 'Y') { @@ -826,19 +826,19 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."ORDER BY question_order"; $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to Array questions
$aquery
".$connect->ErrorMsg()); - + foreach ($aresult->result_array() as $arows) { $shortanswer = "{$arows['title']}: [" . strip_tags($arows['question']) . "]"; $shortquestion=$rows['title'].":$shortanswer ".strip_tags($rows['question']); $cquestions[]=array($shortquestion, $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title']); - + // Only Show No-Answer if question is not mandatory if ($rows['mandatory'] != 'Y') { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['title'], "", $clang->gT("No answer")); } - + } //while } elseif ($rows['type'] == "R") //Answer Ranking @@ -882,12 +882,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."AND language='".GetBaseLanguageFromSurveyID($surveyid)."' " ."ORDER BY question_order"; $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to this question
$aquery
".$connect->ErrorMsg()); - + foreach ($aresult->result_array() as $arows) { $theanswer = addcslashes($arows['question'], "'"); $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], $arows['title'], $theanswer); - + $shortanswer = "{$arows['title']}: [" . strip_tags($arows['question']) . "]"; $shortanswer .= "[".$clang->gT("Single checkbox")."]"; $shortquestion=$rows['title'].":$shortanswer ".strip_tags($rows['question']); @@ -934,16 +934,16 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], " ", $clang->gT("No answer")); } break; - + case "N": // Simple Numerical questions - + // Only Show No-Answer if question is not mandatory if ($rows['mandatory'] != 'Y') { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], " ", $clang->gT("No answer")); } break; - + default: $aquery="SELECT * " ."FROM {$dbprefix}answers " @@ -954,7 +954,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."answer"; // Ranking question? Replacing "Ranking" by "this" $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to this question
$aquery
".$connect->ErrorMsg()); - + foreach ($aresult->result_array() as $arows) { $theanswer = addcslashes($arows['answer'], "'"); @@ -981,7 +981,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $canswers[]=array($rows['sid'].$X.$rows['gid'].$X.$rows['qid'], "-oth-", $clang->gT("Other")); } - + // Only Show No-Answer if question is not mandatory if ($rows['mandatory'] != 'Y') { @@ -994,8 +994,8 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } //foreach theserows } //if questionscount > 0 //END Gather Information for this question - - + + $quesitonNavOptions = ""; foreach ($theserows as $row) { @@ -1057,20 +1057,17 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $jn=0; if (isset($canswers)) { - foreach($canswers as $can) - { - $an=str_replace("'", "`", $can[2]); - $an=str_replace("\r", " ", $an); - $an=str_replace("\n", " ", $an); - $an=strip_tags($an); - $javascriptpre .= "Fieldnames[$jn]='$can[0]';\n" - ."Codes[$jn]='$can[1]';\n" - ."Answers[$jn]='$an';\n"; - $jn++; - } + foreach($canswers as $can) + { + $an=json_encode(FlattenText($can[2])); + $conditionsoutput_main_content .= "Fieldnames[$jn]='$can[0]';\n" + ."Codes[$jn]='$can[1]';\n" + ."Answers[$jn]={$an};\n"; + $jn++; + } } $jn=0; - + if (isset($cquestions)) { foreach ($cquestions as $cqn) @@ -1081,7 +1078,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $jn++; } } - + // record a JS variable to let jQuery know if survey is Anonymous if ($thissurvey['anonymized'] == 'Y') { @@ -1091,10 +1088,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $javascriptpre .= "isAnonymousSurvey = false;"; } - + $javascriptpre .= "//-->\n" ."\n"; - + //END: PREPARE JAVASCRIPT TO SHOW MATCHING ANSWERS TO SELECTED QUESTION @@ -1112,7 +1109,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $data['javascriptpre'] = $javascriptpre; $this->load->view("admin/conditions/conditionshead_view",$data); - + //BEGIN DISPLAY CONDITIONS FOR THIS QUESTION if ($subaction=='index' || $subaction=='editconditionsform' || $subaction=='insertcondition' || @@ -1132,10 +1129,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."ORDER BY {$dbprefix}conditions.scenario"; $scenarioresult = db_execute_assoc($scenarioquery) or safe_die ("Couldn't get other (scenario) conditions for question $qid
$query
".$connect->Error); $scenariocount=$scenarioresult->num_rows(); - + $showreplace="$questiontitle". self::_showSpeaker($questiontext); $onlyshow=str_replace("{QID}", $showreplace, $clang->gT("Only show question {QID} IF")); - + $data['conditionsoutput'] = $conditionsoutput_main_content; $data['extraGetParams'] = $extraGetParams; $data['quesitonNavOptions'] = $quesitonNavOptions; @@ -1145,10 +1142,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $data['subaction'] = $subaction; $data['scenariocount'] = $scenariocount; $this->load->view("admin/conditions/conditionslist_view",$data); - + if ($scenariocount > 0) { - + self::_js_admin_includes($this->config->item("generalscripts").'jquery/jquery.checkgroup.js'); foreach ($scenarioresult->result_array() as $scenarionr) { @@ -1171,7 +1168,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $initialCheckbox = ""; } - + $conditionsoutput_main_content .= "\n" ."$initialCheckbox\n" . "
$scenariotext \n" ."
\n"; - + if ($scenariotext != "" && ($subaction == "editconditionsform" ||$subaction == "insertcondition" || $subaction == "updatecondition" || $subaction == "editthiscondition" || $subaction == "renumberscenarios" || $subaction == "updatescenario" || @@ -1196,23 +1193,23 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ." onclick=\"if ( confirm('".$clang->gT("Are you sure you want to delete all conditions set in this scenario?","js")."')) {document.getElementById('deletescenario{$scenarionr['scenario']}').submit();}\"" ." title='".$clang->gTview("Delete this scenario")."' >" ." gT("Delete this scenario")." name='DeleteWholeGroup' />\n"; - + $conditionsoutput_main_content .= "\t" ." ".$clang->gT("Edit scenario")."\n"; - + } - + $conditionsoutput_main_content .= "\t\n" ."\t\n" ."\t\n" ."\t\n" ."
\n"; - + unset($currentfield); - + $query = "SELECT {$dbprefix}conditions.cid, " ."{$dbprefix}conditions.scenario, " ."{$dbprefix}conditions.cqid, " @@ -1234,7 +1231,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."ORDER BY {$dbprefix}groups.group_order,{$dbprefix}questions.question_order"; $result = db_execute_assoc($query) or safe_die ("Couldn't get other conditions for question $qid
$query
".$connect->ErrorMsg()); $conditionscount=$result->num_rows(); - + $querytoken = "SELECT {$dbprefix}conditions.cid, " ."{$dbprefix}conditions.scenario, " ."{$dbprefix}conditions.cqid, " @@ -1250,9 +1247,9 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."ORDER BY {$dbprefix}conditions.cfieldname"; $resulttoken = db_execute_assoc($querytoken) or safe_die ("Couldn't get other conditions for question $qid
$query
".$connect->ErrorMsg()); $conditionscounttoken=$resulttoken->num_rows(); - + $conditionscount=$conditionscount+$conditionscounttoken; - + if ($conditionscount > 0) { $aConditionsMerged=Array(); @@ -1264,7 +1261,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $aConditionsMerged[]=$arow; } - + // while ($rows=$result->FetchRow()) foreach ($aConditionsMerged as $rows) { @@ -1286,7 +1283,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) // Style used when editing a condition $markcidstyle="background-color: #FCCFFF;"; } - + if (isset($currentfield) && $currentfield != $rows['cfieldname']) { $conditionsoutput_main_content .= "\n" @@ -1305,7 +1302,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\t
\n" ."\n" ."\t\n"; - + if ( $subaction == "copyconditionsform" || $subaction == "copyconditions") { $conditionsoutput_main_content .= "" @@ -1316,7 +1313,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .= "" ."\n" ."\t" @@ -1362,7 +1359,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\n" ."\t\n" ."\t\n" ."\t\n" @@ -1530,26 +1527,26 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } $conditionsoutput_main_content .= "" . "
  \n" ."\t\n"; - + $leftOperandType = 'unknown'; // prevquestion, tokenattr if ($thissurvey['anonymized'] != 'Y' && preg_match('/^{TOKEN:([^}]*)}$/',$rows['cfieldname'],$extractedTokenAttr) > 0) { @@ -1352,7 +1349,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) } } } - + $conditionsoutput_main_content .= "\t\n" ."\n" // .$clang->gT("Equals")."\n" ."\n"; - + // let's read the condition's right operand // determine its type and display it $rightOperandType = 'unknown'; // predefinedAnsw,constantVal, prevQsgqa, tokenAttr, regexp @@ -1388,7 +1385,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $matchedSGQAText=$rows['value'].' ('.$clang->gT("Not found").')'; } - + $conditionsoutput_main_content .= "".html_escape($matchedSGQAText)."\n"; } elseif ($thissurvey['anonymized'] != 'Y' && preg_match('/^{TOKEN:([^}]*)}$/',$rows['value'],$extractedTokenAttr) > 0) @@ -1413,7 +1410,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $conditionsoutput_main_content .= "$can[2] ($can[1])\n"; $rightOperandType = 'predefinedAnsw'; - + } } } @@ -1431,10 +1428,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .= "".html_escape($rows['value'])."\n"; } } - + $conditionsoutput_main_content .= "\t\n"; - + if ($subaction == "editconditionsform" ||$subaction == "insertcondition" || $subaction == "updatecondition" || $subaction == "editthiscondition" || $subaction == "renumberscenarios" || $subaction == "deleteallconditions" || @@ -1469,7 +1466,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .= "" ."\t\n"; } - + // now set the corresponding hidden input field // depending on the rightOperandType // This is used when Editting a condition @@ -1499,7 +1496,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\t\n"; } } - + $conditionsoutput_main_content .= "" ."\t
\n"; - + $conditionsoutput_main_content .= "\n"; } //END DISPLAY CONDITIONS FOR THIS QUESTION - - + + // Separator $conditionsoutput_main_content .= "\t\n"; - - + + // BEGIN: DISPLAY THE COPY CONDITIONS FORM if ($subaction == "copyconditionsform" || $subaction == "copyconditions") { $conditionsoutput_main_content .= "\n" ."\n"; - + $conditionsoutput_main_content .= "
".$clang->gT("Copy conditions")."
\n"; - - + + //CopyConditionsMessage if (isset ($CopyConditionsMessage)) { @@ -1557,14 +1554,14 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."$CopyConditionsMessage\n" ."\n"; } - + if (isset($conditionsList) && is_array($conditionsList)) { //TIBO self::_js_admin_includes($this->config->item("generalscripts").'jquery/jquery.multiselect.min.js'); - + $conditionsoutput_main_content .= ""; - + $conditionsoutput_main_content .= "\t
\n" ."\t
".$clang->gT("Copy the selected conditions to").":
\n" ."\t
\n" @@ -1579,7 +1576,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .= "\t\t\n" ."\t
\n" ."\t
\n"; - + if ( !isset($pquestions) || count($pquestions) == 0) { $disableCopyCondition=" disabled='disabled'"; @@ -1588,7 +1585,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $disableCopyCondition=" "; } - + $conditionsoutput_main_content .= "\t
\n" // ."\t\tgT("Are you sure you want to copy these condition(s) to the questions you have selected?","js")."')){prepareCopyconditions(); return true;} else {return false;}\" $disableCopyCondition/>\n" ."\t\t\n" @@ -1597,7 +1594,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\n" ."\n" ."
\n"; - + $conditionsoutput_main_content .= "\n"; - + } else { @@ -1618,12 +1615,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."
".$clang->gT("This survey's questions don't use conditions")."

\n" ."\n"; } - + $conditionsoutput_main_content .= "
\n"; - + } // END: DISPLAY THE COPY CONDITIONS FORM - + if ( isset($cquestions) ) { if ( count($cquestions) > 0 && count($cquestions) <=10) @@ -1639,8 +1636,8 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) { $qcount = 0; } - - + + //BEGIN: DISPLAY THE ADD or EDIT CONDITION FORM if ($subaction == "editconditionsform" || $subaction == "insertcondition" || $subaction == "updatecondition" || $subaction == "deletescenario" || @@ -1659,9 +1656,9 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $mytitle = $clang->gT("Add condition"); } $conditionsoutput_main_content .= "
".$mytitle."
\n"; - + /////////////////////////////////////////////////////////////////////////////////////////// - + // Begin "Scenario" row if ( ( $subaction != "editthiscondition" && isset($scenariocount) && ($scenariocount == 1 || $scenariocount==0)) || ( $subaction == "editthiscondition" && isset($scenario) && $scenario == 1) ) @@ -1677,14 +1674,14 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $scenarioTxt = ""; $scenarioInputStyle = "style = ''"; } - + $conditionsoutput_main_content .="
\n" ."
$scenarioAddBtn ".$clang->gT("Scenario")."
\n" ."
" ."$scenarioTxt\n" ."
\n" ."
\n"; - + // Begin "Question" row $conditionsoutput_main_content .="
\n" ."
".$clang->gT("Question")."
\n" @@ -1694,7 +1691,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\t
  • ".$clang->gT("Previous questions")."
  • \n" ."\t
  • ".$clang->gT("Token fields")."
  • \n" ."\t\n"; - + // Previous question tab $conditionsoutput_main_content .= "
    \n" ."
    \n"; - + // Source token Tab $conditionsoutput_main_content .= "
    \n" ."
    \n\n"; - + $conditionsoutput_main_content .= "\t
    \n"; // end conditionsource div - + $conditionsoutput_main_content .= "\n" ."\n"; - + // Begin "Comparison operator" row $conditionsoutput_main_content .="
    \n" ."
    ".$clang->gT("Comparison operator")."
    \n" @@ -1773,11 +1770,11 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .="\n" ."
    \n" ."\n"; - + // Begin "Answer" row $conditionsoutput_main_content .="
    \n" ."
    ".$clang->gT("Answer")."
    \n"; - + if ($subaction == "editthiscondition") { $multipletext = ""; @@ -1818,8 +1815,8 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $EDITConditionRegexp=""; } } - - + + $conditionsoutput_main_content .= "" ."
    \n" ."
    \n" @@ -1830,14 +1827,14 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\t\t
  • ".$clang->gT("Token fields")."
  • \n" ."\t\t
  • ".$clang->gT("RegExp")."
  • \n" ."\t\n"; - + // Predefined answers tab $conditionsoutput_main_content .= "\t
    \n" ."\t\t\n" ."\t\t
    ".$clang->gT("Predefined answer options for this question")."\n" ."\t
    \n"; - + // Constant tab $conditionsoutput_main_content .= "\t
    \n" ."\t\t\n" @@ -1861,7 +1858,7 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $conditionsoutput_main_content .= "\t\t\n" ."\t\t
    ".$clang->gT("Answers from previous questions")."\n" ."\t
    \n"; - + // Token tab $conditionsoutput_main_content .= "\t
    \n" ."\t\t\n" ."\t\t
    ".$clang->gT("Attributes values from the participant's token")."\n" ."\t
    \n"; - + // Regexp Tab $conditionsoutput_main_content .= "\t
    \n" ."\t\t\n" ."\t\t
    \n" ."\t
    \n"; - + $conditionsoutput_main_content .= "
    \n"; // end conditiontarget div - - + + self::_js_admin_includes($this->config->item("adminscripts").'conditions.js'); self::_js_admin_includes($this->config->item("generalscripts").'jquery/lime-conditions-tabs.js'); self::_js_admin_includes($this->config->item("generalscripts").'jquery/jquery-ui.js'); - + if ($subaction == "editthiscondition" && isset($p_cid)) { $submitLabel = $clang->gT("Update condition"); @@ -1899,10 +1896,10 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) $submitSubaction = "insertcondition"; $submitcid = ""; } - + $conditionsoutput_main_content .= "
    \n" ."
    \n"; - + // Begin buttons row $conditionsoutput_main_content .= "
    \n" ."\t\n" @@ -1918,12 +1915,12 @@ function action($subaction, $surveyid=null, $gid=null, $qid=null) ."\n" // auto-select target answers by jQuery when editing a condition ."
    \n" ."\n"; - + if (!isset($js_getAnswers_onload)) { $js_getAnswers_onload = ''; } - + $conditionsoutput_main_content .= "