Commit 720aab24 authored by Chenu Denis's avatar Chenu Denis

Fixed issue #07895: Quota are not tested for hidden question (relevance to 1)

Fixed issue : Previous button in quota in citronade are not the same.
Dev: Change sentence of quota_action : reflect reality now
Dev: Don't change behaviour for quota_action=='2'
Dev: remove some $_POST var ($fieldname not in actual page)
Dev: this fieldname is needed for EM javascript : put disabled='disabled' inside.
Dev: DON'T do same think for relevance : else eremoved $_POST[$fieldname] : to be fixed
Dev: Same HTML previous button for quota page: todo : add navigator.pstpl (but allow save and clear all must be removed)
parent a3249e55
......@@ -6771,7 +6771,7 @@
{
// TODO - is different type needed for text? Or process value to striphtml?
if ($jsVar == '') continue;
$jsParts[] = "<input type='hidden' id='" . $jsVar . "' name='" . substr($jsVar,4) . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
$jsParts[] = "<input type='hidden' disabled='disabled' id='" . $jsVar . "' name='" . substr($jsVar,4) . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
}
}
else
......@@ -6799,7 +6799,7 @@
foreach ($undeclaredJsVars as $jsVar)
{
if ($jsVar == '') continue;
$jsParts[] = "<input type='hidden' id='" . $jsVar . "' name='" . $jsVar . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
$jsParts[] = "<input type='hidden' disabled='disabled' id='" . $jsVar . "' name='" . $jsVar . "' value='" . htmlspecialchars($undeclaredVal[$jsVar],ENT_QUOTES) . "'/>\n";
}
}
foreach ($qidList as $qid)
......@@ -6810,6 +6810,7 @@
else {
$relStatus = 1;
}
// Don't set to disabled : else remove posted answers ....
$jsParts[] = "<input type='hidden' id='relevance" . $qid . "' name='relevance" . $qid . "' value='" . $relStatus . "'/>\n";
}
......
......@@ -2359,6 +2359,9 @@ function checkQuota($checkaction,$surveyid)
$x=0;
$clang = Yii::app()->lang;
// Fill this step "can be modified value"
// Must be replaced by Yii::app()->request->getPost($fieldname) but EM add hidden $fieldname answers (put deactivated on 130622)
$aPostedFields = explode("|",Yii::app()->request->getPost('fieldnames'));
if(count($quota_info) > 0) // Quota's have to exist
{
......@@ -2366,6 +2369,7 @@ function checkQuota($checkaction,$surveyid)
$querycond = array();
foreach ($quota_info as $quota)
{
$bQuotaEnforced=($quota['Action']=='1' || ($quota['AutoloadUrl'] && $quota['Url']!=''));// Quota Enforced don't test if quota memebers is in post value (can be modified)
if (count($quota['members']) > 0) // Quota can't be empty
{
$fields_list = array(); // Keep a list of fields for easy reference
......@@ -2397,6 +2401,7 @@ function checkQuota($checkaction,$surveyid)
$querycond[] = $select_query;
}
// Test if the fieldname is in the array of value in the session
$matched_fields = false;
foreach($quota['members'] as $member)
{
foreach($member['fieldnames'] as $fieldname)
......@@ -2406,27 +2411,23 @@ function checkQuota($checkaction,$surveyid)
if (in_array($_SESSION['survey_'.$surveyid][$fieldname],$fields_value_array[$fieldname])){
$quota_info[$x]['members'][$y]['insession'] = "true";
}
// Control if $_SESSION['survey_'.$surveyid][$fieldname] is answered (not NULL or !='')
if($bQuotaEnforced)
{
$matched_fields = true;
$global_matched = true;
}
elseif(in_array($fieldname,$aPostedFields))// Can we test Yii::app()->request->getPost($fieldname) ?
{
$matched_fields = true;
$global_matched = true;
}
}
}
$y++;
}
unset($fields_query_array);unset($fields_value_array);
// Lets only continue if any of the quota fields is in the posted page
$matched_fields = false;
if (isset($_POST['fieldnames']))
{
$posted_fields = explode("|",$_POST['fieldnames']);
foreach ($fields_list as $checkfield)
{
if (in_array($checkfield,$posted_fields))
{
$matched_fields = true;
$global_matched = true;
}
}
}
// A field was submitted that is part of the quota
if ($matched_fields == true)
{
......@@ -2506,12 +2507,12 @@ function checkQuota($checkaction,$surveyid)
}
doHeader();
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper[2617]');
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper['.__LINE__.']');
echo "\t<div class='quotamessage'>\n";
echo "\t".$quota['Message']."<br /><br />\n";
echo "\t<a href='".$quota['Url']."'>".$quota['UrlDescrip']."</a><br />\n";
echo "\t</div>\n";
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper[2622]');
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper['.__LINE__.']');
doFooter();
killSurveySession($surveyid);
exit;
......@@ -2522,21 +2523,22 @@ function checkQuota($checkaction,$surveyid)
sendCacheHeaders();
doHeader();
$surveymover = "<input type='hidden' name='move' value='movenext' id='movenext' />\n"
. "<button class='submit' accesskey='p' type='button' onclick=\"javascript:document.limesurvey.move.value = 'moveprev'; $('#limesurvey').submit();\""
. " value='". $clang->gT("Previous")."' name='move2' id='moveprevbtn' >". $clang->gT("Previous")."</button>\n"
. "<input type='hidden' name='thisstep' value='".($_SESSION['survey_'.$surveyid]['step'])."' id='thisstep' />\n"
. "<input type='hidden' name='sid' value='".returnGlobal('sid',true)."' id='sid' />\n"
. "<input type='hidden' name='token' value='".$clienttoken."' id='token' />";
$redata = compact(array_keys(get_defined_vars()));
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper[2634]');
echo templatereplace(file_get_contents($sTemplatePath."/startpage.pstpl"),array(),$redata,'frontend_helper['.__LINE__.']');
echo "\t<div class='quotamessage'>\n";
echo "\t".$quota['Message']."<br /><br />\n";
echo "\t<a href='".$quota['Url']."'>".$quota['UrlDescrip']."</a><br />\n";
echo CHtml::form(array("/survey/index"), 'post', array('id'=>'limesurvey','name'=>'limesurvey'))."
<input type='hidden' name='move' value='movenext' id='movenext' />
<button class='nav-button nav-button-icon-left ui-corner-all' class='submit' accesskey='p' onclick=\"javascript:document.limesurvey.move.value = 'moveprev'; document.limesurvey.submit();\" id='moveprevbtn'>".$clang->gT("Previous")."</button>
<input type='hidden' name='thisstep' value='".($_SESSION['survey_'.$surveyid]['step'])."' id='thisstep' />
<input type='hidden' name='sid' value='".returnGlobal('sid',true)."' id='sid' />
<input type='hidden' name='token' value='".$clienttoken."' id='token' />
</form>\n";
echo CHtml::form(array("/survey/index"), 'post', array('id'=>'limesurvey','name'=>'limesurvey'));
echo $surveymover;
echo "</form>\n";
echo "\t</div>\n";
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper[2644]');
echo templatereplace(file_get_contents($sTemplatePath."/endpage.pstpl"),array(),$redata,'frontend_helper['.__LINE__.']');
doFooter();
exit;
}
......
......@@ -4,15 +4,14 @@
<li><label for='quota_name'><?php $clang->eT("Quota name:");?></label> <input id="quota_name" name="quota_name" type="text" size="30" maxlength="255" value="<?php echo $quotainfo['name'];?>" /></li>
<li><label for='quota_limit'><?php $clang->eT("Quota limit:");?></label><input id="quota_limit" name="quota_limit" type="text" size="12" maxlength="8" value="<?php echo $quotainfo['qlimit'];?>" /></li>
<li><label for='quota_action'><?php $clang->eT("Quota action:");?></label> <select name="quota_action" id="quota_action">
<option value ="1" <?php
if($quotainfo['action'] == 1) echo "selected='selected'"; ?>><?php $clang->eT("Terminate survey");?></option>
<option value ="2" <?php if($quotainfo['action'] == 2) echo "selected='selected'"; ?>><?php $clang->eT("Terminate survey with warning");?></option>
<option value ="1" <?php if($quotainfo['action'] == 1) echo "selected='selected'"; ?>><?php $clang->eT("Terminate survey");?></option>
<option value ="2" <?php if($quotainfo['action'] == 2) echo "selected='selected'"; ?>><?php $clang->eT("Show message and allow user to modify answers");?></option>
</select></li>
<li><label for='autoload_url'><?php $clang->eT("Autoload URL:");?></label><input id="autoload_url" name="autoload_url" type="checkbox" value="1"<?php if($quotainfo['autoload_url'] == "1") {echo " checked";}?> /></li>
</ul>
<div id="tabs">
</ul>
<div id="tabs">
<ul>
<?php foreach ($aTabTitles as $sLanguageCode=>$sTitle){?>
<li style='clear:none'><a href='#tabpage_<?php echo $sLanguageCode;?>'><?php echo $sTitle;?></a></li><?php
}?>
</ul>
\ No newline at end of file
</ul>
......@@ -13,7 +13,7 @@
<label for="quota_action"><?php $clang->eT("Quota action");?>:</label>
<select id="quota_action" name="quota_action">
<option value ="1"><?php $clang->eT("Terminate survey");?></option>
<option value ="2"><?php $clang->eT("Terminate survey with warning");?></option>
<option value ="2"><?php $clang->eT("Show message and allow user to modify answers");?></option>
</select>
</li>
<li>
......@@ -52,4 +52,4 @@
<input type="hidden" name="subaction" value="insertquota" />
</div>
<p><input name="submit" type="submit" value="<?php $clang->eT("Add New Quota");?>" />
</form>
\ No newline at end of file
</form>
......@@ -90,7 +90,7 @@ a:hover, a:focus, a:active {background-color: #E5F8A8;color: #5670A1;text-decora
ul#surveylist li a{color:#5670A1;}
ul#surveylist li a.surveytitle{color:#5670A1;}
/* information block and message*/
.note,#tokenmessage{border:#8195BA 1px solid;background:#EEF6FF;}
.note,#tokenmessage,.quotamessage{border:#8195BA 1px solid;background:#EEF6FF;}
p.url{font-size:1.2em;text-align:center;font-weight:bold}
#privacy{font-style: italic;}
#surveydescription{font-size:1.1em;color:#5670A1}
......@@ -145,6 +145,7 @@ input[type="text"]:focus, input.text:focus,textarea:focus{
}
input.checkbox[disabled],input.radio[disabled]{opacity: 0.3;}
/* survey tool decoration */
#movenextbtn,#movesubmitbtn,#moveprevbtn,
.tools select,.tools input,.tools a,input.submit,input#savebutton,input#loadbutton,input#registercontinue,.navigator input,.navigator button
{
border:1px solid #ABB8D1;background:#FEFEFE;color:#415479;
......@@ -155,24 +156,31 @@ input.checkbox[disabled],input.radio[disabled]{opacity: 0.3;}
}
.tools select
{padding:1px 2px;}
#movenextbtn,#movesubmitbtn,#moveprevbtn,
.tools input,.tools a,input.submit,input#savebutton,input#loadbutton,input#registercontinue,.navigator input,.navigator button
{box-sizing: border-box;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;-ms-box-sizing: border-box;}/* same box sizing for link and button */
#movenextbtn:hover,#movesubmitbtn:hover,#moveprevbtn:hover,
#movenextbtn:focus,#movesubmitbtn:focus,#moveprevbtn:focus,
.tools select:hover,.tools input:hover,.tools a:hover,.navigator input:hover,.navigator button:hover,input.submit:hover,input#savebutton:hover,input#loadbutton:hover,input#registercontinue:hover,
.tools select:focus,.tools input:focus,.tools a:focus,.navigator input:focus,.navigator button:focus,input.submit:focus,input#savebutton:focus,input#loadbutton:focus,input#registercontinue:focus
{
border-color:#ABB8D1;color:#415479;background:#f0f0f0;
border-color:#ABB8D1;color:#415479;background-color:#f0f0f0;
-moz-box-shadow: 2px 2px 5px #415479;-webkit-box-shadow: 2px 2px 5px #415479;box-shadow: 2px 2px 5px #415479;
}
.tools select:hover option{background:#FEFEFE;}
/* for disabled tools */
#movenextbtn[disabled],#movesubmitbtn[disabled],#moveprevbtn[disabled],
.tools input[disabled],.navigator input[disabled],.navigator button[disabled],input.submit[disabled],input#savebutton[disabled],input#loadbutton[disabled],input#registercontinue[disabled],.tools select[disabled]
{
border:1px solid #dbdbdb;background:#FEFEFE;color:#dbdbdb;cursor:inherit;
border:1px solid #dbdbdb;background-color:#FEFEFE;color:#dbdbdb;cursor:inherit;
}
#movenextbtn,#movesubmitbtn,#moveprevbtn,
.tools *,.navigator,.tools :active,.navigator :active,.tools :focus,.navigator :focus{ outline: 0 none; }
#movenextbtn::-moz-focus-inner,#movesubmitbtn::-moz-focus-inner,#moveprevbtn::-moz-focus-inner,
.tools ::-moz-focus-inner,.navigator ::-moz-focus-inner {border:0;}
/* ie specific: maybe some lt ? */
.ie .tools input,.ie .tools a,.ie .navigator input,.ie .navigator button,.ie input#savebutton,.ie input#loadbutton
.ielt8 #movenextbtn,.ielt8 #movesubmitbtn,.ielt8 #moveprevbtn,
.ielt8 .tools input,.ielt8 .tools a,.ielt8 .navigator input,.ielt8 .navigator button,.ielt8 input#savebutton,.ie input#loadbutton
{height:2em}
/* movenext, moveprev specific */
#movenextbtn{background-image:url(go-east.png);background-repeat:no-repeat;background-position:right center;padding:3px 26px 3px 6px;}
......@@ -336,7 +344,7 @@ ul.tools li{margin-right:1em;}
.help-wrapper .mandatory strong br{display:none}
.help-wrapper .mandatory{display:none;}
.input-error .help-wrapper .mandatory{display:block;}
.note,#tokenmessage{margin: 0.5em auto;padding: 1em;width: 80%;}
.note,#tokenmessage,.quotamessage{margin: 0.5em auto;padding: 1em;width: 80%;}
/* Inside question text*/
.question-text img{max-width:100%;}
#tokenform ul{list-style: none ;margin: 0.5em auto;padding: 0;text-align: center;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment