Example #1
0
function submit()
{
    //Only administrators can delete sites, double check user is an administrator
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    if (isset($_REQUEST['id'])) {
        $ngi = \Factory::getNgiService()->getNgi($_REQUEST['id']);
    } else {
        throw new \Exception("A NGI must be specified in the url");
    }
    //save name to display later
    $params['Name'] = $ngi->getName();
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    //remove ngi
    try {
        \Factory::getNgiService()->deleteNgi($ngi, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('/site/deleted_site.php', $params);
}
Example #2
0
/**
 * Retrieves the new isadmin value from a portal request and submit it to the
 * services layer's user functions.
 * @return null 
*/
function submit()
{
    require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
    if (true) {
        throw new Exception("Disabled in controller");
    }
    //Check the user has permission, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get a user service
    $serv = \Factory::getUserService();
    //Get the posted user data
    $userID = $_REQUEST['ID'];
    $user = $serv->getUser($userID);
    //Note that a string is recived from post and must be converted to boolean
    if ($_REQUEST['IsAdmin'] == "true") {
        $isAdmin = true;
    } else {
        $isAdmin = false;
    }
    //get the user data for the set user isAdmin function (so it can check permissions)
    $currentUserDN = Get_User_Principle();
    $currentUser = $serv->getUserByPrinciple($currentUserDN);
    try {
        //function will through error if user does not have the correct permissions
        $serv->setUserIsAdmin($user, $currentUser, $isAdmin);
        $params = array('Name' => $user->getForename() . " " . $user->getSurname(), 'IsAdmin' => $user->isAdmin(), 'ID' => $user->getId());
        show_view("admin/edited_user_isadmin.php", $params, "Success");
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Example #3
0
/**
 * Draws the add service type form
 * @return null
 */
function draw()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //show the add service type view
    show_view("admin/add_service_type.php", null, "Add Service Type");
}
Example #4
0
/**
 * Draws the add project form
 * @return null
 */
function draw()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //show the add NGI view
    show_view("admin/add_project.php", null, "Add Project");
}
Example #5
0
function show_all()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $serviceTypes = \Factory::getServiceTypeService()->getServiceTypes();
    $params['ServiceTypes'] = $serviceTypes;
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    show_view('admin/view_service_types.php', $params, 'Service Types');
}
Example #6
0
/**
 * Draws the add NGI form
 * @return null
 */
function draw()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get the list of scopes to chose from and the minimum number that need to be selected
    $params['Scopes'] = \Factory::getScopeService()->getDefaultScopesSelectedArray();
    $params['NumberOfScopesRequired'] = \Factory::getConfigService()->getMinimumScopesRequired('ngi');
    //show the add NGI view
    show_view("admin/add_ngi.php", $params, "Add NGI");
}
Example #7
0
/**
 * Draws the edit service type form
 * @return null
 */
function draw()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    // Get the service type
    $serviceType = \Factory::getServiceTypeService()->getServiceType($_REQUEST['id']);
    $params = array('Name' => $serviceType->getName(), 'ID' => $serviceType->getId(), 'Description' => $serviceType->getDescription());
    show_view("admin/edit_service_type.php", $params, "Edit " . $serviceType->getName());
}
function deny_delete_type()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get a service type service and then the service type to be deleted
    $serv = \Factory::getServiceTypeService();
    $serviceType = $serv->getServiceType($_REQUEST['id']);
    //Get the services for that service and pass them to the denied view
    $params['ServiceType'] = $serviceType;
    $params['Services'] = $serv->getServices($serviceType->getId());
    //display the deletion denied view
    show_view("admin/delete_service_type_denied.php", $params, 'Deletion Failed');
}
Example #9
0
function submit(\Site $site, \User $user = null)
{
    //Only administrators can delete sites, double check user is an administrator
    checkUserIsAdmin();
    //save name to display later
    $params['Name'] = $site->getName();
    //remove Site
    try {
        \Factory::getSiteService()->deleteSite($site, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('/site/deleted_site.php', $params);
}
Example #10
0
/**
 * Controller for a request to add NGIs to a project
 * @global array $_POST only set if the browser has POSTed data
 * @return null
 */
function add_ngis_to_project()
{
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    //Check the portal is not in read only mode, returns exception if it is and user is not an admin
    checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    ////Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    if ($_POST) {
        // If we receive a POST request it's to add ngis
        submit();
    } else {
        // If there is no post data, draw the add NGI page
        draw();
    }
}
Example #11
0
function view_service_type()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $serv = \Factory::getServiceTypeService();
    $serviceType = $serv->getServiceType($_REQUEST['id']);
    $params['Name'] = $serviceType->getName();
    $params['Description'] = $serviceType->getDescription();
    $params['ID'] = $serviceType->getId();
    $params['Services'] = $serv->getServices($params['ID']);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    show_view("admin/view_service_type.php", $params, $params['Name']);
}
Example #12
0
function show_users()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //If specified, set parameters
    $surname = null;
    if (!empty($_REQUEST['Surname'])) {
        $surname = $_REQUEST['Surname'];
    }
    $params["Surname"] = $surname;
    $forename = null;
    if (!empty($_REQUEST['Forename'])) {
        $forename = $_REQUEST['Forename'];
    }
    $params["Forename"] = $forename;
    $dn = null;
    if (!empty($_REQUEST['DN'])) {
        $dn = $_REQUEST['DN'];
    }
    $params["DN"] = $dn;
    //Note that the true/false specified must be converted into boolean true/false.
    $isAdmin = null;
    if (!empty($_REQUEST['IsAdmin'])) {
        if ($_REQUEST['IsAdmin'] == "true") {
            $isAdmin = true;
        } elseif ($_REQUEST['IsAdmin'] == "false") {
            $isAdmin = false;
        }
    }
    $params["IsAdmin"] = $isAdmin;
    $currentUserDN = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($currentUserDN);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    //get users
    $params["Users"] = \Factory::getUserService()->getUsers($surname, $forename, $dn, $isAdmin);
    show_view("admin/users.php", $params, "Users");
}
Example #13
0
/**
 * Draws the edit user DN form
 * @return null
 */
function draw()
{
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    //Get user details
    $serv = \Factory::getUserService();
    $user = $serv->getUser($_REQUEST['id']);
    //Throw exception if not a valid user id
    if (is_null($user)) {
        throw new \Exception("A user with ID '" . $_REQUEST['id'] . "' Can not be found");
    }
    $params["ID"] = $user->getId();
    $params["Title"] = $user->getTitle();
    $params["Forename"] = $user->getForename();
    $params["Surname"] = $user->getSurname();
    $params["CertDN"] = $user->getCertificateDn();
    //show the edit user dn view
    show_view("admin/edit_user_dn.php", $params, "Edit Certificate DN");
}
Example #14
0
/**
 *  Draws a form to select the NGI from which you wish to move a site
 *  @return null
 */
function drawSelectOldNgi()
{
    // Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get a list  of NGIs to select from
    $ngis = \Factory::getSiteService()->getNGIs();
    //Put into an array to be passed to view
    $params = array('Ngis' => $ngis);
    show_view("admin/move_site_select_old_ngi.php", $params);
}
Example #15
0
function showHeader(array $css = [])
{
    session_start();
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../config/constants.php';
    require_once BASE_PATH . 'src/sessionVerify.php';
    checkUserLogedIn();
    require_once BASE_PATH . 'src/connection.php';
    require_once BASE_PATH . 'src/showMessage.php';
    require_once BASE_PATH . 'src/prepareCrud.php';
    ?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/ico" href="<?php 
    echo SITE_URL;
    ?>
assets/img/php.ico">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="<?php 
    echo SITE_URL;
    ?>
assets/css/normalize.css">
    <link rel="stylesheet" href="<?php 
    echo SITE_URL;
    ?>
assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="<?php 
    echo SITE_URL;
    ?>
assets/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="<?php 
    echo SITE_URL;
    ?>
assets/css/styles.css">
    <link rel="stylesheet" href="<?php 
    echo SITE_URL;
    ?>
assets/css/sticky-footer.css">
    <?php 
    if ($css) {
        foreach ($css as $script) {
            $src = SITE_URL . 'assets/css/' . $script . '.css';
            if (file_exists(BASE_PATH . 'public/assets/css/' . $script . '.css')) {
                ?>
            <link rel="stylesheet" href="<?php 
                echo $src;
                ?>
">
    <?php 
            }
        }
    }
    ?>

    <script src="<?php 
    echo SITE_URL;
    ?>
assets/js/jquery-2.1.4.min.js"></script>
    <title><?php 
    echo SITE_TITLE;
    ?>
</title>
</head>

<body>
    <head>
        <nav class="navbar navbar-default navbar-fixed-top">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="<?php 
    echo SITE_URL;
    ?>
dashboard.php">
                        <img src="<?php 
    echo SITE_URL;
    ?>
assets/img/php.ico" width="30px">
                    </a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active"><a hreh="<?php 
    echo SITE_URL;
    ?>
dasboard.php"><span class="glyphicon glyphicon-dashboard"></span>  Dashboard</a></li>
                        <li><a href="<?php 
    echo SITE_URL;
    ?>
atividades/index.php"><span class="glyphicon glyphicon-tasks"></span> Listar atividades</a></li>
                        <li><a href="<?php 
    echo SITE_URL;
    ?>
atividades/form.php"><span class="glyphicon glyphicon-pencil"></span> Criar nova atividade</a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                aria-haspopup="true" aria-expanded="false">
                                <span class="glyphicon glyphicon-cog"></span> Administração <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a href="<?php 
    echo SITE_URL;
    ?>
usuarios/form.php?id=<?php 
    echo $_SESSION['id'];
    ?>
">
                                    <span class="glyphicon glyphicon-user"></span> <?php 
    echo $_SESSION['nome'];
    ?>
</a>
                                </li>
                                <li role="separator" class="divider"></li>

                                <?php 
    if (checkUserIsAdmin()) {
        ?>
                                <li><a href="<?php 
        echo SITE_URL;
        ?>
usuarios/index.php"><span class="glyphicon glyphicon-user"></span> Usuários</a></li>
                                <li><a href="<?php 
        echo SITE_URL;
        ?>
setores/index.php"><span class="glyphicon glyphicon-map-marker"></span> Setores</a></li>
                                <li><a href="<?php 
        echo SITE_URL;
        ?>
status-atividade/index.php"><span class="glyphicon glyphicon-check"></span> Status atividade</a></li>
                                <li role="separator" class="divider"></li>
                                <?php 
    }
    ?>
                                <li><a href="<?php 
    echo SITE_URL;
    ?>
autenticacao/logout.php"><span class="glyphicon glyphicon-log-out"></span> Sair</a></li>
                            </ul>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav><br />
        <div class="page-header text-center">
            <h1>Gerenciador de adividades <small><?php 
    echo VERSION;
    ?>
</small></h1>
        </div>
    </head>
    <main>
<?php 
}
/**
 *  Draws a form to select the Site from which you wish to move a service 
 *  @return null
 */
function drawSelectOldSite()
{
    // Check the user has permission to see the page, will throw exception
    //if the user does not
    checkUserIsAdmin();
    //Get a list  of Sites to select from
    $sites = \Factory::getSiteService()->getSitesBy();
    //Put into an array to be passed to view
    $params = array('Sites' => $sites);
    show_view("admin/move_service_end_point_select_old_site.php", $params);
}
Example #17
0
function remove_scope()
{
    //The following line will be needed if this controller is ever used for non administrators:
    //checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    //Check user has permission
    checkUserIsAdmin();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    //Get the scope from the id
    $serv = \Factory::getScopeService();
    $scope = $serv->getScope($_REQUEST['id']);
    //keep the name to display later
    $params['Name'] = $scope->getName();
    //check to see if there are NGIs, Sites, Service Groups, & services,
    // with this scope tag. If there are, prevent deletion of it.
    $ngisWithScope = $serv->getNgisFromScope($scope);
    $sitesWithScope = $serv->getSitesFromScope($scope);
    $sGroupWithScope = $serv->getServiceGroupsFromScope($scope);
    $serviceWithScope = $serv->getServicesFromScope($scope);
    $deletionAllowed = true;
    if (sizeof($ngisWithScope) > 0) {
        $deletionAllowed = false;
    }
    if (sizeof($sitesWithScope) > 0) {
        $deletionAllowed = false;
    }
    if (sizeof($sGroupWithScope) > 0) {
        $deletionAllowed = false;
    }
    if (sizeof($serviceWithScope) > 0) {
        $deletionAllowed = false;
    }
    //Allow the deletion of scopes that are in use
    $scopeInUseOveride = false;
    if (isset($_REQUEST['ScopeInUseOveride'])) {
        if ($_REQUEST['ScopeInUseOveride'] == 'true') {
            $scopeInUseOveride = true;
            $deletionAllowed = true;
        }
    }
    if ($deletionAllowed) {
        //Delete the scope. This fuction will check the user is allowed to
        //perform this action and throw an error if not.
        $dn = Get_User_Principle();
        $user = \Factory::getUserService()->getUserByPrinciple($dn);
        try {
            $serv->deleteScope($scope, $user, $scopeInUseOveride);
        } catch (\Exception $e) {
            show_view('error.php', $e->getMessage());
            die;
        }
        show_view("admin/deleted_scope.php", $params, $params['Name'] . 'deleted');
    } else {
        $params['ID'] = $scope->getId();
        $params['NGIs'] = $ngisWithScope;
        $params['Sites'] = $sitesWithScope;
        $params['ServiceGroups'] = $sGroupWithScope;
        $params['Services'] = $serviceWithScope;
        show_view('admin/delete_scope_denied.php', $params, "Scope still in use");
    }
}