File tree Expand file tree Collapse file tree 11 files changed +64
-55
lines changed Expand file tree Collapse file tree 11 files changed +64
-55
lines changed Original file line number Diff line number Diff line change 42
42
<link >index.php?Page_Type=Services</link >
43
43
</Services >
44
44
45
+ <ServiceTypes >
46
+ <show_on_instance >all</show_on_instance >
47
+ <name >Service Types</name >
48
+ <link >index.php?Page_Type=Service_Types</link >
49
+ </ServiceTypes >
50
+
45
51
<Scopes >
46
52
<show_on_instance >all</show_on_instance >
47
53
<name >Scopes</name >
136
142
<name >Add Project</name >
137
143
<link >index.php?Page_Type=Admin_Add_Project</link >
138
144
</AddProject >
139
-
145
+
146
+ <AddServiceTypes >
147
+ <show_on_instance >admin</show_on_instance >
148
+ <name >Add Service Type</name >
149
+ <link >index.php?Page_Type=Admin_Add_Service_Type</link >
150
+ </AddServiceTypes >
151
+
140
152
<MoveServiceEndPoint >
141
153
<show_on_instance >admin</show_on_instance >
142
154
<name >Move Service</name >
149
161
<link >index.php?Page_Type=Admin_Move_Site</link >
150
162
</MoveSite >
151
163
152
- <ServiceTypes >
153
- <show_on_instance >admin</show_on_instance >
154
- <name >Service Types</name >
155
- <link >index.php?Page_Type=Admin_Service_Types</link >
156
- </ServiceTypes >
157
-
158
164
<Users >
159
165
<show_on_instance >admin</show_on_instance >
160
166
<name >Users</name >
Original file line number Diff line number Diff line change 15
15
<xs : element name =" Sites" type =" showType" minOccurs =" 0" />
16
16
<xs : element name =" ServiceGroups" type =" showType" minOccurs =" 0" />
17
17
<xs : element name =" Services" type =" showType" minOccurs =" 0" />
18
+ <xs : element name =" ServiceTypes" type =" showType" minOccurs =" 0" />
18
19
<xs : element name =" Scopes" type =" showType" minOccurs =" 0" />
19
20
<xs : element name =" RoleActionMappings" type =" showType" minOccurs =" 0" />
20
21
<xs : element name =" AddSite" type =" showType" minOccurs =" 0" />
26
27
<xs : element name =" HelpAndContact" type =" showType" minOccurs =" 0" />
27
28
<xs : element name =" AddNGI" type =" showType" minOccurs =" 0" />
28
29
<xs : element name =" AddProject" type =" showType" minOccurs =" 0" />
30
+ <xs : element name =" AddServiceType" type =" showType" minOccurs =" 0" />
29
31
<xs : element name =" MoveServiceEndPoint" type =" showType" minOccurs =" 0" />
30
32
<xs : element name =" MoveSite" type =" showType" minOccurs =" 0" />
31
- <xs : element name =" ServiceTypes" type =" showType" minOccurs =" 0" />
32
33
<xs : element name =" Users" type =" showType" minOccurs =" 0" />
33
34
</xs : all >
34
35
</xs : complexType >
Original file line number Diff line number Diff line change 24
24
25
25
function view_service_type ()
26
26
{
27
- //Check the user has permission to see the page, will throw exception
28
- //if correct permissions are lacking
29
- checkUserIsAdmin ();
27
+ $ params = [];
28
+
29
+ $ identifier = Get_User_Principle ();
30
+ $ user = \Factory::getUserService ()->getUserByPrinciple ($ identifier );
31
+
32
+ if ($ user != null ) {
33
+ $ params ['isUserAdmin ' ] = checkUserForAdminCredentials ($ user );
34
+ }
30
35
if (!isset ($ _REQUEST ['id ' ]) || !is_numeric ($ _REQUEST ['id ' ])) {
31
36
throw new Exception ("An id must be specified " );
32
37
}
33
- $ dn = Get_User_Principle ();
34
- $ user = \Factory::getUserService ()->getUserByPrinciple ($ dn );
35
38
36
39
$ serv = \Factory::getServiceTypeService ();
37
40
/**
38
41
* @var \ServiceType $serviceType
39
42
*/
40
43
$ serviceType = $ serv ->getServiceType ($ _REQUEST ['id ' ]);
41
44
42
- $ params = [];
43
45
$ params ['Name ' ] = $ serviceType ->getName ();
44
46
$ params ['Description ' ] = $ serviceType ->getDescription ();
45
47
$ params ['ID ' ] = $ serviceType ->getId ();
46
48
$ params ['AllowMonitoringException ' ] = $ serviceType ->getAllowMonitoringException ();
47
49
$ params ['Services ' ] = $ serv ->getServices ($ params ['ID ' ]);
48
- /**
49
- * @var \User $user
50
- */
51
- $ params ['portalIsReadOnly ' ] = portalIsReadOnlyAndUserIsNotAdmin ($ user );
52
50
53
- show_view ("admin /view_service_type.php " , $ params , $ params ['Name ' ]);
51
+ show_view ("service_type /view_service_type.php " , $ params , $ params ['Name ' ]);
54
52
}
Original file line number Diff line number Diff line change 23
23
require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php ' ;
24
24
25
25
function show_all (){
26
- //Check the user has permission to see the page, will throw exception
27
- //if correct permissions are lacking
28
- checkUserIsAdmin ();
29
-
30
- $ dn = Get_User_Principle ();
31
- $ user = \Factory::getUserService ()->getUserByPrinciple ($ dn );
32
26
33
27
$ serviceTypes = \Factory::getServiceTypeService ()->getServiceTypes ();
34
28
$ params ['ServiceTypes ' ]= $ serviceTypes ;
35
- $ params [ ' portalIsReadOnly ' ] = portalIsReadOnlyAndUserIsNotAdmin ( $ user );
36
- show_view ('admin /view_service_types.php ' , $ params , 'Service Types ' );
29
+
30
+ show_view ('service_type /view_service_types.php ' , $ params , 'Service Types ' );
37
31
}
Original file line number Diff line number Diff line change @@ -817,3 +817,14 @@ function getReadPDParams($user)
817
817
}
818
818
return array ($ userIsAdmin , $ authenticated );
819
819
}
820
+
821
+ /**
822
+ * Helper to identify whether the user is an Admin or NOT.
823
+ * Useful for deciding whether to display elements based on admin status.
824
+ *
825
+ * Returns `true` if the user is an Admin, `false` otherwise.
826
+ */
827
+ function checkUserForAdminCredentials ($ user )
828
+ {
829
+ return $ user ->isAdmin ();
830
+ }
Original file line number Diff line number Diff line change @@ -450,14 +450,14 @@ function Draw_Page($Page_Type) {
450
450
require_once __DIR__ .'/controllers/admin/move_service_end_point.php ' ;
451
451
move_service_end_point ();
452
452
break ;
453
- case "Admin_Service_Types " :
453
+ case "Service_Types " :
454
454
rejectIfNotAuthenticated ();
455
- require_once __DIR__ .'/controllers/admin /view_service_types.php ' ;
455
+ require_once __DIR__ .'/controllers/service_type /view_service_types.php ' ;
456
456
show_all ();
457
457
break ;
458
- case "Admin_Service_Type " :
458
+ case "Service_Type " :
459
459
rejectIfNotAuthenticated ();
460
- require_once __DIR__ .'/controllers/admin /view_service_type.php ' ;
460
+ require_once __DIR__ .'/controllers/service_type /view_service_type.php ' ;
461
461
view_service_type ();
462
462
break ;
463
463
case "Admin_Edit_Service_Type " :
Original file line number Diff line number Diff line change 4
4
5
5
<?php require_once __DIR__ . '/../fragments/serviceTypeInfo.php ' ; ?>
6
6
7
- <a href="index.php?Page_Type=Admin_Service_Type &id=<?php echo $ params ['ID ' ] ?> ">
7
+ <a href="index.php?Page_Type=Service_Type &id=<?= $ params ['ID ' ]; ?> ">
8
8
Click here</a> to view the <?php xecho ($ params ['Name ' ])?> service type.
9
9
10
10
Original file line number Diff line number Diff line change 3
3
<div class="rightPageContainer">
4
4
<h1 class="Success">Deletion Failed</h1><br />
5
5
The service type '
6
- <a href="index.php?Page_Type=Admin_Service_Type&id=<?php echo $ serviceType ->getId ();?> ">
6
+ <?php
7
+ $ serviceTypeRelPath = "index.php?Page_Type=Service_Type " ;
8
+ ?>
9
+ <a href="<?= $ serviceTypeRelPath ; ?> &id=<?= $ serviceType ->getId (); ?> ">
7
10
<?php xecho ($ serviceType ->getName ());?>
8
11
</a>'
9
12
can not be deleted as the following services are still of this type:
Original file line number Diff line number Diff line change 1
1
<div class="rightPageContainer">
2
2
<h1 class="Success">Success</h1><br />
3
- <p><a href="index.php?Page_Type=Admin_Service_Type&id=<?php echo $ params ['ID ' ]?> ">
4
- <?php xecho ($ params ['Name ' ])?> </a> Service Type properties have been successfully edited to -
3
+ <p>
4
+ <a href="index.php?Page_Type=Service_Type&id=<?= $ params ['ID ' ]; ?> "
5
+ ><?php xecho ($ params ['Name ' ]); ?> </a>
6
+ Service Type properties have been successfully edited to -
5
7
</p>
6
8
7
9
<?php require_once __DIR__ . '/../fragments/serviceTypeInfo.php ' ; ?>
Original file line number Diff line number Diff line change 5
5
$ id = $ params ['ID ' ];
6
6
$ services = $ params ['Services ' ];
7
7
$ SEsCount = sizeof ($ services );
8
- $ portalIsReadOnly = $ params ['portalIsReadOnly ' ];
8
+ $ isUserAdmin = $ params ['isUserAdmin ' ];
9
9
?>
10
10
11
11
20
20
</div>
21
21
22
22
<!--Edit/Delete buttons-->
23
- <!-- Only show when portal is not read only mode -->
24
- <?php if (!$ portalIsReadOnly ) :?>
23
+ <!--Enable edit and delete functionality ONLY when
24
+ the web portal is accessed by an Admin.-->
25
+ <?php if ($ isUserAdmin ) :?>
25
26
<div style="float: right;">
26
27
<div style="float: right; margin-left: 2em;">
27
28
<a href="index.php?Page_Type=Admin_Edit_Service_Type&id=<?php echo $ id ?> ">
You can’t perform that action at this time.
0 commit comments