예제 #1
0
require_once 'common.php';
require_once 'exec.inc.php';
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
list($args, $gui, $its, $issueT) = initEnv($db);
if (($args->user_action == 'create' || $args->user_action == 'doCreate') && $gui->issueTrackerCfg->tlCanCreateIssue) {
    // get matadata
    $gui->issueTrackerMetaData = getIssueTrackerMetaData($its);
    switch ($args->user_action) {
        case 'create':
            $dummy = generateIssueText($db, $args, $its);
            $gui->bug_summary = $dummy->summary;
            break;
        case 'doCreate':
            $gui->bug_summary = $args->bug_summary;
            $ret = addIssue($db, $args, $its);
            $gui->issueTrackerCfg->tlCanCreateIssue = $ret['status_ok'];
            $gui->msg = $ret['msg'];
            break;
    }
} else {
    if ($args->user_action == 'link' || $args->user_action == 'add_note') {
        // Well do not think is very elegant to check for $args->bug_id != ""
        // to understand if user has pressed ADD Button
        if (!is_null($issueT) && $args->bug_id != "") {
            $l18n = init_labels(array("error_wrong_BugID_format" => null, "error_bug_does_not_exist_on_bts" => null));
            switch ($args->user_action) {
                case 'link':
                    $gui->msg = $l18n["error_wrong_BugID_format"];
                    if ($its->checkBugIDSyntax($args->bug_id)) {
                        if ($its->checkBugIDExistence($args->bug_id)) {
예제 #2
0
require_once 'common.php';
require_once 'exec.inc.php';
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
list($args, $gui, $its, $issueT) = initEnv($db);
if (($args->user_action == 'create' || $args->user_action == 'doCreate') && $gui->issueTrackerCfg->tlCanCreateIssue) {
    // get matadata
    $gui->issueTrackerMetaData = getIssueTrackerMetaData($its);
    switch ($args->user_action) {
        case 'create':
            $issueText = generateIssueText($db, $args, $its);
            $gui->bug_summary = $issueText->summary;
            break;
        case 'doCreate':
            $gui->bug_summary = $args->bug_summary;
            list($gui->issueTrackerCfg->tlCanCreateIssue, $gui->msg) = addIssue($db, $args, $its);
            break;
    }
} else {
    if ($args->user_action == 'link' || $args->user_action == 'add_note') {
        // Well do not think is very elegant to check for $args->bug_id != ""
        // to understand if user has pressed ADD Button
        new dBug($args);
        if (!is_null($issueT) && $args->bug_id != "") {
            $l18n = init_labels(array("error_wrong_BugID_format" => null, "error_bug_does_not_exist_on_bts" => null));
            switch ($args->user_action) {
                case 'link':
                    $gui->msg = $l18n["error_wrong_BugID_format"];
                    if ($its->checkBugIDSyntax($args->bug_id)) {
                        if ($its->checkBugIDExistence($args->bug_id)) {
                            if (write_execution_bug($db, $args->exec_id, $args->bug_id)) {
예제 #3
0
<?php

require_once 'config.php';
require 'design_head.php';
echo '<h1>New issue</h1>';
if (isset($_POST['desc'])) {
    $issueId = addIssue($session->id, 0, $_POST['desc']);
    if ($issueId) {
        echo 'Thank you for the report!<br/>';
        echo 'The issue have been stored and will be overlooked as soon as possible!<br/><br/>';
        echo 'What do you want to do now?<br/><br/>';
        echo '* <a href="show_issue.php?id=' . $issueId . '">Go to issue report</a><br/>';
        echo '* <a href="' . $_SERVER['PHP_SELF'] . '">Report another issue</a><br/>';
    } else {
        echo 'Error adding the issue.';
    }
} else {
    echo 'From here you can submit bug reports or feature requests regarding the game or website.<br/>';
    echo 'Please leave as many details as possible.<br/><br/>';
    echo xhtmlForm();
    //FIXME categories dropdown
    echo 'Description:<br/>';
    echo xhtmlTextarea('desc', '', 60, 8) . '</td></tr>';
    echo '<tr><td><br>' . xhtmlSubmit('Submit issue') . '</td></tr>';
    echo xhtmlFormClose();
}
require 'design_foot.php';
예제 #4
0
function checkForModuleIssues($modulePath, $moduleName, &$issues)
{
    $id = 1;
    $i = 0;
    $j = 0;
    if (!file_exists($modulePath . "moduleTables.txt")) {
        addFatalIssue($issues, "Module Info file is missing", $id++);
        $i = 1;
    }
    if (!file_exists($modulePath . $moduleName . ".lib.php")) {
        addFatalIssue($issues, "The module file is corrupt, Please download a fresh copy of the module", $id++);
        $i = 1;
    } else {
        $content = file_get_contents($modulePath . $moduleName . ".lib.php");
        $reqd = array("class " . $moduleName . " implements module", "public function getHtml", "public function createModule", "public function deleteModule", "public function copyModule");
        foreach ($reqd as $var) {
            switch (mycount($content, $var)) {
                case 0:
                    addFatalIssue($issues, "{$var} is missing", $id);
                    $i = 1;
                    $id++;
                    break;
                case 1:
                    break;
                default:
                    addFatalIssue($issues, "{$var} is more than once", $id);
                    $i = 1;
                    $id++;
            }
        }
    }
    if (!file_exists($modulePath . $moduleName . ".sql")) {
        addIssue($issue, "No sql file found", $id++);
        $j = 1;
    }
    return array($i, $j);
}
예제 #5
0
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);
}
예제 #6
0
/**
 * write execution result to DB
 * 
 * @param resource &$db reference to database handler
 * @param obj &$exec_signature object with tproject_id,tplan_id,build_id,platform_id,user_id
 * 
 * @internal revisions
 * 
 */
function write_execution(&$db, &$exec_signature, &$exec_data, &$issueTracker)
{
    static $docRepo;
    if (is_null($docRepo)) {
        $docRepo = tlAttachmentRepository::create($db);
    }
    $executions_table = DB_TABLE_PREFIX . 'executions';
    $resultsCfg = config_get('results');
    $execCfg = config_get('exec_cfg');
    $db_now = $db->db_now();
    $cfield_mgr = new cfield_mgr($db);
    $cf_prefix = $cfield_mgr->get_name_prefix();
    $len_cfp = tlStringLen($cf_prefix);
    $cf_nodeid_pos = 4;
    $bulk_notes = '';
    $ENABLED = 1;
    $cf_map = $cfield_mgr->get_linked_cfields_at_execution($exec_signature->tproject_id, $ENABLED, 'testcase');
    $has_custom_fields = is_null($cf_map) ? 0 : 1;
    // extract custom fields id.
    $map_nodeid_array_cfnames = null;
    foreach ($exec_data as $input_name => $value) {
        if (strncmp($input_name, $cf_prefix, $len_cfp) == 0) {
            $dummy = explode('_', $input_name);
            $map_nodeid_array_cfnames[$dummy[$cf_nodeid_pos]][] = $input_name;
        }
    }
    if (isset($exec_data['do_bulk_save'])) {
        // create structure to use common algoritm
        $item2loop = $exec_data['status'];
        $is_bulk_save = 1;
        $bulk_notes = $db->prepare_string(trim($exec_data['bulk_exec_notes']));
        $execStatusKey = 'status';
    } else {
        $item2loop = $exec_data['save_results'];
        $is_bulk_save = 0;
        $execStatusKey = 'statusSingle';
    }
    $addIssueOp = array('createIssue' => null, 'issueForStep' => null);
    foreach ($item2loop as $tcversion_id => $val) {
        $tcase_id = $exec_data['tc_version'][$tcversion_id];
        $current_status = $exec_data[$execStatusKey][$tcversion_id];
        $version_number = $exec_data['version_number'][$tcversion_id];
        $has_been_executed = $current_status != $resultsCfg['status_code']['not_run'] ? TRUE : FALSE;
        if ($has_been_executed) {
            $my_notes = $is_bulk_save ? $bulk_notes : $db->prepare_string(trim($exec_data['notes'][$tcversion_id]));
            $sql = "INSERT INTO {$executions_table} " . "(build_id,tester_id,status,testplan_id,tcversion_id," . " execution_ts,notes,tcversion_number,platform_id,execution_duration)" . " VALUES ( {$exec_signature->build_id}, {$exec_signature->user_id}, '{$exec_data[$execStatusKey][$tcversion_id]}'," . "{$exec_signature->tplan_id}, {$tcversion_id},{$db_now},'{$my_notes}'," . "{$version_number},{$exec_signature->platform_id}";
            $dura = 'NULL ';
            if (isset($exec_data['execution_duration'])) {
                if (trim($exec_data['execution_duration']) == '') {
                    $dura = 'NULL ';
                } else {
                    $dura = floatval($exec_data['execution_duration']);
                }
            }
            $sql .= ',' . $dura . ")";
            $db->exec_query($sql);
            // at least for Postgres DBMS table name is needed.
            $execution_id = $db->insert_id($executions_table);
            $execSet[$tcversion_id] = $execution_id;
            if ($has_custom_fields) {
                // test useful when doing bulk update, because some type of custom fields
                // like checkbox can not exist on exec_data. => why ??
                //
                $hash_cf = null;
                $access_key = $is_bulk_save ? 0 : $tcase_id;
                if (isset($map_nodeid_array_cfnames[$access_key])) {
                    foreach ($map_nodeid_array_cfnames[$access_key] as $cf_v) {
                        $hash_cf[$cf_v] = $exec_data[$cf_v];
                    }
                }
                $cfield_mgr->execution_values_to_db($hash_cf, $tcversion_id, $execution_id, $exec_signature->tplan_id, $cf_map);
            }
            $hasMoreData = new stdClass();
            $hasMoreData->step_notes = isset($exec_data['step_notes']);
            $hasMoreData->step_status = isset($exec_data['step_status']);
            $hasMoreData->nike = $execCfg->steps_exec && ($hasMoreData->step_notes || $hasMoreData->step_status);
            if ($hasMoreData->nike) {
                $target = DB_TABLE_PREFIX . 'execution_tcsteps';
                $key2loop = array_keys($exec_data['step_notes']);
                foreach ($key2loop as $step_id) {
                    $doIt = !is_null($exec_data['step_notes'][$step_id]) && trim($exec_data['step_notes'][$step_id]) != '' || $exec_data['step_status'][$step_id] != $resultsCfg['status_code']['not_run'];
                    if ($doIt) {
                        $sql = " INSERT INTO {$target} (execution_id,tcstep_id,notes";
                        $values = " VALUES ( {$execution_id}, {$step_id}," . "'" . $db->prepare_string($exec_data['step_notes'][$step_id]) . "'";
                        $status = strtolower(trim($exec_data['step_status'][$step_id]));
                        $status = $status[0];
                        if ($status != $resultsCfg['status_code']['not_run']) {
                            $sql .= ",status";
                            $values .= ",'" . $db->prepare_string($status) . "'";
                        }
                        $sql .= ") " . $values . ")";
                        $db->exec_query($sql);
                        $execution_tcsteps_id = $db->insert_id($target);
                        // NOW MANAGE attachments
                        if (isset($_FILES['uploadedFile']['name'][$step_id]) && !is_null($_FILES['uploadedFile']['name'][$step_id])) {
                            $repOpt = array('allow_empty_title' => TRUE);
                            // May be we have enabled MULTIPLE on file upload
                            if (is_array($_FILES['uploadedFile']['name'][$step_id])) {
                                $curly = count($_FILES['uploadedFile']['name'][$step_id]);
                                for ($moe = 0; $moe < $curly; $moe++) {
                                    $fSize = isset($_FILES['uploadedFile']['size'][$step_id][$moe]) ? $_FILES['uploadedFile']['size'][$step_id][$moe] : 0;
                                    $fTmpName = isset($_FILES['uploadedFile']['tmp_name'][$step_id][$moe]) ? $_FILES['uploadedFile']['tmp_name'][$step_id][$moe] : '';
                                    if ($fSize && $fTmpName != "") {
                                        $fk2loop = array_keys($_FILES['uploadedFile']);
                                        foreach ($fk2loop as $tk) {
                                            $fInfo[$tk] = $_FILES['uploadedFile'][$tk][$step_id][$moe];
                                        }
                                        $uploaded = $docRepo->insertAttachment($execution_tcsteps_id, $target, '', $fInfo, $repOpt);
                                    }
                                }
                            } else {
                                $fSize = isset($_FILES['uploadedFile']['size'][$step_id]) ? $_FILES['uploadedFile']['size'][$step_id] : 0;
                                $fTmpName = isset($_FILES['uploadedFile']['tmp_name'][$step_id]) ? $_FILES['uploadedFile']['tmp_name'][$step_id] : '';
                                if ($fSize && $fTmpName != "") {
                                    $fk2loop = array_keys($_FILES['uploadedFile']);
                                    foreach ($fk2loop as $tk) {
                                        $fInfo[$tk] = $_FILES['uploadedFile'][$tk][$step_id];
                                    }
                                    $uploaded = $docRepo->insertAttachment($execution_tcsteps_id, $target, '', $fInfo);
                                }
                            }
                        }
                    }
                }
            }
            $itCheckOK = !is_null($issueTracker) && method_exists($issueTracker, 'addIssue');
            // re-init
            $addIssueOp = array('createIssue' => null, 'issueForStep' => null);
            if ($itCheckOK) {
                $execContext = new stdClass();
                $execContext->exec_id = $execution_id;
                $execContext->tcversion_id = $tcversion_id;
                $execContext->user = $exec_signature->user;
                $execContext->basehref = $exec_signature->basehref;
                $execContext->tplan_apikey = $exec_signature->tplan_apikey;
                // Issue on Test Case
                if (isset($exec_data['createIssue'])) {
                    completeCreateIssue($execContext, $exec_signature);
                    $addIssueOp['createIssue'] = addIssue($db, $execContext, $issueTracker);
                }
                // Issues at step level
                if (isset($exec_data['issueForStep'])) {
                    foreach ($exec_data['issueForStep'] as $stepID => $val) {
                        completeIssueForStep($execContext, $exec_signature, $exec_data, $stepID);
                        $addIssueOp['issueForStep'][$stepID] = addIssue($db, $execContext, $issueTracker, $stepID);
                    }
                }
            }
            // $itCheckOK
        }
    }
    return array($execSet, $addIssueOp);
}