Scott M. Mcdermott

UNIX Systems & Network Administrator
available for contract or salaried positions

edits.php

<?

require_once("inputs.php");

function
do_edit_page ($what, $edits, $search_attr, $search_base, $search_filter_prefix,
              $search_filter_suffix)
{
        if (!(isset($_GET[$search_attr]))) {
                pagehead ("Corporate Directory - Error", "Error",
                          MENU_NAVBAR_HEADER);
                print ("do_edit_page: called without $search_attr argument");
                pagefoot();
                die();
        }
        $edit_what = $_GET[$search_attr];
        $search_filter = $search_filter_prefix . $edit_what .
                         $search_filter_suffix;
        if (!($search = ldap_search($_SESSION["bind_linkid"], $search_base,
                                    $search_filter)))
                die("ldap search returned failure");

        if (!($attribs = _ldap_get_entries($_SESSION["bind_linkid"],
                                           $search)))
                die("search succeeded but returned no entries!");

        if ($attribs["count"] != 1)
                die("attribs size isn't 1!");

        pagehead("Corporate Directory - $what Edit", "Edit: $edit_what",
                 MENU_NAVBAR_HEADER);
?>
        &nbsp; <br>

        <form action="<?echo($_SESSION["requested_base"])?>">

        <table cellpadding=4>
        <tr>
                <td class=tablealtcell valign=top>
                <strong> Distinguished Name: </strong>  &nbsp; </td>
                <td class=tablealtcell valign=top>
                <em> <?echo($attribs[0]["dn"])?> </em> </td>
        </tr>
        <tr>
                <td class=tablecell colspan=2> &nbsp; </td>
        </tr>

<?
        foreach ($edits as $edit) {

?>              <tr class=tablecell>

                <td valign=top>
<?              if (!empty($edit->helplink)) {
?>                      <a href="<?echo($edit->helplink)?>">
                        <?echo($edit->name)?>
                        </a>
<?              } else {
                        echo($edit->name);
                }
?>              </td>
<?
                /*
                 * if the user doesn't have an attribute of this type yet, we
                 * still need to display an empty input for the user so they can
                 * add it if they want want.  The following kluge creates what
                 * will end up displaying as an empty string input box for just
                 * such an occation.  Note: unexplored what effect this has on
                 * non-text inputs.
                 */
                if (isset($attribs[0][$edit->ldapattr]))
                        $attrib = $attribs[0][$edit->ldapattr];
                else
                        $attrib = array("count" => 1, 0 => "");

                /*
                 * now invoke the display and submit methods for our input type
                 */
?>                      <td>
                <table> <?$edit->display($attrib)?> </table>
                </td>
                </tr>
<?
        }
?>
        </table>
        <input type=hidden name=submitted value=submitted>
        <input type=hidden name=moddn value="<?echo($attribs[0]["dn"])?>">
        </form>
<?

        pagefoot();
}

?>