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'); }
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; }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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(); } }
/** * 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'); }
/** * Controller for a Site role request. * Is called by 'Page_Type=Request_Role' page mapping in index.php front controller. * @global array $_POST only set if the browser has POSTed data */ function request_role() { $user = \Factory::getUserService()->getUserByPrinciple(Get_User_Principle()); if ($user == null) { throw new Exception("Unregistered users can't request roles"); } //Check the portal is not in read only mode, returns exception if it is and user is not an admin checkPortalIsNotReadOnlyOrUserIsAdmin($user); // If we receive a POST request it's for a new role if (isset($_REQUEST['Role_Name_Value']) && isset($_REQUEST['Object_ID'])) { submitRoleRequest($_REQUEST['Role_Name_Value'], $_REQUEST['Object_ID'], $user); } else { if (isset($_REQUEST['id'])) { drawViewRequestRole($_REQUEST['id'], $user); } else { // If there is no post data, draw the request role form } } }
/** * Controller for an edit downtime request * @global array $_POST only set if the browser has POSTed data * @return null */ function endDt() { require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php'; require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php'; require_once __DIR__ . '/../utils.php'; if (!isset($_POST['id']) || !is_numeric($_POST['id'])) { throw new Exception("A downtime id must be specified"); } $serv = \Factory::getDowntimeService(); $dt = $serv->getDowntime($_POST['id']); if ($dt == null) { throw new Exception("No downtime with that id"); } $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); $serv->endDowntime($dt, $user); $params = array('downtime' => $dt); show_view("downtime/ended_downtime.php", $params); }
function view_deny_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 view/deny role requests"); } $requestId = $_POST['id']; //Check the portal is not in read only mode, returns exception if it is and user is not an admin checkPortalIsNotReadOnlyOrUserIsAdmin($user); if (!isset($requestId) || !is_numeric($requestId)) { throw new LogicException("Invalid role request id"); } // Lookup role request with id $roleRequest = \Factory::getRoleService()->getRoleById($requestId); \Factory::getRoleService()->rejectRoleRequest($roleRequest, $user); show_view('political_role/request_denied.php'); die; }
/** * Controller for a delete service group request * @return null */ function delete() { require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php'; require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php'; require_once __DIR__ . '/../utils.php'; if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) { throw new Exception("An id must be specified"); } $serv = \Factory::getServiceGroupService(); $sg = $serv->getServiceGroup($_REQUEST['id']); $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); try { $serv->deleteServiceGroup($sg, $user); } catch (\Exception $e) { show_view('error.php', $e->getMessage()); die; } show_view('service_group/deleted_service_group.php'); }
/** * Controller for a delete downtime request * @return null */ function delete() { require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php'; require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php'; require_once __DIR__ . '/../utils.php'; $dn = Get_User_Principle(); $user = \Factory::getUserService()->getUserByPrinciple($dn); if (is_null($user)) { throw new \Exception("Unregistered users can't delete a downtime."); } //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::getDowntimeService(); if (isset($_REQUEST['id'])) { $dt = $serv->getDowntime($_REQUEST['id']); if ($dt != null) { $serv->deleteDowntime($dt, $user); } } show_view('downtime/deleted_downtime.php'); }