Ejemplo n.º 1
0
/**
 * @param object dbHandler reference to db handler
 *
 */
function doImport(&$dbHandler, $testproject_id)
{
    $import_msg = array('ok' => array(), 'ko' => array());
    $file_check = array('show_results' => 0, 'status_ok' => 0, 'msg' => '', 'filename' => '', 'import_msg' => $import_msg);
    $key = 'targetFilename';
    $dest = TL_TEMP_PATH . session_id() . "-import_platforms.tmp";
    $fInfo = $_FILES[$key];
    $source = isset($fInfo['tmp_name']) ? $fInfo['tmp_name'] : null;
    if ($source != 'none' && $source != '') {
        $file_check['filename'] = $fInfo['name'];
        $xml = false;
        if (move_uploaded_file($source, $dest)) {
            $xml = @simplexml_load_file($dest);
        }
        if ($xml !== FALSE) {
            $file_check['status_ok'] = 1;
            $file_check['show_results'] = 1;
            $platform_mgr = new tlPlatform($dbHandler, $testproject_id);
            $platformsOnSystem = $platform_mgr->getAllAsMap('name', 'rows');
            foreach ($xml as $platform) {
                // Check if platform with this name already exists on test Project
                // if answer is yes => update fields
                $name = trim($platform->name);
                if (isset($platformsOnSystem[$name])) {
                    $import_msg['ok'][] = sprintf(lang_get('platform_updated'), $platform->name);
                    $platform_mgr->update($platformsOnSystem[$name]['id'], $name, $platform->notes);
                } else {
                    $import_msg['ok'][] = sprintf(lang_get('platform_imported'), $platform->name);
                    $platform_mgr->create($name, $platform->notes);
                }
            }
        } else {
            $file_check['msg'] = lang_get('problems_loading_xml_content');
        }
    } else {
        $msg = getFileUploadErrorMessage($fInfo);
        $file_check = array('show_results' => 0, 'status_ok' => 0, 'msg' => $msg);
    }
    $file_check['import_msg'] = $import_msg;
    return $file_check;
}
Ejemplo n.º 2
0
 /**
  * Copy platforms
  * 
  * @param int $source_id original Test Project identificator
  * @param int $target_id new Test Project identificator
  */
 private function copy_platforms($source_id, $target_id)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $platform_mgr = new tlPlatform($this->db, $source_id);
     $old_new = null;
     $platformSet = $platform_mgr->getAll();
     if (!is_null($platformSet)) {
         $platform_mgr->setTestProjectID($target_id);
         foreach ($platformSet as $platform) {
             $op = $platform_mgr->create($platform['name'], $platform['notes']);
             $old_new[$platform['id']] = $op['id'];
         }
     }
     return $old_new;
 }