Skip to content

Commit

Permalink
Fix in export_helper and copysurvey action.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10742 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
sachdeva-shubham committed Aug 15, 2011
1 parent 933d014 commit 7c71f35
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
56 changes: 50 additions & 6 deletions application/controllers/admin/survey.php
Expand Up @@ -890,6 +890,8 @@ function copy()
{
$importsurvey = "";
$action = $this->input->post('action');
$surveyid = $this->input->post('sid');

if ($action == "importsurvey" || $action == "copysurvey")
{
if ( $this->input->post('copysurveytranslinksfields') == "on" || $this->input->post('translinksfields') == "on")
Expand Down Expand Up @@ -952,6 +954,7 @@ function copy()
{
$surveyid = sanitize_int($this->input->post('copysurveylist'));
$exclude = array();

if (get_magic_quotes_gpc()) {$sNewSurveyName = stripslashes($this->input->post('copysurveyname'));}
else{
$sNewSurveyName=$this->input->post('copysurveyname');
Expand Down Expand Up @@ -979,8 +982,47 @@ function copy()
$exclude['conditions'] = true;
}
//include("export_structure_xml.php");
$this->load->helper('admin/export_structure_xml');
$copysurveydata = getXMLData($exclude);

if (!$surveyid)
{
self::_getAdminHeader();
echo ""
."<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("Export Survey")."</strong></td></tr>\n"
."\t<tr><td align='center'>\n"
."<br /><strong><font color='red'>"
.$clang->gT("Error")."</font></strong><br />\n"
.$clang->gT("No SID has been provided. Cannot dump survey")."<br />\n"
."<br /><input type='submit' value='"
.$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\">\n"
."\t</td></tr>\n"
."</table>\n"
."</body></html>\n";
exit;
}


$this->load->helper('export_helper');


if (!isset($copyfunction))
{
$fn = "limesurvey_survey_$surveyid.lss";
header("Content-Type: text/xml");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public"); // HTTP/1.0
echo getXMLData();
exit;
}

$copysurveydata = survey_getXMLData($surveyid,$exclude);


}

// Now, we have the survey : start importing
Expand Down Expand Up @@ -1172,8 +1214,8 @@ function index($action,$surveyid=null)
}
$editsurvey .= "</form>";
if ($action == "newsurvey") {
$editsurvey .= self::_tabImport();
$editsurvey .= self::_tabCopy();
$editsurvey .= self::_tabImport($surveyid);
$editsurvey .= self::_tabCopy($surveyid);
} elseif ($action == "editsurveysettings") {
$editsurvey .= self::_tabResourceManagement($surveyid);
}
Expand Down Expand Up @@ -2223,7 +2265,7 @@ function _tabTokens($esrow)
return $this->load->view('admin/survey/superview/superTokens_view',$data, true);
}

function _tabImport()
function _tabImport($surveyid)
{
$clang = $this->limesurvey_lang;
/**
Expand All @@ -2244,13 +2286,14 @@ function _tabImport()
$editsurvey .= "</div>\n";
return $editsurvey; */
$data['clang'] = $clang;
$data['surveyid'] = $surveyid;
//$data['esrow'] = $esrow;

//$data['showqnumcode'] = $showqnumcode;
return $this->load->view('admin/survey/superview/superImport_view',$data, true);
}

function _tabCopy()
function _tabCopy($surveyid)
{
$clang = $this->limesurvey_lang;
/**
Expand Down Expand Up @@ -2284,6 +2327,7 @@ function _tabCopy()
*/

$data['clang'] = $clang;
$data['surveyid'] = $surveyid;
//$data['esrow'] = $esrow;

//$data['showqnumcode'] = $showqnumcode;
Expand Down
2 changes: 2 additions & 0 deletions application/helpers/export_helper.php
Expand Up @@ -482,8 +482,10 @@ function BuildXMLFromQuery($xmlwriter, $Query, $tagname='', $excludes = array())
{
$CI =& get_instance();
$dbprefix = $CI->db->dbprefix;
$CI->load->helper('database');
$QueryResult = db_execute_assoc($Query) or safe_die ("ERROR: $QueryResult<br />".$connect->ErrorMsg()); //safe
preg_match('/FROM (\w+)( |,)/', $Query, $MatchResults);

if ($tagname!='')
{
$TableName=$tagname;
Expand Down
Expand Up @@ -16,6 +16,7 @@
<li><label for='copysurveyresetconditions'><?php echo $clang->gT("Reset conditions?") ; ?></label>
<input id='copysurveyresetconditions' name="copysurveyresetconditions" type="checkbox" /></li></ul>
<p><input type='submit' value='<?php echo $clang->gT("Copy survey"); ?>' />
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
<input type='hidden' name='action' value='copysurvey' /></p></form>


Expand Down
Expand Up @@ -8,6 +8,7 @@
<li><label for='translinksfields'><?php echo $clang->gT("Convert resource links and INSERTANS fields?"); ?> </label>
<input id='translinksfields' name="translinksfields" type="checkbox" checked='checked'/></li></ul>
<p><input type='submit' value='<?php echo $clang->gT("Import survey"); ?>' />
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
<input type='hidden' name='action' value='importsurvey' /></p></form>

</div>

0 comments on commit 7c71f35

Please sign in to comment.