Example #1
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // If $form is a number, it's an dhcp entry record id- so we transform $form into an array
    if ($form['id']) {
        list($status, $rows, $dhcp_entry) = ona_get_dhcp_option_entry_record(array('id' => $form['id']));
        $window['title'] = "Edit DHCP Entry";
    } else {
        $window['title'] = "Add DHCP Entry";
    }
    // If they are adding a global option
    $global_id = 'N';
    if (is_numeric($form['global_id'])) {
        // Setup a title description for this edit type
        $window['edit_type'] = "Global";
        $window['edit_type_value'] = 'This will be a Global DHCP option';
        $global_id = 'Y';
    }
    // Load the subnet record and associated info.
    if (is_numeric($form['subnet_id'])) {
        list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet_id']));
        // Setup a title description for this edit type
        $window['edit_type'] = "Subnet";
        $window['edit_type_value'] = "{$subnet['name']}";
    }
    // If they are adding a new DHCP entry they will usually pass a host_id in
    if (is_numeric($form['host_id'])) {
        list($status, $rows, $host) = ona_find_host($form['host_id']);
        // Setup a title description for this edit type
        $window['edit_type'] = "Host";
        $window['edit_type_value'] = $host['fqdn'];
    }
    // If they are adding a new server level DHCP entry they will usually pass a server_id in
    if (is_numeric($form['server_id'])) {
        list($status, $rows, $server) = ona_find_host($form['server_id']);
        // Setup a title description for this edit type
        $window['edit_type'] = "Server";
        $window['edit_type_value'] = $server['fqdn'];
    }
    // Escape data for display in html
    foreach (array_keys((array) $subnet) as $key) {
        $subnet[$key] = htmlentities($subnet[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $zone) as $key) {
        $zone[$key] = htmlentities($zone[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $host) as $key) {
        $host[$key] = htmlentities($host[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $server) as $key) {
        $server[$key] = htmlentities($server[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Build dhcp option list
    list($status, $rows, $dhcpoptions) = db_get_records($onadb, 'dhcp_options', 'id >= 1', 'display_name');
    $dhcp_option_list = '<option value="">&nbsp;</option>\\n';
    $dhcpoptions['dhcp_options'] = htmlentities($dhcpoptions['display_name']);
    foreach ($dhcpoptions as $record) {
        $selected = "";
        if ($record['id'] == $dhcp_entry['dhcp_option_id']) {
            $selected = "SELECTED=\"selected\"";
        }
        if ($record['id']) {
            $dhcp_option_list .= "<option {$selected} value=\"{$record['id']}\">{$record['display_name']} ({$record['number']})</option>\n";
        }
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        el('{$window_name}_form').onsubmit = function() { return false; };
EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- DHCP entry Edit Form -->
    <form id="{$window_name}_form" onSubmit="return false;">
    <input type="hidden" name="host" value="{$host['id']}">
    <input type="hidden" name="subnet" value="{$subnet['id']}">
    <input type="hidden" name="server" value="{$server['id']}">
    <input type="hidden" name="global" value="{$global_id}">
    <input type="hidden" name="id" value="{$dhcp_entry['id']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- DHCP ENTRY RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>DHCP Entry Record</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                {$window['edit_type']}:
            </td>
            <td class="padding" align="left" width="100%">
                {$window['edit_type_value']}
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true" >
                DHCP Option
            </td>
            <td class="padding" align="left" width="100%">
                <select id="option" name="option" class="edit" accesskey="l">
                    {$dhcp_option_list}
                </select>
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Value
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="value"
                    alt="Value"
                    value="{$dhcp_entry['value']}"
                    class="edit"
                    type="text"
                    size="31" maxlength="255"
                >
            </td>
        </tr>



        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #2
0
function ws_toggleenable($window_name, $form = '')
{
    global $include, $conf, $self, $onadb;
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $js = "xajax_window_submit('app_plugin_list', xajax.getFormValues('app_plugin_list_filter_form'), 'display_list');";
    if (is_writable($form['path'])) {
        if ($form['state'] == 'disable') {
            touch($form['path'] . '/plugin_disabled');
        }
        if ($form['state'] == 'enable') {
            unlink($form['path'] . '/plugin_disabled');
        }
    } else {
        $js .= "alert('Plugin path {$form['path']} is not writeable by the web server!');";
    }
    if ($form['task'] == 'install') {
        return window_open('', $window);
    }
    if ($form['js']) {
        $js .= $form['js'];
    }
    // usually js will refresh the window we got called from
    // Return an XML response
    $response->addScript($js);
    return $response->getXML();
}
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'Custom Attribute Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If we got type, load it for display
    $overwrite = 'no';
    if (is_numeric($form)) {
        list($status, $rows, $record) = db_get_record($onadb, 'custom_attribute_types', array('id' => $form));
        if (!$status and $rows) {
            $overwrite = 'yes';
        }
    }
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple class types Edit Form -->
    <form id="custom_attribute_type_edit_form" onSubmit="return false;">
    <input name="id" type="hidden" value="{$record['id']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">
        <tr>
            <td align="right">
                Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="cust_attrib_type_name"
                    alt="Custom Attribute Type Name"
                    value="{$record['name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="63"
                >
            </td>
        </tr>

        <tr>
            <td align="right">
                Field Validaiton Rule
            </td>
            <td class="padding" align="left" width="100%">
                <textarea
                    name="field_validation_rule"
                    alt="Field Validaiton Rule"
                    class="edit"
                    rows="2"
                    cols="40"
                >{$record['field_validation_rule']}</textarea>
            </td>
        </tr>

        <tr>
            <td align="right">
                Failed Rule Text
            </td>
            <td class="padding" align="left" width="100%">
                <textarea
                    name="failed_rule_text"
                    alt="Failed Rule Text"
                    class="edit"
                    rows="2"
                    cols="40"
                >{$record['failed_rule_text']}</textarea>
            </td>
        </tr>

        <tr>
            <td align="right">
                Notes
            </td>
            <td class="padding" align="left" width="100%">
                <textarea
                    name="notes"
                    alt="Notes"
                    class="edit"
                    rows="2"
                    cols="40"
                >{$record['notes']}</textarea>
            </td>
        </tr>

        <tr>
            <td align="right" valign="top">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('custom_attribute_type_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #4
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    if ($form['server']) {
        list($status, $rows, $host) = ona_find_host($form['server']);
    }
    if ($form['host_id']) {
        list($status, $rows, $host) = ona_find_host($form['host_id']);
    }
    if ($form['domain']) {
        list($status, $rows, $domain) = ona_find_domain($form['domain']);
    }
    // Escape data for display in html
    foreach (array_keys((array) $host) as $key) {
        $host[$key] = htmlentities($host[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Set the window title:
    $window['title'] = "Assign domain to server";
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        suggest_setup('domain_server_name',  'suggest_domain_server_name');
        suggest_setup('domain_server_edit',  'suggest_domain_server_edit');

EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- DNS server Edit Form -->
    <form id="{$window_name}_form" onSubmit="return false;">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <tr>
            <td align="left" nowrap="true"><b><u>Assign Domain</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Server
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="domain_server_name"
                    name="server"
                    alt="Server name"
                    value="{$host['fqdn']}"
                    class="edit"
                    type="text"
                    size="34" maxlength="255"
                >
               <div id="suggest_domain_server_name" class="suggest"></div>
            </td>
        </tr>


        <tr>
            <td class="input_required" align="right" nowrap="true">
                Domain
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="domain_server_edit"
                    name="domain"
                    alt="Domain name"
                    value="{$domain['fqdn']}"
                    class="edit"
                    type="text"
                    size="34" maxlength="255"
                >
               <div id="suggest_domain_server_edit" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Role
            </td>
            <td class="padding" align="left" width="100%" nowrap="true">
                <select class="edit" name="role" alt="Role">
                    <option value="forward">Forward</option>
                    <option value="master" selected>Master</option>
                    <option value="slave">Slave</option>
                </select>
            </td>
        </tr>

        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #5
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'DHCP Option Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If we got an option, load it for display
    $overwrite = 'no';
    if (is_numeric($form)) {
        list($status, $rows, $record) = db_get_record($onadb, 'dhcp_options', array('id' => $form));
        if (!$status and $rows) {
            $overwrite = 'yes';
        }
    }
    // Internal tag type array, there is no table for this
    $type = array("L" => "IP Address List", "S" => "String", "N" => "Numeric", "I" => "IP Address", "B" => "Boolean");
    // Build tag type list
    while ($tag = current($type)) {
        $selected = "";
        // If this entry matches the record you are editing, set it to selected
        if (key($type) == $record['type']) {
            $selected = "SELECTED=\"selected\"";
        }
        if (key($type)) {
            $type_list .= "<option {$selected} value=\"" . key($type) . "\">{$tag}</option>\n";
        }
        next($type);
    }
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple Edit Form -->
    <form id="dhcp_option_edit_form" onSubmit="return false;">
    <input name="id" type="hidden" value="{$record['id']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">
        <tr>
            <td align="right" nowrap="true">
                Display Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="display_name"
                    alt="Description"
                    value="{$record['display_name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="30"
                >
            </td>
        </tr>

        <tr>
            <td align="right">
                Option Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="name"
                    alt="Name"
                    value="{$record['name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="30"
                >
            </td>
        </tr>

        <tr>
            <td align="right">
                Number
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="number"
                    alt="DHCP Number"
                    value="{$record['number']}"
                    class="edit"
                    type="text"
                    size="5" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td nowrap="yes" align="right">
                Option type
            </td>
            <td class="padding" align="left" width="100%">
                <select id="type" name="type" class="edit" accesskey="t">
                    {$type_list}
                </select>
            </td>
        </tr>


        <tr>
            <td align="right" valign="top">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('dhcp_option_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #6
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'DNS View Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // If we got a view, load it for display
    if (is_numeric($form['id'])) {
        list($status, $rows, $record) = db_get_record($onadb, 'dns_views', array('id' => $form['id']));
    }
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple class types Edit Form -->
    <form id="dns_view_edit_form" onSubmit="return false;">
    <input name="id" type="hidden" value="{$record['id']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">
        <tr>
            <td class="input_required" align="right">
                Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="dns_view_name"
                    alt="DNS View Name"
                    value="{$record['name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="64"
                >
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right">
                Description
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="dns_view_description"
                    alt="DNS View Description"
                    value="{$record['description']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="64"
                >
            </td>
        </tr>

        <tr>
            <td align="right" valign="top">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('dns_view_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #7
0
function ws_display($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    printmsg("ws_display in app_full_list.inc.php called with: " . print_r($form, 1), 3);
    $window['title'] = "Host List by IP";
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML = 
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
        
        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML = 
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

EOL;
    // Load some html into $window['html']
    // HOST LIST
    $tab = 'hosts_by_ip';
    $submit_window = "list_{$tab}";
    $form_id = "{$submit_window}_filter_form";
    $_SESSION['ona'][$form_id]['tab'] = $tab;
    $content_id = "{$window_name}_{$submit_window}";
    if (array_key_exists('ip', $form) && array_key_exists('ip_thru', $form)) {
        // Set the window title:
        $window['subtitle'] = "Range: {$form['ip']} to {$form['ip_thru']}";
        // Define javascript to run after the window is created
        $window['js'] .= <<<EOL
         /* Tell the browser to load/display the list */
         xajax_window_submit('app_full_list', 'ip=>{$form['ip']},ip_thru=>{$form['ip_thru']},form_id=>{$form_id},content_id=>{$content_id}', 'display_list');
         
EOL;
    }
    if (array_key_exists('subnet_id', $form)) {
        list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet_id']));
        // Set the window title:
        $window['subtitle'] = "Subnet: {$subnet['name']}";
        // Define javascript to run after the window is created
        $window['js'] .= <<<EOL
         /* Tell the browser to load/display the list */
         xajax_window_submit('app_full_list', 'subnet_id=>{$form['subnet_id']},form_id=>{$form_id},content_id=>{$content_id}', 'display_list');
         
EOL;
    }
    $window['html'] .= <<<EOL
    <!-- HOST LIST -->
    <div style="border: 1px solid {$color['border']}; height : 700px; overflow-y : auto;overflow-x : hidden">
        
        <!-- Tab & Quick Filter -->
        <table id="{$form_id}_table" cellspacing="0" border="0" cellpadding="0">
            <tr>
                <td id="{$form_id}_{$tab}_tab" class="table-tab-active">
                   <b>{$window['subtitle']}</b>&nbsp;<span id="{$form_id}_{$tab}_count" />
                </td>
                <td>
                    &nbsp;<a onclick="toggle_table_rows('{$form_id}_full_host_list','byip_available');" class="button" ><img src="{$images}/silk/arrow_rotate_clockwise.png" border="0"> Toggle Available IPs</a>
                </td>
            </tr>
        </table>
         <div id='{$content_id}'>
            {$conf['loading_icon']}
        </div>
    </div>        
EOL;
    return window_open($window_name, $window);
}
Example #8
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('user_admin')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'User Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If we got a user ID, load it for display
    $overwrite = 'no';
    if (is_string($form) and $form) {
        list($status, $rows, $user) = db_get_record($onadb, 'users', array('id' => $form));
        if (!$status and $rows) {
            $overwrite = 'yes';
        }
    }
    // Load the user's groups
    $user_groups = array();
    list($status, $rows, $records) = db_get_records($onadb, 'group_assignments', array('user_id' => $user['id']));
    foreach ($records as $record) {
        list($status, $rows, $g) = db_get_record($onadb, 'groups', array('id' => $record['group_id']));
        $user_groups[$g['name']] = $g['id'];
    }
    // Get all the groups from the database
    list($status, $rows, $allgroups) = db_get_records($onadb, 'groups', 'id > 0');
    $group_check_list = "";
    foreach ($allgroups as $group) {
        $checked = '';
        if ($user_groups[$group['name']]) {
            $checked = 'checked';
        }
        $group_check_list .= <<<EOL
            <input type="checkbox" name="groups[{$group['name']}]" value="{$group['id']}" {$checked}> {$group['name']}<br>
EOL;
    }
    // Escape data for display in html
    foreach (array_keys($user) as $key) {
        $user[$key] = htmlentities($user[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple User Edit Form -->
    <form id="user_edit_form" onSubmit="return false;">
    <input type="hidden" name="user_id" value="{$user['id']}">
    <input id="password" type="hidden" name="password" value="{$user['password']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">
        <tr>
            <td align="right">
                Username
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="username"
                    alt="Username"
                    value="{$user['username']}"
                    class="edit"
                    type="text"
                    size="20" maxlength="32"
                >
            </td>
        </tr>

        <tr>
            <td align="right">
                Password
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="pass"
                    name="pass"
                    alt="pass"
                    value=""
                    class="edit"
                    type="password"
                    size="20" maxlength="32"
                >
            </td>
        </tr>

        <tr>
            <td align="right" valign="top">
                Groups
            </td>
            <td class="padding" align="left" width="100%">
                {$group_check_list}
            </td>
        </tr>

        <tr>
            <td align="right" valign="top">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="if (el('pass').value != '') { el('password').value = make_md5(el('pass').value); } xajax_window_submit('{$window_name}', xajax.getFormValues('user_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #9
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('vlan_add')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Load an existing host record (and associated info) if $form is a vlan_campus_id
    if (is_numeric($form['vlan_campus_id'])) {
        list($status, $rows, $vlan_campus) = ona_get_vlan_campus_record(array('id' => $form['vlan_campus_id']));
    } else {
        list($status, $rows, $vlan_campus) = ona_get_vlan_campus_record(array('name' => $form['vlan_campus_name']));
    }
    // Escape data for display in html
    foreach (array_keys((array) $vlan_campus) as $key) {
        $vlan_campus[$key] = htmlentities($vlan_campus[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Set the window title:
    $window['title'] = "Add VLAN campus";
    if ($vlan_campus['id']) {
        $window['title'] = "Edit VLAN campus";
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- Vlan Campus Edit Form -->
    <form id="{$window_name}_edit_form" onSubmit="return false;">
    <input type="hidden" name="vlan_campus_id" value="{$vlan_campus['id']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- VLAN CAMPUS RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>Vlan Campus Record</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Vlan Campus Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="name"
                    alt="Vlan Campus Name"
                    value="{$vlan_campus['name']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #10
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $mysql;
    global $color, $style, $images;
    // Make sure they have permission
    if (!auth('admin')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If we got a record ID, load it for display
    $admin_checked = '';
    if (is_string($form) and is_numeric($form)) {
        list($status, $rows, $record) = db_get_record($mysql, 'users', array('id' => $form, 'client_id' => $_SESSION['auth']['client']['id']));
        list($status, $rows, $perm) = db_get_record($mysql, 'permissions', array('name' => 'admin'));
        list($status, $rows, $acl) = db_get_record($mysql, 'acl', array('user_id' => $record['id'], 'perm_id' => $perm['id']));
        if ($acl['id']) {
            $admin_checked = 'CHECKED';
        }
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'Employee Editor', 'html' => '', 'js' => '');
    // Escape data for display in html
    foreach (array_keys($record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL
    
    <!-- Simple Employee Edit Form -->
    <form id="{$window_name}_edit_form" onSubmit="return false;">
    <input type="hidden" name="id" value="{$record['id']}">
    <table cellspacing="1" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding: 5px 20px;">
        
        <tr>
            <td align="right" nowrap="true" class="padding">
                First Name
            </td>
            <td class="padding" align="left" width="100%" class="padding">
                <input 
                    name="fname" 
                    alt="First Name"
                    value="{$record['fname']}"
                    class="edit" 
                    type="text" 
                    size="32" maxlength="64" 
                >
            </td>
        </tr>
        
        <tr>
            <td align="right" nowrap="true" class="padding">
                Last Name
            </td>
            <td class="padding" align="left" width="100%" class="padding">
                <input 
                    name="lname" 
                    alt="Last Name"
                    value="{$record['lname']}"
                    class="edit" 
                    type="text" 
                    size="32" maxlength="64" 
                >
            </td>
        </tr>
        
        <tr>
            <td align="right" nowrap="true" class="padding">
                Username
            </td>
            <td class="padding" align="left" width="100%" class="padding">
                <input 
                    name="username"
                    alt="Username"
                    value="{$record['username']}"
                    class="edit" 
                    type="text"
                    size="32" maxlength="255"
                >
            </td>
        </tr>
        
        <tr>
            <td align="right" valign="top" nowrap="true" class="padding">
                Password
            </td>
            <td class="padding" align="left" width="100%" class="padding">
                <input 
                    name="passwd"
                    alt="Password"
                    value=""
                    class="edit" 
                    type="password"
                    size="32" maxlength="64"
                >
            </td>
        </tr>
        
        <tr>
            <td align="right" valign="top" nowrap="true" class="padding">
                Admin
            </td>
            <td class="padding" align="left" width="100%" class="padding">
                <input 
                    name="admin"
                    alt="Admin"
                    type="checkbox"
                    {$admin_checked}
                >
            </td>
        </tr>
        
        <tr>
            <td align="right" valign="top" nowrap="true" class="padding">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%" class="padding">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button" 
                    name="submit" 
                    value="Save" 
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_edit_form'), 'save');"
                >
            </td>
        </tr>
    
    </table>
    </form>
    
EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // Load an existing host record (and associated info) if $form is a host_id
    if ($form['id']) {
        list($status, $rows, $failovergroup) = ona_get_dhcp_failover_group_record(array('id' => $form['id']));
        if (!$rows) {
            $self['error'] = "ERROR => Unable to find the DHCP failover record using {$form['id']}!";
            return array(4, $self['error'] . "\n");
        }
        list($status, $rows, $pri_server) = ona_find_host($failovergroup['primary_server_id']);
        list($status, $rows, $sec_server) = ona_find_host($failovergroup['secondary_server_id']);
        $failovergroup['pri_server_name'] = $pri_server['fqdn'];
        $failovergroup['sec_server_name'] = $sec_server['fqdn'];
        // Set the window title:
        $window['title'] = "Edit DHCP Failover Group";
    } else {
        // Set up default failover information
        $failovergroup['max_response_delay'] = '60';
        $failovergroup['max_unacked_updates'] = '10';
        $failovergroup['max_load_balance'] = '3';
        $failovergroup['primary_port'] = '647';
        $failovergroup['peer_port'] = '847';
        $failovergroup['mclt'] = '1800';
        $failovergroup['split'] = '255';
        // Set the window title:
        $window['title'] = "Add DHCP Failover Group";
    }
    // Escape data for display in html
    foreach (array_keys((array) $failovergroup) as $key) {
        $failovergroup[$key] = htmlentities($failovergroup[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;


        suggest_setup('failover_pri_hostname', 'suggest_failover_pri_hostname');
        suggest_setup('failover_sec_hostname', 'suggest_failover_sec_hostname');

        el('{$window_name}_edit_form').onsubmit = function() { return false; };

EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- DHCP Failover Group Edit Form -->
    <form id="{$window_name}_edit_form" onSubmit="return false;">
    <input type="hidden" name="id" value="{$failovergroup['id']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- DHCP FAILOVER GROUP RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>DHCP Failover Group Record</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Primary Server
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="failover_pri_hostname"
                    name="pri_server"
                    alt="Primary Server"
                    value="{$failovergroup['pri_server_name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
                <div id="suggest_failover_pri_hostname" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Secondary Server
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="failover_sec_hostname"
                    name="sec_server"
                    alt="Secondary Server"
                    value="{$failovergroup['sec_server_name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
                <div id="suggest_failover_sec_hostname" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Max Response Delay
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="response_delay"
                    alt="Max Response Delay"
                    value="{$failovergroup['max_response_delay']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Max Unacked Updates
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="unacked_updates"
                    alt="Max Unacked Updates"
                    value="{$failovergroup['max_unacked_updates']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Max Load Balance
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="max_balance"
                    alt="Load Balance"
                    value="{$failovergroup['max_load_balance']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Primary Port Num
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="priport"
                    alt="Primary Port Num"
                    value="{$failovergroup['primary_port']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Peer Port Num
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="peerport"
                    alt="Peer Port Num"
                    value="{$failovergroup['peer_port']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                MCLT
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="mclt"
                    alt="MCLT"
                    value="{$failovergroup['mclt']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Split
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="split"
                    alt="split"
                    value="{$failovergroup['split']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>


        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #12
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('user_admin')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'Permission Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If we got a group ID, load it and it's permissions
    if ($form['group_id']) {
        list($status, $rows, $group) = db_get_record($onadb, 'groups', array('id' => $form['group_id']));
        list($status, $rows, $perms) = db_get_records($onadb, 'permission_assignments', array('group_id' => $group['id']));
        $form['type'] = 'group_id';
        $form['id'] = $group['id'];
    } else {
        if ($form['user_id']) {
            list($status, $rows, $user) = db_get_record($onadb, 'users', array('id' => $form['user_id']));
            list($status, $rows, $perms) = db_get_records($onadb, 'permission_assignments', array('user_id' => $user['id']));
            $form['type'] = 'user_id';
            $form['id'] = $user['id'];
        }
    }
    $assigned = array();
    foreach ($perms as $perm) {
        $assigned[$perm['perm_id']] = 1;
    }
    // Select every permission so we can build a checklist of them
    list($status, $rows, $permissions) = db_get_records($onadb, 'permissions', 'id > 0', 'name');
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple Permission Edit Form -->
    <form id="permission_edit_form" onSubmit="return false;">
    <input type="hidden" name="id" value="{$form['id']}">
    <input type="hidden" name="type" value="{$form['type']}">
    <table width="100%" cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding: 4px 20px;">

EOL;
    // Build the html for selecting the permissions the user/group has
    foreach ($permissions as $permission) {
        $checked = '';
        if ($assigned[$permission['id']] == 1) {
            $checked = 'CHECKED';
        }
        // Escape data for display in html
        foreach (array_keys($permission) as $key) {
            $permission[$key] = htmlentities($permission[$key], ENT_QUOTES, $conf['php_charset']);
        }
        $window['html'] .= <<<EOL
        <tr><td align="left" nowrap="true">
            <input type="checkbox" name="perms[{$permission['id']}]" value="{$permission['name']}" {$checked}> {$permission['name']}
        </td><td>
            {$permission['description']}
        </td></tr>
EOL;
    }
    $window['html'] .= <<<EOL
            </td>
        </tr>

        <tr>
            <td align="right">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('permission_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #13
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('location_add')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    if ($form['id']) {
        list($status, $rows, $record) = ona_get_location_record(array('id' => $form['id']));
    }
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Set the window title:
    $window['title'] = "Add Location";
    if ($record['id']) {
        $window['title'] = "Edit Location";
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        el('{$window_name}_edit_form').onsubmit = function() { return false; };
        el('ref').focus();

EOL;
    // MP: TODO:  Add a quick find for city and state that looks up existing records.
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- Location Edit Form -->
    <form id="{$window_name}_edit_form" onSubmit="return false;">
    <input type="hidden" name="location_id" value="{$record['id']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- Location RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>Location Record</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>
EOL;
    $window['html'] .= <<<EOL
        <tr>
            <td class="input_required" align="right">
                <u>R</u>eference
            </td>
            <td align="left" class="qf-search-line">
                <input id="ref" name="reference" type="text" class="edit" size="32" accesskey="r" value="{$record['reference']}"/>
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right">
                <u>N</u>ame
            </td>
            <td align="left" class="qf-search-line">
                <input name="name" type="text" class="edit" size="32" accesskey="n" value="{$record['name']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                <u>A</u>ddress
            </td>
            <td align="left" class="qf-search-line">
                <input name="address" type="text" class="edit" size="32" accesskey="a" value="{$record['address']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                <u>C</u>ity
            </td>
            <td align="left" class="qf-search-line" nowrap="true">
                <input name="city" class="edit" type="text" size="20" accesskey="c" value="{$record['city']}"/>&nbsp;
                <u>S</u>tate <input name="state" class="edit" type="text" size="2" maxlength="2" value="{$record['state']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                <u>Z</u>ip
            </td>
            <td align="left" class="qf-search-line" nowrap="true">
                <input name="zip_code" class="edit" type="text" size="10" maxlength="10" accesskey="z" value="{$record['zip_code']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                <u>L</u>atitude
            </td>
            <td align="left" class="qf-search-line" nowrap="true">
                <input name="latitude" class="edit" type="text" size="10" maxlength="10" accesskey="l" value="{$record['latitude']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                L<u>o</u>ngitude
            </td>
            <td align="left" class="qf-search-line" nowrap="true">
                <input name="longitude" class="edit" type="text" size="10" maxlength="10" accesskey="o" value="{$record['longitude']}"/>
            </td>
        </tr>

        <tr>
            <td align="right">
                <u>M</u>isc info
            </td>
            <td align="left" class="qf-search-line">
                <textarea name="misc" class="edit" rows="3" cols="20" size="256" accesskey="m">{$record['misc']}</textarea>
            </td>
        </tr>



        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #14
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    if ($form['subnet_id']) {
        $form['subnet'] = $form['subnet_id'];
    }
    // if it is a new pool, setup some things
    if (!$form['id']) {
        list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet']));
        // set start and end IP to subnet IP
        $pool['start_ip'] = $pool['end_ip'] = ip_mangle($subnet['ip_addr'], 'dotted');
        // setup defaults for form values-- FIXME use $conf['dhcp_pool'] stuff later
        $pool['lease_length'] = '604800';
        $pool['lease_grace_period'] = '0';
        $pool['lease_rebind_time'] = '0';
        $pool['lease_renewal_time'] = '0';
        $pool['server_name_text'] = 'None';
        $window['title'] = "Add DHCP Pool";
    } else {
        list($status, $rows, $pool) = ona_get_dhcp_pool_record(array('id' => $form['id']));
        $pool['start_ip'] = ip_mangle($pool['ip_addr_start']);
        $pool['end_ip'] = ip_mangle($pool['ip_addr_end']);
        $pool['server_name_text'] = 'None';
        // Load the subnet record and associated info.
        if (is_numeric($form['subnet'])) {
            list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet']));
        }
        // Load the server record and associated info.
        if ($pool['dhcp_failover_group_id'] >= 1) {
            list($status, $rows, $failover) = ona_get_dhcp_failover_group_record(array('id' => $pool['dhcp_failover_group_id']));
            list($status, $rows, $fail_host1) = ona_find_host($failover['primary_server_id']);
            list($status, $rows, $fail_host2) = ona_find_host($failover['secondary_server_id']);
            $pool['server_name_text'] = $fail_host1['fqdn'] . "/" . $fail_host2['fqdn'];
        }
        $window['title'] = "Edit DHCP Pool";
    }
    // Escape data for display in html
    foreach (array_keys((array) $subnet) as $key) {
        $subnet[$key] = htmlentities($subnet[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $failover) as $key) {
        $failover[$key] = htmlentities($failover[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $zone) as $key) {
        $zone[$key] = htmlentities($zone[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $host) as $key) {
        $host[$key] = htmlentities($host[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $server) as $key) {
        $server[$key] = htmlentities($server[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        el('{$window_name}_form').onsubmit = function() { return false; };

        /* Setup the Quick Find pool server icon */
    var _button = el('qf_pool_server_{$window_name}');
    _button.style.cursor = 'pointer';
    _button.onclick =
        function(ev) {
            if (!ev) ev = event;
            /* Create the popup div */
            wwTT(this, ev,
                 'id', 'tt_qf_pool_server_{$window_name}',
                 'type', 'static',
                 'direction', 'south',
                 'delay', 0,
                 'styleClass', 'wwTT_qf',
                 'javascript',
                 "xajax_window_submit('tooltips', '" +
                     "tooltip=>qf_pool_server," +
                     "id=>tt_qf_pool_server_{$window_name}," +
                     "text_id=>pool_server_text_{$window_name}," +
                     "server=>set_pool_server_{$window_name}," +
                     "server_name=>{$pool['server_name_text']}," +
                     "failover_group_id=>{$pool['dhcp_failover_group_id']}," +
                     "failover_group=>set_failover_group_{$window_name}');"
            );
        };


EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- DHCP pool Edit Form -->
    <form id="{$window_name}_form" onSubmit="return false;">
    <input type="hidden" name="id" value="{$pool['id']}">
    <input type="hidden" name="subnet_id" value="{$form['subnet']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- DHCP POOL RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>DHCP Pool</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Subnet:
            </td>
            <td class="padding" align="left" width="100%">
                {$subnet['name']}
            </td>
        </tr>


        <tr>
            <td align="right" nowrap="true">
                Failover Group
            </td>
            <td class="padding" align="left" width="100%" nowrap="true">
                <input
                    type="hidden"
                    id="set_failover_group_{$window_name}"
                    name="failover_group"
                    value="{$pool['dhcp_failover_group_id']}">

                <span id="qf_pool_server_{$window_name}" title="DHCP Pool Server Quick Select">
                    <a id="pool_server_text_{$window_name}"
                       class="nav"
                    >{$pool['server_name_text']}</a>
                    <img src="{$images}/silk/find.png" border="0"
                /></span>
            </td>
        </tr>


        <!-- TODO: add a qf for IP addresses to list avail ips on subnet -->



        <tr>
            <td class="input_required" align="right" nowrap="true">
                IP Start
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="start"
                    alt="IP Start"
                    value="{$pool['start_ip']}"
                    class="edit"
                    type="text"
                    size="25" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                IP End
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="end"
                    alt="IP End"
                    value="{$pool['end_ip']}"
                    class="edit"
                    type="text"
                    size="25" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Lease Length
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="llength"
                    alt="Lease Length"
                    value="{$pool['lease_length']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Lease Grace
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="lgrace"
                    alt="Lease Grace"
                    value="{$pool['lease_grace_period']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Lease Renewal
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="lrenewal"
                    alt="Lease Renewal"
                    value="{$pool['lease_renewal_time']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>


        <tr>
            <td align="right" nowrap="true">
                Lease Rebind
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="lrebind"
                    alt="Lease Rebind"
                    value="{$pool['lease_rebind_time']}"
                    class="edit"
                    type="text"
                    size="10" maxlength="10"
                >
            </td>
        </tr>




        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #15
0
function ws_delete($window_name, $form = '')
{
    global $include, $conf, $self, $onadb;
    // Check permissions
    if (!auth('host_del')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $js = '';
    // Run the module
    list($status, $output) = run_module('host_del', array('host' => $form['host_id'], 'commit' => $form['commit']));
    // If commit was N, display the confirmation dialog box
    if (!$form['commit']) {
        $build_commit_html = 1;
        $commit_function = 'delete';
        include window_find_include('module_results');
        return window_open("{$window_name}_results", $window);
    }
    // If the module returned an error code display a popup warning
    if ($status) {
        $js .= "alert('Delete failed. " . preg_replace('/[\\s\']+/', ' ', $output) . "');";
    } else {
        if ($form['js']) {
            $js .= $form['js'];
        }
    }
    // usually js will refresh the window we got called from
    // Return an XML response
    $response->addScript($js);
    return $response->getXML();
}
Example #16
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // Set a few parameters for the "results" window we're about to create
    $window = array('title' => 'Device Model Editor', 'html' => '', 'js' => '');
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;
EOL;
    // If we got a device model, load it for display
    $overwrite = 'no';
    if (is_numeric($form)) {
        list($status, $rows, $record) = db_get_record($onadb, 'models', array('id' => $form));
        if (!$status and $rows) {
            $overwrite = 'yes';
        }
    }
    // Build manufacturer list
    // TODO: this needs to be made more efficent
    list($status, $rows, $manufacturer) = db_get_records($onadb, 'manufacturers', 'id >= 1', 'name');
    $manufacturer_list = '<option value="">&nbsp;</option>\\n';
    $manufacturer['name'] = htmlentities($manufacturer['name']);
    foreach ($manufacturer as $entry) {
        $selected = "";
        // If this entry matches the record you are editing, set it to selected
        if ($entry['id'] == $record['manufacturer_id']) {
            $selected = "SELECTED=\"selected\"";
        }
        if ($entry['id']) {
            $manufacturer_list .= "<option {$selected} value=\"{$entry['id']}\">{$entry['name']}</option>\n";
        }
    }
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Load some html into $window['html']
    $window['html'] .= <<<EOL

    <!-- Simple device models Edit Form -->
    <form id="device_model_edit_form" onSubmit="return false;">
    <input name="id" type="hidden" value="{$record['id']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <tr>
            <td nowrap="yes" align="right">
                Manufacturer
            </td>
            <td class="padding" align="left" width="100%">
                <select id="manufacturer_id" name="manufacturer_id" class="edit" accesskey="m">
                    {$manufacturer_list}
                </select>
            </td>
        </tr>

        <tr>
            <td nowrap="yes" align="right">
                Model
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="model_description"
                    alt="Device Model Description"
                    value="{$record['name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="30"
                >
            </td>
        </tr>

        <tr>
            <td nowrap="yes" align="right">
                SNMP sysobjectid
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="snmp_sysobjectid"
                    alt="SNMP sysobjectid"
                    value="{$record['snmp_sysobjectid']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="30"
                >
            </td>
        </tr>

        <tr>
            <td align="right" valign="top">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('device_model_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #17
0
function ws_window_progressbar($window_name, $form = '')
{
    global $images;
    // If an array in a string was provided, build the array and store it in $form
    $form = parse_options_string($form);
    $window_name = $form['name'];
    $output = "<center>Working on the results, please wait<br><img src={$images}/loading.gif></center>";
    $window['title'] = 'Processing...';
    $window['js'] = "el('{$window_name}_extras').innerHTML='<br>';";
    $build_commit_html = 0;
    $commit_function = '';
    include window_find_include('module_results');
    return window_open("{$window_name}_results", $window);
}
Example #18
0
function ws_editor($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    $window = array();
    // Check permissions
    if (!auth('advanced')) {
        $response = new xajaxResponse();
        $response->addScript("alert('Permission denied!');");
        return $response->getXML();
    }
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Load an existing record (and associated info) if $form has an id
    if (is_numeric($form['id'])) {
        list($status, $rows, $domain) = ona_get_domain_record(array('id' => $form['id']));
        list($status, $rows, $parent) = ona_get_domain_record(array('id' => $domain['parent_id']));
        $domain['parent'] = ona_build_domain_name($parent['id']);
        // Set the window title:
        $window['title'] = "Edit Domain";
    } else {
        // Set up default domain information
        $domain['admin_email'] = $conf['dns_admin_email'];
        $domain['primary_master'] = $conf['dns_primary_master'];
        $domain['refresh'] = $conf['dns_refresh'];
        $domain['retry'] = $conf['dns_retry'];
        $domain['expiry'] = $conf['dns_expiry'];
        $domain['minimum'] = $conf['dns_minimum'];
        $domain['default_ttl'] = $conf['dns_default_ttl'];
        $domain['parent'] = $conf['dns_parent'];
        // Set the window title:
        $window['title'] = "Add Domain";
    }
    if ($form['newptrdomainname']) {
        $domain['name'] = $form['newptrdomainname'];
    }
    // Escape data for display in html
    foreach (array_keys((array) $domain) as $key) {
        $domain[$key] = htmlentities($domain[$key], ENT_QUOTES, $conf['php_charset']);
    }
    // Javascript to run after the window is built
    $window['js'] = <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        suggest_setup('domain_edit',     'suggest_domain_edit');
        el('{$window_name}_edit_form').onsubmit = function() { return false; };
        el('domain_name').focus();

EOL;
    // Define the window's inner html
    $window['html'] = <<<EOL

    <!-- Domain Edit Form -->
    <form id="{$window_name}_edit_form" onSubmit="return false;">
    <input type="hidden" name="id" value="{$domain['id']}">
    <input type="hidden" name="domain" value="{$domain['name']}">
    <input type="hidden" name="parent" value="{$domain['id']}">
    <input type="hidden" name="js" value="{$form['js']}">
    <table cellspacing="0" border="0" cellpadding="0" style="background-color: {$color['window_content_bg']}; padding-left: 20px; padding-right: 20px; padding-top: 5px; padding-bottom: 5px;">

        <!-- DOMAIN RECORD -->
        <tr>
            <td align="left" nowrap="true"><b><u>Domain Record</u></b>&nbsp;</td>
            <td class="padding" align="left" width="100%">&nbsp;</td>
        </tr>

        <tr>
            <td class="input_required" align="right" nowrap="true">
                Domain Name
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="domain_name"
                    name="name"
                    alt="Domain name"
                    value="{$domain['name']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Parent Domain
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    id="domain_edit"
                    name="parent"
                    alt="Parent Domain"
                    value="{$domain['parent']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
                <div id="suggest_domain_edit" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Primary Master
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="primary_master"
                    alt="Primary Master FQDN"
                    value="{$domain['primary_master']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Domain Admin
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="admin"
                    alt="Domain Admin"
                    value="{$domain['admin_email']}"
                    class="edit"
                    type="text"
                    size="30" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Refresh
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="refresh"
                    alt="Refresh"
                    value="{$domain['refresh']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Retry
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="retry"
                    alt="Retry"
                    value="{$domain['retry']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Expiry
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="expiry"
                    alt="Expiry"
                    value="{$domain['expiry']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Minimum (Neg cache)
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="minimum"
                    alt="Minimum/Negative Cache"
                    value="{$domain['minimum']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="255"
                >
            </td>
        </tr>

        <tr>
            <td align="right" nowrap="true">
                Default TTL
            </td>
            <td class="padding" align="left" width="100%">
                <input
                    name="default_ttl"
                    alt="Default TTL"
                    value="{$domain['default_ttl']}"
                    class="edit"
                    type="text"
                    size="17" maxlength="10"
                >
            </td>
        </tr>

        <tr>
            <td align="right" valign="top" nowrap="true">
                &nbsp;
            </td>
            <td class="padding" align="right" width="100%">
                <input type="hidden" name="overwrite" value="{$overwrite}">
                <input class="edit" type="button" name="cancel" value="Cancel" onClick="removeElement('{$window_name}');">
                <input class="edit" type="button"
                    name="submit"
                    value="Save"
                    accesskey=" "
                    onClick="xajax_window_submit('{$window_name}', xajax.getFormValues('{$window_name}_edit_form'), 'save');"
                >
            </td>
        </tr>

    </table>
    </form>
EOL;
    return window_open($window_name, $window);
}
Example #19
0
function ws_search_results_submit($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $font_family, $color, $style, $images;
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // We're building the window in $window and will use window_open() to create the window
    $window = array('title' => "Search Results", 'html' => "", 'js' => "");
    $max_img = "{$images}/silk/bullet_arrow_down.png";
    $min_img = "{$images}/silk/bullet_arrow_up.png";
    // Build subnet type list
    list($status, $rows, $records) = db_get_records($onadb, 'subnet_types', 'id >= 1', 'display_name');
    $subnet_type_list = '<option value="">&nbsp;</option>\\n';
    foreach ($records as $record) {
        $record['display_name'] = htmlentities($record['display_name']);
        $subnet_type_list .= "<option value=\"{$record['id']}\">{$record['display_name']}</option>\n";
    }
    // Build subnet type list
    if ($conf['dns_views']) {
        list($status, $rows, $records) = db_get_records($onadb, 'dns_views', 'id >= 0', 'name');
        $dns_view_list = '<option value="">&nbsp;</option>\\n';
        foreach ($records as $record) {
            $record['name'] = htmlentities($record['name']);
            $dns_view_list .= "<option value=\"{$record['name']}\">{$record['name']}</option>\n";
        }
    }
    // keep wildcard checkbox value
    if ($form['nowildcard']) {
        $wildchecked = 'checked="yes"';
    }
    // Load some html into $window['html']
    $form_id = "{$window_name}_filter_form";
    $content_id = $_SESSION['ona'][$form_id]['content_id'] = "{$window_name}_list";
    $window['html'] .= <<<EOL

    <!-- Tabs & Quick Filter -->
    <table id="{$form_id}_table" width="100%" cellspacing="0" border="0" cellpadding="0" style="{$style['borderT']} {$style['borderB']}">
        <tr>
            <td id="{$form_id}_blocks_tab" class="table-tab-inactive" onClick="xajax_window_submit('{$window_name}', 'form_id=>{$form_id},tab=>blocks', 'change_tab');">
                Blocks <span id="{$form_id}_blocks_count"></span>
            </td>

            <td id="{$form_id}_vlan_campus_tab" class="table-tab-inactive" onClick="xajax_window_submit('{$window_name}', 'form_id=>{$form_id},tab=>vlan_campus', 'change_tab');">
                Vlan campuses <span id="{$form_id}_vlan_campus_count"></span>
            </td>

            <td id="{$form_id}_subnets_tab" class="table-tab-inactive" onClick="xajax_window_submit('{$window_name}', 'form_id=>{$form_id},tab=>subnets', 'change_tab');">
                Subnets <span id="{$form_id}_subnets_count"></span>
            </td>

            <td id="{$form_id}_hosts_tab" class="table-tab-inactive" onClick="xajax_window_submit('{$window_name}', 'form_id=>{$form_id},tab=>hosts', 'change_tab');">
                Hosts <span id="{$form_id}_hosts_count"></span>
            </td>

            <td id="{$form_id}_records_tab" class="table-tab-inactive" onClick="xajax_window_submit('{$window_name}', 'form_id=>{$form_id},tab=>records', 'change_tab');">
                DNS records <span id="{$form_id}_records_count"></span>
            </td>

            <td style="vertical-align: middle;" class="padding" nowrap="true">
                <img id="adv_search_img" src="{$min_img}" />
                <span id="adv_search_div_toggle"
                    style="text-align: right;"
                    title="Min/Max"
                    onclick="if (el('adv_search_div').style.display=='none') {
                                el('adv_search_div').style.display='';
                                el('toggle_text').innerHTML='Hide search form';
                                el('adv_search_img').src='{$min_img}';
                            } else {
                                el('adv_search_div').style.display='none';
                                el('toggle_text').innerHTML='Show search form';
                                el('adv_search_img').src='{$max_img}';}" >
                <span id="toggle_text" style="font-size: xx-small;">Hide search form</span>
                </span>
            </td>

            <td id="{$form_id}_quick_filter" class="padding" align="right" width="100%">
                <form id="{$form_id}" onSubmit="return false;">
                <input id="{$form_id}_page" name="page" value="1" type="hidden">
                <input id="{$form_id}_tab" name="tab" value="" type="hidden">
                <input name="content_id" value="{$content_id}" type="hidden">
                <input name="form_id" value="{$form_id}" type="hidden">
                    <div id="{$form_id}_filter_overlay"
                         style="position: relative;
                                display: inline;
                                color: #CACACA;
                                cursor: text;"
                         onClick="this.style.display = 'none'; el('{$form_id}_filter').focus();"
                    >Filter</div>
                <input
                    id="{$form_id}_filter"
                    name="filter"
                    class="filter"
                    type="text"
                    value=""
                    size="10"
                    maxlength="20"
                    alt="Quick Filter"
                    onFocus="el('{$form_id}_filter_overlay').style.display = 'none';"
                    onBlur="if (this.value == '') el('{$form_id}_filter_overlay').style.display = 'inline';"
                    onKeyUp="
                        if (typeof(timer) != 'undefined') clearTimeout(timer);
                        code = 'if ({$form_id}_last_search != el(\\'{$form_id}_filter\\').value) {' +
                               '    {$form_id}_last_search = el(\\'{$form_id}_filter\\').value;' +
                               '    el(\\'{$form_id}_page\\').value = 1;' +
                               '    xajax_window_submit(\\'list_\\' + el(\\'{$form_id}_tab\\').value, xajax.getFormValues(\\'{$form_id}\\'), \\'display_list\\');' +
                               '}';
                        timer = setTimeout(code, 700);"
                >
                </form>
            </td>

        </tr>
    </table>

    <div id="adv_search_div" style="background-color: {$color['window_content_bg']};padding-top: 5px;">
    <!-- Block Search Tab -->
    <form id="block_search_form">
    <input type="hidden" name="search_form_id" value="block_search_form">
    <table id="blocks_search" style="display: none;" cellspacing="0" border="0" cellpadding="0">

    <tr>
        <td align="right" class="asearch-line">
            <u>B</u>lock name
        </td>
        <td align="left" class="asearch-line">
            <input id="blocks_field1" name="blockname" type="text" class="edit" size="35" accesskey="b" value="{$form['blockname']}" />
            <div id="suggest_hostname" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            &nbsp;
        </td>
        <td align="right" class="asearch-line">
            <input class="button" type="button" name="clear" value="Clear" onClick="clearElements('block_search_form');">
            <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="xajax_window_submit('search_results', xajax.getFormValues('block_search_form'));">
        </td>
    </tr>

    </table>
    </form>


    <!-- Vlan Campus Search Tab -->
    <form id="vlan_campus_search_form">
    <input type="hidden" name="search_form_id" value="vlan_campus_search_form">
    <table id="vlan_campus_search" style="display: none;" cellspacing="0" border="0" cellpadding="0">

    <tr>
        <td align="right" class="asearch-line">
            <u>C</u>ampus name
        </td>
        <td align="left" class="asearch-line">
            <input id="vlan_campus_field1" name="campusname" type="text" class="edit" size="35" accesskey="c" value="{$form['campusname']}" />
            <div id="suggest_hostname" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            &nbsp;
        </td>
        <td align="right" class="asearch-line">
            <input class="button" type="button" name="clear" value="Clear" onClick="clearElements('vlan_campus_search_form');">
            <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="xajax_window_submit('search_results', xajax.getFormValues('vlan_campus_search_form'));">
        </td>
    </tr>

    </table>
    </form>



    <!-- Host Search Tab -->
    <form id="host_search_form">
    <input type="hidden" name="search_form_id" value="host_search_form">
    <table id="hosts_search" style="display: none;" cellspacing="0" border="0" cellpadding="0">

    <tr>
     <td>
      <table cellspacing="0" border="0" cellpadding="0">
        <tr>
            <td align="right" class="asearch-line">
                <u>H</u>ostname
            </td>
            <td align="left" class="asearch-line">
                <input id="hosts_field1" name="hostname" type="text" class="edit" size="35" accesskey="h" value="{$form['hostname']}" />
                <div id="suggest_hostname" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                Subdomain (<u>z</u>one)
            </td>
            <td align="left" class="asearch-line">
                <input id="domain" name="domain" type="text" class="edit" size="35" accesskey="z" value="{$form['domain']}" />
                <div id="suggest_domain" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>M</u>AC
            </td>
            <td align="left" class="asearch-line">
                <input id="mac" name="mac" type="text" class="edit" size="17" accesskey="m" value="{$form['mac']}" />
                <div id="suggest_mac" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>I</u>P Address
            </td>
            <td align="left" class="asearch-line" nowrap="true">
                <input id="ip" name="ip" type="text" class="edit" size="15" accesskey="i" value="{$form['ip']}" />
                <div id="suggest_ip" class="suggest"></div>
                thru
                <input id="ip_thru" name="ip_thru" class="edit" type="text" size="15" value="{$form['ip_thru']}">
                <div id="suggest_ip_thru" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>N</u>otes
            </td>
            <td align="left" class="asearch-line">
                <input id="notes" name="notes" type="text" class="edit" size="17" accesskey="n" value="{$form['notes']}" />
                <div id="suggest_notes" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>L</u>ocation Ref
            </td>
            <td align="left" class="asearch-line">
                <input id="location" class="edit" type="text" name="location" size="8" accesskey="l" value="{$form['location']}" />
                <span id="qf_location_{$window_name}"><img src="{$images}/silk/find.png" border="0"/></span>
                <div id="suggest_location" class="suggest"></div>
            </td>
        </tr>

      </table>

    </td>
    <td>

      <table cellspacing="0" border="0" cellpadding="0">

        <tr>
            <td align="right" class="asearch-line">
                <u>C</u>ustom attribute
            </td>
            <td align="left" class="asearch-line">
                <input id="custom_attribute_type" type="text" name="custom_attribute_type" size="20" class="edit" accesskey="c" value="{$form['custom_attribute_type']}">
                <div id="suggest_custom_attribute_type" class="suggest"></div>
                <u>V</u>alue
                <input id="ca_value" name="ca_value" type="text" class="edit" size="15" accesskey="v" value="{$form['ca_value']}"/>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                Device mode<u>l</u>
            </td>
            <td align="left" class="asearch-line">
                <input id="model" type="text" name="model" class="edit" size="20" accesskey="l" value="{$form['model']}">
                <div id="suggest_model" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                Device <u>t</u>ype Role
            </td>
            <td align="left" class="asearch-line">
                <input id="role" type="text" name="role" class="edit" size="20" accesskey="t" value="{$form['role']}">
                <div id="suggest_role" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                Device man<u>u</u>facturer
            </td>
            <td align="left" class="asearch-line">
                <input id="manufacturer" type="text" name="manufacturer" class="edit" size="20" accesskey="u" value="{$form['manufacturer']}">
                <div id="suggest_manufacturer" class="suggest"></div>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>T</u>ag
            </td>
            <td align="left" class="asearch-line">
                <input id="tag_host" type="text" name="tag_host" size="20" class="edit" accesskey="t" value="{$form['tag_host']}">
                <div id="suggest_tag_host" class="suggest"></div>
            </td>
        </tr>

      </table>

    </td>
    </tr>

    <tr>
        <td colspan=4 align="right" class="asearch-line">
            Disable Wildcards: <input class="button" type="checkbox" name="nowildcard" {$wildchecked} title="Disable usage of SQL wildcards in queries, you must supply your own in the search form as needed.">
            <input class="button" type="button" name="reset" value="Clear" onClick="clearElements('host_search_form');">
            <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="xajax_window_submit('search_results', xajax.getFormValues('host_search_form'));">
        </td>
    </tr>

    </table>
    </form>




    <!-- DNS record Search Tab -->
    <form id="dns_record_search_form">
    <input type="hidden" name="search_form_id" value="dns_record_search_form">
    <table id="records_search" style="display: none;" cellspacing="0" border="0" cellpadding="0">

EOL;
    // Display view dropdown
    if ($conf['dns_views']) {
        $window['html'] .= <<<EOL
    <tr>
        <td align="right" class="asearch-line">
            DNS <u>V</u>iew
        </td>
        <td align="left" class="asearch-line">
            <select id="dns_view" name="dns_view" class="edit" accesskey="v" >
                {$dns_view_list}
            </select>
        </td>
    </tr>
EOL;
    }
    $window['html'] .= <<<EOL
    <tr>
        <td align="right" class="asearch-line">
            <u>H</u>ostname
        </td>
        <td align="left" class="asearch-line">
            <input id="records_field1" name="hostname" type="text" class="edit" size="35" accesskey="h" value="{$form['hostname']}" />
            <div id="suggest_hostname" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            Subdomain (<u>z</u>one)
        </td>
        <td align="left" class="asearch-line">
            <input id="dns_domain" name="domain" type="text" class="edit" size="35" accesskey="z" value="{$form['domain']}" />
            <div id="suggest_dns_domain" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            Type
        </td>
        <td align="left" class="asearch-line">
            <select id="dnstype" name="dnstype" class="edit" accesskey="u" >
                <option></option>
                <option>A</option>
                <option>CNAME</option>
                <option>NS</option>
                <option>PTR</option>
                <option>MX</option>
                <option>SRV</option>
                <option>TXT</option>
            </select>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            <u>I</u>P Address
        </td>
        <td align="left" class="asearch-line" nowrap="true">
            <input id="dns_ip" name="ip" type="text" class="edit" size="15" accesskey="i" value="{$form['ip']}" />
            <div id="suggest_dns_ip" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            <u>N</u>otes
        </td>
        <td align="left" class="asearch-line">
            <input id="notes" name="notes" type="text" class="edit" size="17" accesskey="n" value="{$form['notes']}" />
            <div id="suggest_notes" class="suggest"></div>
        </td>
    </tr>


    <tr>
        <td align="right" class="asearch-line">
            &nbsp;
        </td>
        <td align="right" class="asearch-line">
            Disable Wildcards: <input class="button" type="checkbox" name="nowildcard" {$wildchecked} title="Disable usage of SQL wildcards in queries, you must supply your own in the search form as needed.">
            <input class="button" type="button" name="clear" value="Clear" onClick="clearElements('dns_record_search_form');">
            <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="xajax_window_submit('search_results', xajax.getFormValues('dns_record_search_form'));">
        </td>
    </tr>

    </table>
    </form>

    <!-- END DNS record Search Tab -->



    <!-- subnet Search Tab -->
    <form id="subnet_search_form">
    <input type="hidden" name="search_form_id" value="subnet_search_form">
    <table id="subnets_search" style="display: none;" cellspacing="0" border="0" cellpadding="0">

    <tr>
        <td align="right" class="asearch-line">
            <u>V</u>lan
        </td>
        <td align="left" class="asearch-line">
            <input id="subnets_field1" name="vlandesc" type="text" class="edit" size="32" accesskey="v" value="{$form['vlandesc']}" />
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            Subnet <u>T</u>ype
        </td>
        <td align="left" class="asearch-line">
            <select id="nettype" name="nettype" class="edit" accesskey="u" accesskey="t" >
                {$subnet_type_list}
            </select>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            Subnet <u>N</u>ame
        </td>
        <td align="left" class="asearch-line">
            <input id="subnet" name="subnetname" type="text" class="edit" size="32" accesskey="n" value="{$form['subnetname']}" />
            <div id="suggest_subnet" class="suggest"></div>
        </td>
    </tr>

    <tr>
        <td align="right" class="asearch-line">
            <u>I</u>P Address
        </td>
        <td align="left" class="asearch-line" nowrap="true">
            <input id="ip_subnet" name="ip_subnet" class="edit" type="text" size="15" accesskey="i" value="{$form['ip_subnet']}" />
            <div id="suggest_ip_subnet" class="suggest"></div>
            thru
            <input id="ip_subnet_thru" name="ip_subnet_thru" class="edit" type="text" size="15" value="{$form['ip_subnet_thru']}" />
            <div id="suggest_ip_subnet_thru" class="suggest"></div>
        </td>
    </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>C</u>ustom attribute
            </td>
            <td align="left" class="asearch-line">
                <input id="custom_attribute_type_net" type="text" name="custom_attribute_type_net" size="20" class="edit" value="{$form['custom_attribute_type_net']}">
                <div id="suggest_custom_attribute_type_net" class="suggest"></div>
                <u>V</u>alue
                <input id="ca_value_net" name="ca_value_net" type="text" class="edit" size="15" value="{$form['ca_value_net']}"/>
            </td>
        </tr>

        <tr>
            <td align="right" class="asearch-line">
                <u>T</u>ag
            </td>
            <td align="left" class="asearch-line">
                <input id="tag_net" type="text" name="tag_net" size="20" class="edit" accesskey="t" value="{$form['tag_net']}">
                <div id="suggest_tag_net" class="suggest"></div>
            </td>
        <tr>

    <tr>
        <td align="right" class="asearch-line">
            &nbsp;
        </td>
        <td align="right" class="asearch-line">
            Disable Wildcards: <input class="button" type="checkbox" name="nowildcard" {$wildchecked} title="Disable usage of SQL wildcards in queries, you must supply your own in the search form as needed.">
            <input class="button" type="button" name="reset" value="Clear" onClick="clearElements('subnet_search_form');">
            <input class="button" type="button" name="search" value="Search" accesskey="s" onClick="xajax_window_submit('search_results', xajax.getFormValues('subnet_search_form'));">
        </td>
    </tr>

    </table>
    </form>
    <center><span style="font-weight: bold;color: green; font-size: small;" id="search_results_msg"></span></center>
    </div>

    <!-- Item List -->
    <div id="{$content_id}">{$conf['loading_icon']}</div>
EOL;
    //TODO: this is a test I did on having a click focus bring up the full list of entries.. kinda like a dropdown dialog..
    //onfocus="suggest_display('role', 'suggest_role');searchKeyDown('37', el('role'), 'suggest_role');"
    // Before we can let the browser call "display_list"
    // we need to make sure we know what type of list we'll be displaying
    switch ($form['search_form_id']) {
        case 'host_search_form':
            $tab = 'hosts';
            break;
        case 'subnet_search_form':
            $tab = 'subnets';
            break;
        case 'block_search_form':
            $tab = 'blocks';
            break;
        case 'vlan_campus_search_form':
            $tab = 'vlan_campus';
            break;
        case 'dns_record_search_form':
            $tab = 'records';
            break;
        case 'qsearch_form':
            // If the quick search begins with a "/" it's a command
            if (strpos($form['q'], '/') === 0) {
                $form['q'] = substr($form['q'], 1);
                return qsearch_command($form['q']);
            }
            // We (unfortunately) have to do a few sql queries to see what kind of
            // search this is and what "tab" we'll be displaying data on.
            list($tab, $form) = quick_search($form['q']);
            break;
    }
    // Save a few things in the session (the search query, page, and tab)
    $_SESSION['ona'][$form_id]['tab'] = $tab;
    $_SESSION['ona'][$form_id][$tab]['q'] = $form;
    // A little javascript for the browser to run once we've created the window
    $window['js'] .= <<<EOL
        /* Put a minimize icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Put a help icon in the title bar */
        el('{$window_name}_title_r').innerHTML =
            '&nbsp;<a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
            el('{$window_name}_title_r').innerHTML;

        /* Setup the quick filter */
        el('{$form_id}_filter_overlay').style.left = (el('{$form_id}_filter_overlay').offsetWidth + 10) + 'px';
        {$form_id}_last_search = '';

        /* Save the new tab and make it look active */
        el('{$form_id}_tab').value = '{$tab}';
        el('{$form_id}_{$tab}_tab').className = 'table-tab-active';
        el('{$tab}_search').style.display = 'block';

        /* make the first field have focus */
        el('{$tab}_field1').focus();

        suggest_setup('hosts_field1', 'suggest_hostname');
        suggest_setup('domain',     'suggest_domain');
        suggest_setup('dns_domain', 'suggest_dns_domain');
        suggest_setup('mac',      'suggest_mac');
        suggest_setup('ip',       'suggest_ip');
        suggest_setup('dns_ip',   'suggest_dns_ip');
        suggest_setup('ip_thru',  'suggest_ip_thru');
        suggest_setup('notes',    'suggest_notes');
        suggest_setup('ip_subnet', 'suggest_ip_subnet');
        suggest_setup('ip_subnet_thru',  'suggest_ip_subnet_thru');
        suggest_setup('subnet', 'suggest_subnet');
        suggest_setup('location', 'suggest_location');
        suggest_setup('custom_attribute_type', 'suggest_custom_attribute_type');
        suggest_setup('custom_attribute_type_net', 'suggest_custom_attribute_type_net');
        suggest_setup('role', 'suggest_role');
        suggest_setup('model', 'suggest_model');
        suggest_setup('manufacturer', 'suggest_manufacturer');
        suggest_setup('tag_host', 'suggest_tag_host');
        suggest_setup('tag_net', 'suggest_tag_net');


        el('host_search_form').onsubmit = function() { return false; };
        el('subnet_search_form').onsubmit = function() { return false; };

        /* Setup the Quick Find location icon */
        var _button = el('qf_location_{$window_name}');
        _button.style.cursor = 'pointer';
        _button.onclick =
            function(ev) {
                if (!ev) ev = event;
                /* Create the popup div */
                wwTT(this, ev,
                     'id', 'tt_qf_location_{$window_name}',
                     'type', 'static',
                     'direction', 'south',
                     'delay', 0,
                     'styleClass', 'wwTT_qf',
                     'javascript',
                     "xajax_window_submit('tooltips', '" +
                         "tooltip=>qf_location," +
                         "id=>tt_qf_location_{$window_name}," +
                         "input_id=>qf_location_{$window_name}');"
                );
            };

        /* Display the list of results */
        xajax_window_submit('list_' + el('{$form_id}_tab').value, xajax.getFormValues('{$form_id}'), 'display_list');



EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}
Example #20
0
function ws_work_space_submit($window_name, $javascript = '')
{
    global $conf, $self, $color, $style, $images;
    /****     UPDATE THIS WINDOW'S "HISTORY"     ****/
    if (!is_array($_SESSION['ona'][$window_name]['history'])) {
        $_SESSION['ona'][$window_name]['history'] = array();
    }
    // Get the "URL" and it's "Title"
    $title = '';
    if (preg_match("/xajax_window_submit\\('([^']+)'/", $javascript, $matches)) {
        $title = $matches[1];
    }
    // Remove old history items that are duplicates of the current "URL"
    $new_history = array();
    foreach ($_SESSION['ona'][$window_name]['history'] as $history) {
        if ($history['url'] != $javascript) {
            array_push($new_history, $history);
        }
    }
    $_SESSION['ona'][$window_name]['history'] = $new_history;
    // Add the current "URL"
    array_push($_SESSION['ona'][$window_name]['history'], array('title' => $title, 'type' => $title, 'url' => $javascript));
    // If there are to many url's in the history, trim some.
    while (count($_SESSION['ona'][$window_name]['history']) > 7) {
        array_shift($_SESSION['ona'][$window_name]['history']);
    }
    // We're building the window in $window and will use window_open() to create the window
    $window = array('title' => "Search Results", 'html' => "", 'js' => "");
    // Set the window title:
    $window['title'] = "Work Space";
    // Define javascript to run after the window is created
    $window['js'] .= <<<EOL

    /* Hide the 'Search Results' box if it's visible */
    var _el = el('search_results');
    if (_el && (_el.style.visibility == 'visible' || _el.style.display == 'block')) {
        _el.style.visibility = "hidden";
        _el.style.display = "none";
    }

    var _el = el('{$window_name}');

    /* Get the size of the box we live 'in' */
    var content_top    = calcOffset(el('content_table'), 'offsetTop');
    var content_left   = calcOffset(el('content_table'), 'offsetLeft');
    var content_width  = el('content_table').offsetWidth;
    var content_height = el('content_table').offsetHeight;

    /* Now calculate where we will sit .. the -4 and -2 are for borders */
    var my_top  = content_top;
    var my_left  = content_left;
    var my_width  = '100%';
    var my_height = document.body.clientHeight - el('bar_top').clientHeight - el('trace_history').clientHeight;
    if (browser.isIE) {
        my_height += 2;
    }

    /* Finally reposition/resize the window, hide any overflow, and bring it up behind other windows. */
    _el.style.top    = my_top    + 'px';
    _el.style.left   = my_left   + 'px';
    _el.style.width  = my_width ;
    _el.style.height = my_height + 'px';
    _el.style.zIndex = 1;
    _el.style.overflow = 'hidden';

    /* Now disable the drag library from moving this 'window' */
    el('{$window_name}').onclick = function() { return true; };
    el('{$window_name}_title').onmousedown = function() { return true; };
    el('{$window_name}_title').style.cursor = 'default';

    /* Make sure the title bar goes all the way across */
    el('{$window_name}_title_table').style.width = my_width  ;

    /* Gray the title bar */
    el('{$window_name}_title_table').className = '';
    el('{$window_name}_title_table').style.backgroundColor = '#A6A6A6';
    el('{$window_name}_title_table').style.borderBottom = 'none';
    el('{$window_name}_title').style.color = '#F0F0F0';

    /* Make the content peice scroll */
    _el = el('{$window_name}_content');
    _el.style.width  = my_width  ;
    _el.style.height = (my_height - el('{$window_name}_title').offsetHeight - 4 ) + 'px';
    _el.style.overflow = 'auto';

    {$javascript}

    el('{$window_name}').style.border='0px';

    el('work_space').setAttribute('wsname', '{$title}');

EOL;
    // Define the window's inner html -
    $window['html'] .= <<<EOL

    </div>

    <div id="{$window_name}_content">
        <br><br><br><br><center><img src="{$images}/loading.gif" /></center>
    </div>

EOL;
    // Lets build a window and display the results
    return window_open($window_name, $window);
}