diff --git a/application/controllers/admin/surveyadmin.php b/application/controllers/admin/surveyadmin.php index 7e2bb078d08..a5806ee0cd0 100644 --- a/application/controllers/admin/surveyadmin.php +++ b/application/controllers/admin/surveyadmin.php @@ -292,6 +292,7 @@ public function deactivate($iSurveyID = null) $iSurveyID = sanitize_int($iSurveyID); $postsid = Yii::app()->request->getPost('sid', $iSurveyID); + $postsid = sanitize_int($postsid); $clang = $this->getController()->lang; $date = date('YmdHis'); //'Hi' adds 24hours+minutes to name to allow multiple deactiviations in a day @@ -327,12 +328,12 @@ public function deactivate($iSurveyID = null) // IF there are any records in the saved_control table related to this survey, they have to be deleted $result = Saved_control::model()->deleteSomeRecords(array('sid' => $postsid)); //Yii::app()->db->createCommand($query)->query(); - $oldtable = "{{survey_{$postsid}}}"; - $newtable = "{{old_survey_{$postsid}_{$date}}}"; - + $sOldSurveyTableName = Yii::app()->db->tablePrefix."survey_{$postsid}"; + $sNewSurveyTableName = Yii::app()->db->tablePrefix."old_survey_{$postsid}_{$date}"; + $aData['sNewSurveyTableName']=$sNewSurveyTableName; //Update the auto_increment value from the table before renaming $new_autonumber_start = 0; - $query = "SELECT id FROM ".Yii::app()->db->quoteTableName($oldtable)." ORDER BY id desc"; + $query = "SELECT id FROM ".Yii::app()->db->quoteTableName($sOldSurveyTableName)." ORDER BY id desc"; $result = Yii::app()->db->createCommand($query)->limit(1)->query(); if ($result->getRowCount() > 0) { @@ -360,12 +361,12 @@ public function deactivate($iSurveyID = null) $survey->save(); if (Yii::app()->db->getDrivername() == 'postgre') { - $deactivateresult = Yii::app()->db->createCommand()->renameTable($oldtable . '_id_seq', $newtable . '_id_seq'); - $setsequence = "ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$newtable}_id_seq'::regclass);"; + $deactivateresult = Yii::app()->db->createCommand()->renameTable($sOldSurveyTableName . '_id_seq', $sNewSurveyTableName . '_id_seq'); + $setsequence = "ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$sNewSurveyTableName}_id_seq'::regclass);"; $deactivateresult = Yii::app()->db->createCommand($setsequence)->execute(); } - $deactivateresult = Yii::app()->db->createCommand()->renameTable($oldtable, $newtable); + $deactivateresult = Yii::app()->db->createCommand()->renameTable($sOldSurveyTableName, $sNewSurveyTableName); $insertdata = array('active' => 'N'); $survey->active = 'N'; @@ -374,15 +375,15 @@ public function deactivate($iSurveyID = null) $prow = Survey::model()->find('sid = :sid', array(':sid' => $postsid)); if ($prow->savetimings == "Y") { - $oldtable = "{{survey_{$postsid}_timings}}"; - $newtable = "{{old_survey_{$postsid}_timings_{$date}}}"; + $sOldTimingsTableName = Yii::app()->db->tablePrefix."survey_{$postsid}_timings"; + $sNewTimingsTableName = Yii::app()->db->tablePrefix."old_survey_{$postsid}_timings_{$date}"; - $deactivateresult2 = Yii::app()->db->createCommand()->renameTable($oldtable, $newtable); + $deactivateresult2 = Yii::app()->db->createCommand()->renameTable($sOldTimingsTableName, $sNewTimingsTableName); $deactivateresult = ($deactivateresult && $deactivateresult2); + $aData['sNewTimingsTableName'] = $sNewTimingsTableName; } $aData['surveyid'] = $iSurveyID; - $aData['newtable'] = $newtable; } $this->_renderWrappedTemplate('survey', 'deactivateSurvey_view', $aData); diff --git a/application/views/admin/survey/deactivateSurvey_view.php b/application/views/admin/survey/deactivateSurvey_view.php index 4e3017c105b..a52b3f1e7d1 100644 --- a/application/views/admin/survey/deactivateSurvey_view.php +++ b/application/views/admin/survey/deactivateSurvey_view.php @@ -49,13 +49,17 @@
eT("Survey Has Been Deactivated"); ?>

- gT("The responses table has been renamed to: ")." ".$newtable; ?> - eT("The responses to this survey are no longer available using LimeSurvey."); ?> -

eT("You should note the name of this table in case you need to access this information later."); ?>

+ eT("The responses to this survey are no longer available using LimeSurvey."); ?>

+

+ gT("The responses table has been renamed to: ")." ".$sNewSurveyTableName; ?>
gT("The tokens table associated with this survey has been renamed to: ")." $tnewtable"; + echo $clang->gT("The tokens table associated with this survey has been renamed to: ")." $tnewtable
"; } ?> + + gT("The response timings table has been renamed to: ")." ".$sNewTimingsTableName; ?>
+

+ eT("You should note the name(s) of the table(s) in case you need to access this information later."); ?>

eT("Note: If you deactivated this survey in error, it is possible to restore this data easily if you do not make any changes to the survey structure. See the LimeSurvey documentation for further details"); ?>


  \ No newline at end of file