Beispiel #1
0
 /**
  * function to import surveys
  *
  * @param  $iVid - desired survey id
  * @param $importFile - name of the file to import in core(survey) dir
  * @return boolean
  */
 function importSurvey($iVid, $importFile)
 {
     global $connect;
     global $dbprefix;
     global $clang;
     include "lsrc.config.php";
     $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
     $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", OK ");
     // HINT FOR IMPORTERS: go to Line 714 to manipulate the Survey, while it's imported
     $the_full_file_path = $coreDir . $importFile;
     $this->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ",the_full_file_path ='{$the_full_file_path}' OK ");
     include "../import_functions.php";
     include "../admin_functions.php";
     if (!isset($copyfunction)) {
         $sFullFilepath = $the_full_file_path;
         $aPathInfo = pathinfo($sFullFilepath);
         $sExtension = $aPathInfo['extension'];
     }
     if (isset($sExtension) && strtolower($sExtension) == 'csv') {
         $aImportResults = CSVImportSurvey($sFullFilepath, $iVid);
     } elseif (isset($sExtension) && strtolower($sExtension) == 'lss') {
         $aImportResults = XMLImportSurvey($sFullFilepath, NULL, NULL, $iVid);
     } elseif (isset($copyfunction)) {
         $aImportResults = XMLImportSurvey('', $copysurveydata, $sNewSurveyName, $iVid);
     }
     //CANNOT BE USED BY LSRC RIGHT NOW
     // Translate INSERTANS codes if chosen
     //        if (isset($aImportResults['fieldnames']) && $sTransLinks === true)
     //        {
     //            transInsertAns($aImportResults['newsid'],$aImportResults['oldsid'],$aImportResults['fieldnames']);
     //        }
     return $aImportResults['newsid'];
 }
Beispiel #2
0
function importSurveyFile($sFullFilepath, $bTranslateLinksFields, $sNewSurveyName = NULL, $DestSurveyID = NULL)
{
    $aPathInfo = pathinfo($sFullFilepath);
    if (isset($aPathInfo['extension'])) {
        $sExtension = $aPathInfo['extension'];
    } else {
        $sExtension = "";
    }
    if (isset($sExtension) && strtolower($sExtension) == 'csv') {
        return CSVImportSurvey($sFullFilepath, $DestSurveyID, $bTranslateLinksFields);
    } elseif (isset($sExtension) && strtolower($sExtension) == 'lss') {
        return XMLImportSurvey($sFullFilepath, null, $sNewSurveyName, $DestSurveyID, $bTranslateLinksFields);
    } elseif (isset($sExtension) && strtolower($sExtension) == 'txt') {
        return TSVImportSurvey($sFullFilepath);
    } elseif (isset($sExtension) && strtolower($sExtension) == 'lsa') {
        Yii::import("application.libraries.admin.pclzip.pclzip", true);
        $pclzip = new PclZip(array('p_zipname' => $sFullFilepath));
        $aFiles = $pclzip->listContent();
        if ($pclzip->extract(PCLZIP_OPT_PATH, Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR, PCLZIP_OPT_BY_EREG, '/(lss|lsr|lsi|lst)$/') == 0) {
            unset($pclzip);
        }
        // Step 1 - import the LSS file and activate the survey
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lss') {
                //Import the LSS file
                $aImportResults = XMLImportSurvey(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], null, null, null, true);
                // Activate the survey
                Yii::app()->loadHelper("admin/activate");
                $activateoutput = activateSurvey($aImportResults['newsid']);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 2 - import the responses file
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lsr') {
                //Import the LSS file
                $aResponseImportResults = XMLImportResponses(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid'], $aImportResults['FieldReMap']);
                $aImportResults = array_merge($aResponseImportResults, $aImportResults);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 3 - import the tokens file - if exists
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lst') {
                Yii::app()->loadHelper("admin/token");
                if (createTokenTable($aImportResults['newsid'])) {
                    $aTokenCreateResults = array('tokentablecreated' => true);
                }
                $aImportResults = array_merge($aTokenCreateResults, $aImportResults);
                $aTokenImportResults = XMLImportTokens(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid']);
                $aImportResults = array_merge($aTokenImportResults, $aImportResults);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 4 - import the timings file - if exists
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lsi' && tableExists("survey_{$aImportResults['newsid']}_timings")) {
                $aTimingsImportResults = XMLImportTimings(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid'], $aImportResults['FieldReMap']);
                $aImportResults = array_merge($aTimingsImportResults, $aImportResults);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        return $aImportResults;
    } else {
        return null;
    }
}
Beispiel #3
0
        $exclude['quotas'] = true;
    }
    if (isset($_POST['copysurveyexcludeanswers']) && $_POST['copysurveyexcludeanswers'] == "on") {
        $exclude['answers'] = true;
    }
    if (isset($_POST['copysurveyresetconditions']) && $_POST['copysurveyresetconditions'] == "on") {
        $exclude['conditions'] = true;
    }
    include "export_structure_xml.php";
    $copysurveydata = getXMLData($exclude);
}
// Now, we have the survey : start importing
require_once 'import_functions.php';
if ($action == 'importsurvey' && !$importerror) {
    if (isset($sExtension) && strtolower($sExtension) == 'csv') {
        $aImportResults = CSVImportSurvey($sFullFilepath);
    } elseif (isset($sExtension) && strtolower($sExtension) == 'lss') {
        $aImportResults = XMLImportSurvey($sFullFilepath, null, null, null, isset($_POST['translinksfields']));
    } else {
        $importerror = true;
    }
} elseif ($action == 'copysurvey' && !$importerror) {
    $aImportResults = XMLImportSurvey('', $copysurveydata, $sNewSurveyName);
} else {
    $importerror = true;
}
if (isset($aImportResults['error']) && $aImportResults['error'] != false) {
    $importsurvey .= "<div class='warningheader'>" . $clang->gT("Error") . "</div><br />\n";
    $importsurvey .= $aImportResults['error'] . "<br /><br />\n";
    $importsurvey .= "<input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_self')\" />\n";
    $importerror = true;