Skip to content
Snippets Groups Projects
Commit ab2887f4 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

add UNL_Services_Peoplefinder to /lib/php

parent d8b338a1
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Package which connects to the peoplefinder services to get information about UNL people.
*
*
* @author Brett Bieber
* @package UNL_Services_Peoplefinder
*/
/**
* This is the basic class for utilizing the UNL Peoplefinder service which can
* give you various pieces of information about a given uid (uniue user id).
*
* @package UNL_Services_Peoplefinder
*/
class UNL_Services_Peoplefinder
{
/**
* returns the name for a given uid
*
* @param string $uid
* @return string|false
*/
function getFullName($uid)
{
if ($vcard = UNL_Services_Peoplefinder::getVCard($uid)) {
$matches = array();
preg_match_all('/FN:(.*)/',$vcard, $matches);
if (isset($matches[1][0]) && $matches[1][0] != ' ') {
return $matches[1][0];
} else {
return false;
}
} else {
return false;
}
}
/**
* returns the email address for the given uid
*
* @param string $uid
* @return string|false
*/
function getEmail($uid)
{
if ($hcard = UNL_Services_Peoplefinder::getHCard($uid)) {
$matches = array();
preg_match_all('/mailto:([^\'\"]*)/',$hcard, $matches);
if (isset($matches[1][0])) {
return $matches[1][0];
} else {
return false;
}
} else {
return false;
}
}
/**
* Gets an hcard for the uid given.
*
* @param string $uid
* @return string|false
*/
function getHCard($uid)
{
if ($hcard = file_get_contents('http://peoplefinder.unl.edu/hcards/'.$uid)) {
return $hcard;
} else {
return false;
}
}
/**
* Gets a vcard for the given uid.
*
* @param string $uid
* @return string|false
*/
function getVCard($uid)
{
if ($vcard = file_get_contents('http://peoplefinder.unl.edu/vcards/'.$uid)) {
return $vcard;
} else {
return false;
}
}
}
?>
\ No newline at end of file
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