Exemplo n.º 1
0
<?php

// GET page for specific knowledge article
$app->get('/fields/:id', function ($id) use($app) {
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $response = $clientObj->getBusinessObjectByPublicId('KnowledgeArticle', $id);
        $xml = simplexml_load_string($response);
        $title = "Knowledge Article Fields";
        $index = 0;
        $fields = array();
        foreach ($xml->FieldList->Field as $field) {
            $fields[$index]['name'] = $field['Name'];
            $fields[$index]['value'] = $field;
            $index++;
        }
        $app->view()->setData(array('base' => $app->base, 'title' => $title, 'fields' => $fields));
        $app->render("fields.html");
    } catch (Exception $e) {
        $app->redirect('/', 301);
    }
});
Exemplo n.º 2
0
function getListOfArticles($app)
{
    $response = '';
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $filter = getHttpQueryParams($app);
        if ($filter['searchBy'] === 'queryByPrompt' && !empty($filter['prompt'])) {
            $response = $clientObj->getQueryResultsUsingPromptInfo("Team", getenv('keyword_scope_owner'), getenv('keyword_stored_query_id_def'), getenv('keyword_bus_ob_id'), '<Inputs><Input InputId="Prompt">%' . $filter['prompt'] . '%</Input></Inputs>');
            $xmlk = simplexml_load_string($response);
            if (count($xmlk->xpath('Record')) == 0) {
                $response = '';
            }
        } else {
            $response = $clientObj->queryByFieldValue('KnowledgeArticle', $filter['queryName'], $filter['prompt']);
        }
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
    if (!empty($response)) {
        $xml = simplexml_load_string($response);
        $pageNumber = getPageNumber($app, $xml);
        $ids = getRecordsForDisplay($xml, $pageNumber);
        $index = 0;
        $links = array();
        foreach ($ids as $record) {
            if ($filter['searchBy'] === 'queryByPrompt' && !empty($filter['prompt'])) {
                $response = $clientObj->getBusinessObject('KnowledgeArticle', $record['RecId']);
            } else {
                $response = $clientObj->getBusinessObjectByPublicId('KnowledgeArticle', $record);
            }
            $xml1 = simplexml_load_string($response);
            $links[$index]['title'] = $xml1->FieldList->Field[19];
            $links[$index]['id'] = $xml1->FieldList->Field[13];
            $links[$index]['recId'] = $xml1->FieldList->Field[0];
            $index++;
        }
    } else {
        $pageNumber = 1;
        $links = array();
    }
    $app->view()->setData(array('base' => $app->base, 'currentPage' => $pageNumber, 'links' => $links, 'filter' => $filter));
    $app->render("articles.html");
}