Exemple #1
0
/**
 * Gets all the email addresses for everyone in the system.
 *
 */
function getAllEmailAddrs()
{
    include_once "phpAD.inc.php";
    // parse the config file
    $config = parse_ini_file("Config.ini", 1);
    // create and connect to the AD
    $ad = new phpAD($config['Security']['ADServer'], $config['Security']['ADPort']);
    // validate the user
    $retVal = $ad->bind($config['Security']['ADServiceName'] . $config['Security']['DomainSuffix'], $config['Security']['ADServicePassword']);
    // if the user authenticated
    if ($retVal) {
        // include the lookup object
        include_once "Lookups.php";
        // get a lookup object
        $lus = new Lookups();
        // get the items for the pull down
        $lus->getLookupByName("RoleLU");
        // get the list
        $items = $lus->getLookupList();
        // init the return value
        $addrs = "";
        // for each AD group
        foreach ($items as $item) {
            // get the items for the role
            $name = "RENCI_" . $lus->getItemNameByID($item->getID());
            // get the members of the group
            $groupMembers = $ad->getGroupMembers($name);
            // did we get any group members
            if (!empty($groupMembers)) {
                // for each member retrieved
                foreach ($groupMembers as $groupMember) {
                    // get the email address
                    if (isset($groupMember['mail'][0])) {
                        $email = $groupMember['mail'][0];
                    } else {
                        $email = null;
                    }
                    // did we get an email address back
                    if (!empty($email)) {
                        // force mine to be something else
                        if ($email == "*****@*****.**") {
                            $email = "*****@*****.**";
                        }
                        // if we dont have this string already, save the email address
                        if (strpos($addrs, $email) === false) {
                            $addrs = $addrs . $email . ",";
                        }
                    }
                }
            }
        }
    }
    $addrs = substr($addrs, 0, strlen($addrs) - 1);
    // return to the caller
    return $addrs;
}
Exemple #2
0
/**
 * Creates the HTML for a pulldown that contains lookup table info (meaning name-value pairs)
 *
 * @param string $label
 * @param $ID
 * @param $luTbl
 * @param var $selectedVal
 * @param $makeTblRow
 * @param $grouping
 */
function displayLUPulldown($label, $ID, $luTbl, $selectedVal, $makeTblRow, $grouping = -1, $tooltip = null)
{
    // include the lookup object
    include_once "Lookups.php";
    // get a lookup object
    $lus = new Lookups();
    // get the items for the pull down
    $retval = $lus->getLookupByName($luTbl, $grouping);
    // success?
    if ($retval == 0) {
        // get the items in the list
        $items = $lus->getLookupList();
        // are we going to put this in a 2 column table
        if ($makeTblRow) {
            echo "<tr><td>" . $label . ": </td><td>";
        } else {
            echo $label . ": ";
        }
        // start the pulldown control
        echo '<select class="form-control"  data-toggle="tooltip" data-placement="bottom"' . ' title="' . $tooltip . '" name="' . $ID . '" id="' . $ID . '"><option value="-1">Select a value...</option>';
        // for each item returned output the control details
        foreach ($items as $item) {
            echo '<option value = "' . $item->ID . '" ' . IsSelected($item->ID, $selectedVal) . '>' . $item->Name . '</option>';
        }
        // finish off the control
        echo "</select>";
        // if this is going in a table finish the HTML
        if ($makeTblRow) {
            echo "</td></tr>";
        }
    } else {
        echo '<div class="err">Error retrieving ' . $label . ' information.</div>';
    }
}
Exemple #3
0
<?php

include_once "Lookups.php";
$lus = new Lookups();
$retval = $lus->GetAllLUItems();
// success?
if ($retval == 0) {
    $arr = $lus->getLookupList();
    foreach ($arr as $item) {
        $luname = $item[0];
        $obj = $item[1];
        if ($luname == "InventoryStatusLU") {
            echo "Name:" . $luname . ", ID:" . $obj->ID . "\n";
        }
    }
}
echo "\n Now by name \n";
$itemName = "InventoryStatusLU";
$retval = $lus->getLookupByName($itemName);
// success?
if ($retval == 0) {
    $arr = $lus->getLookupList();
    foreach ($arr as $item) {
        echo "Name:" . $item->Name . ", ID:" . $item->ID . "\n";
    }
}
echo "\n Now by name by ID \n";
$retval = $lus->getItemNameByID(1);
echo "ID: 1, name:" . $retval . "\n";
echo "\n Get the user names\n";
include_once "UserLU.php";