diff --git a/lib/.pear2registry b/lib/.pear2registry index f1a18171f6e65c0ce4cc073126812778b1760c3e..4725af4a3c8e5ef360ce2e3221cbd16284336017 100644 Binary files a/lib/.pear2registry and b/lib/.pear2registry differ diff --git a/lib/.xmlregistry/packages/pear.unl.edu/UNL_LDAP/0.4.1-info.xml b/lib/.xmlregistry/packages/pear.unl.edu/UNL_LDAP/0.4.1-info.xml new file mode 100644 index 0000000000000000000000000000000000000000..af5a488871cbb28a2f6517ef8b0fc632246f8c5c --- /dev/null +++ b/lib/.xmlregistry/packages/pear.unl.edu/UNL_LDAP/0.4.1-info.xml @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> + <name>UNL_LDAP</name> + <channel>pear.unl.edu</channel> + <summary>LDAP directory services for UNL</summary> + <description>This package simplifies connecting to UNL's LDAP directory for searching for data.</description> + <lead> + <name>Brett Bieber</name> + <user>saltybeagle</user> + <email>brett.bieber@gmail.com</email> + <active>yes</active> + </lead> + <date>2010-09-15</date> + <time>11:32:33</time> + <version> + <release>0.4.1</release> + <api>0.4.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +Bugfix Release: +* Switch to protected attributes instead of private for easier serialization. + </notes> + <contents> + <dir name="/"> + <file name="UNL/LDAP/Result.php" role="php" md5sum="58a0fd030a6b9cc8dd721d3feddb8240"/> + <file name="UNL/LDAP/People.php" role="php" md5sum="89f2d218e91e3fd2413c79df8758e455"/> + <file name="UNL/LDAP/Exception.php" role="php" md5sum="3c3d370c93d9c8fa86039a7650872a2a"/> + <file name="UNL/LDAP/Entry/Attribute.php" role="php" md5sum="0718586648d0db9433f8c983c162269d"/> + <file name="UNL/LDAP/Entry.php" role="php" md5sum="d0fe31664523d1b6f3492db0435d7398"/> + <file name="UNL/LDAP.php" role="php" md5sum="913f674a02c3e4c2c5fbeeaa61dd963f"/> + <file name="tests/UNL_LDAPTest.php" role="test" md5sum="1fa66e7b752de71d29bc1b34d891e139"/> + <file name="docs/examples/twodirectories.php" role="doc" md5sum="4ec63a962bbddbfd1d9b12eafe8148b1"/> + <file name="docs/examples/simpleSearch.php" role="doc" md5sum="2b7c406732936e26f498af7cb4d050a8"/> + <file name="config.sample.php" role="data" md5sum="0218ccc36b1ac31b6a241c43d06bb775"/> + <file name="build.xml" role="data" md5sum="70050811287cb990cdd6e409049e2b5e"/> + </dir> + </contents> + <dependencies> + <required> + <php> + <min>5.1.6</min> + </php> + <pearinstaller> + <min>1.5.4</min> + </pearinstaller> + </required> + </dependencies> + <phprelease> + <changelog> + <release> + <version> + <release>0.1.0</release> + <api>0.1.0</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <date>2008-02-01</date> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +First release. + </notes> + </release> + <release> + <version> + <release>0.2.0</release> + <api>0.2.0</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <date>2008-03-26</date> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +API change feature release +* Remove singleton - multiple connections and multiple directories can now be used. +* Add setOptions(), connect(), disconnect(), &getLink() methods. +* Implement destructor which disconnects from the server. + </notes> + </release> + <release> + <version> + <release>0.3.0</release> + <api>0.3.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2008-11-10</date> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +Feature release: +Issue #8: Throw exception on connection errors. +Bump stability to beta. + </notes> + </release> + <release> + <version> + <release>0.4.0</release> + <api>0.4.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2009-05-11</date> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +Feature release: +Add backup LDAP server. +Increase PHP dependency to 5.1.6 + </notes> + </release> + <release> + <version> + <release>0.4.1</release> + <api>0.4.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <date>2010-04-23</date> + <license uri="http://www1.unl.edu/wdn/wiki/Software_License">BSD</license> + <notes> +Bugfix Release: +* Switch to protected attributes instead of private for easier serialization. + </notes> + </release> + </changelog> + </phprelease> +</package> diff --git a/lib/.xmlregistry/packages/pear.unl.edu/UNL_Peoplefinder/0.1.0-info.xml b/lib/.xmlregistry/packages/pear.unl.edu/UNL_Peoplefinder/0.1.0-info.xml index 21affbe50438c65546edab05194ec6a102e572ad..cb1c350701b41835528499d7d245539a1dd8f3f7 100644 --- a/lib/.xmlregistry/packages/pear.unl.edu/UNL_Peoplefinder/0.1.0-info.xml +++ b/lib/.xmlregistry/packages/pear.unl.edu/UNL_Peoplefinder/0.1.0-info.xml @@ -15,8 +15,8 @@ directory information and perform searches. <email>brett.bieber@gmail.com</email> <active>yes</active> </lead> - <date>2010-01-27</date> - <time>10:10:32</time> + <date>2010-09-15</date> + <time>11:33:00</time> <version> <release>0.1.0</release> <api>0.1.0</api> @@ -35,49 +35,58 @@ web service, and no LDAP connection info is required. Package UNL_Peoplefinder API release notes for version 0.1.0.</notes> <contents> <dir name="/"> - <file role="www" name="www/standardForm.php" md5sum="0bb606ab21c3e7b7ffe2b1927d0157d8"/> - <file role="www" name="www/small_devices.css" md5sum="671b2a2b7ff388a6c7a0256a27dc57a7"/> - <file role="www" name="www/service.php" md5sum="49caa1e90509e3af7431dd3276b16ed1"/> - <file role="www" name="www/README" md5sum="387849598c64632e513c7eefa2155e12"/> - <file role="www" name="www/peoplefinder_default.css" md5sum="6f1677797f73b1a31fecba23a6ce11b2"/> - <file role="www" name="www/peoplefinder.js" md5sum="bc5c3ec9319cc14f1d3ae22ed731321b"/> - <file role="www" name="www/index.php" md5sum="51f36d605af956784f4ab16047dfc02f"/> + <file role="www" name="www/standardForm.php" md5sum=""/> + <file role="www" name="www/service.php" md5sum="7c51e429ab603bf7129fd6ee69f8c2e2"/> + <file role="www" name="www/scripts/peoplefinder.js" md5sum="a35c15f7554182665f2960f07996bfb9"/> + <file role="www" name="www/README" md5sum="2b888a310056fb2a054dda6b1c5ae552"/> + <file role="www" name="www/index.php" md5sum="f41b9dc3311b71344f65b38d48170309"/> <file role="www" name="www/images/person.gif" md5sum="833a67d6d816e88d0bfe25b2854d2295"/> + <file role="www" name="www/images/organization.png" md5sum="f8667cbb5d7165d8b49b401c0b57a884"/> <file role="www" name="www/images/mobile.gif" md5sum="c5489ea5b5eb1d8814e2b49f6fdb9cdd"/> <file role="www" name="www/images/icon_question.gif" md5sum="e26a423eed7840f8eece890631e246b9"/> <file role="www" name="www/images/home.gif" md5sum="d2c93d8510e7fc077f9ef7765ff20a89"/> - <file role="www" name="www/departments/index.php" md5sum="37bbf184fb9944a5e29c33dd7ce6d323"/> - <file role="www" name="www/config.inc.php" md5sum="49d1a921b7b4edb23b1e2e4bdc766000"/> - <file role="www" name="www/config-sample.inc.php" md5sum="3b75e12039198b0f51c41a6e7c8360eb"/> + <file role="www" name="www/images/formSearch.png" md5sum="e751fdb5eb627b51b7f78c44b6eb4397"/> + <file role="www" name="www/departments/index.php" md5sum="8d5530ad679e9c1ae055e6955d1c17df"/> + <file role="www" name="www/css/small_devices.css" md5sum="f65099d2d6f85185873927e7fe3db72d"/> + <file role="www" name="www/css/peoplefinder_default.css" md5sum="7198d99ca186895f0d71d54361cc0e40"/> + <file role="www" name="www/css/images/selectedBG.png" md5sum="0351aecb36c3ed5650b137298a3858bd"/> + <file role="www" name="www/css/images/iconContactSprite.png" md5sum="ef07bb5f2c644144477b3f30c5394d9f"/> + <file role="www" name="www/css/images/formSearchEnds.png" md5sum="0da0b153ab9ee55b02997f70e6b8f401"/> + <file role="www" name="www/css/images/formSearchBG.png" md5sum="551928d28da5f3d1ef8c865b223a27f8"/> + <file role="www" name="www/css/images/formFilterBG.png" md5sum="af56cd3c9ce245d1e04c17ad7b89a084"/> + <file role="www" name="www/config.inc.php" md5sum="dac1fbcde7d75f4d222cc60bb012b48b"/> + <file role="www" name="www/config-sample.inc.php" md5sum="658348cab33f4ec032d9e34671ed8c2d"/> <file role="www" name="www/apple-touch-icon.png" md5sum="e182bd1eb8858d0f406187e21d03c6fd"/> - <file role="www" name="www/advancedForm.php" md5sum="be5159d40d1cc6f9ed6399089fd748da"/> + <file role="www" name="www/advancedForm.php" md5sum=""/> <file role="test" name="tests/testStudentWithNoLocalAddress.html" md5sum="1636d84da04979ce70d9d46b862f896b"/> - <file role="test" name="tests/PeoplefinderTest.php" md5sum="d4da346cb13ca1357ee89b37b59dba6c"/> + <file role="test" name="tests/PeoplefinderTest.php" md5sum="4401d4a149a94650348b1f6ad2135f47"/> <file role="test" name="tests/OUTest.php" md5sum="e40ef5265dd4213fdcbfeb0735e1b8b0"/> <file role="test" name="tests/BrowserTest.php" md5sum="9cce4b1ffdbab7375b1cf3f60fb4987d"/> - <file role="php" name="src/UNL/Peoplefinder/RendererInterface.php" md5sum="7b52d098c49dd4e9915741ac794d8f4a"/> - <file role="php" name="src/UNL/Peoplefinder/Renderer/XML.php" md5sum="9b612809c71a7af3b22de36ea4988b78"/> - <file role="php" name="src/UNL/Peoplefinder/Renderer/vCard.php" md5sum="7c9aeb7c9a898849c173dd894f0f3a05"/> - <file role="php" name="src/UNL/Peoplefinder/Renderer/Serialized.php" md5sum="b7edf78a1f82cd2e790e879462ae5dd3"/> - <file role="php" name="src/UNL/Peoplefinder/Renderer/JSON.php" md5sum="7fa212209cb5e86cb2aefda0b2fca12d"/> - <file role="php" name="src/UNL/Peoplefinder/Renderer/HTML.php" md5sum="9f2789e9724ce6d8033be663c9ed4131"/> - <file role="php" name="src/UNL/Peoplefinder/Record.php" md5sum="7071048e5e91575c01ccb92019c7cafe"/> - <file role="php" name="src/UNL/Peoplefinder/DriverInterface.php" md5sum="8f211374f1a6609f9609ea90c74afcba"/> - <file role="php" name="src/UNL/Peoplefinder/Driver/WebService.php" md5sum="5abd2c0936d173df09c1a36cbd4ee510"/> + <file role="php" name="src/UNL/Peoplefinder/RendererInterface.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Renderer/XML.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Renderer/vCard.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Renderer/Serialized.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Renderer/JSON.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Renderer/HTML.php" md5sum=""/> + <file role="php" name="src/UNL/Peoplefinder/Record.php" md5sum="c32a4b093437095661fc2c5ea720c2c0"/> + <file role="php" name="src/UNL/Peoplefinder/DriverInterface.php" md5sum="03bddb8125850770002718a5f6f45e0a"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/WebService.php" md5sum="de01b423492868f91e70ef996e4799ed"/> <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/Util.php" md5sum="7dc7a0423d62a6e193523d84ad89f4af"/> - <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php" md5sum="6cfe4455d67a76d642dc4b8239e367ac"/> - <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php" md5sum="87b019a6a8a57d0bdfe37145800e23d6"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php" md5sum="613b64dfe87494a1bf2005f003de7c3d"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php" md5sum="b8f01bf21004dc81c3979892cf8ee92a"/> <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/OUFilter.php" md5sum="7028b5a762580c32c76f70c8ccdd14bc"/> - <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php" md5sum="4547ed66c563bd0f8b24d1f07728dbfd"/> - <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP.php" md5sum="5b2d241e70cccdff56d6504691fad864"/> - <file role="php" name="src/UNL/Peoplefinder/Department/Search.php" md5sum="3c3a87e9fc95a53231dd408b45c82d0a"/> - <file role="php" name="src/UNL/Peoplefinder/Department.php" md5sum="763b1e19c28712a251c1552857cf8e7d"/> - <file role="php" name="src/UNL/Peoplefinder.php" md5sum="86236345234234cc5a4dd1e66a2e8393"/> - <file role="doc" name="examples/getUID.php" md5sum="b2e8620bc6e9b9ce921ebea48bab3133"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/AffiliationFilter.php" md5sum="04de55c30f2ba6e6cc59cf7064637faa"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php" md5sum="277d3960216fca172340e3e922a41d1f"/> + <file role="php" name="src/UNL/Peoplefinder/Driver/LDAP.php" md5sum="79ca15cea10ea91bdf1663bae8ae5c86"/> + <file role="php" name="src/UNL/Peoplefinder/Department/Search.php" md5sum="2492838aec5517effcba1ec095397b6e"/> + <file role="php" name="src/UNL/Peoplefinder/Department.php" md5sum="5c0353c08b9e48e1153b3af5cb62737f"/> + <file role="php" name="src/UNL/Peoplefinder.php" md5sum="e819399325bb52b207cda328a2dcf023"/> + <file role="script" name="scripts/peoplefinder.php" md5sum="2f8dbe7651b0534dd604e5e5c2f6b4bd"/> + <file role="doc" name="examples/getUID.php" md5sum="354a9851ede9e65a48e85653f47af9d7"/> <file role="doc" name="examples/getLikeMatches.php" md5sum="ff695239f9295eabaa187cf74e056408"/> <file role="doc" name="examples/getExactMatches.php" md5sum="187f8be90f09db8cb49a7aec912be8c4"/> - <file role="doc" name="examples/config.inc.php" md5sum="8aa9afd73dcf4178a8214b98eb2c5771"/> - <file role="data" name="data/hr_tree.xml" md5sum="d9962fcbef0e4e6ed3869f9dc4843899"/> + <file role="doc" name="examples/config.inc.php" md5sum="225033b0a9a0656843bdc5f75e31592a"/> + <file role="data" name="data/hr_tree.xml" md5sum="3f2f7bf61f627264c6c3b977aa0bbcb5"/> </dir> </contents> <dependencies> diff --git a/lib/bin/peoplefinder.php b/lib/bin/peoplefinder.php new file mode 100755 index 0000000000000000000000000000000000000000..34ab88887733a64ad39c3bbba50f9c6368a96992 --- /dev/null +++ b/lib/bin/peoplefinder.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +<?php +ini_set('display_errors', true); +error_reporting(E_ALL|E_STRICT); + +function autoload($class) +{ + $class = str_replace('_', '/', $class); + include $class . '.php'; +} + +spl_autoload_register("autoload"); + +set_include_path(dirname(dirname(__FILE__)).'/src/'.PATH_SEPARATOR.dirname(dirname(__FILE__)).'/lib/php'); +require_once 'UNL/Autoload.php'; + +$options = UNL_Peoplefinder_CLI_Router::route(); +$options['driver'] = new UNL_Peoplefinder_Driver_WebService(); +$peoplefinder = new UNL_Peoplefinder($options); + +Savvy_ClassToTemplateMapper::$classname_replacement = 'UNL_'; +$savvy = new Savvy(); +$savvy->setTemplatePath(dirname(dirname(__FILE__)).'/data/cli'); + +echo $savvy->render($peoplefinder); + +?> \ No newline at end of file diff --git a/lib/data/UNL_LDAP/build.xml b/lib/data/UNL_LDAP/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..00b85eabca11f79914e8b6f55b7338832dd54f8d --- /dev/null +++ b/lib/data/UNL_LDAP/build.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="UNL_LDAP" default="build" basedir="."> + <target name="build" depends="checkphp,php-documentor,php-codesniffer,phpunit"/> + <target name="checkphp"> + <apply executable="php" failonerror="true"> + <arg value="-l" /> + <fileset dir="${basedir}"> + <include name="**/*.php" /> + </fileset> + </apply> + </target> + <target name="php-documentor"> + <exec executable="phpdoc" dir="${basedir}" logerror="on"> + <arg line="-ue on -t ${basedir}/build/api -d ."/> + </exec> + </target> + <target name="php-codesniffer"> + <exec executable="phpcs" dir="${basedir}" output="${basedir}/build/logs/checkstyle.xml"> + <arg line="--report=checkstyle --standard=PEAR ."/> + </exec> + </target> + <target name="phpunit"> + <exec executable="phpunit" dir="${basedir}" failonerror="on"> + <arg line=" --log-xml ${basedir}/build/logs/phpunit.xml --log-pmd ${basedir}/build/logs/phpunit.pmd.xml --log-metrics ${basedir}/build/logs/phpunit.metrics.xml UNL_LDAPTest ${basedir}/tests/UNL_LDAPTest.php"/> + </exec> + </target> +</project> \ No newline at end of file diff --git a/lib/data/UNL_LDAP/config.sample.php b/lib/data/UNL_LDAP/config.sample.php new file mode 100644 index 0000000000000000000000000000000000000000..bea137cf54b44826f0b9b0c6f0322996b41554d8 --- /dev/null +++ b/lib/data/UNL_LDAP/config.sample.php @@ -0,0 +1,19 @@ +<?php +/** + * This is a sample configuration file for the LDAP connection + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +require_once 'UNL/LDAP.php'; + +$options['bind_dn'] = 'uid=youruidhere,ou=service,dc=unl,dc=edu'; +$options['bind_password'] = 'yourpasswordhere'; diff --git a/lib/data/UNL_Peoplefinder/pear.unl.edu/hr_tree.xml b/lib/data/UNL_Peoplefinder/pear.unl.edu/hr_tree.xml index b5ca227ea379d1a0f10ca1b1601215fcbff7b900..729b22ddc731aaf408937581362ef1d0b1ebf69b 100644 --- a/lib/data/UNL_Peoplefinder/pear.unl.edu/hr_tree.xml +++ b/lib/data/UNL_Peoplefinder/pear.unl.edu/hr_tree.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE tree SYSTEM "treeml.dtd"> -<!-- Generated Tue Nov 17 14:04:19 2009 --> +<!-- Generated Wed Sep 1 08:47:38 2010 --> <tree> <declarations> <attributeDecl name="name" type="String" /> @@ -62,6 +62,10 @@ <branch> <attribute name="name" value="Peter Kiewit Institute"/> <attribute name="org_unit" value="50006525"/> + <branch> + <attribute name="name" value="Peter Kiewit Institute - Omaha"/> + <attribute name="org_unit" value="50006950"/> + </branch> </branch> </branch> <branch> @@ -82,17 +86,8 @@ <attribute name="postal_code" value="68583-0742"/> </branch> <branch> - <attribute name="name" value="Audit and Advisory Services"/> - <attribute name="org_unit" value="50000327"/> - <attribute name="building" value="Varner Hall"/> - <attribute name="room" value="207"/> - <attribute name="city" value="Lincoln"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68583-0742"/> - <branch> - <attribute name="name" value="Administrative Systems Group"/> - <attribute name="org_unit" value="50002325"/> - </branch> + <attribute name="name" value="Administrative Systems Group"/> + <attribute name="org_unit" value="50002325"/> </branch> </branch> <branch> @@ -229,6 +224,23 @@ <attribute name="org_unit" value="50004475"/> </branch> </branch> + <branch> + <attribute name="name" value="Audit and Advisory Services"/> + <attribute name="org_unit" value="50000327"/> + <attribute name="building" value="Varner Hall"/> + <attribute name="room" value="207"/> + <attribute name="city" value="Lincoln"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68583-0742"/> + </branch> + <branch> + <attribute name="name" value="Nebraska P-16 Initiative"/> + <attribute name="org_unit" value="50007200"/> + </branch> + </branch> + <branch> + <attribute name="name" value="Corporation Secretary"/> + <attribute name="org_unit" value="50007201"/> </branch> </branch> <branch> @@ -307,15 +319,6 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68588-0413"/> </branch> - <branch> - <attribute name="name" value="Academic Conferences"/> - <attribute name="org_unit" value="50001053"/> - <attribute name="building" value="NCCE"/> - <attribute name="room" value="271"/> - <attribute name="city" value="Lincoln"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68583-9100"/> - </branch> <branch> <attribute name="name" value="Financial Systems"/> <attribute name="org_unit" value="50006425"/> @@ -651,6 +654,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68583-9100"/> </branch> + <branch> + <attribute name="name" value="Academic Conferences"/> + <attribute name="org_unit" value="50001053"/> + <attribute name="building" value="NCCE"/> + <attribute name="room" value="271"/> + <attribute name="city" value="Lincoln"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68583-9100"/> + </branch> <branch> <attribute name="name" value="EE&O Distance Education Srvcs"/> <attribute name="org_unit" value="50003002"/> @@ -846,6 +858,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68583-0902"/> </branch> + <branch> + <attribute name="name" value="Graduate Studies"/> + <attribute name="org_unit" value="50000900"/> + <attribute name="building" value="SHE"/> + <attribute name="room" value="1100"/> + <attribute name="city" value="UNL"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68588-0619"/> + </branch> <branch> <attribute name="name" value="International Affairs"/> <attribute name="org_unit" value="50000901"/> @@ -1046,7 +1067,7 @@ </branch> </branch> <branch> - <attribute name="name" value="Geosciences"/> + <attribute name="name" value="Earth and Atmospheric Sciences"/> <attribute name="org_unit" value="50001086"/> <attribute name="building" value="Bessey Hall"/> <attribute name="room" value="214"/> @@ -1276,7 +1297,7 @@ <attribute name="postal_code" value="68182-0181"/> </branch> <branch> - <attribute name="name" value="School of Architecture & ConstructionUNL"/> + <attribute name="name" value="Durham School Arch Engr & Const"/> <attribute name="org_unit" value="50004975"/> <branch> <attribute name="name" value="Construction Management"/> @@ -1622,15 +1643,6 @@ <attribute name="city" value="UNL"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68588-0433"/> - <branch> - <attribute name="name" value="Graduate Studies"/> - <attribute name="org_unit" value="50000900"/> - <attribute name="building" value="SHE"/> - <attribute name="room" value="1100"/> - <attribute name="city" value="UNL"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68588-0619"/> - </branch> <branch> <attribute name="name" value="Technology Development"/> <attribute name="org_unit" value="50000931"/> @@ -1761,6 +1773,15 @@ <attribute name="city" value="UNL"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68583-0705"/> + <branch> + <attribute name="name" value="Greater NE Business Center"/> + <attribute name="org_unit" value="50000888"/> + <attribute name="building" value="ARDC"/> + <attribute name="room" value="1071 County Rd G"/> + <attribute name="city" value="Ithaca"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68033"/> + </branch> <branch> <attribute name="name" value="Filley Hall Business Center"/> <attribute name="org_unit" value="50000913"/> @@ -2666,6 +2687,18 @@ <branch> <attribute name="name" value="Knoll Center"/> <attribute name="org_unit" value="50006775"/> + <branch> + <attribute name="name" value="Knoll Facilities Operations"/> + <attribute name="org_unit" value="50006776"/> + </branch> + <branch> + <attribute name="name" value="Knoll Snack Bar"/> + <attribute name="org_unit" value="50006778"/> + </branch> + <branch> + <attribute name="name" value="Knoll Residence Life"/> + <attribute name="org_unit" value="50006779"/> + </branch> </branch> </branch> <branch> @@ -2814,6 +2847,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68502"/> </branch> + <branch> + <attribute name="name" value="Midwest Archeological Ctr"/> + <attribute name="org_unit" value="50001422"/> + <attribute name="building" value="100 Centennial Mall N"/> + <attribute name="room" value="47"/> + <attribute name="city" value="Lincoln"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68508"/> + </branch> <branch> <attribute name="name" value="Saratoga Elementary School"/> <attribute name="org_unit" value="50001600"/> @@ -2936,6 +2978,10 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68507"/> </branch> + <branch> + <attribute name="name" value="Friendship Home"/> + <attribute name="org_unit" value="50006926"/> + </branch> </branch> </branch> <branch> @@ -3488,15 +3534,6 @@ <attribute name="city" value="68198-5060"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="UNMC"/> - <branch> - <attribute name="name" value="Lions Eye Bank"/> - <attribute name="org_unit" value="50001235"/> - <attribute name="building" value="ESMA"/> - <attribute name="room" value="1002"/> - <attribute name="city" value="68198-5541"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="UNMC"/> - </branch> <branch> <attribute name="name" value="Bookstore & Parking Services"/> <attribute name="org_unit" value="50006475"/> @@ -4084,6 +4121,19 @@ <attribute name="city" value="68198-3135"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="UNMC"/> + <branch> + <attribute name="name" value="Lions Eye Bank"/> + <attribute name="org_unit" value="50001235"/> + <attribute name="building" value="ESMA"/> + <attribute name="room" value="1002"/> + <attribute name="city" value="68198-5541"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="UNMC"/> + </branch> + <branch> + <attribute name="name" value="FACT"/> + <attribute name="org_unit" value="50007025"/> + </branch> </branch> <branch> <attribute name="name" value="Pediatrics"/> @@ -4382,6 +4432,10 @@ <attribute name="name" value="Surgical Oncology"/> <attribute name="org_unit" value="50005675"/> </branch> + <branch> + <attribute name="name" value="Surgery-Pediatric General"/> + <attribute name="org_unit" value="50006378"/> + </branch> </branch> <branch> <attribute name="name" value="Continuing Education"/> @@ -4843,6 +4897,10 @@ <attribute name="name" value="MMI Ctr for Ped Feeding Disord"/> <attribute name="org_unit" value="50006125"/> </branch> + <branch> + <attribute name="name" value="MMI Neurogenetic Comm Disorders Prg"/> + <attribute name="org_unit" value="50007075"/> + </branch> </branch> <branch> <attribute name="name" value="Information Technology Services"/> @@ -5003,6 +5061,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68583-0740"/> </branch> + <branch> + <attribute name="name" value="COD-General Research"/> + <attribute name="org_unit" value="50000742"/> + <attribute name="building" value="DENT"/> + <attribute name="room" value="110A"/> + <attribute name="city" value="UNMC"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68583-0740"/> + </branch> <branch> <attribute name="name" value="COD-University Dental Associates"/> <attribute name="org_unit" value="50000744"/> @@ -5021,6 +5088,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68583-0740"/> </branch> + <branch> + <attribute name="name" value="COD-UNMC Adult Dentistry"/> + <attribute name="org_unit" value="50000751"/> + <attribute name="building" value="DCC"/> + <attribute name="room" value="3615B"/> + <attribute name="city" value="UNMC"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68198-9375"/> + </branch> <branch> <attribute name="name" value="COD-Hospital Dentistry"/> <attribute name="org_unit" value="50000752"/> @@ -5341,6 +5417,10 @@ <attribute name="name" value="COPH Health Disparities"/> <attribute name="org_unit" value="50005429"/> </branch> + <branch> + <attribute name="name" value="COPH Hlth Pol Analys & Rur Hlth Res"/> + <attribute name="org_unit" value="50005430"/> + </branch> <branch> <attribute name="name" value="COPH Hlth Prm, Soc, & Behv Hlth Sci"/> <attribute name="org_unit" value="50005431"/> @@ -5357,6 +5437,10 @@ <attribute name="name" value="COPH Ctr for Humanities, Ethics&Soc"/> <attribute name="org_unit" value="50006379"/> </branch> + <branch> + <attribute name="name" value="COPH Ctr for Global Hlth & Dev"/> + <attribute name="org_unit" value="50007050"/> + </branch> </branch> <branch> <attribute name="name" value="Vice Chancellor for Research"/> @@ -5692,11 +5776,11 @@ <attribute name="postal_code" value="68182"/> </branch> <branch> - <attribute name="name" value="Telecommunications"/> - <attribute name="org_unit" value="50000782"/> + <attribute name="name" value="Parking and Transit Operations"/> + <attribute name="org_unit" value="50006975"/> <attribute name="building" value="EAB"/> - <attribute name="room" value="119"/> - <attribute name="city" value="Omaha"/> + <attribute name="room" value="107"/> + <attribute name="city" value="omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> </branch> @@ -5841,6 +5925,10 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> </branch> + <branch> + <attribute name="name" value="University Village"/> + <attribute name="org_unit" value="50006927"/> + </branch> </branch> </branch> <branch> @@ -6103,25 +6191,25 @@ <branch> <attribute name="name" value="College of Business Administration"/> <attribute name="org_unit" value="50000176"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="414"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="300"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> <branch> <attribute name="name" value="Department of Accounting"/> <attribute name="org_unit" value="50000862"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="408"/> - <attribute name="city" value="Omaha"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="228"/> + <attribute name="city" value="omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> </branch> <branch> <attribute name="name" value="Economics"/> <attribute name="org_unit" value="50000863"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="508"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="332"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> @@ -6129,8 +6217,8 @@ <branch> <attribute name="name" value="Finance, Banking and Law"/> <attribute name="org_unit" value="50000864"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="501"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="228"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> @@ -6138,8 +6226,8 @@ <branch> <attribute name="name" value="Marketing and Management"/> <attribute name="org_unit" value="50000865"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="503"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="303"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> @@ -6147,8 +6235,8 @@ <branch> <attribute name="name" value="Executive MBA Program"/> <attribute name="org_unit" value="50000872"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="414"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="100"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> @@ -6156,8 +6244,8 @@ <branch> <attribute name="name" value="Nebraska Business Development Center"/> <attribute name="org_unit" value="50000873"/> - <attribute name="building" value="RH"/> - <attribute name="room" value="415"/> + <attribute name="building" value="MH"/> + <attribute name="room" value="200"/> <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> @@ -6360,6 +6448,10 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> </branch> + <branch> + <attribute name="name" value="School of Interdisciplinary Informat"/> + <attribute name="org_unit" value="50007000"/> + </branch> </branch> <branch> <attribute name="name" value="College of Public Affrs & Comm Svcs"/> @@ -6566,6 +6658,15 @@ </branch> </branch> </branch> + <branch> + <attribute name="name" value="Telecommunications"/> + <attribute name="org_unit" value="50000782"/> + <attribute name="building" value="EAB"/> + <attribute name="room" value="119"/> + <attribute name="city" value="Omaha"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68182"/> + </branch> <branch> <attribute name="name" value="Multimedia Technology Services"/> <attribute name="org_unit" value="50000967"/> @@ -6583,15 +6684,6 @@ <attribute name="city" value="Omaha"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> - </branch> - <branch> - <attribute name="name" value="Information Tech Infrastructure"/> - <attribute name="org_unit" value="50004951"/> - <attribute name="building" value="EAB"/> - <attribute name="room" value="008"/> - <attribute name="city" value="Omaha"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68182"/> <branch> <attribute name="name" value="Customer Services"/> <attribute name="org_unit" value="50004952"/> @@ -6602,6 +6694,15 @@ <attribute name="postal_code" value="68182"/> </branch> </branch> + <branch> + <attribute name="name" value="Information Tech Infrastructure"/> + <attribute name="org_unit" value="50004951"/> + <attribute name="building" value="EAB"/> + <attribute name="room" value="008"/> + <attribute name="city" value="Omaha"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68182"/> + </branch> <branch> <attribute name="name" value="Administrative Information Services"/> <attribute name="org_unit" value="50004953"/> @@ -6710,6 +6811,10 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68182"/> </branch> + <branch> + <attribute name="name" value="Dual Enrollment"/> + <attribute name="org_unit" value="50006875"/> + </branch> </branch> <branch> <attribute name="name" value="Engineering"/> @@ -7034,7 +7139,7 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> <branch> - <attribute name="name" value="Student Life Division"/> + <attribute name="name" value="Student Affairs"/> <attribute name="org_unit" value="50000106"/> <attribute name="building" value="FNDH"/> <attribute name="room" value="1000"/> @@ -7045,7 +7150,7 @@ <attribute name="name" value="Academic Success"/> <attribute name="org_unit" value="50002775"/> <attribute name="building" value="MSAB"/> - <attribute name="room" value="163"/> + <attribute name="room" value="172"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> @@ -7053,7 +7158,7 @@ <attribute name="name" value="Learning Strategies"/> <attribute name="org_unit" value="50000578"/> <attribute name="building" value="MSAB"/> - <attribute name="room" value="163"/> + <attribute name="room" value="172"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> @@ -7071,14 +7176,32 @@ <attribute name="name" value="Writing Center"/> <attribute name="org_unit" value="50001504"/> <attribute name="building" value="LIBR"/> - <attribute name="room" value="208"/> + <attribute name="room" value="223"/> + <attribute name="city" value="Kearney"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68849"/> + </branch> + </branch> + <branch> + <attribute name="name" value="Admissions"/> + <attribute name="org_unit" value="50000617"/> + <attribute name="building" value="MSAB"/> + <attribute name="room" value="112"/> + <attribute name="city" value="Kearney"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68849"/> + <branch> + <attribute name="name" value="Summer Advising Enrollment"/> + <attribute name="org_unit" value="50000650"/> + <attribute name="building" value="MSAB"/> + <attribute name="room" value="112"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> </branch> </branch> <branch> - <attribute name="name" value="Career Services"/> + <attribute name="name" value="Academic and Career Services"/> <attribute name="org_unit" value="50000618"/> <attribute name="building" value="MSAB"/> <attribute name="room" value="140"/> @@ -7113,6 +7236,14 @@ <attribute name="postal_code" value="68849"/> </branch> </branch> + <branch> + <attribute name="name" value="Financial Aid"/> + <attribute name="org_unit" value="50000620"/> + <attribute name="building" value="MSAB"/> + <attribute name="city" value="Kearney"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68849"/> + </branch> <branch> <attribute name="name" value="Residential and Greek Life"/> <attribute name="org_unit" value="50000621"/> @@ -7270,7 +7401,7 @@ <attribute name="room" value="116"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68449"/> + <attribute name="postal_code" value="68849"/> </branch> <branch> <attribute name="name" value="Health Science Programs"/> @@ -7285,7 +7416,7 @@ <attribute name="name" value="History"/> <attribute name="org_unit" value="50000551"/> <attribute name="building" value="COPH"/> - <attribute name="room" value="103N"/> + <attribute name="room" value="130N"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> @@ -7596,6 +7727,15 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> </branch> + <branch> + <attribute name="name" value="Thompson Scholar Lrng Comm"/> + <attribute name="org_unit" value="50007125"/> + <attribute name="building" value="MANH"/> + <attribute name="room" value="107"/> + <attribute name="city" value="Kearney"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68849"/> + </branch> </branch> <branch> <attribute name="name" value="Library"/> @@ -7658,41 +7798,6 @@ <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> </branch> - <branch> - <attribute name="name" value="Academic Advising"/> - <attribute name="org_unit" value="50000616"/> - <attribute name="building" value="MSAB"/> - <attribute name="room" value="180"/> - <attribute name="city" value="Kearney"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68849"/> - </branch> - <branch> - <attribute name="name" value="Admissions"/> - <attribute name="org_unit" value="50000617"/> - <attribute name="building" value="MSAB"/> - <attribute name="room" value="112"/> - <attribute name="city" value="Kearney"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68849"/> - <branch> - <attribute name="name" value="Summer Advising Enrollment"/> - <attribute name="org_unit" value="50000650"/> - <attribute name="building" value="MSAB"/> - <attribute name="room" value="112"/> - <attribute name="city" value="Kearney"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68849"/> - </branch> - </branch> - <branch> - <attribute name="name" value="Financial Aid"/> - <attribute name="org_unit" value="50000620"/> - <attribute name="building" value="MSAB"/> - <attribute name="city" value="Kearney"/> - <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68849"/> - </branch> <branch> <attribute name="name" value="Student Records"/> <attribute name="org_unit" value="50000624"/> @@ -7780,6 +7885,15 @@ <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> + <branch> + <attribute name="name" value="Ombudsperson"/> + <attribute name="org_unit" value="50000657"/> + <attribute name="building" value="FNDH"/> + <attribute name="room" value="1200"/> + <attribute name="city" value="Kearney"/> + <attribute name="state" value="NE"/> + <attribute name="postal_code" value="68849"/> + </branch> <branch> <attribute name="name" value="Retirees"/> <attribute name="org_unit" value="50001354"/> @@ -7832,7 +7946,7 @@ <attribute name="room" value="1203"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> - <attribute name="postal_code" value="68449"/> + <attribute name="postal_code" value="68849"/> <branch> <attribute name="name" value="Budget Adjustments"/> <attribute name="org_unit" value="50002025"/> @@ -7932,10 +8046,10 @@ <attribute name="postal_code" value="68849"/> </branch> <branch> - <attribute name="name" value="EO/Affirmative Action"/> + <attribute name="name" value="EO/ Affirmative Action"/> <attribute name="org_unit" value="50000480"/> <attribute name="building" value="FNDH"/> - <attribute name="room" value="1203"/> + <attribute name="room" value="1200"/> <attribute name="city" value="Kearney"/> <attribute name="state" value="NE"/> <attribute name="postal_code" value="68849"/> @@ -7944,8 +8058,4 @@ </branch> </branch> </branch> -<branch> - <attribute name="name" value="Enrollment Mgmt & Student Affrs PSC"/> - <attribute name="org_unit" value="50006625"/> -</branch> </tree> diff --git a/lib/docs/UNL_LDAP/docs/examples/simpleSearch.php b/lib/docs/UNL_LDAP/docs/examples/simpleSearch.php new file mode 100644 index 0000000000000000000000000000000000000000..0ad47282dabbad2dfe7da7338106591f1542d070 --- /dev/null +++ b/lib/docs/UNL_LDAP/docs/examples/simpleSearch.php @@ -0,0 +1,41 @@ +<?php +/** + * This file conducts a simple ldap search + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +chdir(dirname(__FILE__).'/../../'); +require_once 'UNL/LDAP.php'; +require_once 'config.inc.php'; + +$ldap = UNL_LDAP::getConnection($options); +$results = $ldap->search('dc=unl,dc=edu', '(|(sn=ryan lim)(cn=ryan lim)(&(| (givenname=ryan) (sn=ryan) (mail=ryan) (unlemailnickname=ryan) (unlemailalias=ryan))(| (givenname=lim) (sn=lim) (mail=lim) (unlemailnickname=lim) (unlemailalias=lim))))'); + +$results->sort('uid'); + +echo count($results).' results found.'.PHP_EOL; + +foreach ($results as $entry) { + echo '<pre>'; + print_r($entry); + + echo $entry->givenName.' '.$entry->sn.' is '.$entry->uid.PHP_EOL; + echo $entry->cn; + if (count($entry->objectClass)) { + echo $entry->givenName.' is a member of:'; + foreach ($entry->objectClass as $class) { + echo $class.','; + } + echo PHP_EOL.'<br>'; + } +} +highlight_file(__FILE__); \ No newline at end of file diff --git a/lib/docs/UNL_LDAP/docs/examples/twodirectories.php b/lib/docs/UNL_LDAP/docs/examples/twodirectories.php new file mode 100644 index 0000000000000000000000000000000000000000..9b10de99780cddaa959d96ba435fe704ca875b5f --- /dev/null +++ b/lib/docs/UNL_LDAP/docs/examples/twodirectories.php @@ -0,0 +1,45 @@ +<?php + +chdir(dirname(__FILE__).'/../../'); +require_once 'UNL/LDAP.php'; +require_once 'config.inc.php'; +echo '<pre>'; +$ldap1 = UNL_LDAP::getConnection($options); + +$result = $ldap1->search('dc=unl,dc=edu', '(|(sn=ryan lim)(cn=ryan lim)(&(| (givenname=ryan) (sn=ryan) (mail=ryan) (unlemailnickname=ryan) (unlemailalias=ryan))(| (givenname=lim) (sn=lim) (mail=lim) (unlemailnickname=lim) (unlemailalias=lim))))'); + +$result->sort('uid'); + +echo $result->count().' results found.'.PHP_EOL; + +foreach ($result as $entry) { + echo $entry->givenName.' '.$entry->sn.' is '.$entry->uid.PHP_EOL; + if (count($entry->objectClass)) { + echo $entry->givenName.' is a member of:'; + foreach ($entry->objectClass as $class) { + echo $class.','; + } + echo PHP_EOL; + } +} +echo '<br />'; + +$ldap2 = UNL_LDAP::getConnection($ldap2_options); +$result = $ldap2->search('dc=unl,dc=edu', '(|(sn=ryan lim)(cn=ryan lim)(&(| (givenname=ryan) (sn=ryan) (mail=ryan) (unlemailnickname=ryan) (unlemailalias=ryan))(| (givenname=lim) (sn=lim) (mail=lim) (unlemailnickname=lim) (unlemailalias=lim))))'); + +$result->sort('uid'); + +echo $result->count().' results found.'.PHP_EOL; + +foreach ($result as $entry) { + echo $entry->givenName.' '.$entry->sn.' is '.$entry->uid.PHP_EOL; + if (count($entry->objectClass)) { + echo $entry->givenName.' is a member of:'; + foreach ($entry->objectClass as $class) { + echo $class.','; + } + echo PHP_EOL; + } +} + +?> \ No newline at end of file diff --git a/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/config.inc.php b/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/config.inc.php index eecf1ba0e7a9ab6722e74836c9c247050b9ad667..446b1237cab95906bdbcf9d62f3ad4151298e5f4 100644 --- a/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/config.inc.php +++ b/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/config.inc.php @@ -1,4 +1,4 @@ <?php require_once 'UNL/Autoload.php'; -set_include_path(dirname(__FILE__).'/../src'.PATH_SEPARATOR.get_include_path()); \ No newline at end of file +set_include_path(dirname(dirname(__FILE__)).'/src/'.PATH_SEPARATOR.dirname(dirname(__FILE__)).'/lib/php'.PATH_SEPARATOR.get_include_path()); diff --git a/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/getUID.php b/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/getUID.php index e54d6f11b6144a1e258eba43f7a3b84ed2d8350e..c0876270e475704ef871dadd5c8745ec1b0b0817 100644 --- a/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/getUID.php +++ b/lib/docs/UNL_Peoplefinder/pear.unl.edu/examples/getUID.php @@ -1,7 +1,14 @@ <?php require_once 'config.inc.php'; -$pf = new UNL_Peoplefinder(); +$pf = new UNL_Peoplefinder($driver); + $uid = $pf->getUID('bbieber2'); -echo 'uid:' . $uid->uid; -echo ' cn:' . $uid->cn; \ No newline at end of file + +echo 'uid:' . $uid->uid; +echo ' cn:' . $uid->cn; +echo ' mail:' . $uid->mail; +echo ' department:' . $uid->unlHRPrimaryDepartment; +foreach ($uid->eduPersonAffiliation as $affiliation) { + echo ' affiliation:' . $affiliation; +} \ No newline at end of file diff --git a/lib/php/UNL/LDAP.php b/lib/php/UNL/LDAP.php new file mode 100644 index 0000000000000000000000000000000000000000..f35111f25cb49458d288c6273a9133bc7cda73c6 --- /dev/null +++ b/lib/php/UNL/LDAP.php @@ -0,0 +1,214 @@ +<?php +/** + * This file contains a class for operating with the UNL LDAP directory. + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ + +require_once 'UNL/LDAP/Exception.php'; + +/** + * This class is a singleton class for operating with the UNL LDAP directory. + * + * <code> + * $options['bind_dn'] = 'uid=youruseridhere,ou=service,dc=unl,dc=edu'; + * $options['bind_password'] = 'passwordhere'; + * echo UNL_LDAP::getConnection($options)->getFirstAttribute('bbieber2', 'sn'); + * </code> + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP +{ + + /** + * The actual ldap connection link id. + * + * @var link + */ + private $_ldap = false; + + /** + * @var array + */ + public $options = array('uri' => 'ldap://ldap.unl.edu/ ldap://ldap-backup.unl.edu/', + 'base' => 'dc=unl,dc=edu', + 'suffix' => 'ou=People,dc=unl,dc=edu', + 'bind_dn' => 'get this from the identity management team', + 'bind_password' => 'get this from the identity management team'); + + /** + * <code> + * UNL_LDAP::getConnection($options)->getAttribute('bbieber','cn'); + * </code> + * + * @param array $options Associative array of options. + */ + public function __construct(array $options = null) + { + $this->setOptions($options); + } + + /** + * Set options for the ldap connection. + * + * @param array $options Associative array of options to set. + * + * @return void + */ + public function setOptions(array $options = null) + { + if (count($options)) { + foreach ($options as $attr=>$value) { + $this->options[$attr] = $value; + } + } + } + + /** + * Connect & bind to the directory. + * + * @return UNL_LDAP + */ + public function connect() + { + if ($this->_ldap !== false) { + return $this; + } + if ($this->_ldap = ldap_connect($this->options['uri'])) { + if (ldap_bind($this->_ldap, $this->options['bind_dn'], $this->options['bind_password'])) { + return $this; + } + throw new UNL_LDAP_Exception('Connection failure: ldap_bind() returned false for the server.'); + } + throw new UNL_LDAP_Exception('Could not connect to the LDAP server.'); + } + + /** + * Get the LDAP connection + * + * <code> + * $conn = UNL_LDAP::getConnection($options); + * </code> + * + * @param array $options Associative array of options to set. + * + * @return UNL_LDAP + */ + public static function getConnection(array $options = null) + { + $ldap = new self($options); + return $ldap->connect(); + } + + /** + * Get an attribute from LDAP given the LDAP-uid and attribute name. + * + * @param string $uid The LDAP-uid of the user we are looking for. + * @param string $attribute The attribute name we are interested in. + * + * @return array The array of attribute values. + */ + public function getAttribute($uid, $attribute) + { + $uid = addslashes($uid); + $result = ldap_search($this->_ldap, $this->options['suffix'], "uid=$uid"); + $info = ldap_get_entries($this->_ldap, $result); + + if (count($info) == 0) { + return false; + } else { + if (isset($info[0][$attribute])) { + return $info[0][$attribute]; + } else { + return false; + } + } + } + + /** + * Return the first attribute of an entry + * + * @param string $uid The LDAP uid of the user we are looking for. + * @param string $attribute The attribute name we are interested in. + * + * @return string | false + */ + public function getFirstAttribute($uid, $attribute) + { + if ($ret = $this->getAttribute($uid, $attribute)) { + return $ret[0]; + } else { + return false; + } + } + + /** + * Search the directory for matching entries. + * + * @param string $base Search base + * @param string $filter LDAP filter to use + * @param array $params Optional parameters to add to the LDAP query + * + * @return UNL_LDAP_Result + */ + public function search($base = null, $filter = null, array $params = array()) + { + include_once 'UNL/LDAP/Result.php'; + /* setting searchparameters */ + (isset($params['sizelimit'])) ? $sizelimit = $params['sizelimit'] : $sizelimit = 0; + (isset($params['timelimit'])) ? $timelimit = $params['timelimit'] : $timelimit = 0; + (isset($params['attrsonly'])) ? $attrsonly = $params['attrsonly'] : $attrsonly = 0; + (isset($params['attributes'])) ? $attributes = $params['attributes'] : $attributes = array(); + + $sr = ldap_search($this->_ldap, $base, $filter, $attributes, $attrsonly, $sizelimit, $timelimit); + if ($sr === false) { + throw new UNL_LDAP_Exception('Search failed'); + } + return new UNL_LDAP_Result($this->_ldap, $sr); + } + + /** + * returns the ldap connection resource link + * + * @return resource + */ + public function &getLink() + { + return $this->_ldap; + } + + /** + * unbinds from the ldap directory. + * + * @return void + */ + function disconnect() + { + return ldap_unbind($this->_ldap); + } + + /** + * destroy the object + * + * @return void + */ + function __destruct() + { + $this->disconnect(); + } +} diff --git a/lib/php/UNL/LDAP/Entry.php b/lib/php/UNL/LDAP/Entry.php new file mode 100644 index 0000000000000000000000000000000000000000..afbd21a2f7b2215014212aa260c5b9b41f5277fe --- /dev/null +++ b/lib/php/UNL/LDAP/Entry.php @@ -0,0 +1,74 @@ +<?php +/** + * LDAP entry class. + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ + +require_once 'UNL/LDAP/Entry/Attribute.php'; + +/** + * Class for handling an ldap entry + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP_Entry +{ + + protected $_attributes; + + /** + * Construct an LDAP entry object + * + * @param resource &$link LDAP connection + * @param resource $entry Entry resource from ldap_next_entry + */ + function __construct(&$link, $entry) + { + $this->_attributes = ldap_get_attributes($link, $entry); + } + + /** + * Determines if a specific attribute is set + * + * @param string $name Attribute name to check + * + * @return bool + */ + function __isset($name) + { + if (isset($this->_attributes[$name])) { + return true; + } else { + return false; + } + } + + /** + * Retrieve the requested attribute + * + * @param string $name Attribute to get + * + * @return UNL_LDAP_Entry_Attribute + */ + function __get($name) + { + if (isset($this->_attributes[$name])) { + return new UNL_LDAP_Entry_Attribute($this->_attributes[$name]); + } + } +} diff --git a/lib/php/UNL/LDAP/Entry/Attribute.php b/lib/php/UNL/LDAP/Entry/Attribute.php new file mode 100644 index 0000000000000000000000000000000000000000..f3bd288a972065787f3cf56b4c2c31ea700348ec --- /dev/null +++ b/lib/php/UNL/LDAP/Entry/Attribute.php @@ -0,0 +1,70 @@ +<?php +/** + * LDAP attribute object + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ + +/** + * Class representing an LDAP entry's attribute + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP_Entry_Attribute extends ArrayIterator +{ + public $count; + + /** + * construct an ldap attribute object + * + * @param array $attribute Array returned from ldap_next_attribute + */ + public function __construct(array $attribute) + { + $this->count = $attribute['count']; + unset($attribute['count']); + parent::__construct($attribute); + } + + /** + * Return the total number of attributes + * + * @return int + */ + public function count() + { + return $this->count; + } + + public function __wakeup() + { + if (isset($this->storage)) { + parent::__construct($this->storage); + } + $this->rewind(); + } + + /** + * Returns the first attribute entry + * + * @return string + */ + public function __toString() + { + return (string)$this->current(); + } +} \ No newline at end of file diff --git a/lib/php/UNL/LDAP/Exception.php b/lib/php/UNL/LDAP/Exception.php new file mode 100644 index 0000000000000000000000000000000000000000..7f35d283b303190ffe678826f9ab45c53b34764c --- /dev/null +++ b/lib/php/UNL/LDAP/Exception.php @@ -0,0 +1,31 @@ +<?php +/** + * This file contains a class for handling UNL_LDAP exceptions + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ + +/** + * Class for exception handling + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP_Exception extends Exception +{ + +} +?> \ No newline at end of file diff --git a/lib/php/UNL/LDAP/People.php b/lib/php/UNL/LDAP/People.php new file mode 100644 index 0000000000000000000000000000000000000000..1d784ffcf6c3b0152fb6091938384648d919f232 --- /dev/null +++ b/lib/php/UNL/LDAP/People.php @@ -0,0 +1,169 @@ +<?php +/** + * A class for obtaining info about People from the LDAP directory. + * + * <code> + * include_once 'UNL/LDAP.php' + * include_once 'UNL/LDAP/People.php'; + * + * echo UNL_LDAP_People::getCommonName('bbieber2'); + * </code> + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ + +/** + * Class for managing records for people. + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP_People +{ + /** + * Returns the 'sn' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's lastname. + */ + function getLastName($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'sn'); + } + + /** + * Returns the 'cn' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's common name (typically givenname + cn). + */ + function getCommonName($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'cn'); + } + + /** + * Returns the 'givenname' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's first name. + */ + function getFirstName($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'givenname'); + } + + /** + * Returns the 'telephonenumber' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's telephone number. + */ + function getTelephone($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'telephonenumber'); + } + + /** + * Returns the 'facsimiletelephonenumber' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's fax number. + */ + function getFax($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'fascimiletelephonenumber'); + } + + /** + * Returns the 'street' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's street address. + */ + function getStreet($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'street'); + } + + /** + * Returns the 'l' (locality) LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's city. + */ + function getCity($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'l'); + } + + /** + * Returns the 'st' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's state. + */ + function getState($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'st'); + } + + /** + * Returns the 'postalcode' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's zipcode. + */ + function getZip($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'postalcode'); + } + + /** + * Returns the 'country' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's zipcode. + */ + function getCountry($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'c'); + } + + /** + * Returns the 'mail' LDAP attribute of the user. + * + * @param string $uid Unique ID for the user + * + * @return string The user's email address. + */ + function getEmail($uid) + { + return UNL_LDAP::getConnection()->getFirstAttribute($uid, 'mail'); + } +} + +?> \ No newline at end of file diff --git a/lib/php/UNL/LDAP/Result.php b/lib/php/UNL/LDAP/Result.php new file mode 100644 index 0000000000000000000000000000000000000000..ba451ba7734d5bc5a9bc568d3ada3f8cf9e95473 --- /dev/null +++ b/lib/php/UNL/LDAP/Result.php @@ -0,0 +1,145 @@ +<?php +/** + * LDAP result record + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +require_once 'UNL/LDAP/Entry.php'; + +/** + * LDAP result record + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAP_Result implements Countable, Iterator +{ + private $_link; + + private $_result; + + private $_valid = false; + + private $_currentEntry = false; + + /** + * Resets the iterator to the first entry in the result set. + * + * @return void + */ + function rewind() + { + $this->_currentEntry = ldap_first_entry($this->_link, $this->_result); + } + + /** + * returns the current entry in the result iteration + * + * @return UNL_LDAP_Entry + */ + function current() + { + return new UNL_LDAP_Entry($this->_link, $this->_currentEntry); + } + + /** + * Advances the iterator to the next entry + * + * @return UNL_LDAP_Entry | false + */ + function next() + { + if ($this->_currentEntry !== false + && $this->_currentEntry = ldap_next_entry($this->_link, + $this->_currentEntry)) { + return $this->current(); + } else { + $this->_valid = false; + return false; + } + } + + /** + * returns a key for this entry within the array + * + * @return unknown + */ + function key() + { + //FIXME + return $this->_currentEntry; + } + + /** + * returns whether this result is valid or not + * + * @return bool + */ + function valid() + { + return $this->_valid; + } + + /** + * returns the size of the result + * + * @return int + */ + public function count() + { + return ldap_count_entries($this->_link, $this->_result); + } + + /** + * Construct an LDAP Result object + * + * @param resource &$link Connected ldap link + * @param resource &$result Identifier for the result + */ + public function __construct(&$link, &$result) + { + $this->_link = $link; + $this->_result = $result; + $this->_valid = true; + + $this->_currentEntry = ldap_first_entry($this->_link, $this->_result); + } + + /** + * frees the ldap result set + * + * @return void + */ + function __destruct() + { + unset($this->_currentEntry); + @ldap_free_result($this->_result); + } + + /** + * Sort the returned results by a specific attribute + * + * @param string $attr Attribute to sort by + * + * @return void + */ + public function sort($attr) + { + if (!ldap_sort($this->_link, $this->_result, $attr)) { + throw new Exception('Failed to sort by '.$attr); + } + } +} diff --git a/lib/php/UNL/Peoplefinder.php b/lib/php/UNL/Peoplefinder.php index fd48eed6a3a787675312b345e0687c3c6c2a42dd..3956caa5a184b3bba20c4e31e3aca187d9b648be 100644 --- a/lib/php/UNL/Peoplefinder.php +++ b/lib/php/UNL/Peoplefinder.php @@ -31,6 +31,15 @@ class UNL_Peoplefinder static public $resultLimit = UNL_PF_RESULT_LIMIT; static public $displayResultLimit = UNL_PF_DISPLAY_LIMIT; + static public $url = ''; + + /** + * Options for this use. + */ + public $options = array('view' => 'instructions', + 'format' => 'html', + 'mobile' => false); + /** * Driver for data retrieval * @@ -38,20 +47,137 @@ class UNL_Peoplefinder */ public $driver; + /** + * The results of the search + * + * @var mixed + */ + public $output; + + public $view_map = array('instructions' => 'UNL_Peoplefinder_Instructions', + 'search' => 'UNL_Peoplefinder_SearchController', + 'record' => 'UNL_Peoplefinder_Record'); + /** * Constructor for the object. + * + * @param array $options Options, format, driver, mobile etc. */ - function __construct(UNL_Peoplefinder_DriverInterface $driver = null) + function __construct($options = array()) + { + if (!isset($options['driver'])) { + $options['driver'] = new UNL_Peoplefinder_Driver_WebService(); + } + + $this->driver = $options['driver']; + + $this->options = $options + $this->options; + + if (isset($_SERVER['HTTP_ACCEPT']) + && $this->options['format'] == 'html' && ( + ($this->options['mobile'] !== false && $this->options['mobile'] != 'no') + || (preg_match('/text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml/', $_SERVER['HTTP_ACCEPT'])) + || preg_match('/sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera/', $_SERVER['HTTP_USER_AGENT']) + || preg_match('/mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox/', $_SERVER['HTTP_USER_AGENT']) + || preg_match('/blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-/', $_SERVER['HTTP_USER_AGENT']) + || preg_match('/portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc/', $_SERVER['HTTP_USER_AGENT']) + || preg_match('/smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|Android/', $_SERVER['HTTP_USER_AGENT']) + )) { + $this->options['mobile'] = true; + } + + try { + $this->run(); + } catch(Exception $e) { + $this->output[] = $e; + } + } + + public static function getURL($mixed = null, $additional_params = array()) { - if (!$driver) { - $driver = new UNL_Peoplefinder_Driver_WebService(); + + $url = self::$url; + + if (is_object($mixed)) { + switch (get_class($mixed)) { + default: + + } } - $this->driver = $driver; + + return self::addURLParams($url, $additional_params); } + public static function addURLParams($url, $additional_params = array()) + { + $params = array(); + $params = array_merge($params, $additional_params); + + $url .= '?'; + + foreach ($params as $option=>$value) { + if ($option == 'driver') { + continue; + } + if ($option == 'format' + && $value = 'html') { + continue; + } + if (!empty($value)) { + $url .= "&$option=$value"; + } + } + $url = str_replace('?&', '?', $url); + return trim($url, '?;='); + } + + public function determineView() + { + switch(true) { + case isset($this->options['q']): + case isset($this->options['sn']): + case isset($this->options['cn']): + $this->options['view'] = 'search'; + return; + case isset($this->options['uid']): + $this->options['view'] = 'record'; + return; + } + + } + + function run() + { + $this->determineView(); + if (isset($this->view_map[$this->options['view']])) { + if ($this->view_map[$this->options['view']] == 'UNL_Peoplefinder_Record') { + $this->output[] = $this->getUID($this->options['uid']); + return; + } + $this->options['peoplefinder'] =& $this; + $this->output[] = new $this->view_map[$this->options['view']]($this->options); + } else { + throw new Exception('Un-registered view', 404); + } + } + + /** + * Pass through calls to the driver. + * + * @method UNL_Peoplefinder_Record getUID() getUID(string $uid) get a record + * + * @param string $method The method to call + * @param mixed $args Arguments + * + * @return mixed + */ function __call($method, $args) { return call_user_func_array(array($this->driver, $method), $args); } + public static function getDataDir() + { + return dirname(__FILE__).'/../../data'; + } } diff --git a/lib/php/UNL/Peoplefinder/Department.php b/lib/php/UNL/Peoplefinder/Department.php index 4400e63a0eba8e9a4c36b8481d1f1cbfedce08bb..7fde8f7b8fdc631111e30845dd6f9e0ff44c0862 100644 --- a/lib/php/UNL/Peoplefinder/Department.php +++ b/lib/php/UNL/Peoplefinder/Department.php @@ -65,24 +65,42 @@ class UNL_Peoplefinder_Department implements Countable, Iterator protected $_xml; + public $options = array(); + /** * construct a department * * @param string $name Name of the department */ - function __construct($name) + function __construct($options = array()) { - $this->name = $name; - $this->_xml = new SimpleXMLElement(file_get_contents(dirname(__FILE__).'/../../data/hr_tree.xml')); - $results = $this->_xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="name"][@value="'.$this->name.'"]/..'); - if (isset($results[0])) { - foreach ($results[0] as $attribute) { - if (isset($attribute['name'])) { - $this->{$attribute['name']} = (string)$attribute['value']; - } - } + if (!(isset($options['d']) || isset($options['org_unit']))) { + throw new Exception('No department name or org_unit! Pass as the d or org_unit value.'); + } + $this->options = $options + $this->options; + + $this->_xml = new SimpleXMLElement(file_get_contents(UNL_Peoplefinder::getDataDir().'/hr_tree.xml')); + + if (isset($options['org_unit'])) { + $this->org_unit = $options['org_unit']; + $xpath = '//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="org_unit"][@value="'.$this->org_unit.'"]/..'; } else { - throw new Exception('Invalid department name.'); + $this->name = $options['d']; + $quoted = preg_replace('/([\'\"\?])/', '\\$1', $this->name); + + $xpath = '//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="name"][@value="'.$quoted.'"]/..'; + } + + $results = $this->_xml->xpath($xpath); + + if (!isset($results[0])) { + throw new Exception('Invalid department name "'.$this->name.'"', 404); + } + + foreach ($results[0] as $attribute) { + if (isset($attribute['name'])) { + $this->{$attribute['name']} = (string)$attribute['value']; + } } } @@ -94,17 +112,9 @@ class UNL_Peoplefinder_Department implements Countable, Iterator function getLDAPResults() { if (!isset($this->_results)) { - $options = array( - 'bind_dn' => UNL_Peoplefinder_Driver_LDAP::$bindDN, - 'bind_password' => UNL_Peoplefinder_Driver_LDAP::$bindPW, - ); - - $this->_ldap = UNL_LDAP::getConnection($options); - $name = str_replace(array('(',')','*','\'','"'), '', $this->name); - $this->_results = $this->_ldap->search('dc=unl,dc=edu', - '(unlHRPrimaryDepartment='.$name.')'); - $this->_results->sort('cn'); - $this->_results->sort('sn'); + UNL_Peoplefinder::$resultLimit = 500; + $pf = new UNL_Peoplefinder($this->options); + $this->_results = new ArrayIterator($pf->getHRPrimaryDepartmentMatches($this->name)); } return $this->_results; } @@ -131,7 +141,7 @@ class UNL_Peoplefinder_Department implements Countable, Iterator */ function current() { - return UNL_Peoplefinder_Record::fromUNLLDAPEntry($this->getLDAPResults()->current()); + return $this->getLDAPResults()->current(); } function key() @@ -151,24 +161,40 @@ class UNL_Peoplefinder_Department implements Countable, Iterator function hasChildren() { - $results = $this->_xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="name"][@value="'.$this->name.'"]/../branch'); + $results = $this->_xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="org_unit"][@value="'.$this->org_unit.'"]/../branch'); return count($results)?true:false; } function getChildren() { $children = array(); - $results = $this->_xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="name"][@value="'.$this->name.'"]/../branch'); + $results = $this->_xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="org_unit"][@value="'.$this->org_unit.'"]/../branch'); foreach ($results as $result) { foreach ($result[0] as $attribute) { if (isset($attribute['name']) - && $attribute['name']=='name') { - $children[] = (string)$attribute['value']; + && $attribute['name']=='org_unit') { + $children[] = self::getById((string)$attribute['value']); break; } } } - asort($children); + return $children; } + + /** + * Retrieve an official SAP Org entry by ID + * + * @param int $id ID, such as 5000XXXX + */ + public static function getById($id, $options = array()) + { + $xml = new SimpleXMLElement(file_get_contents(UNL_Peoplefinder::getDataDir().'/hr_tree.xml')); + $results = $xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="org_unit"][@value='.$id.']/..'); + if (!$results) { + return false; + } + $options['org_unit'] = $id; + return new self($options); + } } diff --git a/lib/php/UNL/Peoplefinder/Department/Search.php b/lib/php/UNL/Peoplefinder/Department/Search.php index 58648ae9f40ba0fe9da3f1be498696d4f632d96d..c6e889d89f45c7c9ef1237c37b881badfde9b12c 100644 --- a/lib/php/UNL/Peoplefinder/Department/Search.php +++ b/lib/php/UNL/Peoplefinder/Department/Search.php @@ -1,6 +1,8 @@ <?php class UNL_Peoplefinder_Department_Search implements Countable, Iterator { + public $options = array('q' => ''); + public $q; /** @@ -14,16 +16,17 @@ class UNL_Peoplefinder_Department_Search implements Countable, Iterator protected $current = 0; - function __construct($q) + function __construct($options = array()) { - $q = strtolower(str_replace('"', '', $q)); - $this->xml = new SimpleXMLElement(file_get_contents(dirname(__FILE__).'/../../../data/hr_tree.xml')); + $this->options = $options + $this->options; + $q = strtolower(str_replace('"', '', $this->options['q'])); + $this->xml = new SimpleXMLElement(file_get_contents(UNL_Peoplefinder::getDataDir().'/hr_tree.xml')); $this->results = $this->xml->xpath('//attribute[@name="org_unit"][@value="50000003"]/..//attribute[@name="name"][contains(translate(@value,"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"),"'.$q.'")]'); } function current() { - return new UNL_Peoplefinder_Department($this->results[$this->current]['value']); + return new UNL_Peoplefinder_Department(array('d'=>$this->results[$this->current]['value'])); } function next() diff --git a/lib/php/UNL/Peoplefinder/Driver/LDAP.php b/lib/php/UNL/Peoplefinder/Driver/LDAP.php index fc5928f7850da20806dac29f3e1c04b1ca666e12..4b75f9f20c50ae22468c72dd9fc518b836ebda68 100644 --- a/lib/php/UNL/Peoplefinder/Driver/LDAP.php +++ b/lib/php/UNL/Peoplefinder/Driver/LDAP.php @@ -6,7 +6,7 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface * * @param string */ - static public $ldapServer = 'ldap.unl.edu ldap-backup.unl.edu'; + static public $ldapServer = 'ldap-test.unl.edu'; /** * LDAP Connection bind distinguised name @@ -40,6 +40,7 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface public $listAttributes = array( 'cn', 'eduPersonNickname', + 'eduPersonAffiliation', 'eduPersonPrimaryAffiliation', 'givenName', 'sn', @@ -54,6 +55,7 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface public $detailAttributes = array( 'ou', 'cn', + 'eduPersonAffiliation', 'eduPersonNickname', 'eduPersonPrimaryAffiliation', 'givenName', @@ -112,7 +114,7 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface return $this->connected; } } - throw new Exception('Cound not connect to LDAP directory.'); + throw new Exception('Cound not connect to LDAP directory.', 500); } /** @@ -178,13 +180,18 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface /** * Get records which match the query exactly. * - * @param string $q Search string. + * @param string $query Search string. + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student * * @return array(UNL_Peoplefinder_Record) */ - public function getExactMatches($q) + public function getExactMatches($query, $affiliation = null) { - $filter = new UNL_Peoplefinder_Driver_LDAP_StandardFilter($q, '&', false); + if ($affiliation) { + $filter = new UNL_Peoplefinder_Driver_LDAP_AffiliationFilter($query, $affiliation, '&', false); + } else { + $filter = new UNL_Peoplefinder_Driver_LDAP_StandardFilter($query, '&', false); + } $this->query($filter->__toString(), $this->detailAttributes); return $this->getRecordsFromResults(); } @@ -200,7 +207,7 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface $r = array(); if ($this->lastResultCount > 0) { for ($i = 0; $i < $this->lastResultCount; $i++) { - $r[] = UNL_Peoplefinder_Record::fromLDAPEntry($this->lastResult[$i]); + $r[] = self::recordFromLDAPEntry($this->lastResult[$i]); } } return $r; @@ -215,9 +222,9 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface * * @return array(UNL_Peoplefinder_Record) */ - public function getAdvancedSearchMatches($sn, $cn, $eppa) + public function getAdvancedSearchMatches($query, $affiliation = null) { - $filter = new UNL_Peoplefinder_Driver_LDAP_AdvancedFilter($sn, $cn, $eppa, '&', true); + $filter = new UNL_Peoplefinder_Driver_LDAP_AdvancedFilter($query['sn'], $query['cn'], $affiliation, '&', true); $this->query($filter->__toString(), $this->detailAttributes); return $this->getRecordsFromResults(); } @@ -225,15 +232,20 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface /** * Find matches similar to the query given * - * @param string $q Search query + * @param string $query Search query + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student * @param array $excluded_records Array of records to exclude. * * @return array(UNL_Peoplefinder_Record) */ - public function getLikeMatches($q, $excluded_records = array()) + public function getLikeMatches($query, $affiliation = null, $excluded_records = array()) { - // Build filter excluding those displayed above - $filter = new UNL_Peoplefinder_Driver_LDAP_StandardFilter($q, '&', true); + if ($affiliation) { + $filter = new UNL_Peoplefinder_Driver_LDAP_AffiliationFilter($query, $affiliation, '&', true); + } else { + $filter = new UNL_Peoplefinder_Driver_LDAP_StandardFilter($query, '&', true); + } + // Exclude those displayed above $filter->excludeRecords($excluded_records); $this->query($filter->__toString(), $this->detailAttributes); return $this->getRecordsFromResults(); @@ -242,13 +254,14 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface /** * Get an array of records which matche by the phone number. * - * @param string $q EG: 472-1598 + * @param string $q EG: 472-1598 + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student * * @return array(UNL_Peoplefinder_Record) */ - public function getPhoneMatches($q) + public function getPhoneMatches($query, $affiliation = null) { - $filter = new UNL_Peoplefinder_Driver_LDAP_TelephoneFilter($q); + $filter = new UNL_Peoplefinder_Driver_LDAP_TelephoneFilter($query, $affiliation); $this->query($filter->__toString(), $this->detailAttributes); return $this->getRecordsFromResults(); } @@ -264,12 +277,39 @@ class UNL_Peoplefinder_Driver_LDAP implements UNL_Peoplefinder_DriverInterface { $r = $this->query("(&(uid=$uid))", $this->detailAttributes, false); if (isset($r[0])) { - return UNL_Peoplefinder_Record::fromLDAPEntry($r[0]); + return self::recordFromLDAPEntry($r[0]); } else { header('HTTP/1.0 404 Not Found'); - throw new Exception('Cannot find that UID.'); + throw new Exception('Cannot find that UID.', 404); } } + public static function recordFromLDAPEntry(array $entry) + { + $r = new UNL_Peoplefinder_Record(); + foreach (get_object_vars($r) as $var=>$val) { + if (isset($entry[strtolower($var)], $entry[strtolower($var)][0])) { + $r->$var = new UNL_LDAP_Entry_Attribute($entry[strtolower($var)]); + } + } + $r->imageURL = $r->getImageURL(); + return $r; + } + public static function recordFromUNLLDAPEntry(UNL_LDAP_Entry $entry) + { + $r = new UNL_Peoplefinder_Record(); + foreach (get_object_vars($r) as $var=>$val) { + $r->$var = $entry->$var; + } + $r->imageURL = $r->getImageURL(); + return $r; + } + + public function getHRPrimaryDepartmentMatches($query, $affiliation = null) + { + $filter = new UNL_Peoplefinder_Driver_LDAP_HRPrimaryDepartmentFilter($query); + $this->query($filter->__toString(), $this->detailAttributes); + return $this->getRecordsFromResults(); + } } diff --git a/lib/php/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php b/lib/php/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php index 45e6e82be97c59198508041bff3438555774537b..231112af125e25c2110efb0efa6d02d451af3fd9 100644 --- a/lib/php/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php +++ b/lib/php/UNL/Peoplefinder/Driver/LDAP/AdvancedFilter.php @@ -72,7 +72,7 @@ class UNL_Peoplefinder_Driver_LDAP_AdvancedFilter function __toString() { - $this->_filter = '(&'.$this->_filter.'(!(eduPersonPrimaryAffiliation=guest)))'; + $this->_filter = '(&'.$this->_filter.'(!(|(ou=org)(eduPersonPrimaryAffiliation=guest))))'; return $this->_filter; } diff --git a/lib/php/UNL/Peoplefinder/Driver/LDAP/AffiliationFilter.php b/lib/php/UNL/Peoplefinder/Driver/LDAP/AffiliationFilter.php new file mode 100644 index 0000000000000000000000000000000000000000..6eb338ca9920b67cf2d29daca348f59aad6f1034 --- /dev/null +++ b/lib/php/UNL/Peoplefinder/Driver/LDAP/AffiliationFilter.php @@ -0,0 +1,25 @@ +<?php +class UNL_Peoplefinder_Driver_LDAP_AffiliationFilter extends UNL_Peoplefinder_Driver_LDAP_StandardFilter +{ + protected $affiliation = 'staff'; + + function __construct($query, $affiliation, $operator = '&', $wild = false) + { + switch($affiliation) { + case 'student': + case 'faculty': + case 'staff': + case 'guest': + $this->affiliation = $affiliation; + break; + } + parent::__construct($query, $operator, $wild); + } + + function __toString() + { + $this->addExcludedRecords(); + $this->_filter = '(&'.$this->_filter.'(eduPersonAffiliation='.$this->affiliation.'))'; + return $this->_filter; + } +} \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php b/lib/php/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php index b6d51957015b39f071099db2c9f1a5078088f5c2..ed7439ecd761fcf39fd08f5362e361a78620f787 100644 --- a/lib/php/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php +++ b/lib/php/UNL/Peoplefinder/Driver/LDAP/StandardFilter.php @@ -21,9 +21,9 @@ */ class UNL_Peoplefinder_Driver_LDAP_StandardFilter { - private $_filter; + protected $_filter; - private $_excludeRecords = array(); + protected $_excludeRecords = array(); /** * Construct a standard filter. @@ -44,7 +44,9 @@ class UNL_Peoplefinder_Driver_LDAP_StandardFilter //put the query into an array of words $query = preg_split('/\s+/', $inquery, 4); - if ($operator!='&') $operator = '|'; + if ($operator != '&') { + $operator = '|'; + } //create our filter //search for the string parts @@ -87,10 +89,14 @@ class UNL_Peoplefinder_Driver_LDAP_StandardFilter */ function excludeRecords($records = array()) { - $this->_excludeRecords = array_merge($this->_excludeRecords, $records); + if (count($this->_excludeRecords)) { + $this->_excludeRecords = array_merge($this->_excludeRecords, $records); + } else { + $this->_excludeRecords = $records; + } } - function __toString() + protected function addExcludedRecords() { if (count($this->_excludeRecords)) { $excludeFilter = ''; @@ -99,7 +105,12 @@ class UNL_Peoplefinder_Driver_LDAP_StandardFilter } $this->_filter = '(&'.$this->_filter.'(!(|'.$excludeFilter.')))'; } - $this->_filter = '(&'.$this->_filter.'(!(eduPersonPrimaryAffiliation=guest)))'; + } + + function __toString() + { + $this->addExcludedRecords(); + $this->_filter = '(&'.$this->_filter.'(!(|(ou=org)(eduPersonPrimaryAffiliation=guest))))'; return $this->_filter; } } diff --git a/lib/php/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php b/lib/php/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php index 7015152d71d0972d256ad7b608d59a29d6387501..f41be75190ad97448d9e6dc93ce9d17267ea7c72 100644 --- a/lib/php/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php +++ b/lib/php/UNL/Peoplefinder/Driver/LDAP/TelephoneFilter.php @@ -15,16 +15,30 @@ class UNL_Peoplefinder_Driver_LDAP_TelephoneFilter { private $_filter; - function __construct($q) + protected $affiliation; + + function __construct($q, $affiliation = null) { if (!empty($q)) { $this->_filter = '(telephoneNumber=*'.str_replace('-','*',$q).')'; } + + switch ($affiliation) { + case 'faculty': + case 'staff': + case 'student': + $this->affiliation = $affiliation; + break; + } } function __toString() { - $this->_filter = '(&'.$this->_filter.'(!(eduPersonPrimaryAffiliation=guest)))'; + $this->_filter = '(&'.$this->_filter.'(!(|(ou=org)(eduPersonPrimaryAffiliation=guest)))'; + if ($this->affiliation) { + $this->_filter .= '(eduPersonAffiliation='.$this->affiliation.')'; + } + $this->_filter .= ')'; return $this->_filter; } } diff --git a/lib/php/UNL/Peoplefinder/Driver/WebService.php b/lib/php/UNL/Peoplefinder/Driver/WebService.php index 17e1d714eac387cfa8d2b8947080a7204936a07b..79d86c6f7f6b00c45277d59083774081a6b97e0b 100644 --- a/lib/php/UNL/Peoplefinder/Driver/WebService.php +++ b/lib/php/UNL/Peoplefinder/Driver/WebService.php @@ -1,40 +1,90 @@ <?php class UNL_Peoplefinder_Driver_WebService implements UNL_Peoplefinder_DriverInterface { + /** + * The address to the webservice + * + * @var string + */ public $service_url = 'http://peoplefinder.unl.edu/service.php'; + + function __construct($options = array()) + { + if (isset($options['service_url'])) { + $this->service_url = $options['service_url']; + } + } - function getExactMatches($query) + function getExactMatches($query, $affiliation = null) { - $results = file_get_contents($this->service_url.'?q='.urlencode($query).'&format=php&method=getExactMatches'); + $results = file_get_contents($this->service_url.'?q='.urlencode($query).'&format=php&affiliation='.urlencode($affiliation).'&method=getExactMatches'); if ($results) { $results = unserialize($results); } return $results; } - function getAdvancedSearchMatches($sn, $cn, $eppa) + function getAdvancedSearchMatches($query, $affliation = null) { - throw new Exception('Not implemented yet'); + if (empty($affiliation)) { + $affiliation = ''; + } + $results = file_get_contents($this->service_url.'?sn='.urlencode($query['sn']).'&cn='.urlencode($query['cn']).'&format=php&affiliation='.urlencode($affiliation).'&method=getAdvancedSearchMatches'); + if ($results) { + $results = unserialize($results); + } + return $results; } - function getLikeMatches($query) + function getLikeMatches($query, $affiliation = null, $excluded_records = array()) { - $results = file_get_contents($this->service_url.'?q='.urlencode($query).'&format=php&method=getLikeMatches'); + $results = file_get_contents($this->service_url.'?q='.urlencode($query).'&format=php&affiliation='.urlencode($affiliation).'&method=getLikeMatches'); if ($results) { $results = unserialize($results); } return $results; } - function getPhoneMatches($query) + + /** + * Get matches for a phone search + * + * @param string $query Numerical search query + * @param string $affiliation eduPersonAffiliation, eg, student, staff, faculty + * + * @return UNL_Peoplefinder_SearchResults + */ + function getPhoneMatches($query, $affiliation = null) { - throw new Exception('Not implemented yet'); + $results = file_get_contents($this->service_url.'?q='.urlencode($query).'&format=php&affiliation='.urlencode($affiliation).'&method=getPhoneMatches'); + if ($results) { + $results = unserialize($results); + } + return $results; } - + + /** + * Get an individual's record within the directory. + * + * @param string $uid Unique ID for the user, eg: bbieber2 + * + * @return UNL_Peoplefinder_Record + */ function getUID($uid) { $record = file_get_contents($this->service_url.'?uid='.urlencode($uid).'&format=php'); - if ($record) { - $record = unserialize($record); + + if (false === $record) { + throw new Exception('Could not find that user!', 404); } - return $record; + + return unserialize($record); + } + + function getHRPrimaryDepartmentMatches($query, $affiliation = null) + { + $results = file_get_contents($this->service_url.'?q=d:'.urlencode($query).'&format=php&affiliation='.urlencode($affiliation).'&method=getHRPrimaryDepartmentMatches'); + if ($results) { + $results = unserialize($results); + } + return $results; } } ?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/DriverInterface.php b/lib/php/UNL/Peoplefinder/DriverInterface.php index 7a1a0dfe6af8440ee6233cae22ee90022c07eddc..51889fb5b5b9de4982ece89e39f1bf371dd9c58d 100644 --- a/lib/php/UNL/Peoplefinder/DriverInterface.php +++ b/lib/php/UNL/Peoplefinder/DriverInterface.php @@ -10,33 +10,43 @@ interface UNL_Peoplefinder_DriverInterface /** * Return an array of records exactly matching the query. * - * @param string $query A general query + * @param string $query A general query + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student */ - function getExactMatches($query); + function getExactMatches($query, $affiliation = null); /** * perform a detailed search * - * @param string $sn surname, eg bieber - * @param string $cn common name, eg brett - * @param string $eppa eduPersonPrimaryAffiliation, eg staff/faculty/student + * @param array(cn,sn) Where cn = common name, sn surname, eg bieber + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student */ - function getAdvancedSearchMatches($sn, $cn, $eppa); + function getAdvancedSearchMatches($query, $affiliation = null); /** * Return an array of records somewhat matching the query * - * @param string $query A general query + * @param string $query A general query + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student */ - function getLikeMatches($query); + function getLikeMatches($query, $affiliation = null); /** * return matches for a phone number search * - * @param string $query Phone number eg: 472-1598 + * @param string $query Phone number eg: 472-1598 + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student */ - function getPhoneMatches($query); - + function getPhoneMatches($query, $affiliation = null); + + /** + * Get results by organization + * + * @param string $query The organization name, eg: University Communications + * @param string $affiliation eduPersonAffiliation, eg staff/faculty/student + */ + function getHRPrimaryDepartmentMatches($query, $affiliation = null); + /** * get a UNL_Peoplefinder_Record for the user * diff --git a/lib/php/UNL/Peoplefinder/Record.php b/lib/php/UNL/Peoplefinder/Record.php index 83d346a2907edfae0d6b86a489ad140ec6c6e4b7..2116b688339dfe2a992b935bc422e07d61bed061 100644 --- a/lib/php/UNL/Peoplefinder/Record.php +++ b/lib/php/UNL/Peoplefinder/Record.php @@ -14,6 +14,7 @@ class UNL_Peoplefinder_Record { public $cn; public $ou; + public $eduPersonAffiliation; public $eduPersonNickname; public $eduPersonPrimaryAffiliation; public $givenName; @@ -42,26 +43,15 @@ class UNL_Peoplefinder_Record public $unlSISMajor; public $unlEmailAlias; - - static function fromLDAPEntry(array $entry) + function __construct($options = array()) { - $r = new self(); - foreach (get_object_vars($r) as $var=>$val) { - if (isset($entry[strtolower($var)], $entry[strtolower($var)][0])) { - $r->$var = $entry[strtolower($var)][0]; - } + if (isset($options['uid']) + && $options['peoplefinder']) { + return $options['peoplefinder']->getUID($options['uid']); } - return $r; } - static function fromUNLLDAPEntry(UNL_LDAP_Entry $entry) - { - $r = new self(); - foreach (get_object_vars($r) as $var=>$val) { - $r->$var = $entry->$var; - } - return $r; - } + /** * Takes in a string from the LDAP directory, usually formatted like: @@ -73,50 +63,128 @@ class UNL_Peoplefinder_Record */ 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); - } + $parts = explode(',', $this->postalAddress); + + // Set up defaults: + $address = array(); + $address['street-address'] = trim($parts[0]); + $address['locality'] = ''; $address['region'] = 'NE'; - $address['street-address'] = trim($addressComponent[0]); - if (isset($addressComponent[1])) { - $address['postal-code'] = trim($addressComponent[1]); - } else { - $address['postal-code'] = ''; + $address['postal-code'] = ''; + + if (count($parts) == 3) { + // Assume we have a street address, city, zip. + $address['locality'] = trim($parts[1]); + } + + // 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); + } } - switch (substr($address['postal-code'],0,3)) { + + switch (substr($address['postal-code'], 0, 3)) { case '681': $address['locality'] = 'Omaha'; - break; + break; case '685': - default: $address['locality'] = 'Lincoln'; - break; + break; } return $address; } + +/** + * Formats a major subject code into a text description. + * + * @param string $subject Subject code for the major eg: MSYM + * + * @return string + */ + public function formatMajor($subject) + { + + $c = new UNL_Cache_Lite(); + if ($subject_xml = $c->get('catalog subjects')) { + + } 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'); + } + } + + $d = new DOMDocument(); + $d->loadXML($subject_xml); + if ($subject_el = $d->getElementById($subject)) { + return $subject_el->textContent; + } + + switch ($subject) { + case 'UNDL': + return 'Undeclared'; + case 'PBAC': + return 'Non-Degree Post-Baccalaureate'; + default: + return $subject; + } + } + + /** + * Format a three letter college abbreviation into the full college name. + * + * @param string $college College abbreviation = FPA + * + * @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]); + } + + 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 __wakeup() + { + foreach ($this as $var=>$val) { + if ($val instanceof UNL_LDAP_Entry_Attribute) { + $this->$var->__wakeup(); + } + } + } + function __toString() { return $this->uid; } } -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Renderer/HTML.php b/lib/php/UNL/Peoplefinder/Renderer/HTML.php index 121f83dea292abf8fa9a3d9860509e9fdbd9002d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/Renderer/HTML.php +++ b/lib/php/UNL/Peoplefinder/Renderer/HTML.php @@ -1,518 +0,0 @@ -<?php -/** - * Peoplefinder HTML Renderer - * - * 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/ - */ - -/** - * Determines if a network in the form of 192.168.17.1/16 or - * 127.0.0.1/255.255.255.255 or 10.0.0.1 matches a given ip - * @param $network The network and mask - * @param $ip The ip to check - * @return bool true or false - */ -function net_match($network, $ip) { - $ip_arr = explode('/', $network); - $network_long = ip2long($ip_arr[0]); - $x = ip2long($ip_arr[1]); - $mask = long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 - $ip_arr[1]); - $ip_long = ip2long($ip); - return ($ip_long & $mask) == ($network_long & $mask); -} - -/** - * Class to render html output for results - * - * 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_Renderer_HTML -{ - - protected $trustedIP = false; - public $uri; - - public $displayLimit; - - /** This can be set to a javascript function name to send the UID to when clicking a uid */ - public $uid_onclick; - /** This defines a mode in which the directory is searched to return one user. */ - public $choose_uid = false; - public $page_onclick; - - function __construct(array $options = null) - { - if (isset($_SERVER['REMOTE_ADDR'])) { - $validIPs = array('129.93.0.0/16','65.123.32.0/19','64.39.240.0/20','216.128.208.0/20'); - foreach ($validIPs as $range) { - if (net_match($range, $_SERVER['REMOTE_ADDR'])) { - $this->trustedIP = true; - break; - } - } - } - $this->displayLimit = UNL_Peoplefinder::$displayResultLimit; - $this->uri = $_SERVER['SCRIPT_NAME']; - if (isset($options)) { - $this->setOptions($options); - } - } - - /** - * This function sets parameters for this class. - * - * @param array $options an associative array of options to set. - */ - function setOptions(array $options) - { - foreach ($options as $option=>$val) { - if (property_exists($this,$option)) { - $this->$option = $val; - } else { - echo 'Warning: Trying to set unkown option ['.$option.'] for object '.get_class($this)."\n"; - } - } - } - - /** - * Renders a peoplefinder record object - * - * @param UNL_Peoplefinder_Record $r record to render - */ - public function renderRecord(UNL_Peoplefinder_Record $r) - { - echo "<div class='vcard {$r->eduPersonPrimaryAffiliation}'>\n"; - if (isset($r->mail) - && ($r->eduPersonPrimaryAffiliation != 'student' || $this->displayStudentEmail==true)) { - $displayEmail = true; - } else { - $displayEmail = false; - } - if ($displayEmail && isset($r->unlEmailAlias)) echo "<a class='email' href='mailto:{$r->unlEmailAlias}@unl.edu'>"; - if ($r->ou == 'org') { - echo '<span class="cn">'.$r->cn.'</span>'.PHP_EOL; - } else { - echo '<span class="fn">'.$r->displayName.'</span>'.PHP_EOL; - if (isset($r->eduPersonNickname)) echo '<span class="nickname">'.$r->eduPersonNickname.'</span>'.PHP_EOL; - } - if ($displayEmail && isset($r->unlEmailAlias)) echo "</a>\n"; - if (!empty($r->eduPersonPrimaryAffiliation)) echo '<span class="eppa">('.$r->eduPersonPrimaryAffiliation.')</span>'.PHP_EOL; - echo '<div class="vcardInfo">'.PHP_EOL; - echo '<a class="planetred_profile" href="http://planetred.unl.edu/pg/profile/unl_'.$r->uid.'" title="Planet Red Profile for '.$r->cn.'"><img class="photo frame" src="http://planetred.unl.edu/mod/profile/icondirect.php?username=unl_'.$r->uid.'&size=medium" alt="Photo of '.$r->displayName.'" /></a>'; - if (isset($r->unlSISClassLevel)) { - switch ($r->unlSISClassLevel) { - case 'FR': - $class = 'Freshman,'; - break; - case 'SR': - $class = 'Senior,'; - break; - case 'SO': - $class = 'Sophomore,'; - break; - case 'JR': - $class = 'Junior,'; - break; - case 'GR': - $class = 'Graduate Student,'; - break; - default: - $class = $r->unlSISClassLevel; - } - echo '<span class="title">'.$class." ".$this->formatMajor($r->unlSISMajor).'–'.$this->formatCollege($r->unlSISCollege).'</span>'; - } - -// if (isset($r->unlSISLocalAddr1)) { -// $localaddr = array($r->unlSISLocalAddr1, $r->unlSISLocalAddr2, $r->unlSISLocalCity, $r->unlSISLocalState, $r->unlSISLocalZip); -// $this->renderAddress($localaddr, 'Local', 'workAdr'); -// } -// -// if (isset($r->unlSISPermAddr1)) { -// $permaddr = array($r->unlSISPermAddr1, $r->unlSISPermAddr2, $r->unlSISPermCity, $r->unlSISPermState, $r->unlSISPermZip); -// $this->renderAddress($permaddr, 'Home', 'homeAdr'); -// } - - if (isset($r->title)) { - echo "<span class='title'>{$r->title}</span>\n"; - } - - if (isset($r->unlHRPrimaryDepartment)) { - $org_name = 'University of Nebraska–Lincoln'; - if ($r->unlHRPrimaryDepartment == 'Office of the President') { - $org_name = 'University of Nebraska'; - } - $dept_url = UNL_PEOPLEFINDER_URI.'departments/?d='.urlencode($r->unlHRPrimaryDepartment); - echo "<span class='org'>\n\t<span class='organization-unit'><a href='{$dept_url}'>{$r->unlHRPrimaryDepartment}</a></span>\n\t<span class='organization-name'>$org_name</span></span>\n"; - } - - if (isset($r->postalAddress)) { - if (strpos($r->postalAddress,'UNL')!= -1 || strpos($r->postalAddress,'UNO')!= -1) { - $address = $r->formatpostalAddress(); - - if( strpos($address['postal-code'],'68588') == 0 ) - { - $address['street-address'] = $this->replaceBuildingCode($address['street-address']); - } - - echo '<div class="adr workAdr"> - <span class="type">Work</span> - <span class="street-address">'. $address['street-address'] . '</span> - <span class="locality">' . $address['locality'] . '</span> - <span class="region">' . $address['region'] . '</span> - <span class="postal-code">' . $address['postal-code'] . '</span> - <div class="country-name">USA</div> - </div>'.PHP_EOL; - } else { - echo "<span class='adr'>{$r->postalAddress}</span>\n"; - } - } - - if (strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") === false) { - $href = "wtai://wp/mc;"; - $isIPhone = false; - } else { - $href = "tel:"; - $isIPhone = true; - } - if (isset($r->telephoneNumber)) { - - echo '<div class="tel workTel"> - <span class="type">Work</span> - <span class="value">'.$this->formatPhone($r->telephoneNumber).'</span> - </div>'.PHP_EOL; - } - - if (isset($r->unlSISLocalPhone)) { - echo '<div class="tel homeTel"> - <span class="type">Phone</span> - <span class="value">'.$this->formatPhone($r->unlSISLocalPhone).'</span> - </div>'.PHP_EOL; - } - - if ($displayEmail) { - if ($r->unlEmailAlias != 'president') { - $email = $r->unlEmailAlias.'@unl.edu'; - } else { - $email = $r->unlEmailAlias.'@nebraska.edu'; - } - echo "<span class='email'><a class='email' href='mailto:$email'>$email</a></span>\n"; - if ($this->trustedIP===true) echo "<span class='email delivery'>Delivery Address: {$r->mail}</span>\n"; - } - $linktext = '<img src="/ucomm/templatedependents/templatecss/images/mimetypes/text-vcard.gif" alt="vCard" /> <span class="caption">vCard</span>'.PHP_EOL; - echo $this->getVCardLink($r->uid, $linktext, null, 'Download V-Card for '.$r->givenName.' '.$r->sn); - echo '</div>'.PHP_EOL.'</div>'.PHP_EOL; - } - - public function renderAddress($address, $type, $class = null) - { - if (!isset($class)) { - $class = ''; - } - $addr = ' - <div class="adr '.$class.'"> - <span class="type">'.$type.'</span> - <span class="street-address">'.$address[0].'</span> - <span class="locality">'.$address[2].'</span> - <span class="region">'.$address[3].'</span> - <span class="postal-code">'.$address[4].'</span>'; - if (isset($address[5])) { - $addr .= '<div class="country-name">'.$address[5].'</div>'; - } - $addr .= '</div>'; - echo $addr; - } - - /** - * Takes in a street address of a staff or faculty member, a building - * code in a string with a link to the building in the virtual tour - * - * @param string $streetaddress Street Address of a staff or faculty member - * - * @return string - */ - private function replaceBuildingCode($streetaddress) - { - require_once 'UNL/Common/Building.php'; - $regex = "/([A-Za-z0-9].) ([A-Z0-9\&]{2,4})/" ; //& is for M&N Building - - if (preg_match($regex, $streetaddress, $matches)) { - $bldgs = new UNL_Common_Building(); - - if ($bldgs->buildingExists($matches[2])) { - - $replace = '${1} <a class="location mapurl" href="http://www1.unl.edu/tour/${2}">${2}</a>'; - return preg_replace($regex, $replace, $streetaddress); - } - } - - return $streetaddress; - } - - /** - * This function takes in a string representing a phone number - * and formats it to be rendered as a clickable calling link - * - * @param string $phone A telephone number - * @return string - */ - public function formatPhone($phone) - { - $link = '<a href="'; - if (strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") === false) { - $link .= "wtai://wp/mc;".str_replace(array("(", ")", "-"), "", $phone); - } else { - $link .= "tel:".$phone; - } - $link .= '">'.$phone.'</a>'; - return $link; - } - - /** - * This function takes in an array of address information and formats it - * - * @param array $addressArray Address information - * <code> - * $addressArray[0] = Address line 1 - * $addressArray[1] = Address line 2 - * $addressArray[2] = City - * $addressArray[3] = State - * $addressArray[4] = Zip - * $addressArray[5] = Country - * </code> - * - * @return string - */ - public function formatAddress($addressArray) - { - if (isset($addressArray[0])) { - $address = $addressArray[0]."<br />"; - if (isset($addressArray[1])) $address .= $addressArray[1]."<br />"; - $address .= $addressArray[2].", ".$addressArray[3]." ".$addressArray[4]; - if (isset($addressArray[5])) $address .= "<br />".$addressArray[4]; - } else { - $address = 'Unlisted'; - } - return $address; - } - - public function displayPageLinks($num_records, $start, $end) - { - //Display Page information - $page = (isset($_GET['p']))?$_GET['p']:0; - $next = $page + 1; - if ($page>=1) $prevLink = '<a class="previous" href="'.$this->uri.'?'.preg_replace('/[&]?p=\d/','',$_SERVER['QUERY_STRING']).'&p='.($page-1).'"><< </a>'; - else $prevLink = '<< '; - if ($end < $num_records) $nextLink = "<a class='next' href='".$this->uri."?".preg_replace("/[&]?p=\d/","",$_SERVER['QUERY_STRING'])."&p=$next'> >></a>"; - else $nextLink = ' >>'; - return '<div class="cNav">'.$prevLink.$nextLink.'</div>'; - } - - public function renderListRecord(UNL_Peoplefinder_Record $r) - { - if ($r->ou == 'org') { - $linktext = $r->cn; - } else { - $linktext = $r->sn . ', '. $r->givenName; - if (isset($r->eduPersonNickname)) { - $linktext .= ' "'.$r->eduPersonNickname.'"'; - } - } - - echo '<div class="fn">'.$this->getUIDLink($r->uid, $linktext, $this->uid_onclick).'</div>'.PHP_EOL; - if (isset($r->eduPersonPrimaryAffiliation)) echo '<div class="eppa">('.$r->eduPersonPrimaryAffiliation.')</div>'.PHP_EOL; - if (isset($r->unlHRPrimaryDepartment)) echo '<div class="organization-unit">'.$r->unlHRPrimaryDepartment.'</div>'.PHP_EOL; - if (isset($r->title)) echo '<div class="title">'.$r->title.'</div>'.PHP_EOL; - if (isset($r->telephoneNumber)) echo '<div class="tel">'.$this->formatPhone($r->telephoneNumber).'</div>'.PHP_EOL; - - echo $this->getUIDLink($r->uid, 'contact info', $this->uid_onclick, 'cInfo'); - if ($this->choose_uid) { - echo '<div class="pfchooser"><a href="#" onclick="return pfCatchUID(\''.$r->uid.'\');">Choose this person</a></div>'.PHP_EOL; - } - } - - public function renderSearchResults(array $records, $start=0, $num_rows=UNL_PF_DISPLAY_LIMIT) - { - if (($start+$num_rows)>count($records)) { - $end = count($records); - } else { - $end = $start+$num_rows; - } - if ($start > 0 || $end < count($records)) { - $navlinks = $this->displayPageLinks(count($records), $start, $end); - } else { - $navlinks = ''; - } - echo "<div class='result_head'>Results ".($start+1)." - $end out of ".count($records).':'.$navlinks.'</div>'.PHP_EOL; - echo '<ul>'; - for ($i = $start; $i<$end; $i++) { - $even_odd = ($i % 2) ? '' : 'alt'; - if ($records[$i]->ou == 'org') { - $class = 'org_Sresult'; - } else { - $class = 'ppl_Sresult'; - } - $class .= ' '.$records[$i]->eduPersonPrimaryAffiliation; - echo '<li class="'.$class.' '.$even_odd.'">'; - $this->renderListRecord($records[$i]); - echo '</li>'.PHP_EOL; - } - echo '</ul>'; - echo "<div class='result_head'>$navlinks</div>"; - } - - public function getUIDLink($uid, $linktext = null, $onclick = null, $class = null) - { - $uri = $this->uri.'?uid='.$uid; - if (isset($linktext)) { - $link = '<a href="'.$uri.'"'; - if (isset($onclick)) { - $link .= ' onclick="return '.$this->uid_onclick.'(\''.$uid.'\');"'; - } - if (isset($class)) { - $link .= ' class="'.$class.'"'; - } - $link .= '>'.$linktext.'</a>'; - return $link; - } else { - return $uri; - } - } - - /** - * Formats a major subject code into a text description. - * - * @param string $subject Subject code for the major eg: MSYM - * - * @return string - */ - public function formatMajor($subject) - { - - include_once 'Cache/Lite.php'; - $c = new Cache_Lite(); - if ($subject_xml = $c->get('catalog subjects')) { - - } 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'); - } - } - - $d = new DOMDocument(); - $d->loadXML($subject_xml); - if ($subject_el = $d->getElementById($subject)) { - return $subject_el->textContent; - } - - switch ($subject) { - case 'UNDL': - return 'Undeclared'; - case 'PBAC': - return 'Non-Degree Post-Baccalaureate'; - default: - return $subject; - } - } - - /** - * Format a three letter college abbreviation into the full college name. - * - * @param string $college College abbreviation = FPA - * - * @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]); - } - - return $college; - } - - public function getVCardLink($uid, $linktext = null,$onclick = null,$title = null) - { - - $uri = $this->uri.'vcards/'.$uid; - if (isset($linktext)) { - $link = '<a href="'.$uri.'"'; - if (isset($onclick)) { - $link .= ' onclick="return '.$onclick.'(\''.$uid.'\');"'; - } - if (isset($title)) { - $link .= ' title="'.$title.'"'; - } - $link .= ' class="vcf">'.$linktext.'</a>'; - return $link; - } else { - return $uri; - } - } - - - - public function renderError() - { - echo "<p>Please enter more information or <a href='".$_SERVER['PHP_SELF']."?adv=y' title='Click here to perform a detailed Peoplefinder search'>try a Detailed Search.</a></p>"; - } - - /** - * Displays the instructions for using peoplefinder. - * - * @param bool $adv Show advanced instructions or default instructions. - * - * @return void - */ - function displayInstructions($adv=false) - { - echo '<div style="padding-top:10px;width:270px;" id="instructions">'; - if ($adv) { - echo 'Enter in as much of the first and/or last name you know, ' . - 'you can also select a primary affiliation to refine your search.'; - } else { - echo 'Enter in as much of the name as you know, first and/or last '. - 'name in any order.<br /><br />Reverse telephone number lookup: '. - 'enter last three or more digits.'; - } - echo '</div>'; - } - - /** - * Display the standard search form. - * - * @return void - */ - function displayStandardForm() - { - include 'standardForm.php'; - } - - /** - * Display the advanced form. - * - * @return void - */ - function displayAdvancedForm() - { - include 'advancedForm.php'; - } -} - -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Renderer/JSON.php b/lib/php/UNL/Peoplefinder/Renderer/JSON.php index 773e333f85eb2a2640c5cfb68beb1dee6ce307e3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/Renderer/JSON.php +++ b/lib/php/UNL/Peoplefinder/Renderer/JSON.php @@ -1,37 +0,0 @@ -<?php -/** - * Peoplefinder JSON renderer - * - * 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_Renderer_JSON -{ - function __construct(array $options = null) - { - - } - - /** - * Renders a peoplefinder record object - * - * @param UNL_Peoplefinder_Record $r record to render - */ - public function renderRecord(UNL_Peoplefinder_Record $r) - { - echo json_encode($r); - } - - public function renderSearchResults(array $records, $start=0, $num_rows=UNL_PF_DISPLAY_LIMIT) - { - echo json_encode($records); - } -} - -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Renderer/Serialized.php b/lib/php/UNL/Peoplefinder/Renderer/Serialized.php index a5e0997a148af86f4e29047db0ac08e98fcda2cb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/Renderer/Serialized.php +++ b/lib/php/UNL/Peoplefinder/Renderer/Serialized.php @@ -1,37 +0,0 @@ -<?php -/** - * Peoplefinder serialized renderer - * - * 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_Renderer_Serialized -{ - function __construct(array $options = null) - { - - } - - /** - * Renders a peoplefinder record object - * - * @param UNL_Peoplefinder_Record $r record to render - */ - public function renderRecord(UNL_Peoplefinder_Record $r) - { - echo serialize($r); - } - - public function renderSearchResults(array $records, $start=0, $num_rows=UNL_PF_DISPLAY_LIMIT) - { - echo serialize($records); - } -} - -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Renderer/XML.php b/lib/php/UNL/Peoplefinder/Renderer/XML.php index 50bcf8fea8228eabd8505bb973ad08e390c36602..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/Renderer/XML.php +++ b/lib/php/UNL/Peoplefinder/Renderer/XML.php @@ -1,68 +0,0 @@ -<?php -class UNL_Peoplefinder_Renderer_XML -{ - - protected $trustedIP = false; - protected $displayStudentTelephone = false; - - protected $sent_headers = false; - - /** - * Sends the headers and XML preamble. - * - * @return void - */ - function sendHeaders() - { - if ($this->sent_headers) { - return; - } - header('Content-type: text/xml'); - echo '<?xml version="1.0" encoding="utf-8"?> -<unl xmlns="http://wdn.unl.edu/xml">'.PHP_EOL; - $this->sent_headers = true; - } - - /** - * Render an individual record - * - * @param UNL_Peoplefinder_Record $r - */ - public function renderRecord(UNL_Peoplefinder_Record $r) - { - $this->sendHeaders(); - echo '<person>'; - foreach (get_object_vars($r) as $key=>$val) { - $val = htmlspecialchars($val); - echo "<$key>{$val}</$key>\n"; - } - echo '</person>'.PHP_EOL; - } - - public function renderSearchResults(array $records, $start=0, $num_rows=UNL_PF_DISPLAY_LIMIT) - { - $this->sendHeaders(); - foreach ($records as $record) { - $this->renderRecord($record); - } - } - - public function renderError() - { - $this->sendHeaders(); - echo '<error>Please enter more information</error>'; - } - - function __destruct() - { - if ($this->sent_headers) { - $this->sendFooter(); - } - } - - function sendFooter() - { - echo '</unl>'; - } -} -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/Renderer/vCard.php b/lib/php/UNL/Peoplefinder/Renderer/vCard.php index 1afab90ce4c63ce971816df1d4076157d15b5e6e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/Renderer/vCard.php +++ b/lib/php/UNL/Peoplefinder/Renderer/vCard.php @@ -1,60 +0,0 @@ -<?php -/** - * Peoplefinder vcard renderer - * - * 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_Renderer_vCard -{ - - protected $displayStudentTelephone = false; - - public function renderRecord(UNL_Peoplefinder_Record $r) - { - header('Content-Type: text/x-vcard'); - header('Content-Disposition: attachment; filename="'.$r->sn.', '.$r->givenName.'.vcf"'); - //connect, taking in UID - echo "BEGIN:VCARD\n"; - echo "VERSION:3.0\n"; - echo "N:".$r->sn.";".$r->givenName.";;;\n"; - echo "FN:".$r->givenName." ".$r->sn."\n"; - if(isset($r->unlHRPrimaryDepartment)) echo "ORG:University of Nebraska-Lincoln;".$r->unlHRPrimaryDepartment."\n"; - if (isset($r->unlEmailAlias)) { - if (($r->eduPersonPrimaryAffiliation != 'student') && isset($r->unlEmailAlias)) echo "EMAIL;type=INTERNET;type=WORK;type=pref:".$r->unlEmailAlias."@unl.edu\n"; - } - if ($r->eduPersonPrimaryAffiliation != "student" || $this->displayStudentTelephone==true) echo "TEL;type=WORK;type=pref:".$r->telephoneNumber."\n"; - //echo "TEL;type=CELL:(402) 555-1111\n"; - if (isset($r->unlSISLocalPhone)) { - echo "TEL;type=HOME:{$r->unlSISLocalPhone}\n"; - } - if (isset($r->unlSISLocalAddr1)) { - echo "item1.ADR;type=WORK;type=pref:;;".$r->unlSISLocalAddr1; - if (isset($r->unlSISLocalAddr2)) echo "\\n".$r->unlSISLocalAddr2; - echo ";".$r->unlSISLocalCity.";".$r->unlSISLocalState.";".$r->unlSISLocalZip.";\n"; - echo "item1.X-ABLabel:local\n"; - } - if (isset($r->unlSISPermaddr1)) { - echo "item2.ADR;type=HOME;type=pref:;;".$r->unlSISPermAddr1; - if(isset($r->unlSISPermAddr2)) echo "\\n".$r->unlSISPermAddr2; - echo ";".@$r->unlSISPermCity.";".@$r->unlSISPermState.";".@$r->unlSISPermZip.";\n"; - echo "item2.X-ABLabel:permanent\n"; - } - //echo "item1.X-ABADR:us\n"; - //echo "item2.X-ABADR:us\n"; - //echo "URL:http://www.unl.edu/\n"; - //echo "LOGO;VALUE=uri:http://www.unl.edu/unlpub/2004sharedgraphics/smcolor_wordmark.gif"; - if (isset($r->title)) { - echo "item3.X-ABRELATEDNAMES;type=pref:".$r->title."\n"; - echo "item3.X-ABLabel:title\n"; - } - echo "END:VCARD\n"; - } -} -?> \ No newline at end of file diff --git a/lib/php/UNL/Peoplefinder/RendererInterface.php b/lib/php/UNL/Peoplefinder/RendererInterface.php index aa853202eae1515a865bdd9c470c23ff57b313af..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/php/UNL/Peoplefinder/RendererInterface.php +++ b/lib/php/UNL/Peoplefinder/RendererInterface.php @@ -1,10 +0,0 @@ -<?php -interface UNL_Peoplefinder_RendererInterface -{ - function renderRecord(UNL_Peoplefinder_Record $r); - function renderListRecord(UNL_Peoplefinder_Record $r); - function renderSearchResults(array $records, $start=0, $num_rows=UNL_PF_DISPLAY_LIMIT); - function renderError($message = null); - function displayInstructions(); -} -?> \ No newline at end of file diff --git a/lib/tests/UNL_LDAP/tests/UNL_LDAPTest.php b/lib/tests/UNL_LDAP/tests/UNL_LDAPTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5961299ca1c100f5df1178900a62ac404048c71f --- /dev/null +++ b/lib/tests/UNL_LDAP/tests/UNL_LDAPTest.php @@ -0,0 +1,124 @@ +<?php +/** + * Test the LDAP class + * + * PHP version 5 + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +ini_set('display_errors', true); +error_reporting(E_ALL); +// Call UNL_LDAPTest::main() if this source file is executed directly. +if (!defined('PHPUNIT_MAIN_METHOD')) { + define('PHPUNIT_MAIN_METHOD', 'UNL_LDAPTest::main'); +} + +require_once 'PHPUnit/Framework.php'; + +chdir(dirname(__FILE__).'/../'); + +require_once 'UNL/LDAP.php'; +require_once 'config.inc.php'; + +/** + * Test class for UNL_LDAP. + * + * $Id$ + * + * @category Default + * @package UNL_LDAP + * @author Brett Bieber <brett.bieber@gmail.com> + * @copyright 2009 Regents of the University of Nebraska + * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License + * @link http://pear.unl.edu/package/UNL_LDAP + */ +class UNL_LDAPTest extends PHPUnit_Framework_TestCase +{ + /** + * @var UNL_LDAP + * @access protected + */ + protected $object; + + /** + * Runs the test methods of this class. + * + * @access public + * @static + * @return void + */ + public static function main() + { + include_once 'PHPUnit/TextUI/TestRunner.php'; + + $suite = new PHPUnit_Framework_TestSuite('UNL_LDAPTest'); + $result = PHPUnit_TextUI_TestRunner::run($suite); + } + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + * + * @access protected + * @return void + */ + protected function setUp() + { + global $options; + $this->object = UNL_LDAP::getConnection($options); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() + { + } + + /** + * Just tests that you can get a connection to the server. + * + * @return void + */ + public function testGetConnection() + { + $this->assertEquals('UNL_LDAP', get_class($this->object)); + } + + /** + * Test get attribute function + * + * @return void + */ + public function testGetAttribute() + { + $this->assertEquals(array('count'=>1, 'Bieber'), $this->object->getAttribute('bbieber2', 'sn')); + } + + /** + * test getFirstAttribute + * + * @return void + */ + public function testGetFirstAttribute() + { + $this->assertEquals('Bieber', $this->object->getFirstAttribute('bbieber2', 'sn')); + } +} + +// Call UNL_LDAPTest::main() if this source file is executed directly. +if (PHPUNIT_MAIN_METHOD == 'UNL_LDAPTest::main') { + UNL_LDAPTest::main(); +} +?> diff --git a/lib/tests/UNL_Peoplefinder/pear.unl.edu/PeoplefinderTest.php b/lib/tests/UNL_Peoplefinder/pear.unl.edu/PeoplefinderTest.php index 11f813054fdb074f1883e73f99244c5c5276ee0b..80e0317edcf06ab36bee37598e1eb2f3d95e992d 100644 --- a/lib/tests/UNL_Peoplefinder/pear.unl.edu/PeoplefinderTest.php +++ b/lib/tests/UNL_Peoplefinder/pear.unl.edu/PeoplefinderTest.php @@ -117,9 +117,9 @@ class PeoplefinderTest extends PHPUnit_Framework_TestCase { $p = new UNL_Peoplefinder(); $r = $p->getLikeMatches('bieber'); $this->assertEquals(7, sizeof($r)); - $r = $p->getLikeMatches('bieber', array($r[0]), 'Testing exclusion of records did not work.'); + $r = $p->getLikeMatches('bieber', null, array($r[0]), 'Testing exclusion of records did not work.'); $this->assertEquals(5, sizeof($r)); - $r = $p->getLikeMatches('bieber', $r, 'Testing exclusion of records did not work.'); + $r = $p->getLikeMatches('bieber', null, $r, 'Testing exclusion of records did not work.'); $this->assertEquals(1, sizeof($r)); } diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/README b/lib/www/UNL_Peoplefinder/pear.unl.edu/README index 93776137a74fa601f1840c2adf73541ec366b727..e997733c1f997117932c91c1917c8444448abc9e 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/README +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/README @@ -11,7 +11,6 @@ username and password. Then browse to http://localhost/peoplefinder/ and try it TODO: Move LDAP connection into a singleton class UNL_LDAP -Change renderers to work like Savant/Zend_View Change UNL_Peoplefinder_Record to use overloading with __get/__set for all attributes LICENSE diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/advancedForm.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/advancedForm.php index c599c875a024c60dd7cbb0cbb091bae354037a6a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/advancedForm.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/advancedForm.php @@ -1,19 +0,0 @@ -<form method="get" id="form1" action="<?php echo htmlentities(str_replace('index.php', '', $_SERVER['PHP_SELF']), ENT_QUOTES); ?>"> - <label for="sn">Last Name: </label> - <input type="text" name="sn" value="<?php echo htmlentities(@$_GET['sn'], ENT_QUOTES); ?>" id="sn" /> - <br /> - <label for="cn">First Name: </label> - <input type="text" name="cn" value="<?php echo htmlentities(@$_GET['cn'], ENT_QUOTES); ?>" id="cn" /> - <?php if (isset($_GET['chooser'])) { - echo '<input type="hidden" name="chooser" value="true" />'; - } ?> - <input type="hidden" name="adv" value="y" /> - <br /> - <label for="eppa">Affiliation: </label> - <select id="eppa" name="eppa"> - <option value="any" <?php if(@$_GET['eppa'] == 'any') echo "selected='selected'"; ?>>Any</option> - <option value="fs" <?php if(@$_GET['eppa'] == 'fs') echo "selected='selected'"; ?>>Faculty/Staff</option> - <option value="stu" <?php if(@$_GET['eppa'] == 'stu') echo "selected='selected'"; ?>>Student</option> - </select> - <input style="margin-bottom:-7px;" name="submitbutton" type="image" src="/ucomm/templatedependents/templatecss/images/go.gif" value="Submit" id="submitbutton" /> -</form> \ No newline at end of file diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/config-sample.inc.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/config-sample.inc.php index 860e8f7c0c6b678c5765f7d3d55860549eeebe37..35ef5fef4f91273d49b3127542ecaceb5a93d82d 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/config-sample.inc.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/config-sample.inc.php @@ -1,7 +1,17 @@ <?php ini_set('display_errors', true); error_reporting(E_ALL|E_STRICT); -set_include_path(dirname(__FILE__).'/../src/'.PATH_SEPARATOR.get_include_path()); + +function autoload($class) +{ + $class = str_replace('_', '/', $class); + include $class . '.php'; +} + +spl_autoload_register("autoload"); + + +set_include_path(dirname(dirname(__FILE__)).'/src/'.PATH_SEPARATOR.dirname(dirname(__FILE__)).'/lib/php'); require_once 'UNL/Autoload.php'; define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']); @@ -9,10 +19,16 @@ define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']); UNL_Peoplefinder_Driver_LDAP::$bindDN = 'uid=giggidy,ou=service,dc=unl,dc=edu'; UNL_Peoplefinder_Driver_LDAP::$bindPW = 'flibbertygibberty'; -define('UNL_PEOPLEFINDER_URI', 'http://peoplefinder.unl.edu/'); +UNL_Peoplefinder::$url = 'http://peoplefinder.unl.edu/'; set_time_limit(5); // If you have LDAP access credentials, best to use this driver $driver = new UNL_Peoplefinder_Driver_LDAP(); // Otherwise, use the webservice driver -$driver = new UNL_Peoplefinder_Driver_WebService(); +$driver = new UNL_Peoplefinder_Driver_WebService(array('service_url'=>'http://ucommbieber.unl.edu/workspace/peoplefinder/www/service.php')); + +/* +//database connection info +UNL_Officefinder::$db_user = ''; +UNL_Officefinder::$db_pass = ''; +*/ \ No newline at end of file diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/config.inc.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/config.inc.php index 0d46c1a92e62c8f7e4ba31a4c3a26024424c2b48..eccbac4c13d586587edd38162e45acda2dba8195 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/config.inc.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/config.inc.php @@ -1,7 +1,17 @@ <?php ini_set('display_errors', true); error_reporting(E_ALL); -set_include_path(dirname(__FILE__).'/../src/'.PATH_SEPARATOR.get_include_path()); + +function autoload($class) +{ + $class = str_replace('_', '/', $class); + include $class . '.php'; +} + +spl_autoload_register("autoload"); + + +set_include_path(dirname(dirname(__FILE__)).'/src/'.PATH_SEPARATOR.dirname(dirname(__FILE__)).'/lib/php'); require_once 'UNL/Autoload.php'; define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']); @@ -9,7 +19,11 @@ define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']); UNL_Peoplefinder_Driver_LDAP::$bindDN = 'uid=unlwebsearch,ou=service,dc=unl,dc=edu'; UNL_Peoplefinder_Driver_LDAP::$bindPW = 'gagfawki'; -define('UNL_PEOPLEFINDER_URI', 'http://ucommbieber.unl.edu/workspace/peoplefinder/www/'); -set_time_limit(5); +UNL_Peoplefinder::$url = 'http://ucommbieber.unl.edu/workspace/peoplefinder/www/'; + +UNL_Officefinder::$admins = array('bbieber2'); + +set_time_limit(0); + //$driver = new UNL_Peoplefinder_Driver_WebService(); -$driver = new UNL_Peoplefinder_Driver_LDAP(); \ No newline at end of file +$driver = new UNL_Peoplefinder_Driver_LDAP(); diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formFilterBG.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formFilterBG.png new file mode 100644 index 0000000000000000000000000000000000000000..eb67c28fdde6bd7ca29429bb5aac8fb1d01b90b2 Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formFilterBG.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchBG.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchBG.png new file mode 100644 index 0000000000000000000000000000000000000000..84526c9ec3d7174bf41c5c11669ae563393e0211 Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchBG.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchEnds.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchEnds.png new file mode 100644 index 0000000000000000000000000000000000000000..fc6ae61b3331814e3b1aec5edf6ec3ba86dcb4ef Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/formSearchEnds.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/iconContactSprite.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/iconContactSprite.png new file mode 100644 index 0000000000000000000000000000000000000000..c6118ce2723aafeb75651c982ec9ec5f161b9b8d Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/iconContactSprite.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/selectedBG.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/selectedBG.png new file mode 100644 index 0000000000000000000000000000000000000000..abd62f37a85332d03e01e916875bceba290c5caf Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/images/selectedBG.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/peoplefinder_default.css b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/peoplefinder_default.css new file mode 100644 index 0000000000000000000000000000000000000000..fe3eda0b8bc3ffaf3e2d7cf178224b86119ce29b --- /dev/null +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/peoplefinder_default.css @@ -0,0 +1,288 @@ +/* +*************************************************** + + Result List Listings + +*************************************************** +*/ +#maincontent #results {min-height: 300px;} +#maincontent ul.pfResult { + padding:0px; + list-style:none; + border-bottom: 1px solid #e6e6e6; + border-top: 1px solid #d0cece; + margin-top:20px; +} +#maincontent ul.pfResult li { + border-bottom: 1px solid #d0cece; + border-top: 1px solid #e6e6e6; + width:100%; + padding: 5px 0px; + display:block; +} +#maincontent ul.pfResult li div.overflow { + min-height:47px; + padding: 7px 5px; + cursor:pointer; +} +#maincontent ul.pfResult li.selected div.overflow {opacity:0.4;filter:alpha(opacity=40);} +#maincontent ul.pfResult li:hover, #maincontent ul.pfResult li.selected { + background:#ecf4f9; +} +#maincontent ul.pfResult li.selected .vcard {display:none;} +.eppa, .organization-unit, .tel, .type {display:none;} +#maincontent ul.pfResult .tel {display:block;} + +.planetred_profile, .recordDetails {float:left;} +.loading { + background:url('images/loading.gif') no-repeat top left; + height:40px; + width:40px; + float:left; + position:absolute; + right:250px; + display:none; +} +.recordDetails { + margin-left:20px; +} +.fn a, .fn { + font-size:18px; + font-weight:bold; + color:#464545 !important; + max-width:530px; + max-height:35px; + min-height:18px; + overflow:hidden; +} +.departments .fn, .departments .fn a {height:42px;max-height:42px;line-height:20px;} +.cInfo {float:right;} + +#maincontent .results {margin-top:15px;} +#maincontent .likeResults ul.pfResult {margin-top:0px;} + +#maincontent .result_head {color:#989898;font-size:10px;} +/* Headings */ + + +#maincontent .results h2, #maincontent .likeResults h3, #maincontent #orgChart h2 { + font-variant:small-caps; + font-weight:bold; +} +#maincontent .results h2, #maincontent #orgChart h2 {border-bottom:2px dotted #E6E6E6;padding-bottom:0;} + +#maincontent .likeResults h3 { + font-size:1em; +} +#maincontent #pfShowRecord .wdn_tabs, #maincontent #pfShowRecord .wdn_tabs_content {display:none;} + +/* +*************************************************** + + Individual Peoplefinder Records + +*************************************************** +*/ +.vcard { + background:#fff; + border:1px solid #ccd2d5; + border-radius:5px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + padding:15px; + min-height:150px; + position:relative; + width:425px; + z-index:9; + margin:0 auto; +} +.vcard > a.email { + +} +.vcard .eppa, .vcard .epa, .vcard .organization-unit, .vcard .tel, .vcf, .title {display:block;} +.vcard a.planetred_profile { + float:left; + margin-right:15px; + min-width:114px; +} +.vcard .eppa, .vcard .epa {font-style:italic;font-size:0.8em;} +.vcardInfo {margin-left:129px;} +.vcard .adr, .departmentInfo .adr { + border-left:2px solid #b7b7b7; + padding-left:5px; + margin:5px 0; +} +.vcard .tel, .vcard span.email, .vcard span.url, .departmentInfo .tel, .departmentInfo span.email, .departmentInfo span.url { + background:url('images/iconContactSprite.png') no-repeat; + padding-left:25px; + height:20px; +} +.vcard span.email, .vcard span.url, .departmentInfo span.email, .departmentInfo span.url { + background-position:0 -21px; + display:block; + margin-top:5px; + margin-bottom:3px; +} +.vcard span.url, .departmentInfo span.url { + background-position:0 -42px; +} +a.email {background:none;} +a.text-vcard{padding-left:24px;padding-right:0;background-position:left -2px;margin:121px 0 0 -122px;float:left;} +a.img-qrcode{padding-left:24px;padding-right:0;background: url(images/qrcode.png) no-repeat 0 0;margin:141px 0 0 -122px;float:left;} + +/* +*************************************************** + + Search form + +*************************************************** +*/ +.directorySearch { + width:940px; + background:url('images/formSearchBG.png') repeat-x top; + margin:15px 0 10px 0; +} +.directorySearch legend {display:none;} +#maincontent form.directorySearch ol{ + list-style:none; + display:block; + margin:0px; + background:url('images/formSearchEnds.png') no-repeat 0 -58px; + position:relative; +} +.directorySearch ol li:first-child{ + background:url('images/formSearchEnds.png') no-repeat top right; + height:46px; + padding:0px; + margin-left:-13px; + margin-bottom:11px; +} +.directorySearch > fieldset > ol > li > label { + position:absolute; + top:-11px; + left:23px; + font-size:1.5em; + color:#5c5c5c; + cursor:text; + background:#fff; + padding:5px; +} +.directorySearch > fieldset > ol > li > label.sn{ + left:253px; +} +.directorySearch ol li:first-child input[type=text] { + width:440px; + height:31px; + border:1px solid #8a7c47; + font-size:1.5em; + color:#5c5c5c; + padding:5px 0 0 8px; + margin-top:10px; +} +.directorySearch ol li:first-child input.n[type=text] { + width:210px; + margin-right:10px; +} +.directorySearch ol li:first-child input.s[type=text]{ + margin-right:0; +} + +.directorySearch ol li:first-child input[type=image] { + margin-bottom:-7px; + padding-left:5px; +} +#maincontent #advancedSearch { + background:#8a7c47; + color:#fff; + font-weight:bold; + font-size:0.8em; + padding:5px; + border-radius:3px; + -moz-border-radius:3px; + -webkit-border-radius:3px; + line-height:auto; + text-shadow:1px 1px 3px #888888; + border:1px solid #d7c47f; +} +#maincontent #advancedSearch:focus, #maincontent #advancedSearch:hover{color:#fff !important;border-color:#c0af70;} +#maincontent #advancedSearch:active{text-shadow:none;} +#maincontent #searchNotice { + display:none; + border-top:1px solid; + border-bottom:1px solid; + border-color:#d7d88d; + background:#FEFFCE; + padding:5px 15px; + color:#5d2401; + font-size:0.9em; +} +#maincontent #searchNotice span { + font-weight:bold; + padding:2px; + color:#000; + background:#e6e4b1; +} +#directoryHelp{ + background:url('/wdn/templates_3.0/css/content/images/notice/information.png') no-repeat 0 0; + position:absolute; + right:0; + width:80px; + height:65px; + top:0; + text-indent:-99999px; + +} +/* +*************************************************** + + Intro Page + +*************************************************** +*/ +#maincontent .intro, #maincontent .intro{ + background-image:-webkit-gradient( + linear, + left bottom, + left top, + color-stop(0.10, rgba(255,255,255, .3)), + color-stop(1, rgba(237,237,237, .8)) +); +background-image:-moz-linear-gradient( + center bottom, + rgba(255,255,255, .3) 10%, + rgba(237,237,237, .8) 100% +); +padding:10px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; +} +#maincontent .right .intro {opacity:0.3;filter:alpha(opacity=30);zoom:1;} +.intro img.profile_pic{float:left;} +h6.recordDetails {margin-top:15px;} +h6.recordDetails span { + font-size:3.6em; + font-weith:bold; + display:block; + margin-top:-6px; +} +.intro_support { + height:150px; + padding:25px 200px 0 0; +} +#maincontent .left .intro_support { + background:url('images/samplePeople.png') no-repeat bottom right; + padding-top:10px; +} +#maincontent h5.coming { + font-size:2.5em; + background:url('images/comingSoon.png') 0 0 no-repeat; + display:block; + text-indent:-999999px; + position:absolute; + top:100px; + right:108px; + width:243px; + height:124px; + opacity:0.8; +} \ No newline at end of file diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/css/small_devices.css b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/small_devices.css new file mode 100644 index 0000000000000000000000000000000000000000..dc1cf82a06046c04b190322f0d665b3e3e85bc23 --- /dev/null +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/css/small_devices.css @@ -0,0 +1,215 @@ +@CHARSET "UTF-8"; +/* +*************************************************** + + Search form + +*************************************************** +*/ +.directorySearch { + width:100%; + margin:0px 0 10px 0; + background:#d7c47f; + background-image:-webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.53, rgb(235,222,170)), + color-stop(0.88, rgb(215,196,127)) + ); + -webkit-border-radius:3px; + +} +.directorySearch legend {display:none;} +#maincontent form.directorySearch ol{ + list-style:none; + display:block; + margin:0px; + position:relative; +} +.directorySearch ol li:first-child{ + height:46px; + padding:0px; + margin-left:-13px; + margin-bottom:0px; +} +.directorySearch label { + display:block; + padding-top:5px; + color:#69581a; + font-weight:bold; + font-size:1.0em; +} +.advanced label { + display:inline-block; +} +.directorySearch input[type=text]{ + width:80%; + border:1px solid #d7c47f; +} +.directorySearch ol li:first-child input.n[type=text] { + width:53%; + margin-right:10px; +} +.directorySearch ol li:first-child input.s[type=text]{ + margin-right:0; +} +.directorySearch input[type=image]{ + width:20px; +} +#maincontent #advancedSearch { + background:#d7c47f; + color:#fff; + font-weight:bold; + font-size:0.8em; + padding:5px; + border-radius:3px; + -moz-border-radius:3px; + -webkit-border-radius:3px; + line-height:auto; + text-shadow:1px 1px 3px #888888; + border:1px solid #d7c47f; +} +#maincontent #advancedSearch:focus, #maincontent #advancedSearch:hover{color:#fff !important;border-color:#c0af70;} +#maincontent #advancedSearch:active{text-shadow:none;} +/* +*************************************************** + + Intro Page + +*************************************************** +*/ +#filters{display:none;} +#maincontent .two_col {width:46%;} +#maincontent .three_col{width:72%;} +#maincontent h6.recordDetails { + font-size:1.6em; + margin-left:0 !important; +} + +/* +*************************************************** + + Results List + +*************************************************** +*/ +#results{width:320px;} +/* +*************************************************** + + Result List Listings + +*************************************************** +*/ +#maincontent #results {min-height: 300px;} +#maincontent ul.pfResult { + padding:0px; + list-style:none; + border-bottom: 1px solid #e6e6e6; + border-top: 1px solid #d0cece; + margin-top:20px; +} +#maincontent ul.pfResult li { + border-bottom: 1px solid #d0cece; + border-top: 1px solid #e6e6e6; + width:100%; + padding: 5px 0px; + display:block; +} +#maincontent ul.pfResult li div.overflow { + min-height:45px; + padding: 7px 5px; + cursor:pointer; +} +#maincontent ul.pfResult li.selected div.overflow {opacity:0.4;filter:alpha(opacity=40);} +#maincontent ul.pfResult li:hover, #maincontent ul.pfResult li.selected { + background:#ecf4f9; +} +#maincontent ul.pfResult li.selected .vcard {display:none;} +.eppa, .organization-unit, .tel, .type {display:none;} +#maincontent ul.pfResult .tel {display:block;} +a.cInfo { + display:none; +} + +.planetred_profile, .recordDetails {float:left;} +.recordDetails { + margin-left:20px; +} +.fn a, .fn { + font-size:18px; + font-weight:bold; + color:#464545 !important; + max-width:530px; + max-height:35px; + min-height:20px; + overflow:hidden; +} +.departments .fn, .departments .fn a {height:42px;max-height:42px;line-height:20px;} +.cInfo {float:right;} + +#maincontent .results {margin-top:15px;} +#maincontent .likeResults ul.pfResult {margin-top:0px;} + +#maincontent .result_head {color:#989898;font-size:10px;} +/* Headings */ + + +#maincontent .results h2, #maincontent .likeResults h3, #maincontent #orgChart h2 { + font-variant:small-caps; + font-weight:bold; +} +#maincontent .results h2, #maincontent #orgChart h2 {border-bottom:2px dotted #E6E6E6;padding-bottom:0;} + +#maincontent .likeResults h3 { + font-size:1em; +} +#maincontent #pfShowRecord .wdn_tabs, #maincontent #pfShowRecord .wdn_tabs_content {display:none;} +/* +*************************************************** + + Individual Peoplefinder Records + +*************************************************** +*/ +.vcard { + padding:15px; + min-height:130px; + position:relative; + z-index:9; + margin:0 auto; +} +.vcard > a.email { + +} +.vcard .eppa, .vcard .epa, .vcard .organization-unit, .vcard .tel, .vcf, .title {display:block;} +.vcard a.planetred_profile { + margin-right:15px; + min-width:114px; + display:block; + float:none; +} +.vcard .eppa, .vcard .epa {font-style:italic;font-size:0.8em;} +.vcard .adr, .departmentInfo .adr { + border-left:2px solid #b7b7b7; + padding-left:5px; + margin:5px 0; +} +.vcard .tel, .vcard span.email, .vcard span.url, .departmentInfo .tel, .departmentInfo span.email, .departmentInfo span.url { + background:url('images/iconContactSprite.png') no-repeat; + padding-left:25px; + height:20px; +} +.vcard span.email, .vcard span.url, .departmentInfo span.email, .departmentInfo span.url { + background-position:0 -21px; + display:block; + margin-top:5px; + margin-bottom:3px; +} +.vcard span.url, .departmentInfo span.url { + background-position:0 -42px; +} +a.email {background:none;} +a.text-vcard{padding-left:24px;padding-right:0;background-position:left -2px;margin:0;display:block;} +a.img-qrcode{padding-left:24px;padding-right:0;background: url(images/qrcode.png) no-repeat 0 0;margin:141px 0 0 -122px;float:left;} diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/departments/index.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/departments/index.php index 9370b293981ef05a08275e1cdb1b2571b1ce0461..00139b2007fa7fa4ba13cd1d528755065fbb3dc1 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/departments/index.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/departments/index.php @@ -1,89 +1,44 @@ <?php -require_once '../config.inc.php'; +require_once dirname(__FILE__).'/../config.inc.php'; -UNL_Templates::$options['version'] = 3; -$page = UNL_Templates::factory('Document'); -$page->doctitle = '<title>UNL | Officefinder</title>'; -$page->titlegraphic = '<h1>Officefinder</h1>'; -$page->addStylesheet('../peoplefinder_default.css'); -$page->head .= <<<META -<meta name="description" content="UNL Officefinder is the searchable department directory for the University. Information obtained from this directory may not be used to provide addresses for mailings to students, faculty or staff. Any solicitation of business, information, contributions or other response from individuals listed in this publication by mail, telephone or other means is forbidden." /> -<meta name="keywords" content="university of nebraska-lincoln student faculty staff directory vcard" /> -<meta name="author" content="Brett Bieber, UNL Office of University Communications" /> -<meta name="viewport" content="width = 320" /> -<link media="only screen and (max-device-width: 480px)" href="../small_devices.css" type="text/css" rel="stylesheet" /> -META; - -if(isset($_GET['q'])) { - $page->head .= '<meta name="robots" content="NOINDEX, NOFOLLOW" />'; +if (isset($_COOKIE['unl_sso'])) { + // The user was logged in before, might as well get the CAS auth info. + UNL_Officefinder::getUser(true); } -$q = ''; -if (!empty($_GET['q'])) { - $q = $_GET['q']; - $departments = new UNL_Peoplefinder_Department_Search($q); -} -if (!empty($_GET['d'])) { - $q = $_GET['d']; - $department = new UNL_Peoplefinder_Department($q); - $q = htmlentities($q, ENT_QUOTES); -} -$page->maincontentarea = <<<FORM -<p>Search for UNL departments:</p> -<form method="get" action="?"> - <div> - <label for="q">Search: </label> - <input style="width:18em;" type="text" value="$q" id="q" name="q" /> - <input style="margin-bottom:-7px;" name="submitbutton" type="image" src="/ucomm/templatedependents/templatecss/images/go.gif" value="Submit" id="submitbutton" /> - </div> -</form> +$options = $_GET; +$options['driver'] = $driver; +$peoplefinder = new UNL_Officefinder($options); -FORM; -if (isset($department)) { - if (count($department)) { - $renderer_options = array('uri'=>UNL_PEOPLEFINDER_URI); - $renderer = new UNL_Peoplefinder_Renderer_HTML($renderer_options); - $page->maincontentarea .= count($department).' results.'; - $page->maincontentarea .= '<h2>'.htmlentities($department->name).'</h2>'; - if (isset($department->building)) { - $bldgs = new UNL_Common_Building(); - if ($bldgs->buildingExists($department->building)) { - $sd = new UNL_Geography_SpatialData_Campus(); - $department->building = '<a href="'.$sd->getMapUrl($department->building).'">'.htmlentities($bldgs->codes[$department->building]).'</a>'; - } - } - $page->maincontentarea .= "<p>{$department->room} <span class='location'>{$department->building}</span><br />{$department->city}, {$department->state} {$department->postal_code}</p>"; - if ($department->hasChildren()) { - $page->maincontentarea .= 'Sub-departments:<ul>'; - foreach ($department->getChildren() as $child) { - $page->maincontentarea .= '<li><a href="'.UNL_PEOPLEFINDER_URI.'departments/?d='.urlencode($child).'">'.htmlentities($child).'</a></li>'; - } - $page->maincontentarea .= '</ul>'; - } - $page->maincontentarea .= '<ul class="department">'; - ob_start(); - foreach ($department as $employee) { - echo '<li class="ppl_Sresult">'; - $renderer->renderListRecord($employee); - echo '</li>'; - } - $page->maincontentarea .= ob_get_clean().'</ul>'; - } else { - $page->maincontentarea .= 'No results could be found.'; - } -} -if (isset($departments)) { - if (count($departments)) { - $page->maincontentarea .= '<h2>Search results for '.$q.'</h2><ul class="departments">'; - foreach($departments as $department) { - $page->maincontentarea .= '<li class="ppl_Sresult"><a href="'.UNL_PEOPLEFINDER_URI.'departments/?d='.urlencode($department->name).'">'.$department->name.'</a></li>'; - } - $page->maincontentarea .= '</ul>'; - } else { - $page->maincontentarea .= 'No results could be found.'; - } +Savvy_ClassToTemplateMapper::$classname_replacement = 'UNL_'; +$savvy = new Savvy(); +$savvy->setTemplatePath(dirname(dirname(__FILE__)).'/templates/html'); + +switch($peoplefinder->options['format']) { + case 'json': + case 'php': + case 'vcard': + case 'xml': + $savvy->addTemplatePath(dirname(dirname(__FILE__)).'/templates/'.$peoplefinder->options['format']); + break; + case 'editing': + $savvy->setEscape('htmlentities'); + $savvy->addTemplatePath(dirname(dirname(__FILE__)).'/templates/'.$peoplefinder->options['format']); + break; + case 'hcard': + case 'partial': + Savvy_ClassToTemplateMapper::$output_template['UNL_Officefinder'] = 'Peoplefinder-partial'; + // intentional no break + default: + $savvy->setEscape('htmlentities'); + break; + case array('editing', 'partial'): + case array('partial', 'editing'): + $savvy->setEscape('htmlentities'); + $savvy->addTemplatePath(dirname(dirname(__FILE__)).'/templates/editing'); + Savvy_ClassToTemplateMapper::$output_template['UNL_Officefinder'] = 'Peoplefinder-partial'; + break; } -echo $page; -?> \ No newline at end of file +echo $savvy->render($peoplefinder); \ No newline at end of file diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/images/formSearch.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/images/formSearch.png new file mode 100644 index 0000000000000000000000000000000000000000..45916676cd4bde1085f19a13f33291d14975622d Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/images/formSearch.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/images/organization.png b/lib/www/UNL_Peoplefinder/pear.unl.edu/images/organization.png new file mode 100644 index 0000000000000000000000000000000000000000..31d0f695ec8d31416de1cf97133ca3d478f89b1b Binary files /dev/null and b/lib/www/UNL_Peoplefinder/pear.unl.edu/images/organization.png differ diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/index.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/index.php index b4ab8b692589f3351ffa5f23ae17cafe121162f8..024540c52cff3b8712e3d5765e497600947d6c22 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/index.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/index.php @@ -1,141 +1,38 @@ <?php require_once 'config.inc.php'; -session_start(); -session_cache_expire(5); +$options = $_GET; +$options['driver'] = $driver; +$peoplefinder = new UNL_Peoplefinder($options); -$renderer_options = array('uri'=>UNL_PEOPLEFINDER_URI); -$peepObj = new UNL_Peoplefinder($driver); -$renderer = new UNL_Peoplefinder_Renderer_HTML($renderer_options); +Savvy_ClassToTemplateMapper::$classname_replacement = 'UNL_'; +$savvy = new Savvy(); +$savvy->setTemplatePath(dirname(__FILE__).'/templates/html'); -$myself = htmlentities(str_replace('index.php', '', $_SERVER['PHP_SELF']), ENT_QUOTES); -UNL_Templates::$options['version'] = 3; -$page = UNL_Templates::factory('Document'); -$page->doctitle = '<title>UNL | Peoplefinder</title>'; - -$page->head .= ' -<meta name="description" content="UNL Peoplefinder is the Faculty, Staff and Student online directory for the University. Information obtained from this directory may not be used to provide addresses for mailings to students, faculty or staff. Any solicitation of business, information, contributions or other response from individuals listed in this publication by mail, telephone or other means is forbidden." /> -<meta name="keywords" content="university of nebraska-lincoln student faculty staff directory vcard" /> -<meta name="author" content="Brett Bieber, UNL Office of University Communications" /> -<meta name="viewport" content="width = 320" /> -<link rel="stylesheet" type="text/css" media="screen" href="peoplefinder_default.css" /> -<link media="only screen and (max-device-width: 480px)" href="small_devices.css" type="text/css" rel="stylesheet" /> -<script type="text/javascript" src="'.UNL_PEOPLEFINDER_URI.'peoplefinder.js"></script> -'; - -if (isset($_GET['q']) - || isset($_GET['uid']) - || isset($_GET['cn']) - || isset($_GET['sn'])) { - $page->head .= '<meta name="robots" content="NOINDEX, NOFOLLOW" />'; -} - -$page->breadcrumbs = ' -<ul> - <li><a href="http://www.unl.edu/" title="University of Nebraska�Lincoln">UNL</a></li> - <li>Peoplefinder</li> -</ul>'; - -$page->titlegraphic = '<h1>UNL Peoplefinder</h1>'; - -ob_start(); - -if (isset($_GET['uid'])) { - try { - $renderer->renderRecord($peepObj->getUID($_GET['uid'])); - } catch (Exception $e) { - header('HTTP/1.0 404 Not Found'); - echo '<p><br />Sorry, no one with that name could be found!</p>'; - } -} else { - // Display form - (@$_GET['adv'] == 'y')?$renderer->displayAdvancedForm():$renderer->displayStandardForm(); - if (isset($_GET['p'])) { - // Display the next page - if ($_SESSION['lastResultCount'] > 0) { - // Old results have been set. - $renderer->renderSearchResults($_SESSION['lastResult'], $_GET['p']*$_SESSION['lastResultDisplayed']); - } else { - echo 'Your session has expired, please search again.'; +switch($peoplefinder->options['format']) { + case 'vcard': + header('Content-Type: text/x-vcard'); + if ($peoplefinder->output[0] instanceof UNL_Peoplefinder_Record) { + header('Content-Disposition: attachment; filename="'.$peoplefinder->output[0]->sn.', '.$peoplefinder->output[0]->givenName.'.vcf"'); } - } else { - if (isset($_GET['q']) && !empty($_GET['q'])) { - // Basic query, build filter and display results - if (strlen($_GET['q']) > 3) { - if (is_numeric(str_replace(array('-', '(', ')'), - array('', '', ''), - $_GET['q']))) { - $records = $peepObj->getPhoneMatches($_GET['q']); - $renderer->renderSearchResults($records); - } else { - $records = $peepObj->getExactMatches($_GET['q']); - if (count($records)) { - echo '<div class="cMatch">Exact matches:'; - if (count($records) >= UNL_Peoplefinder::$resultLimit) { - echo "<p>Your search could only return a subset of the results. "; - if (@$_GET['adv'] != 'y') echo "Would you like to <a href='".$renderer->uri."?adv=y' title='Click here to perform a detailed Peoplefinder search'>try a Detailed Search?</a>\n"; - else echo 'Try refining your search.'; - echo '</p>'; - } - echo '</div>'; - $renderer->renderSearchResults($records); - } else { - echo '<p>Sorry, I couldn\'t find anyone matching '.htmlentities($_GET['q']).'.</p>'; - } - if (count($records) < UNL_Peoplefinder::$displayResultLimit) { - // More room to display LIKE results - UNL_Peoplefinder::$displayResultLimit = UNL_Peoplefinder::$displayResultLimit - count($records); - $records = $peepObj->getLikeMatches($_GET['q'], $records); - if (count($records) > 0) { - echo '<div class="cMatch">Possible matches:'; - if (count($records) >= UNL_Peoplefinder::$resultLimit) { - echo "<p>Your search could only return a subset of the results. "; - if (@$_GET['adv'] != 'y') echo "Would you like to <a href='".$renderer->uri."?adv=y' title='Click here to perform a detailed Peoplefinder search'>try a Detailed Search?</a>\n"; - else echo 'Try refining your search.'; - echo '</p>'; - } - echo '</div>'; - $renderer->renderSearchResults($records); - } - } - } - } else { - echo "<p>Please enter more information or <a href='".$_SERVER['PHP_SELF']."?adv=y' title='Click here to perform a detailed Peoplefinder search'>try a Detailed Search.</a></p>"; - } - } elseif (isset($_GET['sn']) || isset($_GET['cn'])) { - // Advanced search - $records = $peepObj->getAdvancedSearchMatches($_GET['sn'],$_GET['cn'],$_GET['eppa']); - $renderer->renderSearchResults($records); - } - if (isset($records)) { - // Prepare for sleep - $_SESSION['lastResult'] = $records; - $_SESSION['lastResultCount'] = count($records); - $_SESSION['lastResultDisplayed'] = UNL_Peoplefinder::$displayResultLimit; - } - } -} - -//show instructions if no results are showing -if (!isset($_GET['uid']) && !isset($records)) { - echo '<div class="two_col left" id="results">'; - $renderer->displayInstructions((@$_GET['adv'] == 'y')?true:false); - echo '</div> - <div class="two_col right" id="pfShowRecord"></div>'; -} - -if (!isset($_GET['uid'])) { ?> - <div class="clear"> - <a href="<?php echo $myself; ?>" title="Click here to run a basic Peoplefinder search">Basic</a> | <a href="<?php echo $myself; ?>?adv=y" title="Click here to perform a detailed Peoplefinder search">Detailed</a> - </div> -<?php + //intentional no break + case 'json': + case 'php': + case 'xml': + $savvy->addTemplatePath(dirname(__FILE__).'/templates/'.$peoplefinder->options['format']); + break; + case 'partial': + case 'hcard': + Savvy_ClassToTemplateMapper::$output_template['UNL_Peoplefinder'] = 'Peoplefinder-partial'; + // intentional no break + case 'html': + default: + $savvy->setEscape('htmlentities'); } -$page->maincontentarea = ob_get_clean(); +$savvy->setEscape('htmlentities'); -$page->footercontent = 'UNL | Office of University Communications | <a href="http://www1.unl.edu/wdn/wiki/About_Peoplefinder" onclick="window.open(this.href); return false;">About Peoplefinder</a><br /><br />'; -$page->footercontent .= 'Information obtained from this directory may not be used to provide addresses for mailings to students, faculty or staff.<br />Any solicitation of business, information, contributions or other response from individuals listed in this publication by mail, telephone or other means is forbidden.<br />'; +echo $savvy->render($peoplefinder); -echo $page; diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/scripts/peoplefinder.js b/lib/www/UNL_Peoplefinder/pear.unl.edu/scripts/peoplefinder.js new file mode 100644 index 0000000000000000000000000000000000000000..c5ae8e8b708ed3bcf9b3a3040ce70209ed20cc8d --- /dev/null +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/scripts/peoplefinder.js @@ -0,0 +1,259 @@ +var service_peoplefinder = function() { + return { + updatePeopleFinderResults : function(){ //function called when the list has been rendered + if (WDN.jQuery("#results:contains('Sorry, no results could be found.')").length > 0 && attempts < 3) { + if (splitName == false && originalSearch.indexOf(' ') > 0) { //user did a simple search with a space, so try an advanced search + WDN.jQuery("#results").empty(); + splitQuery = originalSearch.split(' ',2); + service_peoplefinder.anotherAttempt(splitQuery[0] ,splitQuery[1].substring(0,1)); + } + if (splitName == true) { //user did an adavanced search, let's try first letter first name, whole last name + if (attempts == 2) { //on our second attempt + splitQuery = originalSearch.split(' ',2); + service_peoplefinder.anotherAttempt(splitQuery[0].substring(0,1) ,splitQuery[1]); + } else { //user did first search from advanced search + splitQuery = originalSearch.split(' ',2); + service_peoplefinder.anotherAttempt(splitQuery[0] ,splitQuery[1].substring(0,1)); + } + } + + return false; + } else if (attempts > 1){ + //we finally have results, or else we've abandonded the search options + directory.showSearchNotice(); + } + WDN.loadJS('scripts/filters.js', function(){ + filters.initialize(); + }); + WDN.jQuery('ul.pfResult li').each(function(){ + //onClick = WDN.jQuery(this).find('.cInfo').attr('onclick'); + WDN.jQuery(this).find('.cInfo, .fn a').removeAttr('onclick'); + }); + WDN.jQuery('ul.pfResult:not(.departments) li .overflow').click(function(){ + service_peoplefinder.showIndividualPeopleFinderRecord(WDN.jQuery(this)); + return false; + } + ); + WDN.jQuery('ul.pfResult.departments li .overflow').click(function(){ + window.location = WDN.jQuery(this + '.fn a').attr('href'); + } + ); + }, + + anotherAttempt : function(firstName, lastName) { + window.location.hash = '#q/' + firstName + '/' +lastName; + directory.buildSearchNotice(originalSearch, firstName, lastName); + attempts++; + }, + + updatePeopleFinderRecord : function(data, textStatus){ //function called when a record has been rendered + if (textStatus == 'success') { + WDN.jQuery('li.current').append(data); + WDN.jQuery('li.current .vcard a.planetred_profile').fadeIn(400); + WDN.jQuery('li.current .vcard').slideDown(); + WDN.jQuery('li.selected .loading').hide(); + } else { + + } + }, + + presentPeopleFinderResults : function(){ + WDN.jQuery('#filters').css({'opacity' : '0.4'}); + WDN.jQuery('#q').siblings('label').hide(); + WDN.jQuery('#maincontent div.two_col').remove(); + if (!splitName) { + WDN.toolbar_peoplefinder.queuePFRequest(query, 'results'); + } else { + WDN.toolbar_peoplefinder.queuePFRequest('', 'results', '', cn, sn); + query = cn +" "+ sn; + } + document.title = 'UNL | Directory | Search for ' + query; + WDN.jQuery("#breadcrumbs ul li:last").remove(); + WDN.jQuery('#breadcrumbs ul').append('<li>Search for '+WDN.jQuery('<div/>').text(query).html()+'</li>'); + }, + + showIndividualPeopleFinderRecord : function(liRecord) { + if (liRecord.parent().hasClass('selected')) { + liRecord.siblings('.vcard').children('a.planetred_profile').fadeOut(400); + liRecord.siblings('.vcard').slideUp(function(){ + WDN.jQuery(this).remove(); + + }); + liRecord.parent().removeClass('selected'); + } else { + liRecord.children('.loading').show(); + WDN.jQuery('li.current').removeClass('current'); + liRecord.parent('li').addClass('selected current'); + var href = liRecord.find('a.cInfo').attr('href'); + href = href.split('?uid='); + var url = WDN.toolbar_peoplefinder.serviceURL + 'service.php?view=hcard&uid=' + href[1]; + WDN.get(url, null, service_peoplefinder.updatePeopleFinderRecord); + } + return false; + } + }; +}(); + +var directory = function() { + return { + initializeSearchBoxes : function() { + WDN.jQuery('#peoplefinder').submit(function(eventObject) { //on submit of the search form + WDN.jQuery("#searchNotice").slideUp(); + if (WDN.jQuery('#'+this.id+' input.q').val().length || WDN.jQuery('#'+this.id+' input.q:gt(0)').val().length) { + if((WDN.jQuery('#cn').length > 0) || (WDN.jQuery('#sn').length > 0)){ + window.location.hash = '#q/' + WDN.jQuery('#cn').val() + '/' + WDN.jQuery('#sn').val(); + originalSearch = WDN.jQuery('#cn').val() + ' ' + WDN.jQuery('#sn').val(); + WDN.jQuery('#cn').focus().select(); + } else { + window.location.hash = '#q/' + WDN.jQuery('#'+this.id+' input.q').val(); //triggering a hash change will run through the searching function + WDN.jQuery('#q').focus().select(); + originalSearch = WDN.jQuery('#'+this.id+' input.q').val(); + } + } + eventObject.preventDefault(); + eventObject.stopPropagation(); + return false; + }); + directory.fixLabel(); + }, + + fixLabel : function() { //called to reposition the label over the input and hide + WDN.jQuery('.directorySearch > fieldset > ol > li > label').css({'top' : '16px'}).focus(function(){ + WDN.jQuery(this).hide().siblings('input[type=text]').next().focus(); + }); + WDN.jQuery('.directorySearch input').bind({ + focus : function(){ + WDN.jQuery(this).siblings('label[for='+this.id+']').hide(); + }, + blur : function(){ + if (WDN.jQuery(this).val() === "") { + WDN.jQuery(this).siblings('label[for='+this.id+']').show(); + } + } + }); + }, + + splitSearchBoxes : function(cn, sn) { //function called to prepare the advanced search boxes + if (WDN.jQuery('#q').length){ + WDN.jQuery("#queryString, #q").remove(); + WDN.jQuery('#peoplefinder li').prepend('<label for="cn" class="cn">First Name</label><input type="text" value="" id="cn" name="cn" class="n q" /><label for="sn" class="sn">Last Name</label><input type="text" value="" id="sn" name="sn" class="s n q" />'); + } + WDN.jQuery('#cn, #sn').focus(function(){ + WDN.jQuery(this).prev('label').hide(); + }); + WDN.jQuery('#advancedSearch').unbind('click').removeClass('advanced').addClass('simple').text('Simple Search').bind({ + focus : function(){ + WDN.jQuery("#queryString").remove(); + }, + click : function(eventObject){ + directory.combineSearchBoxes(); + eventObject.preventDefault(); + eventObject.stopPropagation(); + return false; + } + }); + WDN.jQuery('#cn').val(cn); + WDN.jQuery('#sn').val(sn); + if(cn.length){ + WDN.jQuery('label[for=cn]').hide(); + } + if(sn.length){ + WDN.jQuery('label[for=sn]').hide(); + } + directory.fixLabel(); + }, + + combineSearchBoxes : function() { //function called to prepare the simple search box + WDN.jQuery('#sn, #cn, label.cn, label.sn').remove(); + WDN.jQuery('#advancedSearch').unbind('click').removeClass('simple').addClass('advanced').text('Advanced Search').bind({ + focus : function(){ + WDN.jQuery("#peoplefinder label").remove(); + }, + click : function(eventObject){ + directory.splitSearchBoxes('',''); + eventObject.preventDefault(); + eventObject.stopPropagation(); + return false; + } + }); + WDN.jQuery('#peoplefinder li').prepend('<label for="q" id="queryString">Enter a name to begin your search</label><input type="text" value="" id="q" name="q" class="q" />'); + directory.fixLabel(); + }, + + buildSearchNotice : function(originalSearch, firstName, lastName) { + WDN.jQuery("#searchNotice").remove(); + WDN.jQuery("#peoplefinder").after('<p id="searchNotice">Your original search for <span>'+originalSearch+'</span> did not return any results. So we tried a few more advanced searches and below is what we found for <span>First Name: '+firstName+' AND Last Name: '+lastName+'</span>.'); + }, + + showSearchNotice : function() { + WDN.jQuery("#searchNotice").slideDown(500); + attempts = 1; + } + }; +}(); + +WDN.jQuery(document).ready(function() { + WDN.loadJS('wdn/templates_3.0/scripts/plugins/hashchange/jQuery.hashchange.1-3.min.js', function() { + attempts = 1; // var used to control how many attempts the automatic search guessing goes through + WDN.jQuery(window).bind('hashchange', function(eventObject){ + hash = location.hash; + if (hash.match(/^#q\//)) { + hash = hash.split('/'); //hash[1] + splitName = false; + if(hash.length >= 3){ // if 3, then we're looking for first and last name individually. + splitName = true; + cn = unescape(hash[1]); + sn = unescape(hash[2]); + directory.splitSearchBoxes(cn, sn); + } else { // it's all one search term. + query = unescape(hash[1]); + if (WDN.jQuery('#cn').length){ + directory.combineSearchBoxes(); + } + WDN.jQuery('#q').val(query); + } + + service_peoplefinder.presentPeopleFinderResults(); + + eventObject.preventDefault(); + eventObject.stopPropagation(); + return false; + } + if (!hash) { + // Load the default instructions + WDN.jQuery('#maincontent').load('?format=partial', function(){ + directory.initializeSearchBoxes(); + }); + } + }); + }); + WDN.loadJS('wdn/templates_3.0/scripts/toolbar_peoplefinder.js', function(){ + //WDN.toolbar_peoplefinder.serviceURL = window.location.protocol + '//' + window.location.host + window.location.pathname; + WDN.toolbar_peoplefinder.serviceURL = PF_URL; + WDN.toolbar_peoplefinder.configuedWebService = true; + if (window.location.hash) { + WDN.jQuery(window).trigger('hashchange'); + } + }); + directory.initializeSearchBoxes(); + WDN.jQuery('#advancedSearch').bind({ + focus : function(){ + WDN.jQuery("#queryString").remove(); + }, + click : function(){ + directory.splitSearchBoxes('',''); + return false; + } + }); + WDN.jQuery('a.img-qrcode').live('click', function() { + WDN.jQuery(this).colorbox({open:true}); + return false; + }); +}); +WDN.jQuery(window).keydown(function(event) { + if (event.which == '191') { + WDN.jQuery('#q').focus().select(); + event.preventDefault(); + event.stopPropagation(); + } +}); \ No newline at end of file diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/service.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/service.php index 9745d38219364f44529912ab256a56c65d497ea2..c23b479a262f351d1aaf7c09c039007a54b0f8d1 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/service.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/service.php @@ -16,8 +16,8 @@ header('Access-Control-Allow-Methods: GET, OPTIONS'); // The X-Requested-With header allows jQuery requests to go through header('Access-Control-Allow-Headers: X-Requested-With'); -// Set the ages for the access-control header to 20 days to improve speed/caching. -header('Access-Control-Max-Age: 1728000'); +// Set the ages for the access-control header to 24 hours to improve speed/caching. +header('Access-Control-Max-Age: 86400'); // Set expires header for 24 hours to improve speed caching. header('Expires: '.date('r', strtotime('tomorrow'))); @@ -26,108 +26,36 @@ header('Expires: '.date('r', strtotime('tomorrow'))); if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') { exit(); } +$options = array('format'=>'partial', 'onclick'=>'pf_getUID'); +$options = $_GET + $options; +$options['driver'] = $driver; +$peoplefinder = new UNL_Peoplefinder($options); -$peepObj = new UNL_Peoplefinder(); -$format = 'html'; +Savvy_ClassToTemplateMapper::$classname_replacement = 'UNL_'; +$savvy = new Savvy(); +$savvy->setTemplatePath(dirname(__FILE__).'/templates/html'); -$renderer_options = array('uid_onclick' => 'pf_getUID', - 'uri' => UNL_PEOPLEFINDER_URI); -if (isset($_GET['chooser'])) { - $renderer_options['choose_uid'] = true; -} - -if (isset($_GET['renderer']) || isset($_GET['format'])) { - $format = isset($_GET['renderer'])?$_GET['renderer']:$_GET['format']; -} -switch($format) { -case 'vcard': - $renderer_class = 'vCard'; - break; -case 'serialized': -case 'php': - $renderer_class = 'Serialized'; - break; -case 'xml': - $renderer_class = 'XML'; - break; -case 'json': - $renderer_class = 'JSON'; - break; -default: -case 'hcard': -case 'html': - $renderer_class = 'HTML'; - break; -} -$method = false; -if (isset($_GET['method'])) { - switch ($_GET['method']) { - case 'getLikeMatches': - case 'getExactMatches': - case 'getPhoneMatches': - $method = $_GET['method']; +switch($peoplefinder->options['format']) { + case 'vcard': + header('Content-Type: text/x-vcard'); + if ($peoplefinder->output[0] instanceof UNL_Peoplefinder_Record) { + header('Content-Disposition: attachment; filename="'.$peoplefinder->output[0]->sn.', '.$peoplefinder->output[0]->givenName.'.vcf"'); + } + //intentional no break + case 'json': + case 'php': + case 'xml': + $savvy->addTemplatePath(dirname(__FILE__).'/templates/'.$peoplefinder->options['format']); break; - } + case 'partial': + case 'html': + case 'hcard': + default: + Savvy_ClassToTemplateMapper::$output_template['UNL_Peoplefinder'] = 'Peoplefinder-partial'; + $savvy->setEscape('htmlentities'); } -$renderer_class = 'UNL_Peoplefinder_Renderer_'.$renderer_class; -$renderer = new $renderer_class($renderer_options); -if (isset($_GET['q']) && !empty($_GET['q'])) { - // Basic query, build filter and display results - if (strlen($_GET['q']) > 3) { - if (is_numeric(str_replace('-','',str_replace('(','',str_replace(')','',$_GET['q']))))) { - $records = $peepObj->getPhoneMatches($_GET['q']); - $renderer->renderSearchResults($records); - } else { - if ($method) { - $records = $peepObj->$method($_GET['q']); - if (count($records) > 0) { - $renderer->renderSearchResults($records); - } else { - $renderer->renderError(); - } - } else { - $records = $peepObj->getExactMatches($_GET['q']); - if (count($records) > 0) { - if ($renderer instanceof UNL_Peoplefinder_Renderer_HTML) { - echo "<div class='cMatch'>Exact matches:</div>\n"; - } - $renderer->renderSearchResults($records); - } else { - if ($renderer instanceof UNL_Peoplefinder_Renderer_HTML) { - echo 'No exact matches found.'; - } - } - if (count($records) < UNL_Peoplefinder::$displayResultLimit) { - // More room to display LIKE results - UNL_Peoplefinder::$displayResultLimit = UNL_Peoplefinder::$displayResultLimit-$peepObj->lastResultCount; - $records = $peepObj->getLikeMatches($_GET['q'], $records); - if (count($records) > 0) { - if ($renderer instanceof UNL_Peoplefinder_Renderer_HTML) { - echo "<div class='cMatch'>Possible matches:</div>\n"; - } - $renderer->renderSearchResults($records); - } - } - } - } - } else { - $renderer->renderError(); - } -} elseif (isset($_GET['uid']) && !empty($_GET['uid'])) { - $renderer->renderRecord($peepObj->getUID($_GET['uid'])); -} elseif (isset($_GET['d'])) { - try { - $department = new UNL_Peoplefinder_Department($_GET['d']); - foreach ($department as $employee) { - $renderer->renderRecord($employee); - } - } catch(Exception $e) { - $renderer->renderError($e->getMessage()); - } -} else { - $renderer->renderError(); -} +echo $savvy->render($peoplefinder); diff --git a/lib/www/UNL_Peoplefinder/pear.unl.edu/standardForm.php b/lib/www/UNL_Peoplefinder/pear.unl.edu/standardForm.php index cd6a2fde12cafa3d16b0a66017c42bae63790fbd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/lib/www/UNL_Peoplefinder/pear.unl.edu/standardForm.php +++ b/lib/www/UNL_Peoplefinder/pear.unl.edu/standardForm.php @@ -1,16 +0,0 @@ -<form method="get" id="form1" action="<?php echo htmlentities(str_replace('index.php', '', $_SERVER['PHP_SELF']), ENT_QUOTES); ?>"> - <div> - <label for="q">Search People: </label> - <?php if (isset($_GET['chooser'])) { - echo '<input type="hidden" name="chooser" value="true" />'; - } - if (isset($_GET['q'])) { - $default = htmlentities($_GET['q'], ENT_QUOTES); - } else { - $default = ''; - } - ?> - <input style="width:18ex;" type="text" value="<?php echo $default; ?>" id="q" name="q" /> - <input style="margin-bottom:-7px;" name="submitbutton" type="image" src="/ucomm/templatedependents/templatecss/images/go.gif" value="Submit" id="submitbutton" /> - </div> -</form> \ No newline at end of file