diff --git a/config/web_portal/menu.xml b/config/web_portal/menu.xml index 310afcfc8..ee39eb7f8 100644 --- a/config/web_portal/menu.xml +++ b/config/web_portal/menu.xml @@ -42,6 +42,12 @@ index.php?Page_Type=Services + + all + Service Types + index.php?Page_Type=Service_Types + + all Scopes @@ -136,7 +142,13 @@ Add Project index.php?Page_Type=Admin_Add_Project - + + + admin + Add Service Type + index.php?Page_Type=Admin_Add_Service_Type + + admin Move Service @@ -149,12 +161,6 @@ index.php?Page_Type=Admin_Move_Site - - admin - Service Types - index.php?Page_Type=Admin_Service_Types - - admin Users diff --git a/config/web_portal/menu.xsd b/config/web_portal/menu.xsd index 7a62fad05..ef6fcae0e 100644 --- a/config/web_portal/menu.xsd +++ b/config/web_portal/menu.xsd @@ -15,6 +15,7 @@ + @@ -26,9 +27,9 @@ + - diff --git a/htdocs/web_portal/controllers/admin/view_service_type.php b/htdocs/web_portal/controllers/service_type/view_service_type.php similarity index 80% rename from htdocs/web_portal/controllers/admin/view_service_type.php rename to htdocs/web_portal/controllers/service_type/view_service_type.php index f94895324..77da4bf6b 100644 --- a/htdocs/web_portal/controllers/admin/view_service_type.php +++ b/htdocs/web_portal/controllers/service_type/view_service_type.php @@ -24,14 +24,17 @@ function view_service_type() { - //Check the user has permission to see the page, will throw exception - //if correct permissions are lacking - checkUserIsAdmin(); + $params = []; + + $identifier = Get_User_Principle(); + $user = \Factory::getUserService()->getUserByPrinciple($identifier); + + if ($user != null) { + $params['isUserAdmin'] = checkUserForAdminCredentials($user); + } 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(); /** @@ -39,16 +42,11 @@ function view_service_type() */ $serviceType = $serv ->getServiceType($_REQUEST['id']); - $params = []; $params['Name'] = $serviceType->getName(); $params['Description'] = $serviceType->getDescription(); $params['ID'] = $serviceType->getId(); $params['AllowMonitoringException'] = $serviceType->getAllowMonitoringException(); $params['Services'] = $serv->getServices($params['ID']); - /** - * @var \User $user - */ - $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user); - show_view("admin/view_service_type.php", $params, $params['Name']); + show_view("service_type/view_service_type.php", $params, $params['Name']); } diff --git a/htdocs/web_portal/controllers/admin/view_service_types.php b/htdocs/web_portal/controllers/service_type/view_service_types.php similarity index 75% rename from htdocs/web_portal/controllers/admin/view_service_types.php rename to htdocs/web_portal/controllers/service_type/view_service_types.php index 1e28a3a6c..6f8370fed 100644 --- a/htdocs/web_portal/controllers/admin/view_service_types.php +++ b/htdocs/web_portal/controllers/service_type/view_service_types.php @@ -23,15 +23,9 @@ require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php'; 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'); + + show_view('service_type/view_service_types.php', $params, 'Service Types'); } diff --git a/htdocs/web_portal/controllers/utils.php b/htdocs/web_portal/controllers/utils.php index aa98bb42e..a65b7838f 100644 --- a/htdocs/web_portal/controllers/utils.php +++ b/htdocs/web_portal/controllers/utils.php @@ -817,3 +817,14 @@ function getReadPDParams($user) } return array($userIsAdmin, $authenticated); } + +/** + * Helper to identify whether the user is an Admin or NOT. + * Useful for deciding whether to display elements based on admin status. + * + * Returns `true` if the user is an Admin, `false` otherwise. + */ +function checkUserForAdminCredentials($user) +{ + return $user->isAdmin(); +} diff --git a/htdocs/web_portal/index.php b/htdocs/web_portal/index.php index 6947b333c..bd64c6129 100644 --- a/htdocs/web_portal/index.php +++ b/htdocs/web_portal/index.php @@ -450,14 +450,14 @@ function Draw_Page($Page_Type) { require_once __DIR__.'/controllers/admin/move_service_end_point.php'; move_service_end_point(); break; - case "Admin_Service_Types": + case "Service_Types": rejectIfNotAuthenticated(); - require_once __DIR__.'/controllers/admin/view_service_types.php'; + require_once __DIR__.'/controllers/service_type/view_service_types.php'; show_all(); break; - case "Admin_Service_Type": + case "Service_Type": rejectIfNotAuthenticated(); - require_once __DIR__.'/controllers/admin/view_service_type.php'; + require_once __DIR__.'/controllers/service_type/view_service_type.php'; view_service_type(); break; case "Admin_Edit_Service_Type": diff --git a/htdocs/web_portal/views/admin/added_service_type.php b/htdocs/web_portal/views/admin/added_service_type.php index 8654752d9..21f7ba52d 100644 --- a/htdocs/web_portal/views/admin/added_service_type.php +++ b/htdocs/web_portal/views/admin/added_service_type.php @@ -4,7 +4,7 @@ - + Click here to view the service type. diff --git a/htdocs/web_portal/views/admin/delete_service_type_denied.php b/htdocs/web_portal/views/admin/delete_service_type_denied.php index 170852f70..b3fad629a 100644 --- a/htdocs/web_portal/views/admin/delete_service_type_denied.php +++ b/htdocs/web_portal/views/admin/delete_service_type_denied.php @@ -3,7 +3,10 @@

Deletion Failed


The service type ' - + + getName());?> ' can not be deleted as the following services are still of this type: diff --git a/htdocs/web_portal/views/admin/edited_service_type.php b/htdocs/web_portal/views/admin/edited_service_type.php index 76b3924eb..8d9ed3bb0 100644 --- a/htdocs/web_portal/views/admin/edited_service_type.php +++ b/htdocs/web_portal/views/admin/edited_service_type.php @@ -1,7 +1,9 @@

Success


-

- Service Type properties have been successfully edited to - +

+ + Service Type properties have been successfully edited to -

diff --git a/htdocs/web_portal/views/admin/view_service_type.php b/htdocs/web_portal/views/service_type/view_service_type.php similarity index 97% rename from htdocs/web_portal/views/admin/view_service_type.php rename to htdocs/web_portal/views/service_type/view_service_type.php index 0c407dccf..e06f31137 100644 --- a/htdocs/web_portal/views/admin/view_service_type.php +++ b/htdocs/web_portal/views/service_type/view_service_type.php @@ -5,7 +5,7 @@ $id = $params['ID']; $services = $params['Services']; $SEsCount = sizeof($services); -$portalIsReadOnly = $params['portalIsReadOnly']; +$isUserAdmin = $params['isUserAdmin']; ?> @@ -20,8 +20,9 @@
- - + +