function migrate_cc_specs(&$source_db, &$target_db, &$items, &$old_new)
{
    $mgtcom_keys = array('intro' => 'introduction', 'scope' => 'scope', 'ref' => 'references', 'method' => 'methodology', 'lim' => 'limitations');
    $mgtcat_keys = array('objective' => 'objective', 'config' => 'configuration', 'data' => 'data', 'tools' => 'tools');
    $tproject_mgr = new testproject($target_db);
    $ts_mgr = new testsuite($target_db);
    $tree_mgr = new tree($target_db);
    foreach ($items as $prod_id => $pd) {
        $old_new['product'][$prod_id] = @$tproject_mgr->create($pd['name'], $pd['color'], $pd['option_reqs'], EMPTY_NOTES, $pd['active']);
        echo "<pre><font color='blue'>Product {$pd['name']} has became a test project!</font></pre>";
        flush();
        $tproject_id = $old_new['product'][$prod_id];
        $sql = "SELECT * FROM mgtcomponent WHERE prodid={$prod_id}";
        $comp = $source_db->fetchRowsIntoMap($sql, 'id');
        // for change_order_bulk($hash_node_id, $hash_node_order)
        // $hash_node_id=array(10=>10, 23=>23, 30=>30);
        // $hash_node_order=array(10=>3, 23=>1, 30=>2);
        // $hash_node_id=array();
        // $hash_node_order=array();
        // 20071021 - francisco.mancardi@gruppotesi.com
        //
        // $hash_order_node_order=array(3=>10, 1=>23, 2=>30);
        // means:  node_id: 10 order:3
        //         node_id: 23 order:1
        //         node_id: 30 order:2
        $hash_order_node_id = array();
        if (count($comp) > 0) {
            foreach ($comp as $coid => $cod) {
                $details = '';
                foreach ($mgtcom_keys as $key => $val) {
                    $details .= $val . ": <br>" . $cod[$key] . "<p>";
                }
                $ret = $ts_mgr->create($tproject_id, $cod['name'], $details);
                if ($ret['status_ok']) {
                    echo "<pre>Component " . htmlentities($cod['name']) . " Migrated<br></pre>";
                    flush();
                    $mgtcomp_id = $ret['id'];
                    $old_new['mgtcomp'][$coid] = $mgtcomp_id;
                }
                // ----------------------------------------------------------------------------------
                $sql = "SELECT * FROM mgtcategory WHERE compid={$coid}";
                $cat = $source_db->fetchRowsIntoMap($sql, 'id');
                if (count($cat) > 0) {
                    foreach ($cat as $caid => $cad) {
                        // ----------------------------------------------------------------------------------
                        $details = '';
                        foreach ($mgtcat_keys as $key => $val) {
                            $details .= $val . ": <br>" . $cad[$key] . "<p>";
                        }
                        // ----------------------------------------------------------------------------------
                        $ret = $ts_mgr->create($mgtcomp_id, $cad['name'], $details);
                        if ($ret['status_ok']) {
                            echo "<pre>    Category " . htmlentities($cad['name']) . " Migrated<br></pre>";
                            flush();
                            $mgtcat_id = $ret['id'];
                            $old_new['mgtcat'][$caid] = $mgtcat_id;
                            if ($cad['CATorder'] != 0) {
                                // 20071021 - franciscom
                                // $hash_node_id[$mgtcat_id]=$mgtcat_id;
                                // $hash_node_order[$mgtcat_id]=$cad['CATorder'];
                                $node_id = $mgtcat_id;
                                $node_order = $cad['CATorder'];
                                $hash_order_node_id[$node_order] = $node_id;
                            }
                        }
                        // ----------------------------------------------------------------------------------
                    }
                }
            }
            // 20060725 - franciscom
            // $tree_mgr->change_order_bulk($hash_node_id, $hash_node_order) ;
            $tree_mgr->change_order_bulk($hash_order_node_id);
        }
    }
}
Пример #2
0
*   rev: 20080605 - franciscom
*        
*/
require_once '../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
// check if this is really needed
$exclude_node_types = array('testplan' => 1, 'requirement' => 1, 'requirement_spec' => 1);
$args = init_args();
$treeMgr = new tree($db);
switch ($args->doAction) {
    case 'changeParent':
        $treeMgr->change_parent($args->nodeid, $args->newparentid);
        break;
    case 'doReorder':
        $dummy = explode(',', $args->nodelist);
        $treeMgr->change_order_bulk($dummy);
        break;
}
function init_args()
{
    $args = new stdClass();
    $key2loop = array('nodeid', 'newparentid', 'doAction', 'top_or_bottom', 'nodeorder', 'nodelist');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : null;
    }
    return $args;
}
?>