Skip to content

Commit

Permalink
add importCommand (not working doe inaccessible session)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Dec 29, 2017
1 parent 9e8e0b7 commit d45dcb5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
50 changes: 50 additions & 0 deletions application/commands/ImportCommand.php
@@ -0,0 +1,50 @@
<?php
/**
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

class ImportCommand extends CConsoleCommand
{
/**
*/
public function run($args)
{
/** @global ConsoleApplication $app */
global $app;

\Yii::import('application.helpers.admin.import_helper', true);
\Yii::import('application.helpers.common_helper', true);

$fileName = __DIR__ . '/../../'.$args[0];
$surveyFile = $fileName;

if (!file_exists($surveyFile)) {
echo 'Fatal error: found no survey file';
exit(1);
}


$translateLinksFields = false;
$newSurveyName = null;
try {
$result = importSurveyFile(
$fileName,
$translateLinksFields,
$newSurveyName,
null
);
} catch (\Exception $ex) {
throw $ex;
}

}

}
3 changes: 2 additions & 1 deletion application/helpers/admin/import_helper.php
Expand Up @@ -861,7 +861,8 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
//Make sure it is not set active
$insertdata['active'] = 'N';
//Set current user to be the owner
$insertdata['owner_id'] = Yii::app()->session['loginID'];
//$insertdata['owner_id'] = Yii::app()->session['loginID'];
$insertdata['owner_id'] = 1;

if (isset($insertdata['bouncetime']) && $insertdata['bouncetime'] == '') {
$insertdata['bouncetime'] = null;
Expand Down

0 comments on commit d45dcb5

Please sign in to comment.