当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLImportSurvey函数代码示例

本文整理汇总了PHP中XMLImportSurvey函数的典型用法代码示例。如果您正苦于以下问题:PHP XMLImportSurvey函数的具体用法?PHP XMLImportSurvey怎么用?PHP XMLImportSurvey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了XMLImportSurvey函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copy

 /**
  * Function responsible to import/copy a survey based on $action.
  *
  * @access public
  * @return void
  */
 public function copy()
 {
     $importsurvey = "";
     $action = Yii::app()->request->getParam('action');
     $iSurveyID = sanitize_int(Yii::app()->request->getParam('sid'));
     if ($action == "importsurvey" || $action == "copysurvey") {
         // Start the HTML
         if ($action == 'importsurvey') {
             $aData['sHeader'] = gT("Import survey data");
             $aData['sSummaryHeader'] = gT("Survey structure import summary");
             $importingfrom = "http";
             $aPathInfo = pathinfo($_FILES['the_file']['name']);
             if (isset($aPathInfo['extension'])) {
                 $sExtension = $aPathInfo['extension'];
             } else {
                 $sExtension = "";
             }
         } elseif ($action == 'copysurvey') {
             $aData['sHeader'] = gT("Copy survey");
             $aData['sSummaryHeader'] = gT("Survey copy summary");
         }
         // Start traitment and messagebox
         $aData['bFailed'] = false;
         // Put a var for continue
         if ($action == 'importsurvey') {
             $sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20) . '.' . $sExtension;
             if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
                 $aData['sErrorMessage'] = sprintf(gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir'));
                 $aData['bFailed'] = true;
             }
             if (!$aData['bFailed'] && (strtolower($sExtension) != 'csv' && strtolower($sExtension) != 'lss' && strtolower($sExtension) != 'txt' && strtolower($sExtension) != 'lsa')) {
                 $aData['sErrorMessage'] = sprintf(gT("Import failed. You specified an invalid file type '%s'."), $sExtension);
                 $aData['bFailed'] = true;
             }
         } elseif ($action == 'copysurvey') {
             $iSurveyID = sanitize_int(Yii::app()->request->getParam('copysurveylist'));
             $aExcludes = array();
             $sNewSurveyName = Yii::app()->request->getPost('copysurveyname');
             if (Yii::app()->request->getPost('copysurveyexcludequotas') == "on") {
                 $aExcludes['quotas'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludepermissions') == "on") {
                 $aExcludes['permissions'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludeanswers') == "on") {
                 $aExcludes['answers'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyresetconditions') == "on") {
                 $aExcludes['conditions'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyresetstartenddate') == "on") {
                 $aExcludes['dates'] = true;
             }
             if (!$iSurveyID) {
                 $aData['sErrorMessage'] = gT("No survey ID has been provided. Cannot copy survey");
                 $aData['bFailed'] = true;
             } elseif (!Survey::model()->findByPk($iSurveyID)) {
                 $aData['sErrorMessage'] = gT("Invalid survey ID");
                 $aData['bFailed'] = true;
             } elseif (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export')) {
                 $aData['sErrorMessage'] = gT("You don't have sufficient permissions.");
                 $aData['bFailed'] = true;
             } else {
                 Yii::app()->loadHelper('export');
                 $copysurveydata = surveyGetXMLData($iSurveyID, $aExcludes);
             }
         }
         // Now, we have the survey : start importing
         Yii::app()->loadHelper('admin/import');
         if ($action == 'importsurvey' && !$aData['bFailed']) {
             $aImportResults = importSurveyFile($sFullFilepath, isset($_POST['translinksfields']));
             if (is_null($aImportResults) || !empty($aImportResults['error'])) {
                 $aData['sErrorMessage'] = isset($aImportResults['error']) ? $aImportResults['error'] : gt("Unknow error.");
                 $aData['bFailed'] = true;
             }
         } elseif ($action == 'copysurvey' && !$aData['bFailed']) {
             $aImportResults = XMLImportSurvey('', $copysurveydata, $sNewSurveyName, sanitize_int(App()->request->getParam('copysurveyid')), isset($_POST['translinksfields']));
             if (isset($aExcludes['conditions'])) {
                 Question::model()->updateAll(array('relevance' => '1'), 'sid=' . $aImportResults['newsid']);
                 QuestionGroup::model()->updateAll(array('grelevance' => '1'), 'sid=' . $aImportResults['newsid']);
             }
             if (!isset($aExcludes['permissions'])) {
                 Permission::model()->copySurveyPermissions($iSurveyID, $aImportResults['newsid']);
             }
         } else {
             $aData['bFailed'] = true;
         }
         if ($action == 'importsurvey' && isset($sFullFilepath)) {
             unlink($sFullFilepath);
         }
         if (!$aData['bFailed']) {
             $aData['action'] = $action;
             $aData['sLink'] = $this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $aImportResults['newsid']);
             $aData['aImportResults'] = $aImportResults;
//.........这里部分代码省略.........
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:101,代码来源:surveyadmin.php

示例2: importSurveyFile

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;
    }
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:71,代码来源:import_helper.php

示例3: importSurvey

 /**
  * 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'];
 }
开发者ID:rkaldung,项目名称:LimeSurvey,代码行数:40,代码来源:lsrc.helper.php

示例4: getXMLData

    }
    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;
}
if (!$importerror) {
    $importsurvey .= "<br />\n<div class='successheader'>" . $clang->gT("Success") . "</div><br /><br />\n";
    if ($action == 'importsurvey') {
        $importsurvey .= "<strong>" . $clang->gT("Survey copy summary") . "</strong><br />\n";
    } elseif ($action == 'copysurvey') {
        $importsurvey .= "<strong>" . $clang->gT("Survey import summary") . "</strong><br />\n";
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:http_importsurvey.php

示例5: duplicate_survey

 /**
  * RPC Routine to duplicate a survey
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iSurveyXML The XML of the survey to import
  * @return int The key of the new survey created
  * */
 public function duplicate_survey($sSessionKey, $iSurveyID)
 {
     // Check sessionkey
     if (!$this->_checkSessionKey($sSessionKey)) {
         return array('status' => 'Invalid session key');
     }
     // import getSurveyList function
     Yii::app()->loadHelper('common');
     // NOTE: for one language surveys only
     $surveys = getSurveyList(TRUE, $iSurveyID);
     // set a defualt name for the new survey
     if (count($surveys) > 0) {
         $new_survey_name = $surveys[0]['surveyls_title'] . ' (copy)';
     } else {
         $new_survey_name = 'New Duplicate Survey';
     }
     // now get the actual name
     foreach ($surveys as $survey) {
         if ($survey['sid'] == $iSurveyID) {
             $new_survey_name = $survey['surveyls_title'] . ' (copy)';
         }
     }
     // you can use this to get the language code if you want
     //$sLanguageCode = getBaseLanguageFromSurveyID($iSurveyID);
     // check to make sure there isn't another survey with the same name
     foreach ($surveys as $survey) {
         if ($survey['surveyls_title'] == $new_survey_name) {
             return array('status' => 'Error: A survey with that name already exists');
         }
     }
     // export functions
     //Yii::app()->loadHelper('admin/exportresults');
     $aExcludes = array();
     // $aExcludes['quotas'] = true;
     // $aExcludes['permissions'] = true;
     // $aExcludes['answers'] = true;
     // $aExcludes['conditions'] = true;
     // $aExcludes['dates'] = true;
     if (!Survey::model()->findByPk($iSurveyID)) {
         return array('status' => 'Error: Invalid survey ID');
     } elseif (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export')) {
         return array('status' => 'No permissions');
     } else {
         Yii::app()->loadHelper('export');
         $copy_survey_data = surveyGetXMLData($iSurveyID, $aExcludes);
     }
     // Now, we have the survey lets start importing
     Yii::app()->loadHelper('admin/import');
     // XMLImportSurvey(fileName,data,newName,translateInsertansTags,convertInvalidQuestionCodes)
     $result = XMLImportSurvey('', $copy_survey_data, $new_survey_name, NULL, TRUE);
     // (might get used one day)
     // if (isset($aExcludes['conditions'])) {
     //    Question::model()->updateAll(array('relevance'=>'1'),'sid='.$aImportResults['newsid']);
     //    QuestionGroup::model()->updateAll(array('grelevance'=>'1'),'sid='.$aImportResults['newsid']);
     // }
     // if (!isset($aExcludes['permissions'])) {
     //    Permission::model()->copySurveyPermissions($iSurveyID,$aImportResults['newsid']);
     // }
     // the error is set in the XMLImportSurvey function
     if (isset($result['error'])) {
         return FALSE;
     } else {
         return TRUE;
     }
 }
开发者ID:sevenearths,项目名称:limesurvey-api-test,代码行数:73,代码来源:remotecontrol_handle.php

示例6: copy

 /**
  * Function responsible to import/copy a survey based on $action.
  *
  * @access public
  * @return void
  */
 public function copy()
 {
     $importsurvey = "";
     $action = $_POST['action'];
     @($iSurveyID = $_POST['sid']);
     if ($action == "importsurvey" || $action == "copysurvey") {
         if (@$_POST['copysurveytranslinksfields'] == "on" || @$_POST['translinksfields'] == "on") {
             $sTransLinks = true;
         }
         $clang = $this->getController()->lang;
         // Start the HTML
         if ($action == 'importsurvey') {
             $aData['sHeader'] = $clang->gT("Import survey data");
             $aData['sSummaryHeader'] = $clang->gT("Survey structure import summary");
             $importingfrom = "http";
         } elseif ($action == 'copysurvey') {
             $aData['sHeader'] = $clang->gT("Copy survey");
             $aData['sSummaryHeader'] = $clang->gT("Survey copy summary");
         }
         // Start traitment and messagebox
         $aData['bFailed'] = false;
         // Put a var for continue
         if ($action == 'importsurvey') {
             $the_full_file_path = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20) . '_' . $_FILES['the_file']['name'];
             if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path)) {
                 $aData['sErrorMessage'] = sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir'));
                 $aData['bFailed'] = true;
             } else {
                 $sFullFilepath = $the_full_file_path;
                 $aPathInfo = pathinfo($sFullFilepath);
                 if (isset($aPathInfo['extension'])) {
                     $sExtension = $aPathInfo['extension'];
                 } else {
                     $sExtension = "";
                 }
             }
             if (!$aData['bFailed'] && (strtolower($sExtension) != 'csv' && strtolower($sExtension) != 'lss' && strtolower($sExtension) != 'txt' && strtolower($sExtension) != 'lsa')) {
                 $aData['sErrorMessage'] = sprintf($clang->gT("Import failed. You specified an invalid file type '%s'."), $sExtension);
                 $aData['bFailed'] = true;
             }
         } elseif ($action == 'copysurvey') {
             $iSurveyID = sanitize_int($_POST['copysurveylist']);
             $exclude = array();
             if (get_magic_quotes_gpc()) {
                 $sNewSurveyName = stripslashes($_POST['copysurveyname']);
             } else {
                 $sNewSurveyName = Yii::app()->request->getPost('copysurveyname');
             }
             if (Yii::app()->request->getPost('copysurveyexcludequotas') == "on") {
                 $exclude['quotas'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludepermissions') == "on") {
                 $exclude['permissions'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludeanswers') == "on") {
                 $exclude['answers'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyresetconditions') == "on") {
                 $exclude['conditions'] = true;
             }
             if (!$iSurveyID) {
                 $aData['sErrorMessage'] = $clang->gT("No survey ID has been provided. Cannot copy survey");
                 $aData['bFailed'] = true;
             }
             Yii::app()->loadHelper('export');
             $copysurveydata = surveyGetXMLData($iSurveyID, $exclude);
         }
         // Now, we have the survey : start importing
         Yii::app()->loadHelper('admin/import');
         if ($action == 'importsurvey' && !$aData['bFailed']) {
             $aImportResults = importSurveyFile($sFullFilepath, isset($_POST['translinksfields']));
             if (is_null($aImportResults)) {
                 $importerror = true;
             }
         } elseif ($action == 'copysurvey' && (empty($importerror) || !$importerror)) {
             $aImportResults = XMLImportSurvey('', $copysurveydata, $sNewSurveyName);
             if (!isset($exclude['permissions'])) {
                 Survey_permissions::model()->copySurveyPermissions($iSurveyID, $aImportResults['newsid']);
             }
         } else {
             $importerror = true;
         }
         if ($action == 'importsurvey' && isset($sFullFilepath)) {
             unlink($sFullFilepath);
         }
         //            if (isset($aImportResults['error']) && $aImportResults['error']) safeDie($aImportResults['error']);
         if (!$aData['bFailed']) {
             $aData['action'] = $action;
             $aData['sLink'] = $this->getController()->createUrl('admin/survey/view/surveyid/' . $aImportResults['newsid']);
             $aData['aImportResults'] = $aImportResults;
         }
     }
     $this->_renderWrappedTemplate('survey', 'importSurvey_view', $aData);
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:100,代码来源:surveyadmin.php

示例7: copy

 /**
  * Function responsible to import/copy a survey based on $action.
  *
  * @access public
  * @return void
  */
 public function copy()
 {
     $action = Yii::app()->request->getParam('action');
     $iSurveyID = sanitize_int(Yii::app()->request->getParam('sid'));
     if ($action == "importsurvey" || $action == "copysurvey") {
         // Start the HTML
         $sExtension = "";
         if ($action == 'importsurvey') {
             $aData = array();
             $aData['sHeader'] = gT("Import survey data");
             $aData['sSummaryHeader'] = gT("Survey structure import summary");
             $aPathInfo = pathinfo($_FILES['the_file']['name']);
             if (isset($aPathInfo['extension'])) {
                 $sExtension = $aPathInfo['extension'];
             }
         } elseif ($action == 'copysurvey') {
             $aData = array();
             $aData['sHeader'] = gT("Copy survey");
             $aData['sSummaryHeader'] = gT("Survey copy summary");
         }
         // Start traitment and messagebox
         $aData['bFailed'] = false;
         // Put a var for continue
         $sFullFilepath = '';
         if ($action == 'importsurvey') {
             $sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(30) . '.' . $sExtension;
             if ($_FILES['the_file']['error'] == 1 || $_FILES['the_file']['error'] == 2) {
                 $aData['sErrorMessage'] = sprintf(gT("Sorry, this file is too large. Only files up to %01.2f MB are allowed."), getMaximumFileUploadSize() / 1024 / 1024) . '<br>';
                 $aData['bFailed'] = true;
             } elseif (!in_array(strtolower($sExtension), array('lss', 'txt', 'tsv', 'lsa'))) {
                 $aData['sErrorMessage'] = sprintf(gT("Import failed. You specified an invalid file type '%s'."), $sExtension);
                 $aData['bFailed'] = true;
             } elseif ($aData['bFailed'] || !@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
                 $aData['sErrorMessage'] = gT("An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder.");
                 $aData['bFailed'] = true;
             }
         } elseif ($action == 'copysurvey') {
             $iSurveyID = sanitize_int(Yii::app()->request->getParam('copysurveylist'));
             $aExcludes = array();
             $sNewSurveyName = Yii::app()->request->getPost('copysurveyname');
             if (Yii::app()->request->getPost('copysurveyexcludequotas') == "1") {
                 $aExcludes['quotas'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludepermissions') == "1") {
                 $aExcludes['permissions'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyexcludeanswers') == "1") {
                 $aExcludes['answers'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyresetconditions') == "1") {
                 $aExcludes['conditions'] = true;
             }
             if (Yii::app()->request->getPost('copysurveyresetstartenddate') == "1") {
                 $aExcludes['dates'] = true;
             }
             if (!$iSurveyID) {
                 $aData['sErrorMessage'] = gT("No survey ID has been provided. Cannot copy survey");
                 $aData['bFailed'] = true;
             } elseif (!Survey::model()->findByPk($iSurveyID)) {
                 $aData['sErrorMessage'] = gT("Invalid survey ID");
                 $aData['bFailed'] = true;
             } elseif (!Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export')) {
                 $aData['sErrorMessage'] = gT("We are sorry but you don't have permissions to do this.");
                 $aData['bFailed'] = true;
             } else {
                 Yii::app()->loadHelper('export');
                 $copysurveydata = surveyGetXMLData($iSurveyID, $aExcludes);
             }
         }
         // Now, we have the survey : start importing
         Yii::app()->loadHelper('admin/import');
         if ($action == 'importsurvey' && !$aData['bFailed']) {
             $aImportResults = importSurveyFile($sFullFilepath, Yii::app()->request->getPost('translinksfields') == '1');
             if (is_null($aImportResults)) {
                 $aImportResults = array('error' => gT("Unknown error while reading the file, no survey created."));
             }
         } elseif ($action == 'copysurvey' && !$aData['bFailed']) {
             $aImportResults = XMLImportSurvey('', $copysurveydata, $sNewSurveyName, sanitize_int(App()->request->getParam('copysurveyid')), Yii::app()->request->getPost('copysurveytranslinksfields') == '1');
             if (isset($aExcludes['conditions'])) {
                 Question::model()->updateAll(array('relevance' => '1'), 'sid=' . $aImportResults['newsid']);
                 QuestionGroup::model()->updateAll(array('grelevance' => '1'), 'sid=' . $aImportResults['newsid']);
             }
             if (!isset($aExcludes['permissions'])) {
                 Permission::model()->copySurveyPermissions($iSurveyID, $aImportResults['newsid']);
             }
         } else {
             $aData['bFailed'] = true;
         }
         if ($action == 'importsurvey' && isset($sFullFilepath) && file_exists($sFullFilepath)) {
             unlink($sFullFilepath);
         }
         if (!$aData['bFailed']) {
             $aData['aImportResults'] = $aImportResults;
             $aData['action'] = $action;
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:surveyadmin.php


注:本文中的XMLImportSurvey函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。