Skip to content

Commit 214063a

Browse files
committed
[GT-184] Apply styles for the PR #464
1 parent 7bc3b3f commit 214063a

File tree

11 files changed

+2037
-962
lines changed

11 files changed

+2037
-962
lines changed
Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
/*______________________________________________________
34
*======================================================
45
* File: edit_api_auth.php
56
* Author: George Ryall
6-
* Description: Processes a edit API Authentication entity request. If the user
7-
* hasn't POSTed any data we draw the new site
7+
* Description: Processes a edit API Authentication entity request.
8+
* If the user hasn't POSTed any data we draw the new site
89
* form. If they post data we assume they've posted it from
910
* the form and validate then insert it into the DB.
1011
*
@@ -21,24 +22,38 @@
2122
* See the License for the specific language governing permissions and
2223
* limitations under the License.
2324
/*======================================================*/
24-
require_once __DIR__.'/../../../web_portal/components/Get_User_Principle.php';
25-
require_once __DIR__.'/../utils.php';
26-
require_once __DIR__.'/../../../../lib/Gocdb_Services/Factory.php';
25+
require_once __DIR__
26+
. '/../../../web_portal/components/Get_User_Principle.php';
27+
require_once __DIR__ . '/../utils.php';
28+
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
29+
30+
use Exception;
2731

2832
/**
2933
* Controller to edit authentication entity request
30-
* @global array $_POST only set if the browser has POSTed data
34+
*
35+
* @global array $_POST only set if the browser has posted data
36+
*
3137
* @return null
3238
*/
33-
function edit_entity() {
39+
function edit_entity()
40+
{
3441
$dn = Get_User_Principle();
3542
$user = \Factory::getUserService()->getUserByPrinciple($dn);
3643

37-
//Check the portal is not in read only mode, returns exception if it is and user is not an admin
44+
/**
45+
* Check the portal is not in read only mode,
46+
* returns exception if it is and user is not an admin
47+
*/
3848
checkPortalIsNotReadOnlyOrUserIsAdmin($user);
3949

40-
if (!isset($_REQUEST['authentityid']) || !is_numeric($_REQUEST['authentityid']) ){
41-
throw new Exception("A authentication entity id must be specified in the url");
50+
if (
51+
!isset($_REQUEST['authentityid'])
52+
|| !is_numeric($_REQUEST['authentityid'])
53+
) {
54+
throw new Exception(
55+
"A authentication entity id must be specified in the url"
56+
);
4257
}
4358

4459
$serv = \Factory::getSiteService();
@@ -47,48 +62,67 @@ function edit_entity() {
4762

4863
// Validate the user has permission to edit properties
4964
if (!$serv->userCanEditSite($user, $site)) {
50-
throw new \Exception("Permission denied: a site role is required to edit authentication entities at " . $site->getShortName());
65+
throw new Exception(
66+
"Permission denied: a site role is required to edit "
67+
. "authentication entities at "
68+
. $site->getShortName()
69+
);
5170
}
5271

53-
if($_POST) { // If we receive a POST request it's to edit an authentication entity
72+
// If we receive a POST request it's to edit an authentication entity
73+
if ($_POST) {
5474
submit($user, $authEnt, $site, $serv);
55-
} else { // If there is no post data, draw the edit authentication entity form
75+
} else {
76+
// If there is no post data, draw the edit authentication entity form
5677
draw($user, $authEnt, $site);
5778
}
5879
}
5980

60-
function draw(\User $user = null, \APIAuthentication $authEnt = null, \Site $site = null) {
61-
if(is_null($user)){
62-
throw new Exception("Unregistered users can't edit authentication credentials");
81+
function draw(
82+
\User $user = null,
83+
\APIAuthentication $authEnt = null,
84+
\Site $site = null
85+
) {
86+
if (is_null($user)) {
87+
throw new Exception(
88+
"Unregistered users can't edit authentication credentials"
89+
);
6390
}
6491

6592
$params = array();
6693
$params['site'] = $site;
6794
$params['authEnt'] = $authEnt;
6895
$params['authTypes'] = array();
69-
$params['authTypes'][]='X.509';
70-
$params['authTypes'][]='OIDC Subject';
96+
$params['authTypes'][] = 'X.509';
97+
$params['authTypes'][] = 'OIDC Subject';
7198
$params['user'] = $user;
7299

73100
show_view("site/edit_api_auth.php", $params);
101+
74102
die();
75103
}
76104

77-
function submit(\User $user, \APIAuthentication $authEnt, \Site $site, org\gocdb\services\Site $serv) {
105+
function submit(
106+
\User $user,
107+
\APIAuthentication $authEnt,
108+
\Site $site,
109+
org\gocdb\services\Site $serv
110+
) {
78111
$newValues = getAPIAuthenticationFromWeb();
79112

80113
try {
81114
$authEnt = $serv->editAPIAuthEntity($authEnt, $user, $newValues);
82-
} catch(Exception $e) {
115+
} catch (Exception $e) {
83116
show_view('error.php', $e->getMessage());
117+
84118
die();
85119
}
86120

87121
$params = array();
88122
$params['apiAuthenticationEntity'] = $authEnt;
89123
$params['site'] = $site;
90-
show_view("site/edited_api_auth.php", $params);
91-
die();
92124

125+
show_view("site/edited_api_auth.php", $params);
93126

127+
die();
94128
}
Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<div class="rightPageContainer">
22
<?php
3-
43
$user = $params['user'];
54
$entUser = $params['authEnt']->getUser();
65

@@ -9,7 +8,6 @@
98
echo('</h1>');
109

1110
if (!is_null($entUser)) {
12-
1311
echo('<h4>This credential is linked to GOCDB user ');
1412
echo('<a href="');
1513
xecho(\GocContextPath::getPath());
@@ -27,46 +25,90 @@
2725
echo("' to '");
2826
xecho($user->getFullname());
2927
echo("'. Click the browser Back button to cancel the edit.</div>");
30-
}
31-
32-
} else {
33-
// This clause should be deleted or replaced with exception after all
34-
// authentication entities are assigned a user.
35-
echo('<div class="input_warning">');
36-
echo("WARNING: editing will link user '");
37-
xecho($user->getFullname());
38-
echo("' to this credential. Click the browser Back button to cancel the edit.</div>");
28+
}
29+
} else {
30+
/**
31+
* This clause should be deleted or replaced with exception after
32+
* all authentication entities are assigned a user.
33+
*/
34+
echo('<div class="input_warning">');
35+
echo("WARNING: editing will link user '");
36+
xecho($user->getFullname());
37+
echo(
38+
"' to this credential. Click the browser Back button "
39+
. "to cancel the edit.</div>"
40+
);
3941
}
4042
?>
41-
<form class="inputForm" method="post" action="index.php?Page_Type=Edit_API_Authentication_Entity&parentid=<?php echo($params['site']->getId())?>&authentityid=<?php xecho($params['authEnt']->getId())?>" name="addAPIAuthenticationEntity">
43+
<form
44+
class="inputForm"
45+
method="post"
46+
action="<?php
47+
echo "index.php?Page_Type=Edit_API_Authentication_Entity",
48+
"&parentid=",
49+
$params['site']->getId(),
50+
"&authentityid=",
51+
xecho($params['authEnt']->getId());
52+
?>"
53+
name="addAPIAuthenticationEntity"
54+
>
4255
<div style="margin-bottom: 0.5em;">
43-
<span class="input_name">Identifier (e.g. Certificate DN or OIDC Subject)*</span>
44-
<input type="text" value="<?php xecho($params['authEnt']->getIdentifier()) ?>" name="IDENTIFIER" class="input_input_text">
56+
<span class="input_name">
57+
Identifier (e.g. Certificate DN or OIDC Subject)*
58+
</span>
59+
60+
<input
61+
type="text"
62+
value="<?php xecho($params['authEnt']->getIdentifier()); ?>"
63+
name="IDENTIFIER"
64+
class="input_input_text"
65+
>
4566
</div>
67+
4668
<div style="margin-bottom: 0.5em;">
4769
<span class="input_name">Credential type*</span>
70+
4871
<select name="TYPE" class="input_input_text">
49-
<?php foreach($params['authTypes'] as $authType) {?>
50-
<option value="<?php xecho($authType) ?>"<?php if ($params['authEnt']->getType() == $authType) {echo " selected=\"selected\"";} ?>>
72+
<?php foreach ($params['authTypes'] as $authType) { ?>
73+
<option
74+
value="<?php xecho($authType); ?>"
75+
<?php
76+
if ($params['authEnt']->getType() == $authType) {
77+
echo " selected=\"selected\"";
78+
}
79+
?>
80+
>
5181
<?php xecho($authType) ?>
5282
</option>
5383
<?php } ?>
5484
</select>
5585
</div>
86+
5687
<div style="margin-bottom: 1em">
5788
<div class="input_warning">
58-
WARNING: it is possible to delete information using the write functionality of the API. Leave Allow API write unchecked if
89+
WARNING: it is possible to delete information using the write
90+
functionality of the API. Leave Allow API write unchecked if
5991
you do not need to write data.
6092
</div>
93+
6194
<div class="input_checkbox">
62-
<input type="checkbox" name="ALLOW_WRITE" id="ALLOW_WRITE" value="checked"
95+
<input
96+
type="checkbox"
97+
name="ALLOW_WRITE"
98+
id="ALLOW_WRITE"
99+
value="checked"
63100
<?php
64-
if ($params['authEnt']->getAllowAPIWrite()) { echo('checked="checked"');}
101+
if ($params['authEnt']->getAllowAPIWrite()) {
102+
echo('checked="checked"');
103+
}
65104
?>
66105
/>
67-
<label class="input_label" for="ALLOW_WRITE">Allow API write</label>
106+
<label class="input_label" for="ALLOW_WRITE">
107+
Allow API write
108+
</label>
68109
</div>
69110
</div>
111+
70112
<input type="submit" value="Edit credential" class="input_button">
71113
</form>
72114
</div>
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<div class="rightPageContainer">
22
<h1 class="Success">Success</h1><br />
3-
The API authenication credential has now been updated. Type:<?php xecho($params['apiAuthenticationEntity']->getType()) ?>, identifier: <?php xecho($params['apiAuthenticationEntity']->getIdentifier()) ?>.
3+
The API authenication credential has now been updated.
4+
Type: <?php xecho($params['apiAuthenticationEntity']->getType()); ?>,
5+
identifier: <?php
6+
xecho($params['apiAuthenticationEntity']->getIdentifier());
7+
?>.
48
<br />
5-
<a href="index.php?Page_Type=Site&amp;id=<?php echo $params['site']->getID(); ?>">
6-
View site</a>
9+
<a
10+
href="<?php
11+
echo "index.php?Page_Type=Site&amp;id=", $params['site']->getID();
12+
?>"
13+
>View site</a>
714
</div>

0 commit comments

Comments
 (0)