Beispiel #1
0
function doUpdate($argsObj, &$tprojectMgr, $sessionTprojectID)
{
    $key2get = array('status_ok', 'msg');
    $op = new stdClass();
    $op->ui = new stdClass();
    $op->status_ok = 0;
    $op->msg = '';
    $op->template = null;
    $op->reloadType = 'none';
    $oldObjData = $tprojectMgr->get_by_id($argsObj->tprojectID);
    $op->oldName = $oldObjData['name'];
    $check_op = crossChecks($argsObj, $tprojectMgr);
    foreach ($key2get as $key) {
        $op->{$key} = $check_op[$key];
    }
    if ($op->status_ok) {
        $options = prepareOptions($argsObj);
        if ($tprojectMgr->update($argsObj->tprojectID, trim($argsObj->tprojectName), $argsObj->color, $argsObj->notes, $options, $argsObj->active, $argsObj->tcasePrefix, $argsObj->is_public)) {
            $op->msg = '';
            $tprojectMgr->activate($argsObj->tprojectID, $argsObj->active);
            $tprojectMgr->setIssueTrackerEnabled($argsObj->tprojectID, $argsObj->issue_tracker_enabled);
            $itMgr = new tlIssueTracker($tprojectMgr->db);
            if ($doLink = $argsObj->issue_tracker_id > 0) {
                $itMgr->link($argsObj->issue_tracker_id, $argsObj->tprojectID);
            } else {
                $issueT = $itMgr->getLinkedTo($argsObj->tprojectID);
                if (!is_null($issueT)) {
                    $itMgr->unlink($issueT['issuetracker_id'], $issueT['testproject_id']);
                }
            }
            $tprojectMgr->setReqMgrIntegrationEnabled($argsObj->tprojectID, $argsObj->reqmgr_integration_enabled);
            $mgr = new tlReqMgrSystem($tprojectMgr->db);
            if ($doLink = $argsObj->reqmgrsystem_id > 0) {
                $mgr->link($argsObj->reqmgrsystem_id, $argsObj->tprojectID);
            } else {
                $et = $mgr->getLinkedTo($argsObj->tprojectID);
                if (!is_null($et)) {
                    $mgr->unlink($et['reqmgrsystem_id'], $et['testproject_id']);
                }
            }
            if (!$argsObj->is_public) {
                // does user have an SPECIFIC role on Test Project ?
                // if answer is yes => do nothing
                if (!tlUser::hasRoleOnTestProject($tprojectMgr->db, $argsObj->userID, $argsObj->tprojectID)) {
                    $tprojectMgr->addUserRole($argsObj->userID, $argsObj->tprojectID, $argsObj->user->globalRole->dbID);
                }
            }
            $event = new stdClass();
            $event->message = TLS("audit_testproject_saved", $argsObj->tprojectName);
            $event->logLevel = "AUDIT";
            $event->source = "GUI";
            $event->objectID = $argsObj->tprojectID;
            $event->objectType = "testprojects";
            $event->code = "UPDATE";
            logEvent($event);
        } else {
            $op->status_ok = 0;
        }
    }
    if ($op->status_ok) {
        if ($sessionTprojectID == $argsObj->tprojectID) {
            $op->reloadType = 'reloadNavBar';
        }
    } else {
        $op->ui->doActionValue = 'doUpdate';
        $op->ui->buttonValue = lang_get('btn_save');
        $op->ui->caption = sprintf(lang_get('caption_edit_tproject'), $op->oldName);
    }
    return $op;
}