From e1cbbbe051e2e5db3d5715c6b75a1c67d976556c Mon Sep 17 00:00:00 2001
From: Eric Rasmussen <erasmussen2@unl.edu>
Date: Wed, 3 Feb 2010 16:22:19 +0000
Subject: [PATCH] fix for CAS registration when peoplefinder privacy flag is
set
---
plugins/cas_auth_unl/start.php | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/plugins/cas_auth_unl/start.php b/plugins/cas_auth_unl/start.php
index 97e12b7f..c5b8b6ac 100644
--- a/plugins/cas_auth_unl/start.php
+++ b/plugins/cas_auth_unl/start.php
@@ -133,9 +133,15 @@ class elggSimpleCas {
// User exists, return the user object
return $user;
} else {
- // Valid login but user doesn't exist
+ // Valid CAS login but user hasn't been registered in Planet Red yet
+ // We end up going through here twice, first time grabs email from Peoplefinder and forwards to the getemail validation page to ask
+ // them if the email is correct, then when we return with the email we register the user in elgg
+
$pf_user_info = peoplefinderServices($casusername);
- $name = $pf_user_info->cn;
+ if(!empty($pf_user_info->cn))
+ $name = $pf_user_info->cn;
+ else //A peoplefinder record does not exist because they've set their privacy flag so set display name to username so register_user below doesn't break
+ $name = $username;
if (empty($email)){
if($pf_user_info->mail)
@@ -149,17 +155,19 @@ class elggSimpleCas {
if ($user_guid = register_user($username, $password, $name, $email, false, 0, '', true)) {
$thisuser = get_user($user_guid);
- //pre-populate profile fields with data from Peoplefinder Services
- $address = $pf_user_info->formatPostalAddress();
- $thisuser->profile_country = 'USA';
- $thisuser->profile_state = $address['region'];
- $thisuser->profile_city = $address['locality'];
- if($address['locality'] == 'Omaha') {
- $thisuser->longitude = -95.9;
- $thisuser->latitude = 41.25;
- } else { //this is going to cover Lincoln and everyone else
- $thisuser->longitude = -96.7;
- $thisuser->latitude = 40.82;
+ if(!empty($pf_user_info->cn)){
+ //pre-populate profile fields with data from Peoplefinder Services if available
+ $address = $pf_user_info->formatPostalAddress();
+ $thisuser->profile_country = 'USA';
+ $thisuser->profile_state = $address['region'];
+ $thisuser->profile_city = $address['locality'];
+ if($address['locality'] == 'Omaha') {
+ $thisuser->longitude = -95.9;
+ $thisuser->latitude = 41.25;
+ } else { //this is going to cover Lincoln and everyone else
+ $thisuser->longitude = -96.7;
+ $thisuser->latitude = 40.82;
+ }
}
return $thisuser;
--
GitLab