Example #1
0
function showAllServiceGroups()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    $scope = '%%';
    if (!empty($_GET['scope'])) {
        $scope = $_GET['scope'];
    }
    $scopes = \Factory::getScopeService()->getScopes();
    $sgKeyNames = "";
    if (isset($_GET['sgKeyNames'])) {
        $sgKeyNames = $_GET['sgKeyNames'];
    }
    $sgKeyValues = "";
    if (isset($_GET['selectedSGKeyValue'])) {
        $sgKeyValues = $_GET['selectedSGKeyValue'];
    }
    $sGroups = \Factory::getServiceGroupService()->getServiceGroups($scope, $sgKeyNames, $sgKeyValues);
    $exServ = \Factory::getExtensionsService();
    /* Doctrine will provide keynames that are the same even when selecting distinct becase the object
     * is distinct even though the name is not unique. To avoid showing the same name repeatdly in the filter
     * we will load all the keynames into an array before making it unique
     */
    $keynames = array();
    foreach ($exServ->getServiceGroupExtensionsKeyNames() as $extension) {
        $keynames[] = $extension->getKeyName();
    }
    $keynames = array_unique($keynames);
    $params['sGroups'] = $sGroups;
    $params['scopes'] = $scopes;
    $params['selectedScope'] = $scope;
    $params['selectedSGKeyName'] = $sgKeyNames;
    $params['selectedSGKeyValue'] = $sgKeyValues;
    $params['sgKeyName'] = $keynames;
    show_view("service_group/view_all.php", $params);
}
Example #2
0
function drawSEs()
{
    define("RECORDS_PER_PAGE", 30);
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    $seServ = \Factory::getServiceService();
    $exServ = \Factory::getExtensionsService();
    $startRecord = 1;
    if (isset($_REQUEST['record'])) {
        $startRecord = $_REQUEST['record'];
    }
    // Validation, ensure start record >= 1
    if ($startRecord < 1) {
        $startRecord = 1;
    }
    $searchTerm = "";
    if (!empty($_REQUEST['searchTerm'])) {
        $searchTerm = $_REQUEST['searchTerm'];
    }
    //strip leading and trailing whitespace off search term
    $searchTerm = strip_tags(trim($searchTerm));
    if (1 === preg_match("/[';\"]/", $searchTerm)) {
        throw new Exception("Invalid char in search term");
    }
    $serviceType = "";
    if (isset($_REQUEST['serviceType'])) {
        $serviceType = $_REQUEST['serviceType'];
    }
    $production = "";
    if (isset($_REQUEST['production'])) {
        $production = $_REQUEST['production'];
    }
    $monitored = "";
    if (isset($_REQUEST['monitored'])) {
        $monitored = $_REQUEST['monitored'];
    }
    $scope = "";
    if (isset($_REQUEST['scope'])) {
        $scope = $_REQUEST['scope'];
    }
    $ngi = "";
    if (isset($_REQUEST['ngi'])) {
        $ngi = $_REQUEST['ngi'];
    }
    //must be done before the if certstatus in the block that sets $certStatus
    $showClosed = false;
    if (isset($_REQUEST['showClosed'])) {
        $showClosed = true;
    }
    $servKeyNames = "";
    if (isset($_REQUEST['servKeyNames'])) {
        $servKeyNames = $_REQUEST['servKeyNames'];
    }
    $servKeyValues = "";
    if (isset($_REQUEST['selectedServKeyValue'])) {
        $servKeyValues = $_REQUEST['selectedServKeyValue'];
    }
    $certStatus = "";
    if (!empty($_REQUEST['certificationStatus'])) {
        $certStatus = $_REQUEST['certificationStatus'];
        //set show closed as true if production status selected is 'closed' - otherwise
        // there will be no results
        if ($certStatus == 'Closed') {
            $showClosed = true;
        }
    }
    $thisPage = 'index.php?Page_Type=Services';
    if ($serviceType != "") {
        $thisPage .= '&serviceType=' . $serviceType;
    }
    if ($searchTerm != "") {
        $thisPage .= '&searchTerm=' . $searchTerm;
    }
    if ($production != "") {
        $thisPage .= '&production=' . $production;
    }
    if ($monitored != "") {
        $thisPage .= '&monitored=' . $monitored;
    }
    if ($scope != "") {
        $thisPage .= '&scope=' . $scope;
    }
    if ($ngi != "") {
        $thisPage .= '&ngi=' . $ngi;
    }
    if ($certStatus != "") {
        $thisPage .= '&certStatus=' . $certStatus;
    }
    if ($showClosed != "") {
        $thisPage .= '&showClosed=' . $showClosed;
    }
    if ($servKeyNames != "") {
        $thisPage .= '&servKeyNames=' . $servKeyNames;
    }
    if ($servKeyValues != "") {
        $thisPage .= '&servKeyValues=' . $servKeyValues;
    }
    if ($searchTerm != null || $searchTerm != "") {
        if (substr($searchTerm, 0, 1) != '%') {
            $searchTerm = '%' . $searchTerm;
        }
        if (substr($searchTerm, -1) != '%') {
            $searchTerm = $searchTerm . '%';
        }
    }
    $numResults = $seServ->getSesCount($searchTerm, $serviceType, $production, $monitored, $scope, $ngi, $certStatus, $showClosed, $servKeyNames, $servKeyValues, null, null, false);
    $firstLink = $thisPage . "&record=1";
    // Set the "previous" link
    if ($startRecord > RECORDS_PER_PAGE) {
        // Not showing the first page of results so enable the previous link
        $previousLink = $thisPage . "&record=" . ($startRecord - RECORDS_PER_PAGE);
    } else {
        // First page of results, disable previous button
        $previousLink = $thisPage . "&record=" . 0;
    }
    // Set the "Next" link
    // not the last page of results, normal next link
    if ($numResults - $startRecord > RECORDS_PER_PAGE) {
        $nextLink = $thisPage . "&record=" . ($startRecord + RECORDS_PER_PAGE);
    } else {
        // last page of results, disable next link
        $nextLink = $thisPage . '&record=' . ($numResults - RECORDS_PER_PAGE + 1);
    }
    $lastLink = $thisPage . "&record=" . ($numResults + 1 - RECORDS_PER_PAGE);
    // $startRecord + RECORDS_PER_PAGE "-1" because record 1 in the web portal == record 0 from DB
    $ses = $seServ->getSes($searchTerm, $serviceType, $production, $monitored, $scope, $ngi, $certStatus, $showClosed, $servKeyNames, $servKeyValues, $startRecord - 1, RECORDS_PER_PAGE, false);
    $endRecord = $startRecord + RECORDS_PER_PAGE - 1;
    /* Due to differences in counting, startRecord is still set to 1
     * even if there are zero results. If this is the case it's
     * zero here to display accurately in the portal.  */
    if (count($ses) == 0) {
        $startRecord = 0;
    }
    /* Doctrine will provide keynames that are the same even when selecting distinct becase the object
     * is distinct even though the name is not unique. To avoid showing the same name repeatdly in the filter
     * we will load all the keynames into an array before making it unique
     */
    $keynames = array();
    foreach ($exServ->getServiceExtensionsKeyNames() as $extension) {
        $keynames[] = $extension->getKeyName();
    }
    $keynames = array_unique($keynames);
    $serv = \Factory::getSiteService();
    $params['scopes'] = \Factory::getScopeService()->getScopes();
    $params['serviceTypes'] = $seServ->getServiceTypes();
    $params['servKeyNames'] = $keynames;
    $params['selectedServiceType'] = $serviceType;
    $params['searchTerm'] = $searchTerm;
    $params['services'] = $ses;
    $params['totalServices'] = $numResults;
    $params['startRecord'] = $startRecord;
    $params['endRecord'] = $endRecord;
    $params['firstLink'] = $firstLink;
    $params['previousLink'] = $previousLink;
    $params['nextLink'] = $nextLink;
    $params['lastLink'] = $lastLink;
    $params['ngis'] = \Factory::getNgiService()->getNGIs();
    $params['certStatuses'] = $serv->getCertStatuses();
    $params['showClosed'] = $showClosed;
    $params['selectedProduction'] = $production;
    $params['selectedMonitored'] = $monitored;
    $params['selectedScope'] = $scope;
    $params['selectedNgi'] = $ngi;
    $params['selectedClosed'] = $showClosed;
    $params['selectedCertStatus'] = $certStatus;
    $params['selectedServKeyNames'] = $servKeyNames;
    $params['selectedServKeyValue'] = $servKeyValues;
    show_view("service/view_all.php", $params, "Services");
}
Example #3
0
function showAllSites()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    $exServ = \Factory::getExtensionsService();
    // Do we really need to validate the URL parameter values, as the query
    // to the DB always uses bind variables to protect against injection?
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Validate.php';
    $validatorService = new \org\gocdb\services\Validate();
    $ngi = '%%';
    if (!empty($_GET['NGI'])) {
        $ngi = $_GET['NGI'];
        if (!$validatorService->validate('ngi', 'NAME', $ngi)) {
            throw new Exception("Invalid NGI parameter value");
        }
    }
    $prodStatus = '%%';
    if (!empty($_GET['prodStatus'])) {
        $prodStatus = $_GET['prodStatus'];
    }
    //must be done before the if certstatus in the block that sets $certStatus
    $showClosed = false;
    if (isset($_GET['showClosed'])) {
        $showClosed = true;
    }
    $certStatus = '%%';
    if (!empty($_GET['certStatus'])) {
        $certStatus = $_GET['certStatus'];
        //set show closed as true if production status selected is 'closed' - otherwise
        // there will be no results
        if ($certStatus == 'Closed') {
            $showClosed = true;
        }
    }
    // Site extension property key name
    $siteKeyNames = "";
    if (isset($_GET['siteKeyNames'])) {
        $siteKeyNames = $_GET['siteKeyNames'];
    }
    // Site extension property key value
    $siteKeyValues = "";
    if (isset($_GET['selectedSiteKeyValue'])) {
        $siteKeyValues = $_GET['selectedSiteKeyValue'];
    }
    $scope = '%%';
    if (!empty($_GET['scope'])) {
        $scope = $_GET['scope'];
    }
    $serv = \Factory::getSiteService();
    $params['scopes'] = \Factory::getScopeService()->getScopes();
    $params['sites'] = $serv->getSitesBy($ngi, $prodStatus, $certStatus, $scope, $showClosed, null, $siteKeyNames, $siteKeyValues);
    $params['NGIs'] = $serv->getNGIs();
    $params['prodStatuses'] = $serv->getProdStatuses();
    //Remove SC and PPS infrastructures from drop down list. TODO: Delete this block once they no longer exist
    $SCInfrastructure = $serv->getProdStatusByName('SC');
    $PPSInfrastructure = $serv->getProdStatusByName('PPS');
    $productionStatuses = array();
    foreach ($params['prodStatuses'] as $ps) {
        if ($ps != $SCInfrastructure and $ps != $PPSInfrastructure) {
            $productionStatuses[] = $ps;
        }
    }
    $params['prodStatuses'] = $productionStatuses;
    //delete up to here once pps and sc infrastructures have been removed from database
    /* Doctrine will provide keynames that are the same even when selecting distinct becase the object
     * is distinct even though the name is not unique. To avoid showing the same name repeatdly in the filter
     * we will load all the keynames into an array before making it unique
     */
    $keynames = array();
    foreach ($exServ->getSiteExtensionsKeyNames() as $extension) {
        $keynames[] = $extension->getKeyName();
    }
    $keynames = array_unique($keynames);
    $params['selectedNgi'] = $ngi;
    $params['certStatuses'] = $serv->getCertStatuses();
    $params['selectedProdStatus'] = $prodStatus;
    $params['selectedCertStatus'] = $certStatus;
    $params['selectedScope'] = $scope;
    $params['showClosed'] = $showClosed;
    $params['siteKeyNames'] = $keynames;
    $params['selectedSiteKeyNames'] = $siteKeyNames;
    $params['selectedSiteKeyValue'] = $siteKeyValues;
    show_view("site/view_all.php", $params, "Sites");
}