require_once 'configCheck.php'; testlinkInitPage($db); $template_dir = 'project/'; $can_manage_tprojects = $_SESSION['currentUser']->haRight($db, 'mgt_modify_product'); // make sure the user has rights to manage test projects if ($can_manage_tprojects) { if ($_POST) { foreach ($_POST as $testPlan => $testProject) { if ($testProject != "none") { echo "<br />changing test plan {$testPlan} to go with test project {$testProject}"; changeTestProjectForTestPlan($db, $testPlan, $testProject); } } echo "<hr>"; } $testPlans = getTestPlansWithoutProject($db); $testPlansCount = count($testPlans); $tpObj = new testproject($db); $testProjects = $tpObj->get_all(); $smarty = new TLSmarty(); $smarty->assign('testPlans', $testPlans); $smarty->assign('testProjects', $testProjects); $smarty->assign('count', $testPlansCount); $smarty->display($template_dir . 'fix_tplans.tpl'); } else { echo "<p>" . lang_get('fix_tplans_no_rights') . "</p>"; } function changeTestProjectForTestPlan(&$db, $testPlan, $testProject) { $query = "UPDATE testplans SET testproject_id={$testProject} WHERE id={$testPlan}"; $db->exec_query($query);
/** * checks if the install dir is present * * @return msg returns if there are any test plans without a test project * @author Asiel Brumfield **/ function checkForTestPlansWithoutTestProjects(&$db) { $msg = ""; if (count(getTestPlansWithoutProject($db))) { $msg = "You have Test Plans that are not associated with Test Projects!"; if (isset($_SESSION['basehref'])) { $url = $_SESSION['basehref'] . "/lib/project/fix_tplans.php"; $msg .= " <a style=\"color:red\" href=\"{$url}\">Fix This</a>"; } } return $msg; }