/** * doExecuteImport * */ function doExecuteImport($fileName, &$argsObj, &$reqSpecMgr, &$reqMgr) { $retval = new stdClass(); $retval->items = array(); $retval->msg = ''; $retval->file_check = array('status_ok' => 1, 'msg' => 'ok'); $retval->refreshTree = true; $context = new stdClass(); $context->tproject_id = $argsObj->tproject_id; $context->req_spec_id = $argsObj->req_spec_id; $context->user_id = $argsObj->user_id; $context->importType = $argsObj->importType; $context->scope = $argsObj->scope; $opts = array(); $opts['skipFrozenReq'] = $argsObj->skip_frozen_req ? true : false; $opts['hitCriteria'] = $argsObj->hitCriteria; $opts['actionOnHit'] = $argsObj->actionOnHit; // manage file upload process $file_size_limit = config_get('import_file_max_size_bytes'); $source = isset($_FILES['uploadedFile']['tmp_name']) ? $_FILES['uploadedFile']['tmp_name'] : null; $check = checkUploadOperation($_FILES, $file_size_limit); if ($check['status_ok']) { if (move_uploaded_file($source, $fileName)) { if (strcasecmp($argsObj->importType, 'XML') == 0) { $retval->file_check['status_ok'] = !(($xml = simplexml_load_file($fileName)) === FALSE); } } } else { $retval->file_check = array('status_ok' => 0, 'msg' => $check['msg']); } // ---------------------------------------------------------------------------------------------- if ($retval->file_check['status_ok']) { $import_ok = true; if ($argsObj->importType == 'XML') { try { $retval->items = doReqImportFromXML($reqSpecMgr, $reqMgr, $xml, $context, $opts); } catch (Exception $e) { $import_ok = false; $retval->items = null; $retval->msg = $e->getMessage(); $retval->refreshTree = false; } } else { $retval->items = doReqImportOther($reqMgr, $fileName, $context, $opts); } unlink($fileName); if ($import_ok) { $retval->msg = lang_get('req_import_finished'); } } return $retval; }
require_once 'xml.inc.php'; testlinkInitPage($db); $templateCfg = templateConfiguration(); $pcheck_fn = null; $tree_mgr = new tree($db); $args = init_args($tree_mgr); $gui = initializeGui($args); new dBug($_REQUEST); new dBug($args); $obj_mgr = new $gui->class($db); new dBug($obj_mgr); $gui->container_name = ''; if ($args->do_upload) { // check the uploaded file $source = isset($_FILES['uploadedFile']['tmp_name']) ? $_FILES['uploadedFile']['tmp_name'] : null; $gui->file_check = checkUploadOperation($_FILES, $gui->importLimitBytes); if ($gui->file_check['status_ok']) { if (move_uploaded_file($source, $args->supportFile)) { tLog('Renamed uploaded file: ' . $source); switch ($args->importType) { case 'XML': $pcheck_fn = "check_xml_file"; $pimport_fn = "importTestCaseDataFromXML"; break; } if (!is_null($pcheck_fn)) { $gui->file_check = $pcheck_fn($args->supportFile, $args->itemToImport); } } if ($gui->file_check['status_ok'] && $pimport_fn) { tLog('Check is Ok.');