Skip to content

Commit

Permalink
fix save and reload.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@1854 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Shawn Wales committed Aug 1, 2006
1 parent 4c6947b commit b2d60f6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
7 changes: 4 additions & 3 deletions group.php
Expand Up @@ -37,7 +37,8 @@
if (empty($homedir)) {die ("Cannot run this script directly");}

//Move current step ###########################################################################
if (!isset($_SESSION['step'])) {$_SESSION['step'] = 0;}
if (!isset($_SESSION['step'])) {$_SESSION['step']=0;}
if (!isset($_SESSION['totalsteps'])) {$_SESSION['totalsteps']=0;}
if (!isset($_POST['thisstep'])) {$_POST['thisstep'] = "";}
if (!isset($gl)) {$gl=array("null");}
if (isset($_POST['move']) && $_POST['move'] == " << "._("prev")." ") {$_SESSION['step'] = $_POST['thisstep']-1;}
Expand All @@ -46,8 +47,8 @@

// --> START NEW FEATURE - SAVE
// If on SUBMIT page and select SAVE SO FAR it will return to SUBMIT page
if (isset($_POST['saveprompt']) && $_POST['saveprompt'] == "Y" && $_SESSION['step'] > $_SESSION['totalsteps'])
{
if ($_SESSION['step'] > $_SESSION['totalsteps'] && $_POST['move'] != " "._("submit")." ")
{
$_POST['move'] = " "._("last")." ";
}
// <-- END NEW FEATURE - SAVE
Expand Down
35 changes: 17 additions & 18 deletions index.php
Expand Up @@ -171,7 +171,7 @@
{
if (returnglobal('loadname') && returnglobal('loadpass'))
{
$_POST['loadall']="reload";
$_POST['loadall']="reload";
$_POST['loadname']=returnglobal('loadname');
$_POST['loadpass']=returnglobal('loadpass');
$_POST['scid']=returnglobal('scid');
Expand All @@ -185,7 +185,7 @@
// if (loadname is not set) or if ((loadname is set) and (loadname is NULL))
if (!isset($_POST['loadname']) || (isset($_POST['loadname']) && ($_POST['loadname'] == null)))
{
$errormsg .= _("You did not provide a name")."<br />\n";
$errormsg .= _("You did not provide a name")."<br />\n";
}
// if (loadpass is not set) or if ((loadpass is set) and (loadpass is NULL))
if (!isset($_POST['loadpass']) || (isset($_POST['loadpass']) && ($_POST['loadpass'] == null)))
Expand All @@ -198,24 +198,24 @@
{
buildsurveysession();
}
//for later use.

// --> START NEW FEATURE - SAVE
$_SESSION['holdname']=$_POST['loadname']; //Session variable used to load answers every page.
$_SESSION['holdpass']=$_POST['loadpass']; //Session variable used to load answers every page.

loadanswers();
// <-- END NEW FEATURE - SAVE
$_POST['move'] = " "._("next")." >> ";

if ($errormsg)
{
$_POST['loadall'] = _("Load unfinished survey");
$_POST['loadall'] = _("Load Unfinished Survey");
}
}
//Allow loading of saved survey
if (isset($_POST['loadall']) && $_POST['loadall'] == _("Load unfinished survey"))
if (isset($_POST['loadall']) && $_POST['loadall'] == _("Load Unfinished Survey"))
{
require_once("load.php");
require_once("load.php");
}


Expand Down Expand Up @@ -341,27 +341,26 @@ function loadanswers()
global $dbprefix,$surveyid,$errormsg;
global $thissurvey;

if (!isset($_POST['srid']))
{
return true;
}

if (isset($_POST['scid']))
if (isset($_POST['loadall']) && $_POST['loadall'] == "reload")
{
$query = "SELECT * FROM {$dbprefix}saved_control INNER JOIN {$thissurvey['tablename']}
ON {$dbprefix}saved_control.srid = {$thissurvey['tablename']}.id
WHERE {$dbprefix}saved_control.sid=$surveyid\n";
if (isset($_POST['scid']))
if (isset($_POST['scid'])) //Would only come from email
{
$query .= "AND {$dbprefix}saved_control.scid=".auto_escape($_POST['scid'])."\n";
}
$query .="AND {$dbprefix}saved_control.identifier='".auto_escape($_SESSION['holdname'])."'
AND {$dbprefix}saved_control.access_code='".md5(auto_unescape($_SESSION['holdpass']))."'\n";
}
else
elseif (isset($_SESSION['srid']))
{
$query = "SELECT * FROM {$thissurvey['tablename']}
WHERE {$thissurvey['tablename']}.srid=".$_SESSION['srid']."\n";
WHERE {$thissurvey['tablename']}.id=".$_SESSION['srid']."\n";
}
else
{
return;
}
$result = mysql_query($query) or die ("Error loading results<br />$query<br />".mysql_error());

Expand Down Expand Up @@ -905,7 +904,7 @@ function createinsertquery()
}
if ((isset($_POST['move']) && $_POST['move'] == " "._("submit")." "))
{
$query .= ",'submitdate'";
$query .= ",`submitdate`";
}
$query .=") ";
$query .="VALUES (".implode(", ", $values);
Expand Down Expand Up @@ -1046,7 +1045,7 @@ function sendsubmitnotification($sendnotification)

$message = _("Survey Submitted")." - {$thissurvey['name']}\r\n"
. _("A new response was entered for your survey")."\r\n\r\n";
if ($thissurvey['allowsave'] == "Y")
if ($thissurvey['allowsave'] == "Y" && isset($_SESSION['scid']))
{
$message .= _("Click the following link to reload the survey:")."\r\n";
$message .= " $publicurl/index.php?sid=$surveyid&loadall=reload&scid=".$_SESSION['scid']."&loadname=".urlencode($_SESSION['holdname'])."&loadpass=".urlencode($_SESSION['holdpass'])."\r\n\r\n";
Expand Down
9 changes: 3 additions & 6 deletions question.php
Expand Up @@ -37,6 +37,7 @@

//Move current step
if (!isset($_SESSION['step'])) {$_SESSION['step']=0;}
if (!isset($_SESSION['totalsteps'])) {$_SESSION['totalsteps']=0;}
if (!isset($_POST['thisstep'])) {$_POST['thisstep'] = "";}
if (!isset($_POST['newgroupondisplay'])) {$_POST['newgroupondisplay'] = "";}
if (isset($_POST['move']) && $_POST['move'] == " << "._("prev")." " && !$_POST['newgroupondisplay']) {$_SESSION['step'] = $_POST['thisstep']-1;}
Expand All @@ -46,19 +47,15 @@

// --> START NEW FEATURE - SAVE
// If on SUBMIT page and select SAVE SO FAR it will return to SUBMIT page
if (isset($_POST['saveprompt']) && $_POST['saveprompt'] == "Y" && $_SESSION['step'] > $_SESSION['totalsteps'])
if ($_SESSION['step'] > $_SESSION['totalsteps'] && $_POST['move'] != " "._("submit")." ")
{
$_POST['move'] = " "._("last")." ";
}
// <-- END NEW FEATURE - SAVE

//CHECK IF ALL MANDATORY QUESTIONS HAVE BEEN ANSWERED ############################################
//First, see if we are moving backwards or doing a Save so far, and its OK not to check:
<<<<<<< .mine
if ($allowmandbackwards==1 && ((isset($_POST['move']) && $_POST['move'] == " << "._PREV." ") || (isset($_POST['saveall']) && $_POST['saveall'] == _("Save your responses so far"))))
=======
if ($allowmandbackwards==1 && ((isset($_POST['move']) && $_POST['move'] == " << "._("Previous")." ") || (isset($_POST['saveall']) && $_POST['saveall'] == _SAVE_AND_RETURN)))
>>>>>>> .theirs
if ($allowmandbackwards==1 && ((isset($_POST['move']) && $_POST['move'] == " << "._("prev")." ") || (isset($_POST['saveall']) && $_POST['saveall'] == _("Save your responses so far"))))
{
$backok="Y";
}
Expand Down
2 changes: 1 addition & 1 deletion save.php
Expand Up @@ -96,7 +96,7 @@
if ($thissurvey['active'] == "Y") // Only save if active
{
// SAVE DATA TO SURVEY_X RECORD
$subquery = createinsertquery();
$subquery = createinsertquery();
if ($result=$connect->Execute($subquery))
{
$srid = $connect->Insert_ID();
Expand Down
3 changes: 2 additions & 1 deletion survey.php
Expand Up @@ -37,6 +37,7 @@

//Move current step ###########################################################################
if (!isset($_SESSION['step'])) {$_SESSION['step'] = 0;}
if (!isset($_SESSION['totalsteps'])) {$_SESSION['totalsteps']=0;}
if (!isset($_POST['thisstep'])) {$_POST['thisstep'] = "";}

if (isset($_POST['move']) && $_POST['move'] == " << "._("prev")." ") {$_SESSION['step'] = $_POST['thisstep']-1;}
Expand All @@ -45,7 +46,7 @@

// --> START NEW FEATURE - SAVE
// If on SUBMIT page and select SAVE SO FAR it will return to SUBMIT page
if (isset($_POST['saveprompt']) && $_POST['saveprompt'] == "Y" && $_SESSION['step'] > $_SESSION['totalsteps'])
if ($_SESSION['step'] > $_SESSION['totalsteps'])
{
$_POST['move'] = " "._("last")." ";
}
Expand Down

0 comments on commit b2d60f6

Please sign in to comment.