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; }
/** * */ function getIssueTracker(&$dbHandler, $argsObj, &$guiObj) { $its = null; $tprojectMgr = new testproject($dbHandler); $info = $tprojectMgr->get_by_id($argsObj->tproject_id); $guiObj->issueTrackerCfg = new stdClass(); $guiObj->issueTrackerCfg->createIssueURL = null; $guiObj->issueTrackerCfg->VerboseID = ''; $guiObj->issueTrackerCfg->VerboseType = ''; $guiObj->issueTrackerCfg->bugIDMaxLength = 0; $guiObj->issueTrackerCfg->bugSummaryMaxLength = 100; // MAGIC $guiObj->issueTrackerCfg->tlCanCreateIssue = false; $guiObj->issueTrackerCfg->tlCanAddIssueNote = true; if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($dbHandler); $issueTrackerCfg = $it_mgr->getLinkedTo($argsObj->tproject_id); if (!is_null($issueTrackerCfg)) { $its = $it_mgr->getInterfaceObject($argsObj->tproject_id); $guiObj->issueTrackerCfg->VerboseType = $issueTrackerCfg['verboseType']; $guiObj->issueTrackerCfg->VerboseID = $issueTrackerCfg['issuetracker_name']; $guiObj->issueTrackerCfg->bugIDMaxLength = $its->getBugIDMaxLength(); $guiObj->issueTrackerCfg->createIssueURL = $its->getEnterBugURL(); $guiObj->issueTrackerCfg->bugSummaryMaxLength = $its->getBugSummaryMaxLength(); $guiObj->issueTrackerCfg->tlCanCreateIssue = method_exists($its, 'addIssue'); $guiObj->issueTrackerCfg->tlCanAddIssueNote = method_exists($its, 'addNote'); } } return array($its, $issueTrackerCfg); }
function itsProcess(&$dbHandler, $argsObj, &$guiObj) { $its = null; $tprojectMgr = new testproject($dbHandler); $info = $tprojectMgr->get_by_id($argsObj->tproject_id); if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($dbHandler); $issueT = $it_mgr->getLinkedTo($argsObj->tproject_id); if (!is_null($issueT)) { $its = $it_mgr->getInterfaceObject($argsObj->tproject_id); $guiObj->issueTrackerVerboseType = $issueT['verboseType']; $guiObj->issueTrackerVerboseID = $issueT['issuetracker_name']; $guiObj->bugIDMaxLength = $its->getBugIDMaxLength(); $guiObj->createIssueURL = $its->getEnterBugURL(); if (method_exists($its, 'addIssue') && $argsObj->user_action == 'create') { list($guiObj->tlCanCreateIssue, $guiObj->msg) = addIssue($dbHandler, $argsObj, $its); } } } return array($its, $issueT); }
// CRITIC: // If call to testlinkInitPage() is done AFTER require_once for BTS // log to event viewer fails, but log to file works ok testlinkInitPage($db); $templateCfg = templateConfiguration(); $tcversion_id = null; $submitResult = null; $args = init_args($db, $cfg); // get issue tracker config and object to manage TestLink - BTS integration $its = null; $tproject_mgr = new testproject($db); $info = $tproject_mgr->get_by_id($args->tproject_id); if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($db); $its = $it_mgr->getInterfaceObject($args->tproject_id); $issueT = $it_mgr->getLinkedTo($args->tproject_id); unset($it_mgr); } $smarty = new TLSmarty(); $tree_mgr = new tree($db); $tplan_mgr = new testplan($db); $tcase_mgr = new testcase($db); $exec_cfield_mgr = new exec_cfield_mgr($db, $args->tproject_id); $attachmentRepository = tlAttachmentRepository::create($db); $req_mgr = new requirement_mgr($db); $gui = initializeGui($db, $args, $cfg, $tplan_mgr, $tcase_mgr); if ($info['issue_tracker_enabled']) { if (!is_null($its) && $its->isConnected()) { $gui->issueTrackerIntegrationOn = true; $gui->accessToIssueTracker = lang_get('link_bts_create_bug') . "({$issueT['issuetracker_name']})"; $gui->createIssueURL = $its->getEnterBugURL();
function init_args(&$dbHandler, $cfgObj) { $args = new stdClass(); $_REQUEST = strings_stripSlashes($_REQUEST); // Settings and Filters that we put on session to create some // sort of persistent scope, because we have had issues when passing this info // using GET mode (size limits) // // we get info about build_id, platform_id, etc ... getSettingsAndFilters($args); manageCookies($args, $cfgObj); // need to comunicate with left frame, will do via $_SESSION and form_token if (($args->treeFormToken = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0) > 0) { // do not understand why this do not works OK // $_SESSION[$args->treeFormToken]['loadExecDashboard'] = false; $_SESSION['loadExecDashboard'][$args->treeFormToken] = false; } if (is_null($args->refreshTree)) { $args->refreshTree = isset($_REQUEST['refresh_tree']) ? intval($_REQUEST['refresh_tree']) : 0; } $args->basehref = $_SESSION['basehref']; $args->assignTask = isset($_REQUEST['assignTask']) ? 1 : 0; $args->createIssue = isset($_REQUEST['createIssue']) ? 1 : 0; $args->copyIssues = isset($_REQUEST['copyIssues']) ? 1 : 0; $args->tc_id = null; $args->tsuite_id = null; $args->user = $_SESSION['currentUser']; $args->user_id = intval($args->user->dbID); $args->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature'; $args->reload_caller = false; $args->doExec = isset($_REQUEST['execute_cases']) ? 1 : 0; $args->doDelete = isset($_REQUEST['do_delete']) ? $_REQUEST['do_delete'] : 0; // $args->doMoveNext = isset($_REQUEST['move2next']) ? $_REQUEST['move2next'] : 0; $args->doMoveNext = isset($_REQUEST['move2next']) ? 1 : 0; $args->doMovePrevious = isset($_REQUEST['move2previous']) ? $_REQUEST['move2previous'] : 0; $args->moveTowards = $args->doMoveNext ? 'forward' : ($args->doMovePrevious ? 'backward' : null); // can be a list, will arrive via form POST $args->tc_versions = isset($_REQUEST['tc_version']) ? $_REQUEST['tc_version'] : null; $key2loop = array('level' => '', 'status' => null, 'statusSingle' => null, 'do_bulk_save' => 0, 'save_results' => 0, 'save_and_next' => 0, 'save_and_exit' => 0); foreach ($key2loop as $key => $value) { $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : $value; } // See details on: "When nullify filter_status - 20080504" in this file if ($args->level == 'testcase' || is_null($args->filter_status) || !is_array($args->filter_status) && trim($args->filter_status) == '') { $args->filter_status = null; } else { // 20130306 - franciscom // This (without the strlen() check) generated issue 5541: When "Result" filter is used ... // at least when result DIFFERENT that NOT RUN is used on filter // // 20120616 - franciscom // some strange thing to investigate, seems that unserialize is invoked // under the hood when getting data from $_REQUEST, then this piece // of code not only will be useless BUT WRONG, because will try // to unserialize something that IS NOT SERIALIZED!!!! // After TICKET 6651, may be need to limit size of $args->filter_status if (is_string($args->filter_status) && strlen($args->filter_status) > 1) { $args->filter_status = json_decode($args->filter_status); } } switch ($args->level) { case 'testcase': $args->tc_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; if (!is_null($args->tc_versions)) { $args->tc_id = current($args->tc_versions); $args->id = $args->tc_id; $args->version_id = key($args->tc_versions); } $args->tsuite_id = null; break; case 'testsuite': $args->tsuite_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; $args->tc_id = null; break; } $args->tsuitesInBranch = null; if (!is_null($args->tsuite_id)) { // will get all test suites in this branch, in order to limit amount of data returned // by functions/method that collect linked tcversions // THIS COLLECT ONLY FIRST LEVEL UNDER test suite, do not do deep search // Need to understand is still needed $tsuite_mgr = new testsuite($dbHandler); $xx = $tsuite_mgr->get_children($args->tsuite_id, array('details' => 'id')); $ldx = count($xx); $xx[$ldx] = $args->tsuite_id; $args->tsuitesInBranch = $xx; unset($tsuite_mgr); } // TICKET 5630: Test Results by direct link ... $args->tplan_id = intval(isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID']); $args->tproject_id = intval(isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : $_SESSION['testprojectID']); if ($args->tproject_id <= 0) { $tree_mgr = new tree($dbHandler); $dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id); $args->tproject_id = $dm['parent_id']; } // Do this only on single execution mode // get issue tracker config and object to manage TestLink - BTS integration $args->itsCfg = null; $its = null; $tproject_mgr = new testproject($dbHandler); $info = $tproject_mgr->get_by_id($args->tproject_id); unset($tproject_mgr); $bug_summary['minLengh'] = 1; $bug_summary['maxLengh'] = 1; if ($args->issue_tracker_enabled = $info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($dbHandler); $args->itsCfg = $it_mgr->getLinkedTo($args->tproject_id); $its = $it_mgr->getInterfaceObject($args->tproject_id); if (!is_null($args->itsCfg) && !is_null($its)) { $bug_summary['maxLengh'] = $its->getBugSummaryMaxLength(); } unset($it_mgr); } initArgsIssueOnTestCase($args, $bug_summary); initArgsIssueOnSteps($args, $bug_summary); return array($args, $its); }