From 4ff97e6e08b992e57b147a85ab8e60387487eb4e Mon Sep 17 00:00:00 2001 From: Ian Neilson Date: Thu, 28 Apr 2022 13:53:37 +0000 Subject: [PATCH] Fix misc PHP7.4 Notices and Warnings --- .../web_portal/controllers/user/register.php | 30 +++++++++++++------ .../views/political_role/view_requests.php | 8 ++--- htdocs/web_portal/views/user/view_user.php | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/web_portal/controllers/user/register.php b/htdocs/web_portal/controllers/user/register.php index c9e813948..7b66b9fa9 100644 --- a/htdocs/web_portal/controllers/user/register.php +++ b/htdocs/web_portal/controllers/user/register.php @@ -56,23 +56,35 @@ function draw() { die(); } - //Extract users email from oidc claims - $authDetails = $_SERVER['OIDC_CLAIM_external_authn']; - $startPos = 3+strpos($authDetails, ":", (strpos($authDetails, "MAIL"))); - $endPos = strpos($authDetails, "\"", 3+$startPos); - $length = $endPos-$startPos; - $userEmail = substr($authDetails, $startPos, $length); $params = []; + + //Extract users email from oidc claims + $params['email'] = ''; + if (key_exists('OIDC_CLAIM_external_authn', $_SERVER)) { + $authDetails = $_SERVER['OIDC_CLAIM_external_authn']; + $startPos = 3+strpos($authDetails, ":", (strpos($authDetails, "MAIL"))); + $endPos = strpos($authDetails, "\"", 3+$startPos); + $length = $endPos-$startPos; + $params['email'] = substr($authDetails, $startPos, $length); + } + getPolicyURLs($params); /* @var $authToken \org\gocdb\security\authentication\IAuthentication */ $authToken = Get_User_AuthToken(); $params['authAttributes'] = $authToken->getDetails(); - $params['given_name'] = $_SERVER['OIDC_CLAIM_given_name']; - $params['family_name'] = $_SERVER['OIDC_CLAIM_family_name']; - $params['email'] = $userEmail; + $params['given_name'] = ''; + if (key_exists('OIDC_CLAIM_given_name', $_SERVER)) { + $params['given_name'] = $_SERVER['OIDC_CLAIM_given_name']; + } + $params['family_name'] = ''; + if (key_exists('OIDC_CLAIM_family_name', $_SERVER)) { + $params['family_name'] = $_SERVER['OIDC_CLAIM_family_name']; + } + $params['idString'] = $idString; + show_view('user/register.php', $params); } diff --git a/htdocs/web_portal/views/political_role/view_requests.php b/htdocs/web_portal/views/political_role/view_requests.php index 05a08c6e8..b23596c9a 100644 --- a/htdocs/web_portal/views/political_role/view_requests.php +++ b/htdocs/web_portal/views/political_role/view_requests.php @@ -76,8 +76,8 @@ 0)) { - foreach($params['myRequests'] as $request) { + if (is_array($params['myRequests']) && sizeof($params['myRequests']) > 0) { + foreach ($params['myRequests'] as $request) { ?> @@ -144,8 +144,8 @@ 0)) { - foreach($params['allRequests'] as $request) { + if (is_array($params['allRequests']) && sizeof($params['allRequests']) > 0) { + foreach ($params['allRequests'] as $request) { ?> diff --git a/htdocs/web_portal/views/user/view_user.php b/htdocs/web_portal/views/user/view_user.php index 866ab9637..b061c4ea3 100644 --- a/htdocs/web_portal/views/user/view_user.php +++ b/htdocs/web_portal/views/user/view_user.php @@ -118,7 +118,7 @@ --> - getHomeSite()) != 0) { ?> + getHomeSite() != null) { ?> Home Site