Ejemplo n.º 1
0
function my_sites()
{
    require_once __DIR__ . '/../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../components/Get_User_Principle.php';
    $params = array();
    $userServ = \Factory::getUserService();
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if (is_null($user)) {
        show_view('error.php', "Unregistered users can't hold a role over sites, NGIs or service groups.");
        die;
    }
    $sites = $userServ->getSitesFromRoles($user);
    if (!empty($sites)) {
        $params['sites_from_roles'] = $sites;
    }
    $sGroups = $userServ->getSGroupsFromRoles($user);
    if (!empty($sGroups)) {
        $params['sgroups_from_roles'] = $sGroups;
    }
    $ngis = $userServ->getNgisFromRoles($user);
    if (!empty($ngis)) {
        $params['ngis_from_roles'] = $ngis;
    }
    $projects = $userServ->getProjectsFromRoles($user);
    if (!empty($projects)) {
        $params['projects_from_roles'] = $projects;
    }
    $title = "My Sites and Groups";
    show_view('my_sites.php', $params, $title);
}
Ejemplo n.º 2
0
function view_se()
{
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $id = $_GET['id'];
    //get user for case that portal is read only and user is admin, so they can still see edit links
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $serv = \Factory::getServiceService();
    $params['authenticated'] = false;
    if ($user != null) {
        $params['authenticated'] = true;
    }
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    $se = $serv->getService($id);
    // Does current viewer have edit permissions over object ?
    $params['ShowEdit'] = false;
    if ($user != null && count($serv->authorizeAction(\Action::EDIT_OBJECT, $se, $user)) >= 1) {
        $params['ShowEdit'] = true;
    }
    $title = $se->getHostName() . " - " . $se->getServiceType()->getName();
    $params['se'] = $se;
    $params['sGroups'] = $se->getServiceGroups();
    $params['Scopes'] = $serv->getScopesWithParentScopeInfo($se);
    // Show upcoming downtimes and downtimes that started within the last thirty days
    $downtimes = $serv->getDowntimes($id, 31);
    $params['Downtimes'] = $downtimes;
    show_view("service/view_service.php", $params, $title);
}
Ejemplo n.º 3
0
/**
 * Retrieves the NGIS to be added and then add them.
 * @return null 
*/
function submit()
{
    require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
    //Get user details (for the remove ngi function so it can check permissions)
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    //Get a project and NGI services
    $projectServ = \Factory::getProjectService();
    $ngiServ = \Factory::getNgiService();
    //Get the posted service type data
    $projectId = $_REQUEST['ID'];
    $ngiIds = $_REQUEST['NGIs'];
    //turn ngiIds into NGIs
    $ngis = new Doctrine\Common\Collections\ArrayCollection();
    foreach ($ngiIds as $ngiId) {
        $ngis[] = $ngiServ->getNgi($ngiId);
    }
    //get the project
    $project = $projectServ->getProject($projectId);
    try {
        //function will throw error if user does not have the correct permissions
        $projectServ->addNgisToProject($project, $ngis, $user);
        $params = array('Name' => $project->getName(), 'ID' => $project->getId(), 'NGIs' => $ngis);
        show_view("project/added_ngis.php", $params, "Success");
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Ejemplo n.º 4
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);
}
Ejemplo n.º 5
0
function delete_project()
{
    if (true) {
        throw new Exception("Project deletion is disabled - see controller to enable");
    }
    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);
    //Check the portal is not in read only mode, returns exception if it is and user is not an admin
    checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    //Get the project from the id
    $serv = \Factory::getProjectService();
    $project = $serv->getProject($_REQUEST['id']);
    //keep the name to display later
    $params['Name'] = $project->getName();
    // Delete the project. This fuction will check the user is allowed to
    // perform this action and throw an error if not (only gocdb admins allowed).
    // Project deletion does not delete child NGIs and automatically cascade
    // deletes the user Roles over the OwnedEntity.
    try {
        $serv->deleteProject($project, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view("project/deleted_project.php", $params, $params['Name'] . 'deleted');
}
Ejemplo n.º 6
0
function view_revoke_request()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../../components/Get_User_Principle.php';
    require_once __DIR__ . '/../utils.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if ($user == null) {
        throw new Exception("Unregistered users can't revoke roles");
    }
    //Check the portal is not in read only mode, returns exception if it is and user is not an admin
    checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    $requestId = $_POST['id'];
    if (!isset($requestId) || !is_numeric($requestId)) {
        throw new LogicException("Invalid role id");
    }
    // Either a self revocation or revoke is requested by 2nd party
    // check to see that user has permission to revoke role
    $role = \Factory::getRoleService()->getRoleById($requestId);
    \Factory::getRoleService()->revokeRole($role, $user);
    if ($role->getUser() != $user) {
        // revoke by 2nd party
        show_view('political_role/role_revoked.php');
    } else {
        // Self revocation
        show_view('political_role/role_self_revoked.php');
    }
    die;
}
Ejemplo n.º 7
0
function CheckCurrentUserCanEditProject(\Project $project)
{
    require_once __DIR__ . '/../../web_portal/components/Get_User_Principle.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $enablingRoles = \Factory::getProjectService()->authorizeAction('ACTION_EDIT_OBJECT', $project, $user);
    if (count($enablingRoles) == 0) {
        throw new Exception("You do not have a role that enables you to edit this project");
    }
}
Ejemplo n.º 8
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');
}
Ejemplo n.º 9
0
function view_ngi()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $ngiId = $_GET['id'];
    //get user for case that portal is read only and user is admin, so they can still see edit links
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    $params['UserIsAdmin'] = false;
    if (!is_null($user)) {
        $params['UserIsAdmin'] = $user->isAdmin();
    }
    $params['authenticated'] = false;
    if ($user != null) {
        $params['authenticated'] = true;
    }
    $ngiServ = \Factory::getNgiService();
    $siteServ = \Factory::getSiteService();
    $ngi = $ngiServ->getNgi($ngiId);
    // Does current viewer have edit permissions over NGI ?
    $params['ShowEdit'] = false;
    if (count($ngiServ->authorizeAction(\Action::EDIT_OBJECT, $ngi, $user)) >= 1) {
        $params['ShowEdit'] = true;
    }
    // Add ngi to params
    $params['ngi'] = $ngi;
    // Add all roles over ngi to params
    $allRoles = $ngi->getRoles();
    $roles = array();
    foreach ($allRoles as $role) {
        if ($role->getStatus() == \RoleStatus::GRANTED) {
            $roles[] = $role;
        }
    }
    $params['roles'] = $roles;
    // Add ngi's project to params
    $projects = $ngi->getProjects();
    $params['Projects'] = $projects;
    // Add sites and scopes to params
    $params['SitesAndScopes'] = array();
    foreach ($ngi->getSites() as $site) {
        $params['SitesAndScopes'][] = array('Site' => $site, 'Scopes' => $siteServ->getScopesWithParentScopeInfo($site));
    }
    // Add RoleActionRecords to params
    $params['RoleActionRecords'] = \Factory::getRoleService()->getRoleActionRecordsById_Type($ngi->getId(), 'ngi');
    show_view('ngi/view_ngi.php', $params, $ngi->getName());
    die;
}
Ejemplo n.º 10
0
/**
 * Controller for an edit site property request
 * @global array $_POST only set if the browser has POSTed data
 * @return null
 */
function edit_property()
{
    $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);
    if ($_POST) {
        submit($user);
    } else {
        draw($user);
    }
}
Ejemplo n.º 11
0
function view_user()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../../components/Get_User_Principle.php';
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $userId = $_GET['id'];
    $user = \Factory::getUserService()->getUser($userId);
    if ($user === null) {
        throw new Exception("No user with that ID");
    }
    $params['user'] = $user;
    // get the targetUser's roles
    $roles = \Factory::getRoleService()->getUserRoles($user, \RoleStatus::GRANTED);
    //$user->getRoles();
    $callingUser = \Factory::getUserService()->getUserByPrinciple(Get_User_Principle());
    // can the calling user revoke the targetUser's roles?
    if ($user != $callingUser) {
        foreach ($roles as $r) {
            //$ownedEntityDetail = $r->getOwnedEntity()->getName(). ' ('. $r->getOwnedEntity()->getType().')';
            $authorisingRoleNames = \Factory::getRoleService()->authorizeAction(\Action::REVOKE_ROLE, $r->getOwnedEntity(), $callingUser);
            if (count($authorisingRoleNames) >= 1) {
                $allAuthorisingRoleNames = '';
                foreach ($authorisingRoleNames as $arName) {
                    $allAuthorisingRoleNames .= $arName . ', ';
                }
                $allAuthorisingRoleNames = substr($allAuthorisingRoleNames, 0, strlen($allAuthorisingRoleNames) - 2);
                $r->setDecoratorObject('[' . $allAuthorisingRoleNames . '] ');
            }
        }
    } else {
        // current user is viewing their own roles, so they can revoke their own roles
        foreach ($roles as $r) {
            $r->setDecoratorObject('[Self revoke own role]');
        }
    }
    // Check to see if the current calling user has permission to edit the target user
    try {
        \Factory::getUserService()->editUserAuthorization($user, $callingUser);
        $params['ShowEdit'] = true;
    } catch (Exception $e) {
        $params['ShowEdit'] = false;
    }
    /* @var $authToken \org\gocdb\security\authentication\IAuthentication */
    $authToken = Get_User_AuthToken();
    $params['authAttributes'] = $authToken->getDetails();
    $params['roles'] = $roles;
    $params['portalIsReadOnly'] = \Factory::getConfigService()->IsPortalReadOnly();
    $title = $user->getFullName();
    show_view("user/view_user.php", $params, $title);
}
Ejemplo n.º 12
0
/**
 * Dies if the request can't be authenticated. 
 * @param string $message If not specified, a default message is used. 
 */
function rejectIfNotAuthenticated($message = null)
{
    $authPrincipleStr = Get_User_Principle();
    if (empty($authPrincipleStr)) {
        // prob better to do a re-direct here to error page.
        if ($message == null) {
            die('Access Denined, authentication failed - A valid user certificate was not found');
            //or your EGI SSO user account is not associated with a valid certificate.');
        } else {
            die($message);
        }
    }
}
Ejemplo n.º 13
0
function startPage()
{
    require_once __DIR__ . '/../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../components/Get_User_Principle.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $roles = \Factory::getRoleService()->getPendingRolesUserCanApprove($user);
    $configServ = \Factory::getConfigService();
    $showMap = $configServ->getShowMapOnStartPage();
    $apiKey = $configServ->getGoogleAPIKey();
    $params = array('roles' => $roles, 'googleAPIKey' => $apiKey, 'showMap' => $showMap);
    $title = "GOCDB";
    show_view('start_page.php', $params, $title, null);
}
Ejemplo n.º 14
0
/**
 * Controller for an edit service request
 * @global array $_POST only set if the browser has POSTed data
 * @return null
 */
function edit_service()
{
    $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);
    if ($_POST) {
        // If we receive a POST request it's for a new site
        submit($user);
    } else {
        // If there is no post data, draw the edit site form
        draw($user);
    }
}
Ejemplo n.º 15
0
function delete()
{
    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);
    //get the site
    $site = \Factory::getSiteService()->getSite($_REQUEST['id']);
    if ($_POST or sizeof($site->getServices()) == 0) {
        submit($site, $user);
    } else {
        draw($site);
    }
}
Ejemplo n.º 16
0
function getSitesServices()
{
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    if (!isset($_REQUEST['site_id']) || !is_numeric($_REQUEST['site_id'])) {
        throw new Exception("A site_id must be specified");
    }
    $site = \Factory::getSiteService()->getSite($_REQUEST['site_id']);
    $services = $site->getServices();
    $params['services'] = $services;
    show_view("downtime/view_services.php", $params, null, true);
}
Ejemplo n.º 17
0
/**
 * Controller for a new_property request
 * @global array $_POST only set if the browser has POSTed data
 * @return null
 */
function add_service_group_property()
{
    $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 user has modification rights for this entity
    if ($_POST) {
        // If we receive a POST request it's for a new property
        submit($user);
    } else {
        // If there is no post data, draw the New property form
        draw($user);
    }
}
Ejemplo n.º 18
0
/**
 * Controller for a delete service request
 * @return null
 */
function delete()
{
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if ($user == null) {
        throw new \Exception("Unregistered users can't delete services. ");
    }
    //Check the portal is not in read only mode, returns exception if it is and user is not an admin
    checkPortalIsNotReadOnlyOrUserIsAdmin($user);
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $serv = \Factory::getServiceService();
    $se = $serv->getService($_REQUEST['id']);
    $serv->deleteService($se, $user);
    show_view('service/service_deleted.php');
}
Ejemplo n.º 19
0
function submit()
{
    $oldDn = $_REQUEST['OLDDN'];
    $givenEmail = $_REQUEST['EMAIL'];
    $currentDn = Get_User_Principle();
    if (empty($currentDn)) {
        show_view('error.php', "Could not authenticate user - null user principle");
        die;
    }
    try {
        $changeReq = \Factory::getRetrieveAccountService()->newRetrieveAccountRequest($currentDn, $givenEmail, $oldDn);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('user/retrieve_account_accepted.php');
}
function delete()
{
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    //get the site
    if (isset($_REQUEST['propertyid']) || !is_numeric($_REQUEST['propertyid'])) {
        $property = \Factory::getServiceGroupService()->getProperty($_REQUEST['propertyid']);
        $serviceGroup = \Factory::getServiceGroupService()->getServiceGroup($_REQUEST['id']);
    } else {
        throw new \Exception("A service group must be specified");
    }
    if ($_POST) {
        submit($property, $user, $serviceGroup);
    } else {
        draw($property, $serviceGroup, $user);
    }
}
Ejemplo n.º 21
0
function view()
{
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $downtime = \Factory::getDowntimeService()->getDowntime($_REQUEST['id']);
    if ($downtime == null) {
        throw new Exception('No downtime with id [' . $_REQUEST['id'] . ']');
    }
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    $params['downtime'] = $downtime;
    $title = $downtime->getDescription();
    show_view("downtime/view_downtime.php", $params, $title);
}
Ejemplo n.º 22
0
/**
 * Retrieves the new NGI's data from a portal request and submit it to the
 * services layer's NGI functions.
 * @return null
 */
function submit()
{
    require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
    //Get the posted NGI data
    $newValues = getNGIDataFromWeb();
    //get the user data for the add NGI function (so it can check permissions)
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    try {
        //function will through error if user does not have the correct permissions
        $ngi = \Factory::getNgiService()->addNGI($newValues, $user);
        $params = array('Name' => $ngi->getName(), 'ID' => $ngi->getId());
        show_view("admin/added_ngi.php", $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Ejemplo n.º 23
0
/**
 * Retrieves the new service type's data from a portal request and submit it to the
 * services layer's service type functions.
 * @return null
 */
function submit()
{
    require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
    //Get the posted service type data
    $newValues = getSTDataFromWeb();
    //get the user data for the add service type function (so it can check permissions)
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    try {
        //function will through error if user does not have the correct permissions
        $serviceType = \Factory::getServiceTypeService()->addServiceType($newValues, $user);
        $params = array('Name' => $serviceType->getName(), 'Description' => $serviceType->getDescription(), 'ID' => $serviceType->getId());
        show_view("admin/added_service_type.php", $params, "Successfuly added new service type");
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Ejemplo n.º 24
0
function add_menu_item($menu_item)
{
    //Get user in order to correctly display GOCDB admin menu Items
    include_once __DIR__ . '/../Get_User_Principle.php';
    $dn = Get_User_Principle();
    $userserv = \Factory::getUserService();
    $user = $userserv->getUserByPrinciple($dn);
    if ($user == null) {
        $userisadmin = false;
    } else {
        $userisadmin = $user->isAdmin();
    }
    //Find out if the portal is currently read only from local_info.xml
    $portalIsReadOnly = \Factory::getConfigService()->IsPortalReadOnly();
    foreach ($menu_item->children() as $key => $value) {
        $html = "";
        switch ($key) {
            case "show_on_instance":
                $show = strtolower($value);
                break;
            case "name":
                $name = $value;
                break;
            case "link":
                $link = $value;
                break;
            case "spacer":
                // John C: modified this so that we could use show_on_instance for spacers
                foreach ($menu_item as $child_name => $child_value) {
                    if ($child_name == "show_on_instance") {
                        // If the spacer has a show_on_instance type that we want to show, then show it
                        if ($child_value == "all" or $child_value == "write_enabled" and (!$portalIsReadOnly or $userisadmin) or $child_value == "admin" and $userisadmin) {
                            return "</ul><h4 class='menu_title'>{$value}</h4><ul class=\"Smaller_Left_Padding Smaller_Top_Margin\">";
                        }
                    }
                }
                return;
        }
    }
    if ($show == "all" or $show == "write_enabled" and (!$portalIsReadOnly or $userisadmin) or $show == "admin" and $userisadmin) {
        $html .= "<li class=\"Menu_Item\">" . "<a href=\"" . $link . "\"><span class=\"menu_link\">" . $name . "</span></a></li>";
    }
    return $html;
}
Ejemplo n.º 25
0
function submit()
{
    $newValues = getUserDataFromWeb();
    $dn = Get_User_Principle();
    $serv = \Factory::getUserService();
    // Current User
    $currentUser = $serv->getUserByPrinciple($dn);
    // User entity to edit
    $user = $serv->getUser($newValues['ID']);
    unset($newValues['ID']);
    try {
        $user = $serv->editUser($user, $newValues, $currentUser);
        $params = array('user' => $user);
        show_view('user/user_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Ejemplo n.º 26
0
function Get_User_Status_HTML()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../Get_User_Principle.php';
    $HTML = "";
    $HTML .= "<div class=\"Indented\">";
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if ($user == null) {
        $HTML .= "Unregistered user<br />";
        $HTML .= "<br/><a href=\"index.php?Page_Type=Register\">" . "Register</a><br/>" . "<a href=\"index.php?Page_Type=Retrieve_Account\">" . "Retrieve Old Account</a><br/>";
        $HTML .= "</div>";
        return $HTML;
    }
    $HTML .= "Registered as: <br />" . $user->getForename() . " " . $user->getSurname() . "<br /><br />";
    $HTML .= Get_User_Info_HTML($user);
    $HTML .= "</div>";
    return $HTML;
}
Ejemplo n.º 27
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']);
}
Ejemplo n.º 28
0
function delete()
{
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if (!isset($_REQUEST['propertyid']) || !is_numeric($_REQUEST['propertyid'])) {
        throw new Exception("A propertyid must be specified");
    }
    if (!isset($_REQUEST['serviceid']) || !is_numeric($_REQUEST['serviceid'])) {
        throw new Exception("A service id must be specified");
    }
    //get the service and property
    $property = \Factory::getServiceService()->getProperty($_REQUEST['propertyid']);
    $service = \Factory::getServiceService()->getService($_REQUEST['serviceid']);
    if ($_POST) {
        submit($property, $service, $user);
    } else {
        draw($property, $service, $user);
    }
}
Ejemplo n.º 29
0
function submit()
{
    $values = getUserDataFromWeb();
    $dn = Get_User_Principle();
    if (empty($dn)) {
        show_view('error.php', "Could not authenticate user - null user principle");
        die;
    }
    $values['CERTIFICATE_DN'] = $dn;
    $serv = \Factory::getUserService();
    try {
        $user = $serv->register($values);
        $params = array('user' => $user);
        show_view('user/registered.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
Ejemplo n.º 30
0
function delete_endpoint()
{
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if (!isset($_REQUEST['endpointid']) || !is_numeric($_REQUEST['endpointid'])) {
        throw new Exception("An endpointid must be specified");
    }
    if (!isset($_REQUEST['serviceid']) || !is_numeric($_REQUEST['serviceid'])) {
        throw new Exception("A service id must be specified");
    }
    //get the service and endpoint
    $endpoint = \Factory::getServiceService()->getEndpoint($_REQUEST['endpointid']);
    $service = \Factory::getServiceService()->getService($_REQUEST['serviceid']);
    if ($_POST) {
        submit($endpoint, $service, $user);
    } else {
        draw($endpoint, $service, $user);
    }
}