From 7c71f357be0a0642708fbfc0243cf8500d31f7bc Mon Sep 17 00:00:00 2001 From: Shubham Sachdeva Date: Mon, 15 Aug 2011 18:32:45 +0000 Subject: [PATCH] Fix in export_helper and copysurvey action. git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10742 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/controllers/admin/survey.php | 56 +++++++++++++++++-- application/helpers/export_helper.php | 2 + .../admin/Survey/superview/superCopy_view.php | 1 + .../Survey/superview/superImport_view.php | 1 + 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/application/controllers/admin/survey.php b/application/controllers/admin/survey.php index d77efd34da4..5ed51c76bc5 100644 --- a/application/controllers/admin/survey.php +++ b/application/controllers/admin/survey.php @@ -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") @@ -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'); @@ -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 "" + ."
\n" + ."\n" + ."\t\n" + ."\t\n" + ."
" + .$clang->gT("Export Survey")."
\n" + ."
" + .$clang->gT("Error")."
\n" + .$clang->gT("No SID has been provided. Cannot dump survey")."
\n" + ."
\n" + ."\t
\n" + ."\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 @@ -1172,8 +1214,8 @@ function index($action,$surveyid=null) } $editsurvey .= ""; if ($action == "newsurvey") { - $editsurvey .= self::_tabImport(); - $editsurvey .= self::_tabCopy(); + $editsurvey .= self::_tabImport($surveyid); + $editsurvey .= self::_tabCopy($surveyid); } elseif ($action == "editsurveysettings") { $editsurvey .= self::_tabResourceManagement($surveyid); } @@ -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; /** @@ -2244,13 +2286,14 @@ function _tabImport() $editsurvey .= "\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; /** @@ -2284,6 +2327,7 @@ function _tabCopy() */ $data['clang'] = $clang; + $data['surveyid'] = $surveyid; //$data['esrow'] = $esrow; //$data['showqnumcode'] = $showqnumcode; diff --git a/application/helpers/export_helper.php b/application/helpers/export_helper.php index 8dc0b0df8ac..65ee17763ef 100644 --- a/application/helpers/export_helper.php +++ b/application/helpers/export_helper.php @@ -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
".$connect->ErrorMsg()); //safe preg_match('/FROM (\w+)( |,)/', $Query, $MatchResults); + if ($tagname!='') { $TableName=$tagname; diff --git a/application/views/admin/Survey/superview/superCopy_view.php b/application/views/admin/Survey/superview/superCopy_view.php index 8c3d4713894..a9289022495 100644 --- a/application/views/admin/Survey/superview/superCopy_view.php +++ b/application/views/admin/Survey/superview/superCopy_view.php @@ -16,6 +16,7 @@
  • +

    diff --git a/application/views/admin/Survey/superview/superImport_view.php b/application/views/admin/Survey/superview/superImport_view.php index c6a9ea08ad6..16cce4fd383 100644 --- a/application/views/admin/Survey/superview/superImport_view.php +++ b/application/views/admin/Survey/superview/superImport_view.php @@ -8,6 +8,7 @@
  • +

    \ No newline at end of file