Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Yii' into Yii
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Feb 23, 2012
2 parents 7c94e42 + 5b27a76 commit 975449e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
48 changes: 29 additions & 19 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -108,37 +108,47 @@ function run($surveyid,$args) {
$_SESSION['survey_'.$surveyid]['maxstep'] = 0;
}

if (!(isset($_POST['saveall']) || isset($_POST['saveprompt']) || isset($_POST['loadall']) || isset($_GET['sid'])))
if (isset($_SESSION['LEMpostKey']) && isset($_POST['LEMpostKey']) && $_POST['LEMpostKey'] != $_SESSION['LEMpostKey'])
{
// then trying to resubmit (e.g. Next, Previous, Submit) from a cached copy of the page
// Does not try to save anything from the page to the database
$moveResult = LimeExpressionManager::GetLastMoveResult();
if (isset($_POST['thisstep']) && isset($moveResult['seq']) && $_POST['thisstep'] == $moveResult['seq'])
{
// then pressing F5 or otherwise refreshing the current page, which is OK
$LEMskipReprocessing=true;
$move = "movenext"; // so will re-display the survey
}
else
{
// trying to use browser back buttons, which may be disallowed if no 'previous' button is present
$LEMskipReprocessing=true;
$move = "movenext"; // so will re-display the survey
$invalidLastPage=true;
$vpopup="<script type=\"text/javascript\">\n
<!--\n $(document).ready(function(){
alert(\"".$clang->gT("Please use the LimeSurvey navigation buttons or index. It appears you attempted to use the browser back button to re-submit a page.", "js")."\");});\n //-->\n
</script>\n";
}
}

if (!(isset($_POST['saveall']) || isset($_POST['saveprompt']) || isset($_POST['loadall']) || isset($_GET['sid']) || $LEMskipReprocessing || (isset($move) && (preg_match('/^changelang_/',$move)))))
{
$_SESSION['survey_'.$surveyid]['prevstep'] = $_SESSION['survey_'.$surveyid]['step'];
}
if (!isset($_SESSION['prevstep']))
{
$_SESSION['survey_'.$surveyid]['prevstep']=-1; // this only happens on re-load
}

if (isset($_SESSION['LEMpostKey']) && isset($_POST['LEMpostKey']) && $_POST['LEMpostKey'] != $_SESSION['LEMpostKey'])
{
// then trying to resubmit (e.g. Next, Previous, Submit) from a cached copy of the page
// Simply re-display the current page without re-processing POST or re-validating input. Means user will lose whatever data entry the just tried
// Also flash a message
$moveResult = LimeExpressionManager::GetLastMoveResult();
$LEMskipReprocessing=true;
$move = "movenext"; // so will re-display the survey
$invalidLastPage = true;
$vpopup = "<script type=\"text/javascript\">\n
<!--\n $(document).ready(function(){
alert(\"" . $clang->gT("Please use the LimeSurvey navigation buttons or index. It appears you attempted to use the browser back button to re-submit a page.", "js") . "\");});\n //-->\n
</script>\n";
}
else if (isset($_SESSION['LEMtokenResume']))
}

if (isset($_SESSION['LEMtokenResume']))
{
LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel);
$moveResult = LimeExpressionManager::JumpTo($_SESSION['survey_'.$surveyid]['step']+1,false,false); // if late in the survey, will re-validate contents, which may be overkill
unset($_SESSION['LEMtokenResume']);
unset($_SESSION['LEMreload']);
}
else
else if (!$LEMskipReprocessing)
{
//Move current step ###########################################################################
if (isset($move) && $move == 'moveprev' && ($thissurvey['allowprev'] == 'Y' || $thissurvey['allowjumps'] == 'Y'))
Expand Down
4 changes: 4 additions & 0 deletions application/helpers/frontend_helper.php
Expand Up @@ -2775,6 +2775,10 @@ function display_first_page() {
if (isset($loadsecurity)) {
echo "\n<input type='hidden' name='loadsecurity' value='$loadsecurity' id='loadsecurity' />\n";
}
$_SESSION['LEMpostKey'] = mt_rand();
echo "<input type='hidden' name='LEMpostKey' value='{$_SESSION['LEMpostKey']}' id='LEMpostKey' />\n";
echo "<input type='hidden' name='thisstep' id='thisstep' value='0' />\n";

echo "\n</form>\n";
echo templatereplace(file_get_contents("$thistpl/endpage.pstpl"),array(),$redata,'frontend_helper[2782]');

Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/usergroup/addUserGroup_view.php
Expand Up @@ -4,7 +4,7 @@
<ul>
<li>
<label for='group_name'><?php $clang->eT("Name:"); ?></label>
<input type='text' size='50' id='group_name' name='group_name' required="required" autofocus="autofocus" />
<input type='text' size='50' maxlength='20' id='group_name' name='group_name' required="required" autofocus="autofocus" />
<font color='red' face='verdana' size='1'> <?php $clang->eT("Required"); ?></font>
</li>
<li>
Expand Down

0 comments on commit 975449e

Please sign in to comment.