Esempio n. 1
0
/**
 * process_testsuite
 *
 * http://localhost/development/gitorious/testlink/linkto.php?tprojectPrefix=333&item=testsuite&id=2894
 */
function process_testsuite(&$dbHandler, $tsuiteID, $tprojectID, $tprojectPrefix)
{
    $ret = array();
    $ret['url'] = null;
    $ret['msg'] = sprintf(lang_get('testsuite_not_found'), $tsuiteID, $tprojectPrefix);
    $ret['url'] = 'lib/testcases/archiveData.php?print_scope=test_specification' . '&edit=testsuite&level=testsuite&containerType=testsuite&id=' . $tsuiteID;
    $ret['msg'] = 'ok';
    $cookie = buildCookie($dbHandler, $tsuiteID, $tprojectID, 'ys-tproject_');
    setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/');
    return $ret;
}
Esempio n. 2
0
/**
 * process_reqspec
 *
 */
function process_reqspec(&$dbHandler, $docID, $tprojectID, $tprojectPrefix, $version)
{
    $ret = array();
    $ret['url'] = null;
    $ret['msg'] = sprintf(lang_get('req_spec_not_found'), $docID, $tprojectPrefix);
    $reqspec_mgr = new requirement_spec_mgr($dbHandler);
    $reqSpec = $reqspec_mgr->getByDocID($docID, $tprojectID);
    if (!is_null($reqSpec)) {
        $reqSpec = current($reqSpec);
        $id = $reqSpec['id'];
        $ret['url'] = "lib/requirements/reqSpecView.php?req_spec_id={$id}";
        $cookie = buildCookie($dbHandler, $id, $tprojectID, 'ys-requirement_spec');
        setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/');
    }
    return $ret;
}
Esempio n. 3
0
function executeRequest($historyID, $type = '', $action = '', $URL = '', $requestData = '', $timeout = '', $isPluginResponse = true, $callOpt = array())
{
    $responseProcessor = array();
    $responseProcessor['plugins']['install'] = $responseProcessor['themes']['install'] = 'installPluginsThemes';
    $responseProcessor['plugins']['manage'] = $responseProcessor['themes']['manage'] = 'managePluginsThemes';
    $responseProcessor['plugins']['get'] = $responseProcessor['themes']['get'] = 'getPluginsThemes';
    $responseProcessor['stats']['getStats'] = 'getStats';
    $responseProcessor['PTC']['update'] = 'updateAll';
    $responseProcessor['backup']['now'] = 'backup';
    $responseProcessor['backup']['multiCallNow'] = 'backup';
    $responseProcessor['backup']['restore'] = 'restoreBackup';
    $responseProcessor['backup']['remove'] = 'removeBackup';
    $responseProcessor['site']['add'] = 'addSite';
    $responseProcessor['site']['readd'] = 'readdSite';
    $responseProcessor['site']['maintain'] = 'iwpMaintenance';
    $responseProcessor['site']['auto_updater_settings'] = 'editSite';
    $responseProcessor['site']['remove'] = 'removeSite';
    $responseProcessor['site']['backupTest'] = 'backupTest';
    $responseProcessor['clientPlugin']['update'] = 'updateClient';
    $responseProcessor['backup']['trigger'] = 'triggerRecheck';
    $responseProcessor['cookie']['get'] = 'getCookie';
    setHook('responseProcessors', $responseProcessor);
    $historyData = getHistory($historyID);
    $actionResponse = $responseProcessor[$historyData['type']][$historyData['action']];
    if (manageClients::methodPreExists($actionResponse)) {
        manageClients::executePre($actionResponse, $historyID);
        $historyDataTemp = getHistory($historyID);
        if ($historyDataTemp['status'] != 'pending') {
            return false;
        }
        unset($historyDataTemp);
    }
    if (empty($type) || empty($action) || empty($URL) || empty($requestData)) {
        $historyRawDetails = DB::getRow("?:history_raw_details", "*", "historyID='" . $historyID . "'");
        $requestData = unserialize(base64_decode($historyRawDetails['request']));
        $historyData = getHistory($historyID);
        $type = $historyData['type'];
        $action = $historyData['action'];
        $URL = $historyData['URL'];
        $timeout = $historyData['timeout'];
        $isPluginResponse = $historyData['isPluginResponse'];
        $callOpt = @unserialize($historyData['callOpt']);
    }
    $siteID = $historyData['siteID'];
    $callOpt = buildCookie($callOpt, $siteID, $historyData);
    addNoCacheToURL($URL, $historyData);
    updateHistory(array('microtimeInitiated' => microtime(true), 'status' => 'running'), $historyID);
    $updateHistoryData = array();
    list($rawResponseData, $updateHistoryData['microtimeStarted'], $updateHistoryData['microtimeEnded'], $curlInfo, $rawResponseHeader) = doCall($URL, $requestData, $timeout, $callOpt);
    DB::update("?:history_raw_details", array('response' => addslashes($rawResponseData), 'callInfo' => serialize($curlInfo)), "historyID = '" . $historyID . "'");
    $cookie = extractCookie($rawResponseHeader);
    saveCookie($cookie, $siteID);
    $cURLErrors = new cURLErrors($curlInfo);
    if (!$cURLErrors->isOk()) {
        $updateHistoryAdditionalData = array();
        $updateHistoryAdditionalData = $cURLErrors->getErrorDetails();
        $updateHistoryData['status'] = $updateHistoryAdditionalData['status'];
        $updateHistoryData['error'] = $updateHistoryAdditionalData['error'];
        if (!isPluginResponse($rawResponseData)) {
            //sometimes 500 error with proper IWP Client Response, so if it not proper response continue set error and exit
            updateHistory($updateHistoryData, $historyID, $updateHistoryAdditionalData);
            return checkTriggerStatus();
        }
    }
    if ($isPluginResponse) {
        //$isPluginResponse is set to true then expecting result should be pluginResponse
        //$siteID = DB::getField("?:history", "siteID", "historyID='".$historyID."'"); //commented:siteID fetched from $historyData['siteID'];
        //checking response is the plugin data
        if (!isPluginResponse($rawResponseData)) {
            //Checking the timeout
            //For left menu color codes.
            if ($type == 'stats' && $action == 'getStats') {
                DB::update("?:sites", array('connectionStatus' => '0'), "siteID = '" . $siteID . "'");
            }
            $updateHistoryAdditionalData = array();
            $updateHistoryAdditionalData['status'] = $updateHistoryData['status'] = 'error';
            $updateHistoryAdditionalData['error'] = $updateHistoryData['error'] = 'main_plugin_connection_error';
            $updateHistoryAdditionalData['errorMsg'] = 'IWP Client plugin connection error.';
            updateHistory($updateHistoryData, $historyID, $updateHistoryAdditionalData);
            return checkTriggerStatus();
        } else {
            if ($type == 'stats' && $action == 'getStats') {
                DB::update("?:sites", array('connectionStatus' => '1'), "siteID = '" . $siteID . "'");
            }
        }
        removeResponseJunk($rawResponseData);
        $responseData = processCallReturn(unserialize(base64_decode($rawResponseData)));
    } else {
        $responseData = $rawResponseData;
    }
    $updateHistoryData['status'] = 'processingResponse';
    updateHistory($updateHistoryData, $historyID);
    //handling reponseData below
    if (manageClients::methodResponseExists($actionResponse)) {
        manageClients::executeResponse($actionResponse, $historyID, $responseData);
        //call_user_func('manageClients::'.$funcName, $historyID, $responseData);
        $status = "completed";
        $historyReponseStatus = Reg::get("historyResponseStatus");
        if (isset($historyReponseStatus[$historyID])) {
            $status = $historyReponseStatus[$historyID];
        }
        updateHistory(array('status' => $status), $historyID);
        return true;
    } else {
        updateHistory(array('status' => 'completed'), $historyID);
        echo '<br>no_response_processor';
        return 'no_response_processor';
    }
}