Skip to content
Snippets Groups Projects
Commit bae391b5 authored by Brett Bieber's avatar Brett Bieber
Browse files

Remove hard-coded UNL_Peoplefinder_Record class. Update references so we're...

Remove hard-coded UNL_Peoplefinder_Record class. Update references so we're only adding the lib path once. Get peoplefinder usage functioning correctly.
parent b684fc8e
No related branches found
No related tags found
No related merge requests found
<?php
set_include_path(dirname(dirname(dirname(dirname(dirname(__FILE__))))).'/lib/php'.PATH_SEPARATOR.get_include_path());
require_once 'UNL/Services/Peoplefinder.php';
//In order to avoid a "__PHP_Incomplete_Class" problem when we unserialize the Peoplefinder data we need to set up the class here
//http://us2.php.net/manual/en/function.unserialize.php
class UNL_Peoplefinder_Record {
public $cn;
public $ou;
public $eduPersonNickname;
public $eduPersonPrimaryAffiliation;
public $givenName;
public $displayName;
public $mail;
public $postalAddress;
public $sn;
public $telephoneNumber;
public $title;
public $uid;
public $unlHRPrimaryDepartment;
public $unlHRAddress;
public $unlSISClassLevel;
public $unlSISCollege;
public $unlSISLocalAddr1;
public $unlSISLocalAddr2;
public $unlSISLocalCity;
public $unlSISLocalPhone;
public $unlSISLocalState;
public $unlSISLocalZip;
public $unlSISPermAddr1;
public $unlSISPermAddr2;
public $unlSISPermCity;
public $unlSISPermState;
public $unlSISPermZip;
public $unlSISMajor;
public $unlEmailAlias;
/**
* Takes in a string from the LDAP directory, usually formatted like:
* ### ___ UNL 68588-####
* Where ### is the room number, ___ = Building Abbreviation, #### zip extension
*
* @param string
* @return array Associative array.
*/
function formatPostalAddress() {
/* this is a faculty postal address
Currently of the form:
### ___ UNL 68588-####
Where ### is the room number, ___ = Building Abbreviation, #### zip extension
*/
/**
* We assumed that the address format is: ### ___ UNL 68588-####.
* Some 'fortunate' people have addresses not in this format.
*/
//RLIM
// treat UNL as the delimiter for the streetaddress and zip
if (strpos($this->postalAddress,'UNL')) {
$addressComponent = explode('UNL', $this->postalAddress);
} elseif (strpos($this->postalAddress,'UNO')) {
$addressComponent = explode('UNO', $this->postalAddress);
} elseif (strpos($this->postalAddress,'Omaha')) {
$addressComponent = explode('Omaha', $this->postalAddress);
} else {
$addressComponent = array($this->postalAddress);
}
$address['region'] = 'NE';
$address['street-address'] = trim($addressComponent[0]);
if (isset($addressComponent[1])) {
$address['postal-code'] = trim($addressComponent[1]);
} else {
$address['postal-code'] = '';
}
switch (substr($address['postal-code'],0,3)) {
case '681':
$address['locality'] = 'Omaha';
break;
case '685':
default:
$address['locality'] = 'Lincoln';
break;
}
return $address;
}
}
/**
* Gets a UNL SSO user's info from Peoplefinder Services
*
* @param string $username
* @return array of information from PF Services
*/
function peoplefinderServices($username){
$pfrecord = unserialize(file_get_contents('http://peoplefinder.unl.edu/service.php?uid=' . $username . '&format=php'));
return $pfrecord;
}
\ No newline at end of file
require_once 'UNL/Peoplefinder/Record.php';
require_once 'UNL/LDAP/Entry.php';
require_once 'UNL/LDAP/Entry/Attribute.php';
/**
* Gets a UNL SSO user's info from Peoplefinder Services
*
* @param string $username
* @return array of information from PF Services
*/
function peoplefinderServices($username)
{
$pfrecord = unserialize(file_get_contents('http://peoplefinder.unl.edu/service.php?uid=' . $username . '&format=php'));
return $pfrecord;
}
\ No newline at end of file
......@@ -11,9 +11,9 @@
global $CONFIG;
set_include_path(dirname(dirname(dirname(dirname(__FILE__)))).'/lib/php'.PATH_SEPARATOR.get_include_path());
require_once 'peoplefinder/include.php';
set_include_path(dirname(__FILE__).'/../../../lib/php'.PATH_SEPARATOR.get_include_path());
// http://code.google.com/p/simplecas/
require_once 'SimpleCAS/Autoload.php';
require_once 'HTTP/Request2.php';
......@@ -139,7 +139,7 @@ class elggSimpleCas {
$pf_user_info = peoplefinderServices($casusername);
if(!empty($pf_user_info->cn))
$name = $pf_user_info->cn;
$name = (string)$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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment