예제 #1
0
/**
* Get info about user(s) role at test plan level,
* with indication about the nature of role: inherited or assigned.
* 
* To get a user role we consider a 3 layer model:
*          layer 1 - user           <--- uplayer
*          layer 2 - test project   <--- in this fuction we are interested in this level.
*          layer 3 - test plan
 
 args : $tplan_id
        $tproject_id
        [$user_id]
 
* @return array map with effetive_role in context ($tplan_id)
          key: user_id 
          value: map with keys:
                 login                (from users table - useful for debug)
                 user_role_id         (from users table - useful for debug)
                 uplayer_role_id      user role for test project
                 uplayer_is_inherited 1 -> uplayer role is inherited 
                                      0 -> uplayer role is written in table
                 effective_role_id    user role for test plan
                 is_inherited   
                 
 @internal revisions
 20101111 - franciscom - BUGID 4006: test plan is_public                    
*/
function get_tplan_effective_role(&$db, $tplan_id, $tproject, $user_id = null, $users = null)
{
    $tplan_mgr = new testplan($db);
    $tplan = $tplan_mgr->get_by_id($tplan_id);
    unset($tplan_mgr);
    $effective_role = get_tproject_effective_role($db, $tproject, $user_id, $users);
    foreach ($effective_role as $user_id => $row) {
        $isInherited = 1;
        $effective_role[$user_id]['uplayer_role_id'] = $effective_role[$user_id]['effective_role_id'];
        $effective_role[$user_id]['uplayer_is_inherited'] = $effective_role[$user_id]['is_inherited'];
        // Manage administrator exception DO NOT ENTER HERE
        if ($row['user']->globalRoleID != TL_ROLES_ADMIN && !$tplan['is_public']) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = TL_ROLES_NO_RIGHTS;
            $effective_role[$user_id]['effective_role'] = '<no rights>';
        }
        if (isset($row['user']->tplanRoles[$tplan_id])) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = $row['user']->tplanRoles[$tplan_id]->dbID;
            $effective_role[$user_id]['effective_role'] = $row['user']->tplanRoles[$tplan_id];
        }
        $effective_role[$user_id]['is_inherited'] = $isInherited;
    }
    return $effective_role;
}
/**
 * getTestProjectEffectiveRoles
 *
 */
function getTestProjectEffectiveRoles($dbHandler, &$objMgr, &$argsObj, $users)
{
    $features = null;
    $gui_cfg = config_get('gui');
    // Accessible means user has a role on test project ?
    $opt = array('output' => 'map_of_map_full', 'order_by' => $gui_cfg->tprojects_combo_order_by);
    $testprojects = $objMgr->get_accessible_for_user($argsObj->userID, $opt);
    // We need to populate the combo box with test project where current logged user ($argsObj->userID)
    // has right enough to assign user role.
    //
    $features = array();
    $idSet = $key2loop = array_keys($testprojects);
    // $idSet = array_keys($testprojects);
    $rolesCache = null;
    foreach ($idSet as $tk) {
        // $rolesCache[$testprojects[$tk]['effective_role']][] = $tk;
        if (!isset($rolesCache[$testprojects[$tk]['effective_role']])) {
            $rolesCache[$testprojects[$tk]['effective_role']] = new tlRole($testprojects[$tk]['effective_role']);
            $rolesCache[$testprojects[$tk]['effective_role']]->readFromDB($dbHandler);
        }
    }
    foreach ($key2loop as $idx) {
        //echo '<br>Analizing TProj:' . $idx;
        $answer = $rolesCache[$testprojects[$idx]['effective_role']]->hasRight("user_role_assignment");
        //echo 'Question is: user_role_assignment - ANSWER IS:' . $answer . '<br>';
        if ($answer == false) {
            $answer = $rolesCache[$testprojects[$idx]['effective_role']]->hasRight("testproject_user_role_assignment");
            // echo 'Question is: testproject_user_role_assignment - ANSWER IS:' . $answer . '<br>';
        }
        if ($answer == true) {
            $features[$idx] = $testprojects[$idx];
        }
    }
    //new dBug($features);
    //die();
    // If have no a test project ID, try to figure out which test project to show
    // Try with session info, if failed go to first test project available.
    if (!$argsObj->featureID) {
        if ($argsObj->testprojectID) {
            $argsObj->featureID = $argsObj->testprojectID;
        } else {
            if (sizeof($features)) {
                $xx = current($features);
                $argsObj->featureID = $xx['id'];
            }
        }
    }
    // get private/public status for feature2check
    $featureIsPublic = 1;
    // $loop2do = sizeof($testprojects);
    // for($ppx=0; $ppx < $loop2do; $ppx++)
    $key2loop = array_keys($testprojects);
    foreach ($key2loop as $ppx) {
        if ($testprojects[$ppx]['id'] == $argsObj->featureID) {
            $featureIsPublic = $testprojects[$ppx]['is_public'];
            break;
        }
    }
    foreach ($users as &$user) {
        $user->readTestProjectRoles($dbHandler, $argsObj->featureID);
    }
    $effectiveRoles = get_tproject_effective_role($dbHandler, array('id' => $argsObj->featureID, 'is_public' => $featureIsPublic), null, $users);
    return array($effectiveRoles, $features, $argsObj->featureID);
}
예제 #3
0
/**
* Get info about user(s) role at test plan level,
* with indication about the nature of role: inherited or assigned.
* 
* To get a user role we consider a 3 layer model:
*          layer 1 - user           <--- uplayer
*          layer 2 - test project   <--- in this fuction we are interested in this level.
*          layer 3 - test plan
 
 args : $tplan_id
        $tproject_id
        [$user_id]
 
* @return array map with effetive_role in context ($tplan_id)
          key: user_id 
          value: map with keys:
                 login                (from users table - useful for debug)
                 user_role_id         (from users table - useful for debug)
                 uplayer_role_id      user role for test project
                 uplayer_is_inherited 1 -> uplayer role is inherited 
                                      0 -> uplayer role is written in table
                 effective_role_id    user role for test plan
                 is_inherited       
*/
function get_tplan_effective_role(&$db, $tplan_id, $tproject, $user_id = null, $users = null)
{
    // the "1" in parameters caused the user menus to only display one user instead of all
    //$effective_role = get_tproject_effective_role($db,$tproject,1,$user_id,$users);
    $effective_role = get_tproject_effective_role($db, $tproject, $user_id, $users);
    foreach ($effective_role as $user_id => $row) {
        $isInherited = 1;
        $effective_role[$user_id]['uplayer_role_id'] = $effective_role[$user_id]['effective_role_id'];
        $effective_role[$user_id]['uplayer_is_inherited'] = $effective_role[$user_id]['is_inherited'];
        if (isset($row['user']->tplanRoles[$tplan_id])) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = $row['user']->tplanRoles[$tplan_id]->dbID;
            $effective_role[$user_id]['effective_role'] = $row['user']->tplanRoles[$tplan_id];
        }
        $effective_role[$user_id]['is_inherited'] = $isInherited;
    }
    return $effective_role;
}
예제 #4
0
/**
* Get info about user(s) role at test plan level,
* with indication about the nature of role: inherited or assigned.
* 
* To get a user role we consider a 3 layer model:
*          layer 1 - user           <--- uplayer
*          layer 2 - test project   <--- in this fuction we are interested in this level.
*          layer 3 - test plan
 
 args : $tplan_id
        $tproject_id
        [$user_id]
 
* @return array map with effetive_role in context ($tplan_id)
          key: user_id 
          value: map with keys:
                 login                (from users table - useful for debug)
                 user_role_id         (from users table - useful for debug)
                 uplayer_role_id      user role for test project
                 uplayer_is_inherited 1 -> uplayer role is inherited 
                                      0 -> uplayer role is written in table
                 effective_role_id    user role for test plan
                 is_inherited       
*/
function get_tplan_effective_role(&$db, $tplan_id, $tproject_id, $user_id = null, $users = null)
{
    $effective_role = get_tproject_effective_role($db, $tproject_id, $user_id, $users);
    foreach ($effective_role as $user_id => $row) {
        $isInherited = 1;
        $effective_role[$user_id]['uplayer_role_id'] = $effective_role[$user_id]['effective_role_id'];
        $effective_role[$user_id]['uplayer_is_inherited'] = $effective_role[$user_id]['is_inherited'];
        if (isset($row['user']->tplanRoles[$tplan_id])) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = $row['user']->tplanRoles[$tplan_id]->dbID;
            $effective_role[$user_id]['effective_role'] = $row['user']->tplanRoles[$tplan_id];
        }
        $effective_role[$user_id]['is_inherited'] = $isInherited;
    }
    return $effective_role;
}
예제 #5
0
/**
 * getTestProjectEffectiveRoles
 *
 */
function getTestProjectEffectiveRoles($dbHandler, &$objMgr, &$argsObj, $users)
{
    $features = null;
    $gui_cfg = config_get('gui');
    $order_by = $gui_cfg->tprojects_combo_order_by;
    // Accessible means user has a role on test project
    $testprojects = $objMgr->get_accessible_for_user($argsObj->userID, 'array_of_map', $order_by);
    // Another more restrictive filter has to be applied, related to what we want to do
    // user has to be right to manage roles on test project
    if ($argsObj->user->hasRight($dbHandler, "mgt_users")) {
        $features = $testprojects;
    } else {
        $loop2do = sizeof($testprojects);
        for ($idx = 0; $idx < $loop2do; $idx++) {
            $answer = $argsObj->user->hasRight($dbHandler, "testproject_user_role_assignment", $testprojects[$idx]['id'], -1);
            if ($answer == "yes") {
                $features[] = $testprojects[$idx];
            }
        }
    }
    // If have no a test project ID, try to figure out which test project to show
    // Try with session info, if failed go to first test project available.
    if (!$argsObj->featureID) {
        if ($argsObj->testprojectID) {
            $argsObj->featureID = $argsObj->testprojectID;
        } else {
            if (sizeof($features)) {
                $argsObj->featureID = $features[0]['id'];
            }
        }
    }
    // get private/public status for feature2check
    $loop2do = sizeof($testprojects);
    $featureIsPublic = 1;
    for ($ppx = 0; $ppx < $loop2do; $ppx++) {
        if ($testprojects[$ppx]['id'] == $argsObj->featureID) {
            $featureIsPublic = $testprojects[$ppx]['is_public'];
            break;
        }
    }
    foreach ($users as &$user) {
        $user->readTestProjectRoles($dbHandler, $argsObj->featureID);
    }
    $effectiveRoles = get_tproject_effective_role($dbHandler, array('id' => $argsObj->featureID, 'is_public' => $featureIsPublic), null, $users);
    return array($effectiveRoles, $features, $argsObj->featureID);
}