Skip to content

Commit 2063694

Browse files
committed
UnitySite::redirect is not static
1 parent ace27c4 commit 2063694

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

resources/lib/UnitySite.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
class UnitySite
88
{
9-
public static function redirect($destination)
9+
// not static because it is mocked during testing
10+
public function redirect($destination)
1011
{
1112
if ($_SERVER["PHP_SELF"] != $destination) {
1213
header("Location: $destination");

resources/templates/header.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22

3-
use UnityWebPortal\lib\UnitySite;
4-
53
if (isset($SSO)) {
64
if (!$_SESSION["user_exists"]) {
7-
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/new_account.php");
5+
$site = new UnityWebPortal\lib\UnitySite();
6+
$site->redirect($CONFIG["site"]["prefix"] . "/panel/new_account.php");
87
}
98
}
109

@@ -119,7 +118,8 @@
119118
if (isset($_SESSION["is_admin"]) && $_SESSION["is_admin"]) {
120119
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["form_name"]) && $_POST["form_name"] == "clearView") {
121120
unset($_SESSION["viewUser"]);
122-
UnitySite::redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
121+
$site = new UnityWebPortal\lib\UnitySite();
122+
$site->redirect($CONFIG["site"]["prefix"] . "/admin/user-mgmt.php");
123123
}
124124

125125
if (isset($_SESSION["viewUser"])) {
@@ -135,4 +135,4 @@
135135
echo "</div>";
136136
}
137137
}
138-
?>
138+
?>

webroot/admin/user-mgmt.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require_once __DIR__ . "/../../resources/autoload.php";
44

5-
use UnityWebPortal\lib\UnitySite;
6-
75
if (!$USER->isAdmin()) {
86
throw new Exception("access denied");
97
}
@@ -12,7 +10,8 @@
1210
switch ($_POST["form_name"]) {
1311
case "viewAsUser":
1412
$_SESSION["viewUser"] = $_POST["uid"];
15-
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/account.php");
13+
$site = new UnityWebPortal\lib\UnitySite();
14+
$site->redirect($CONFIG["site"]["prefix"] . "/panel/account.php");
1615
break;
1716
}
1817
}

webroot/panel/new_account.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
require_once __DIR__ . "/../../resources/autoload.php";
44

5-
use UnityWebPortal\lib\UnitySite;
65
use UnityWebPortal\lib\UnityGroup;
76

87
require_once $LOC_HEADER;
98

109
if ($USER->exists()) {
11-
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); // Redirect if account already exists
10+
$site = new UnityWebPortal\lib\UnitySite();
11+
$site->redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); // Redirect if account already exists
1212
}
1313

1414
if ($_SERVER["REQUEST_METHOD"] == "POST") {

0 commit comments

Comments
 (0)