diff --git a/plugins/cas_auth_unl/peoplefinder/include.php b/plugins/cas_auth_unl/peoplefinder/include.php index d2123641aa51f9289347e2df0dfb87c712e03d3f..7a10bbe1ea51f840b41d6548f96e5671fc3c23bf 100644 --- a/plugins/cas_auth_unl/peoplefinder/include.php +++ b/plugins/cas_auth_unl/peoplefinder/include.php @@ -1,99 +1,16 @@ <?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 diff --git a/plugins/cas_auth_unl/start.php b/plugins/cas_auth_unl/start.php index c5b8b6acf012b2b72da56be438a081f6dc092efa..5fb32a521ee8db592bf25aebd4e716b16bfcccce 100644 --- a/plugins/cas_auth_unl/start.php +++ b/plugins/cas_auth_unl/start.php @@ -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;