Beispiel #1
0
        // else
        //    need to set test plan on session
        //
        $index = 0;
        $testPlanFound = 0;
        $loop2do = count($testPlanSet);
        for ($idx = 0; $idx < $loop2do; $idx++) {
            if ($testPlanSet[$idx]['id'] == $tplanID) {
                $testPlanFound = 1;
                $index = $idx;
                $break;
            }
        }
        if ($testPlanFound == 0) {
            $tplanID = $testPlanSet[0]['id'];
            setSessionTestPlan($testPlanSet[0]);
        }
        $testPlanSet[$index]['selected'] = 1;
    }
}
if ($gui->tprojectID && isset($args->user->tprojectRoles[$gui->tprojectID])) {
    // test project specific role applied
    $role = $args->user->tprojectRoles[$gui->tprojectID];
    $testprojectRole = $role->getDisplayName();
} else {
    // general role applied
    $testprojectRole = $args->user->globalRole->getDisplayName();
}
$gui->whoami = $args->user->getDisplayName() . ' ' . $tlCfg->gui->role_separator_open . $testprojectRole . $tlCfg->gui->role_separator_close;
// only when the user has changed project using the combo the _GET has this key.
// Use this clue to launch a refresh of other frames present on the screen
    //    need to set test plan on session
    //
    $index = 0;
    $found = 0;
    $loop2do = count($arrPlans);
    for ($idx = 0; $idx < $loop2do; $idx++) {
        if ($arrPlans[$idx]['id'] == $testplanID) {
            $found = 1;
            $index = $idx;
            $break;
        }
    }
    if ($found == 0) {
        // update test plan id
        $testplanID = $arrPlans[0]['id'];
        setSessionTestPlan($arrPlans[0]);
    }
    $arrPlans[$index]['selected'] = 1;
}
$gui->testplanRole = null;
if ($testplanID && isset($currentUser->tplanRoles[$testplanID])) {
    $role = $currentUser->tplanRoles[$testplanID];
    $gui->testplanRole = $tlCfg->gui->role_separator_open . $role->getDisplayName() . $tlCfg->gui->role_separator_close;
}
$rights2check = array('testplan_execute', 'testplan_create_build', 'testplan_metrics', 'testplan_planning', 'testplan_user_role_assignment', 'mgt_testplan_create', 'cfield_view', 'cfield_management', 'testplan_milestone_overview', 'exec_testcases_assigned_to_me', 'testplan_add_remove_platforms', 'testplan_update_linked_testcase_versions', 'testplan_set_urgent_testcases', 'testplan_show_testcases_newest_versions');
foreach ($rights2check as $key => $the_right) {
    $gui->grants[$the_right] = $userIsBlindFolded ? 'no' : $currentUser->hasRight($db, $the_right, $testprojectID, $testplanID);
}
$gui->grants['tproject_user_role_assignment'] = "no";
if ($currentUser->hasRight($db, "testproject_user_role_assignment", $testprojectID, -1) == "yes" || $currentUser->hasRight($db, "user_role_assignment", null, -1) == "yes") {
    $gui->grants['tproject_user_role_assignment'] = "yes";
Beispiel #3
0
/**
 * Update Project and Test Plan data on Project change or startup
 * Data are stored in $_SESSION array
 * 
 * If we receive TestPlan ID in the _SESSION then do some checks and if everything OK
 * Update this value at Session Level, to set it available in other pieces of the application
 * 
 * @param integer $db DB connection identifier
 * @param array $hash_user_sel input data for the page ($_REQUEST)
 * 
 * @uses initMenu() 
 * @internal Revisions:
 * 	20091111 - havlatm - menu generation added, name changed (from upd_session_tplan_tproject)
 *	20090726 - franciscom - getAccessibleTestPlans() now is method on user class
 **/
function initProject(&$db, $hash_user_sel)
{
    $tproject = new testproject($db);
    $user_sel = array("tplan_id" => 0, "tproject_id" => 0);
    $user_sel["tproject_id"] = isset($hash_user_sel['testproject']) ? intval($hash_user_sel['testproject']) : 0;
    $user_sel["tplan_id"] = isset($hash_user_sel['testplan']) ? intval($hash_user_sel['testplan']) : 0;
    $tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    // test project is Test Plan container, then we start checking the container
    if ($user_sel["tproject_id"] != 0) {
        $tproject_id = $user_sel["tproject_id"];
    }
    // We need to do checks before updating the SESSION to cover the case that not defined but exists
    if (!$tproject_id) {
        $all_tprojects = $tproject->get_all();
        if ($all_tprojects) {
            $tproject_data = $all_tprojects[0];
            $tproject_id = $tproject_data['id'];
        }
    }
    $tproject->setSessionProject($tproject_id);
    // set a Test Plan
    // Refresh test project id after call to setSessionProject
    $tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $tplan_id = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : null;
    // Now we need to validate the TestPlan
    // dolezalz, havlatm: added remember the last selection by cookie
    $cookieName = "TL_user{$_SESSION['userID']}_proj{$tproject_id}_testPlanId";
    if ($user_sel["tplan_id"] != 0) {
        $tplan_id = $user_sel["tplan_id"];
        setcookie($cookieName, $tplan_id, time() + 60 * 60 * 24 * 90, '/');
    } elseif (isset($_COOKIE[$cookieName])) {
        $tplan_id = intval($_COOKIE[$cookieName]);
    }
    // check if the specific combination of testprojectid and testplanid is valid
    $tplan_data = $_SESSION['currentUser']->getAccessibleTestPlans($db, $tproject_id, $tplan_id);
    if (is_null($tplan_data)) {
        // Need to get first accessible test plan for user, if any exists.
        $tplan_data = $_SESSION['currentUser']->getAccessibleTestPlans($db, $tproject_id);
    }
    if (!is_null($tplan_data)) {
        $tplan_data = $tplan_data[0];
        setSessionTestPlan($tplan_data);
    }
    // initialize structure of top menu for the user and the project
    initTopMenu($db);
}
 /**
  * 
  * 
  */
 private function init_setting_testplan()
 {
     if (is_null($this->testplan_mgr)) {
         $this->testplan_mgr = new testplan($this->db);
     }
     $key = 'setting_testplan';
     $testplans = $this->user->getAccessibleTestPlans($this->db, $this->args->testproject_id);
     if (isset($_SESSION['testplanID']) && $_SESSION['testplanID'] != $this->args->{$key}) {
         // testplan was changed, we need to reset all filters
         // --> they were chosen for another testplan, not this one!
         $this->args->reset_filters = true;
         // check if user is allowed to set chosen testplan before changing
         foreach ($testplans as $plan) {
             if ($plan['id'] == $this->args->{$key}) {
                 setSessionTestPlan($plan);
             }
         }
     }
     // now load info from session
     $info = $this->testplan_mgr->get_by_id($_SESSION['testplanID']);
     $this->args->testplan_name = $info['name'];
     $this->args->testplan_id = $info['id'];
     $this->args->{$key} = $info['id'];
     $this->settings[$key]['selected'] = $info['id'];
     // Final filtering based on mode:
     // Now get all selectable testplans for the user to display.
     // For execution:
     // For assign test case execution feature:
     //     don't take testplans into selection which have no (active/open) builds!
     //
     // For plan add mode:
     //     add every plan no matter if he has builds or not.
     foreach ($testplans as $plan) {
         $add_plan = $this->mode == 'plan_add_mode' || $this->mode == 'plan_mode' && $this->args->feature != 'tc_exec_assignment';
         if (!$add_plan) {
             $builds = $this->testplan_mgr->get_builds($plan['id'], testplan::GET_ACTIVE_BUILD, testplan::GET_OPEN_BUILD);
             $add_plan = is_array($builds) && count($builds);
         }
         if ($add_plan) {
             $this->settings[$key]['items'][$plan['id']] = $plan['name'];
         }
     }
 }