HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/apklausos/application/commands/ImportSurveyCommand.php
<?php

Yii::import('application.helpers.replacements_helper', true);
Yii::import('application.helpers.expressions.em_manager_helper', true);
Yii::import('application.helpers.common_helper', true);
Yii::import('application.helpers.admin.import_helper', true);

class ImportSurveyCommand extends CConsoleCommand
{
    /**
     * @param string $filename the name of the file
     * @param string|null $baselang the base language either chosen or defaulted to null in the run method
     * @return array Import result
     */
    protected function importFile($filename, $baselang)
    {
        // TODO: Add support to customize these.
        $params = [
            "bTranslateLinkFields" => false,
            "sNewSurveyName" => null,
            "DestSurveyID" => null,
        ];
        return importSurveyFile(
            $filename,
            $params["bTranslateLinkFields"],
            $params["sNewSurveyName"],
            $params["DestSurveyID"],
            $baselang
        );
    }

    /**
     * Sample command: php application/commands/console.php importsurvey tmp/upload/youfile.lss
     *
     * @param array $args
     * @return void
     */
    public function run($args)
    {
        $source = $args[0];
        $baselang = null;
        if (strpos($args[0], ':') !== 0) {
            $split = explode(":", $args[0]);
            $source = $split[0];
            $baselang = $split[1];
        }
        $file = $source;
        $result = $this->importFile($file, $baselang);
        if (is_array($result) && isset($result['newsid'])) {
            echo $result['newsid'];
        } else {
            echo "The import has failed.";
        }
    }
}