Newer
Older
<?php
/**
* Peoplefinder class for UNL's online directory.
*
* PHP version 5
*
* @package UNL_Peoplefinder
* @author Brett Bieber <brett.bieber@gmail.com>
* @copyright 2007 Regents of the University of Nebraska
* @license http://www1.unl.edu/wdn/wiki/Software_License BSD License
* @link http://peoplefinder.unl.edu/
*/
class UNL_Peoplefinder_Record
{
public $dn; // distinguished name
public $cn;
public $ou;
Brett Bieber
committed
public $eduPersonAffiliation;
public $eduPersonNickname;
public $eduPersonPrimaryAffiliation;
public $givenName;
public $displayName;
public $mail;
public $postalAddress;
public $sn;
public $telephoneNumber;
public $title;
public $uid;
public $unlHROrgUnitNumber;
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;
Brett Bieber
committed
function __construct($options = array())
Brett Bieber
committed
if (isset($options['uid'])
&& $options['peoplefinder']) {
return $options['peoplefinder']->getUID($options['uid']);
/**
* 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()
{
Brett Bieber
committed
$parts = explode(',', $this->postalAddress);
// Set up defaults:
$address = array();
$address['street-address'] = trim($parts[0]);
$address['locality'] = '';
$address['region'] = 'NE';
Brett Bieber
committed
$address['postal-code'] = '';
Brett Bieber
committed
if (count($parts) == 3) {
// Assume we have a street address, city, zip.
$address['locality'] = trim($parts[1]);
}
Brett Bieber
committed
// Now lets find some important bits.
foreach ($parts as $part) {
if (preg_match('/([\d]{5})(\-[\d]{4})?/', $part)) {
// Found a zip-code
$address['postal-code'] = trim($part);
}
Brett Bieber
committed
switch (substr($address['postal-code'], 0, 3)) {
case '681':
$address['locality'] = 'Omaha';
Brett Bieber
committed
break;
case '685':
$address['locality'] = 'Lincoln';
Brett Bieber
committed
break;
Brett Bieber
committed
Brett Bieber
committed
* Formats a major subject code into a text description.
*
* @param string $subject Subject code for the major eg: MSYM
Brett Bieber
committed
* @return string
*/
public function formatMajor($subject)
{
$c = new UNL_Cache_Lite();
if ($subject_xml = $c->get('catalog subjects')) {
Brett Bieber
committed
} else {
if ($subject_xml = file_get_contents('http://bulletin.unl.edu/?view=subjects&format=xml')) {
$c->save($subject_xml);
} else {
$c->extendLife();
$c->get('catalog subjects');
}
}
Brett Bieber
committed
$d = new DOMDocument();
$d->loadXML($subject_xml);
if ($subject_el = $d->getElementById($subject)) {
return $subject_el->textContent;
}
Brett Bieber
committed
switch ($subject) {
case 'UNDL':
return 'Undeclared';
case 'PBAC':
return 'Non-Degree Post-Baccalaureate';
default:
return $subject;
}
}
Brett Bieber
committed
/**
* Format a three letter college abbreviation into the full college name.
*
* @param string $college College abbreviation = FPA
Brett Bieber
committed
* @return string College of Fine & Performing Arts
*/
public function formatCollege($college)
{
include_once 'UNL/Common/Colleges.php';
$colleges = new UNL_Common_Colleges();
if (isset($colleges->colleges[$college])) {
return htmlentities($colleges->colleges[$college]);
}
Brett Bieber
committed
return $college;
}
function getImageURL($size = 'medium')
{
if ($this->ou == 'org') {
return UNL_Peoplefinder::getURL().'images/organization.png';
}
switch ($size) {
case 'large':
case 'medium':
case 'tiny':
case 'topbar':
break;
default:
$size = 'medium';
}
return 'http://planetred.unl.edu/pg/icon/unl_'.str_replace('-', '_', $this->uid).'/'.$size.'/';
}
function getRoles()
Brett Bieber
committed
{
return new UNL_Peoplefinder_Person_Roles(array('dn'=>$this->dn));
Brett Bieber
committed
}
function __toString()
{
return (string)$this->uid;