Skip to content

Commit 44ae118

Browse files
committed
remove multiple calls to getPIGroupGIDs
1 parent a2fea85 commit 44ae118

File tree

1 file changed

+45
-55
lines changed

1 file changed

+45
-55
lines changed

webroot/panel/account.php

Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use UnityWebPortal\lib\UnitySite;
66

7+
$hasGroups = count($USER->getPIGroupGIDs()) > 0;
8+
79
if ($_SERVER['REQUEST_METHOD'] == "POST") {
810
switch (UnitySite::arrayGetOrBadRequest($_POST, "form_type")) {
911
case "addKey":
@@ -78,7 +80,6 @@
7880
$USER->getPIGroup()->cancelGroupRequest();
7981
break;
8082
case "account_deletion_request":
81-
$hasGroups = count($USER->getPIGroupGIDs()) > 0;
8283
if ($hasGroups) {
8384
break;
8485
}
@@ -90,39 +91,38 @@
9091
}
9192

9293
include $LOC_HEADER;
93-
?>
94-
95-
<h1>Account Settings</h1>
96-
97-
<hr>
98-
<h5>Account Details</h5>
99-
<table>
100-
<tr>
101-
<th>Username</th>
102-
<td><code><?php echo $USER->uid; ?></code></td>
103-
</tr>
104-
<tr>
105-
<th>Organization</th>
106-
<td><code><?php echo $USER->getOrg(); ?></code></td>
107-
</tr>
108-
<tr>
109-
<th>Email</th>
110-
<td><code><?php echo $USER->getMail(); ?></code></td>
111-
</tr>
112-
</table>
113-
114-
<hr>
115-
<h5>Account Status</h5>
11694

95+
$uid = $USER->uid;
96+
$org = $USER->getOrg();
97+
$mail = $USER->getMail();
98+
echo "
99+
<h1>Account Settings</h1>
100+
<hr>
101+
<h5>Account Details</h5>
102+
<table>
103+
<tr>
104+
<th>Username</th>
105+
<td><code>$uid</code></td>
106+
</tr>
107+
<tr>
108+
<th>Organization</th>
109+
<td><code>$org</code></td>
110+
</tr>
111+
<tr>
112+
<th>Email</th>
113+
<td>
114+
<code>$mail</code></td>
115+
</tr>
116+
</table>
117+
<hr>
118+
<h5>AccountStatus</h5>
119+
";
117120

118-
<?php
119-
120-
$isActive = count($USER->getPIGroupGIDs()) > 0;
121121
$isPI = $USER->isPI();
122122

123123
if ($isPI) {
124124
echo "<p>You are curently a <strong>principal investigator</strong> on the Unity Cluster</p>";
125-
} elseif ($isActive) {
125+
} elseif ($hasGroups) {
126126
echo "<p>You are curently a <strong>user</strong> on the Unity Cluster</p>";
127127
} else {
128128
echo "
@@ -170,12 +170,8 @@
170170
}
171171
echo "</form>";
172172
}
173-
?>
173+
echo "<hr><h5>SSH Keys</h5>";
174174

175-
<hr>
176-
<h5>SSH Keys</h5>
177-
178-
<?php
179175
$sshPubKeys = $USER->getSSHKeys(); // Get ssh public key attr
180176

181177
if (count($sshPubKeys) == 0) {
@@ -198,31 +194,25 @@
198194
</div>";
199195
}
200196

201-
?>
202-
203-
<button type="button" class="plusBtn btnAddKey"><span>&#43;</span></button>
204-
205-
<hr>
206-
<h5>Login Shell</h5>
207-
208-
<form action="" method="POST">
209-
<input type="hidden" name="form_type" value="loginshell" />
210-
<select id="loginSelector" class="code" name="shellSelect">
211-
<?php
197+
echo '
198+
<button type="button" class="plusBtn btnAddKey"><span>&#43;</span></button>
199+
<hr>
200+
<h5>Login Shell</h5>
201+
<form action="" method="POST">
202+
<input type="hidden" name="form_type" value="loginshell" />
203+
<select id="loginSelector" class="code" name="shellSelect">
204+
';
212205
foreach ($CONFIG["loginshell"]["shell"] as $shell) {
213206
echo "<option>$shell</option>";
214207
}
215-
?>
216-
</select>
217-
<br>
218-
<input id='submitLoginShell' type='submit' value='Set Login Shell' />
219-
</form>
220-
221-
<hr>
222-
<h5>Account Deletion</h5>
223-
224-
<?php
225-
$hasGroups = count($USER->getPIGroupGIDs()) > 0;
208+
echo "
209+
</select>
210+
<br>
211+
<input id='submitLoginShell' type='submit' value='Set Login Shell' />
212+
</form>
213+
<hr>
214+
<h5>Account Deletion</h5>
215+
";
226216

227217
if ($hasGroups) {
228218
echo "<p>You cannot request to delete your account while you are in a PI group.</p>";

0 commit comments

Comments
 (0)