Ejemplo n.º 1
0
/**
 * Displays the page header
 *
 * @since 1.0
 * @package facileManager
 *
 * @param string $response Page form response
 * @param string $title The page title
 * @param bool $allowed_to_add Whether the user can add new
 * @param string $name Name value of plus sign
 * @param string $rel Rel value of plus sign
 * @return string
 */
function printPageHeader($response = null, $title = null, $allowed_to_add = false, $name = null, $rel = null)
{
    global $__FM_CONFIG;
    if (empty($title)) {
        $title = getPageTitle();
    }
    echo '<div id="body_container">' . "\n";
    if (!empty($response)) {
        echo '<div id="response"><p class="error">' . $response . "</p></div>\n";
    } else {
        echo '<div id="response" style="display: none;"></div>' . "\n";
    }
    echo '<h2>' . $title;
    if ($allowed_to_add) {
        echo displayAddNew($name, $rel);
    }
    echo '</h2>' . "\n";
}
Ejemplo n.º 2
0
    function displayRow($row, $map, $reload_allowed)
    {
        global $fmdb, $__FM_CONFIG;
        if (!currentUserCan(array('access_specific_zones', 'view_all'), $_SESSION['module'], array(0, $row->domain_id))) {
            return;
        }
        $zone_access_allowed = zoneAccessIsAllowed(array($row->domain_id));
        if ($row->domain_status == 'disabled') {
            $classes[] = 'disabled';
        }
        $response = $add_new = null;
        $checkbox = currentUserCan('reload_zones', $_SESSION['module']) ? '<td></td>' : null;
        $soa_count = getSOACount($row->domain_id);
        $ns_count = getNSCount($row->domain_id);
        $reload_allowed = reloadAllowed($row->domain_id);
        if (!$soa_count && $row->domain_type == 'master') {
            $response = __('The SOA record still needs to be created for this zone');
            $classes[] = 'attention';
        }
        if (!$ns_count && $row->domain_type == 'master' && !$response) {
            $response = __('One more more NS records still needs to be created for this zone');
            $classes[] = 'attention';
        }
        if ($row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            global $map;
            $add_new = displayAddNew($map, $row->domain_id, __('Clone this zone'), 'fa-plus-square-o');
        }
        $clones = $this->cloneDomainsList($row->domain_id);
        $clone_names = $clone_types = $clone_views = $clone_counts = null;
        foreach ($clones as $clone_id => $clone_array) {
            $clone_names .= '<p class="clone' . $clone_id . '"><a href="' . $clone_array['clone_link'] . '" title="' . __('Edit zone records') . '">' . $clone_array['clone_name'] . '</a>' . $clone_array['clone_edit'] . $clone_array['clone_delete'] . "</p>\n";
            $clone_types .= '<p class="clone' . $clone_id . '">' . __('clone') . '</p>' . "\n";
            $clone_views .= '<p class="clone' . $clone_id . '">' . $this->IDs2Name($clone_array['clone_views'], 'view') . "</p>\n";
            $clone_counts_array = explode('|', $clone_array['clone_count']);
            $clone_counts .= '<p class="clone' . $clone_id . '" title="' . __('Differences from parent zone') . '">';
            if ($clone_counts_array[0]) {
                $clone_counts .= '<span class="record-additions">' . $clone_counts_array[0] . '</span>&nbsp;';
            }
            if ($clone_counts_array[1]) {
                $clone_counts .= '&nbsp;<span class="record-subtractions">' . $clone_counts_array[1] . '</span> ';
            }
            if (!array_sum($clone_counts_array)) {
                $clone_counts .= '-';
            }
            $clone_counts .= "</p>\n";
        }
        if ($clone_names) {
            $classes[] = 'clones';
        }
        if ($soa_count && $row->domain_reload == 'yes' && $reload_allowed) {
            if (currentUserCan('reload_zones', $_SESSION['module']) && $zone_access_allowed) {
                $reload_zone = '<form name="reload" id="' . $row->domain_id . '" method="post" action="' . $GLOBALS['basename'] . '?map=' . $map . '"><input type="hidden" name="action" value="reload" /><input type="hidden" name="domain_id" id="domain_id" value="' . $row->domain_id . '" />' . $__FM_CONFIG['icons']['reload'] . '</form>';
                $checkbox = '<td><input type="checkbox" name="domain_list[]" value="' . $row->domain_id . '" /></td>';
            } else {
                $reload_zone = __('Reload Available') . '<br />';
            }
        } else {
            $reload_zone = null;
        }
        if ($reload_zone) {
            $classes[] = 'build';
        }
        /*
        		$edit_status = <<<FORM
        <form method="post" action="{$GLOBALS['basename']}?map={$map}">
        	<input type="hidden" name="action" value="download" />
        	<input type="hidden" name="domain_id" value="{$row->domain_id}" />
        	{$__FM_CONFIG['icons']['export']}
        	</form>
        FORM;
        */
        $edit_status = null;
        if (!$soa_count && $row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            $type = 'SOA';
        } elseif (!$ns_count && $row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            $type = 'NS';
        } else {
            $type = $row->domain_mapping == 'forward' ? 'A' : 'PTR';
        }
        if ($soa_count && $ns_count && $row->domain_type == 'master') {
            $edit_status = '<a href="preview.php" onclick="javascript:void window.open(\'preview.php?server_serial_no=-1&config=zone&domain_id=' . $row->domain_id . '\',\'1356124444538\',\'width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0\');return false;">' . $__FM_CONFIG['icons']['preview'] . '</a>';
        }
        if (currentUserCan('manage_zones', $_SESSION['module']) && $zone_access_allowed) {
            $edit_status .= '<a class="edit_form_link" name="' . $map . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="delete" href="#">' . $__FM_CONFIG['icons']['delete'] . '</a>' . "\n";
        }
        $domain_name = displayFriendlyDomainName($row->domain_name);
        $edit_name = $row->domain_type == 'master' ? "<a href=\"zone-records.php?map={$map}&domain_id={$row->domain_id}&record_type={$type}\" title=\"" . __('Edit zone records') . "\">{$domain_name}</a>" : $domain_name;
        $domain_view = $this->IDs2Name($row->domain_view, 'view');
        $class = 'class="' . implode(' ', $classes) . '"';
        $record_count = null;
        if ($row->domain_type == 'master') {
            $query = "SELECT COUNT(*) record_count FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}records WHERE account_id={$_SESSION['user']['account_id']} AND domain_id={$row->domain_id} AND record_status!='deleted'";
            $fmdb->query($query);
            $record_count = $fmdb->last_result[0]->record_count;
        }
        $template_icon = ($domain_template_id = getNameFromID($row->domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) ? sprintf('<i class="template-icon fa fa-picture-o" title="%s"></i>', sprintf(__('Based on %s'), getNameFromID($domain_template_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name'))) : null;
        echo <<<HTML
\t\t<tr title="{$response}" id="{$row->domain_id}" {$class}>
\t\t\t{$checkbox}
\t\t\t<td>{$row->domain_id}</td>
\t\t\t<td><b>{$edit_name}</b> {$template_icon} {$add_new} {$clone_names}</td>
\t\t\t<td>{$row->domain_type}
\t\t\t\t{$clone_types}</td>
\t\t\t<td>{$domain_view}
\t\t\t\t{$clone_views}</td>
\t\t\t<td align="center">{$record_count}
\t\t\t\t{$clone_counts}</td>
\t\t\t<td id="edit_delete_img">
\t\t\t\t{$reload_zone}
\t\t\t\t{$edit_status}
\t\t\t</td>
\t\t</tr>

HTML;
    }