Skip to content

Commit

Permalink
Fixed issue: Demo rendered unusable with wipe command
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jan 19, 2018
1 parent ea543a5 commit 392a045
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions application/commands/WipeCommand.php
Expand Up @@ -56,6 +56,8 @@ public function run($sArgument)
Yii::app()->db->createCommand($actquery)->execute();
$actquery = "truncate table {{templates}}";
Yii::app()->db->createCommand($actquery)->execute();
$actquery = "truncate table {{template_configuration}}";
Yii::app()->db->createCommand($actquery)->execute();
$actquery = "truncate table {{participants}}";
Yii::app()->db->createCommand($actquery)->execute();
$actquery = "truncate table {{participant_attribute_names}}";
Expand Down Expand Up @@ -93,6 +95,13 @@ public function run($sArgument)
$actquery = "update {{settings_global}} set stg_value='Sea_Green' where stg_name='admintheme'";
Yii::app()->db->createCommand($actquery)->execute();

foreach($templateData=LsDefaultDataSets::getTemplatesData() as $template){
Yii::app()->db->createCommand()->insert("{{templates}}", $template );
}
foreach($templateConfigurationData=LsDefaultDataSets::getTemplateConfigurationData() as $templateConfiguration){
Yii::app()->db->createCommand()->insert("{{template_configuration}}", $templateConfiguration );
}

$surveyidresult = dbGetTablesLike("tokens%");
foreach ($surveyidresult as $sv) {
Yii::app()->db->createCommand("drop table ".$sv)->execute();
Expand All @@ -113,6 +122,8 @@ public function run($sArgument)

SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'surveys', false);
SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'templates', false);
SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'survey', false);
SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'question', false);
} else {
// TODO: a valid error process
echo 'This CLI command wipes a LimeSurvey installation clean (including all user except for the user ID 1 and user-uploaded content). For security reasons this command can only started if you add the parameter \'yes\' to the command line.';
Expand Down

0 comments on commit 392a045

Please sign in to comment.