function doOperation(&$dbHandler, $argsObj, $operation)
{
    $op = new stdClass();
    $op->role = new tlRole();
    $op->userFeedback = null;
    $op->template = 'rolesEdit.tpl';
    switch ($operation) {
        case 'doCreate':
        case 'doUpdate':
            $rights = implode("','", array_keys($argsObj->grant));
            $op->role->rights = tlRight::getAll($dbHandler, "WHERE description IN ('{$rights}')");
            $op->role->name = $argsObj->rolename;
            $op->role->description = $argsObj->notes;
            $op->role->dbID = $argsObj->roleid;
            break;
        case 'duplicate':
            $op->role = tlRole::getByID($dbHandler, $argsObj->roleid);
            $op->role->dbID = null;
            $op->role->name = generateUniqueName($op->role->name);
            break;
    }
    $result = $op->role->writeToDB($dbHandler);
    if ($result >= tl::OK) {
        $auditCfg = null;
        switch ($operation) {
            case 'doCreate':
            case 'duplicate':
                $auditCfg['msg'] = "audit_role_created";
                $auditCfg['activity'] = "CREATE";
                break;
            case 'doUpdate':
                $auditCfg['msg'] = "audit_role_saved";
                $auditCfg['activity'] = "SAVE";
                break;
        }
        logAuditEvent(TLS($auditCfg['msg'], $op->role->name), $auditCfg['activity'], $op->role->dbID, "roles");
        $op->template = null;
    } else {
        $op->userFeedback = getRoleErrorMessage($result);
    }
    return $op;
}
Beispiel #2
0
 /**
  * Inserts a testplan related role for a given user
  *
  * @param int $userID the id of the user
  * @param int $id the testplan id
  * @param int $roleID the role id
  * 
  * @return integer returns tl::OK on success, tl::ERROR else
  **/
 function addUserRole($userID, $id, $roleID)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $status = tl::ERROR;
     $sql = " /* {$debugMsg} */ INSERT INTO {$this->tables['user_testplan_roles']} (user_id,testplan_id,role_id) VALUES " . " ({$userID},{$id},{$roleID})";
     if ($this->db->exec_query($sql)) {
         $testPlan = $this->get_by_id($id);
         $role = tlRole::getByID($this->db, $roleID, tlRole::TLOBJ_O_GET_DETAIL_MINIMUM);
         $user = tlUser::getByID($this->db, $userID, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM);
         if ($user && $testPlan && $role) {
             logAuditEvent(TLS("audit_users_roles_added_testplan", $user->getDisplayName(), $testPlan['name'], $role->name), "ASSIGN", $id, "testplans");
         }
         $status = tl::OK;
     }
     return $status;
 }
Beispiel #3
0
function decodeRoleId(&$dbHandler, $roleID)
{
    $roleInfo = tlRole::getByID($dbHandler, $roleID);
    return $roleInfo->name;
}
 /**
  * Inserts a testproject related role for a given user
  *
  * @param integer $userID the id of the user
  * @param integer $tproject_id
  * @param integer $roleID the role id
  * 
  * @return integer tl::OK on success, tl::ERROR else
  **/
 function addUserRole($userID, $tproject_id, $roleID)
 {
     $query = "INSERT INTO {$this->tables['user_testproject_roles']} " . "(user_id,testproject_id,role_id) VALUES ({$userID},{$tproject_id},{$roleID})";
     if ($this->db->exec_query($query)) {
         $testProject = $this->get_by_id($tproject_id);
         $role = tlRole::getByID($this->db, $roleID, tlRole::TLOBJ_O_GET_DETAIL_MINIMUM);
         $user = tlUser::getByID($this->db, $userID, tlUser::TLOBJ_O_GET_DETAIL_MINIMUM);
         if ($user && $testProject && $role) {
             logAuditEvent(TLS("audit_users_roles_added_testproject", $user->getDisplayName(), $testProject['name'], $role->name), "ASSIGN", $tproject_id, "testprojects");
         }
         return tl::OK;
     }
     return tl::ERROR;
 }
Beispiel #5
0
$editorCfg = getWebEditorCfg('role');
require_once require_web_editor($editorCfg['type']);
testlinkInitPage($db, false, false, "checkRights");
init_global_rights_maps();
$templateCfg = templateConfiguration();
$args = init_args();
$gui = initialize_gui($editorCfg['type']);
$op = initialize_op();
$owebeditor = web_editor('notes', $args->basehref, $editorCfg);
$owebeditor->Value = getItemTemplateContents('role_template', $owebeditor->InstanceName, null);
$canManage = has_rights($db, "role_management") ? true : false;
switch ($args->doAction) {
    case 'create':
        break;
    case 'edit':
        $op->role = tlRole::getByID($db, $args->roleid);
        break;
    case 'doCreate':
    case 'doUpdate':
        if ($canManage) {
            $op = doOperation($db, $args, $args->doAction);
            $templateCfg->template = $op->template;
        }
        break;
    default:
        break;
}
$gui = complete_gui($db, $gui, $args, $op->role, $owebeditor);
$gui->userFeedback = $op->userFeedback;
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
Beispiel #6
0
 *
**/
require_once "../../config.inc.php";
require_once "common.php";
require_once "users.inc.php";
require_once "roles.inc.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
init_global_rights_maps();
$args = init_args();
$affectedUsers = null;
$doDelete = false;
$role = null;
switch ($args->doAction) {
    case 'delete':
        $role = tlRole::getByID($db, $args->roleid, tlRole::TLOBJ_O_GET_DETAIL_MINIMUM);
        if ($role) {
            $affectedUsers = $role->getAllUsersWithRole($db);
            $doDelete = sizeof($affectedUsers) == 0;
        }
        break;
    case 'confirmDelete':
        $doDelete = 1;
        break;
}
$userFeedback = null;
if ($doDelete) {
    $userFeedback = deleteRole($db, $args->roleid);
    //refresh the current user
    checkSessionValid($db);
}