Skip to content

Commit 3f55456

Browse files
committed
getHyperlink
1 parent fc5e108 commit 3f55456

File tree

12 files changed

+34
-26
lines changed

12 files changed

+34
-26
lines changed

resources/lib/utils.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ function pathJoin()
8383
return preg_replace("#/+#", "/", join("/", $paths));
8484
}
8585

86-
function getURL(...$args)
86+
function getURL(...$path_components)
8787
{
88-
return pathJoin([CONFIG["site"]["url"], CONFIG["site"]["prefix"], ...$args]);
88+
return pathJoin([CONFIG["site"]["url"], CONFIG["site"]["prefix"], ...$path_components]);
89+
}
90+
91+
function getHyperlink($text, ...$path_components)
92+
{
93+
$text = htmlspecialchars($text);
94+
$path_components = array_map("htmlspecialchars", $path_components);
95+
$url = getURL(...$path_components);
96+
return "<a href='$url'>$text</a>";
8997
}

resources/mail/footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
>
44
<span>
55
You are receiving this email because you have an account
6-
on the <a target='_blank' href='<?php echo getURL("/"); ?>'>Unity Cluster</a>.
6+
on the <?php echo getHyperlink("Unity Cluster", "/"); ?>.
77
If you would like to stop receiving these emails,
88
you may request to close your account by replying to this email.
99
</span>

resources/mail/group_created.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<p>
99
Your request for a PI account on the Unity cluster has been approved.
1010
You can access the management page for your group
11-
<a href="<?php echo getURL("panel/pi.php"); ?>">on this page</a>.
11+
<?php echo getHyperlink("on this page", "panel/pi.php"); ?>.
1212
</p>
1313

1414
<p>Do not hesitate to reply if you have any questions!</p>

resources/mail/group_request_admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
<p>
2121
You can approve this account
22-
<a href="<?php echo getURL("admin/pi-mgmt.php"); ?>">here</a>
22+
<?php echo getHyperlink("here", "admin/pi-mgmt.php"); ?>
2323
.
2424
</p>

resources/mail/group_user_added.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p>Hello,</p>
77

88
<p>You have been approved to join the PI group <?php echo $data["group"]; ?>.
9-
Navigate to the <a href="<?php echo getURL("panel/groups.php"); ?>">my groups</a>
9+
Navigate to the <?php echo getHyperlink("my groups", "panel/groups.php"); ?>
1010
page to see your PI groups.</p>
1111

1212
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>

resources/mail/group_user_request_owner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
</p>
2323

2424
<p>You can approve or deny this user on the
25-
<a href="<?php echo getURL("panel/pi.php"); ?>">my users</a> page</p>
25+
<?php echo getHyperlink("my users", "panel/pi.php"); ?> page</p>

resources/mail/user_loginshell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
<p>You have updated your login shell on the Unity cluster to <?php echo $data["new_shell"]; ?>.
99
You can view the login shell settings on the
10-
<a href="<?php echo getURL("panel/account.php"); ?>">account settings</a> page</p>
10+
<?php echo getHyperlink("account settings", "panel/account.php"); ?> page</p>
1111

1212
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>

resources/mail/user_qualified.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
<p>Please login to the web portal to access Unity.
1717
If you need console access, you will need to set your SSH keys in the
18-
<a href="<?php echo getURL("/panel/account.php"); ?>">account settings</a> page.</p>
18+
<?php echo getHyperlink("account settings", "/panel/account.php"); ?> page.</p>
1919

2020
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>

resources/mail/user_sshkey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<p>
1717
You can view the SSH public keys attached to your account on the
18-
<a href="<?php echo getURL("/panel/account.php"); ?>">account settings</a>
18+
<?php echo getHyperlink("account settings", "/panel/account.php"); ?>
1919
page.
2020
</p>
2121

resources/templates/header.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@
7777

7878
<nav class="mainNav">
7979
<?php
80-
$prefix = CONFIG["site"]["prefix"];
8180
// Public Items - Always Visible
82-
echo "<a href='$prefix/index.php'>Home</a>";
81+
echo getHyperlink("Home", "index.php");
8382

8483
$num_additional_items = count(CONFIG["menuitems"]["labels"]);
8584
for ($i = 0; $i < $num_additional_items; $i++) {
@@ -89,13 +88,13 @@
8988

9089
if (isset($_SESSION["user_exists"]) && $_SESSION["user_exists"]) {
9190
// Menu Items for Present Users
92-
echo "<a href='$prefix/panel/support.php'>Support</a>";
93-
echo "<a href='$prefix/panel/account.php'>Account Settings</a>";
94-
echo "<a href='$prefix/panel/groups.php'>My PIs</a>";
91+
echo getHyperlink("Support", "panel/support.php");
92+
echo getHyperlink("Account Settings", "panel/account.php");
93+
echo getHyperlink("My PIs", "panel/groups.php");
9594

9695
if (isset($_SESSION["is_pi"]) && $_SESSION["is_pi"]) {
9796
// PI only pages
98-
echo "<a href='$prefix/panel/pi.php'>My Users</a>";
97+
echo getHyperlink("My Users", "panel/pi.php");
9998
}
10099

101100
// additional branding items
@@ -111,13 +110,13 @@
111110
) {
112111
echo "<hr class='navHR'>";
113112
// Admin only pages
114-
echo "<a href='$prefix/admin/user-mgmt.php'>User Management</a>";
115-
echo "<a href='$prefix/admin/pi-mgmt.php'>PI Management</a>";
116-
echo "<a href='$prefix/admin/notices.php'>Cluster Notices</a>";
117-
echo "<a href='$prefix/admin/content.php'>Content Management</a>";
113+
echo getHyperlink("User Management", "admin/user-mgmt.php");
114+
echo getHyperlink("PI Management", "admin/pi-mgmt.php");
115+
echo getHyperlink("Cluster Notices", "admin/notices.php");
116+
echo getHyperlink("Content Management", "admin/content.php");
118117
}
119118
} else {
120-
echo "<a href='$prefix/panel/account.php'>Login / Request Account</a>";
119+
echo getHyperlink("Login / Request Account", "panel/account.php");
121120
}
122121
?>
123122
</nav>

0 commit comments

Comments
 (0)