Example #1
0
$var_id = $_GET['varid'];
$suite_id = $_GET['suiteid'];
$all = $_GET['all'];
$verify = isset($_GET['verify']) ? $_GET['verify'] : 0;
$devices = $platform_mgr->getVarDevices($var_id, $suite_id);
$a = count($devices[0]);
echo "<p align='center'>共有<span style='color:red'>{$a}</span>款设备:<b>{$devices['all']}</b></p>";
if ($a == 0) {
    echo "<p align='center'><a href='viewVar.php?var_id={$var_id}&suite_id={$suite_id}'>返     回</a></p>";
} else {
    echo "<form name='form1' action='/lib/dcnVars/assign2AllPlan_delete.php?varid={$var_id}&suiteid={$suite_id}&all={$all}' method='post'>";
    echo "<table align='center'><tbody>";
    foreach ($devices[0] as $device) {
        $tplans = $platform_mgr->getDeviceTplan($device['id'], $all);
        foreach ($tplans[0] as $nn => $tplan) {
            $needdelete[$device['id'] . '-' . $tplan['id']] = $platform_mgr->modifyTplanCasesFromVar($tplan['id'], $device['id'], $var_id, $suite_id, $args->login_username, 'add');
            if ($needdelete[$device['id'] . '-' . $tplan['id']] != null) {
                echo "<tr><td align='center'>{$tplan['name']}-{$device['name']}:<input type='checkbox' id='{$tplan['id']}-{$device['id']}' name='{$tplan['id']}-{$device['id']}'></input></td></tr>";
            }
        }
    }
    $allneed = 0;
    foreach ($needdelete as $tt) {
        if ($tt != null) {
            $allneed++;
        }
    }
    if ($allneed != 0) {
        echo "<tr><td align='center'><input type='submit' value='确认删除以上勾选的 计划-设备 下的测试例'></input></td></tr>";
        echo "</tbody></table></form>";
        echo "<p align='center'><a href='viewVar.php?var_id={$var_id}&suite_id={$suite_id}'>不删除测试例返 回</a></p>";
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$args = init_args();
$platform_mgr = new tlPlatform($db, $args->testproject_id);
$var_id = $_GET['varid'];
$suite_id = $_GET['suiteid'];
$all = $_GET['all'];
$verify = isset($_GET['verify']) ? $_GET['verify'] : 0;
$needdelete_tplan_device = array_keys($_POST);
$devices = $platform_mgr->getVarDevices($var_id, $suite_id);
foreach ($devices[0] as $device) {
    $tplans = $platform_mgr->getDeviceTplan($device['id'], $all);
    foreach ($tplans[0] as $tplan) {
        if (in_array($tplan['id'] . '-' . $device['id'], $needdelete_tplan_device)) {
            $platform_mgr->modifyTplanCasesFromVar($tplan['id'], $device['id'], $var_id, $suite_id, $args->login_username, 'delete');
        }
    }
}
echo "<script> {window.alert('处理完毕!');location.href='/lib/dcnVars/viewVar.php?var_id={$var_id}&suite_id={$suite_id}'} </script>";
function init_args()
{
    $args = new stdClass();
    $args->testproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->currentUser = $_SESSION['currentUser'];
    $args->login_username = $_SESSION['currentUser']->getDisplayName();
    return $args;
}
function checkRights(&$db, &$user)
{
    return True;