Example #1
0
/**
 * guifi_node_graph_overview
 * outputs an overiew graph of the node
**/
function theme_guifi_node_graphs_overview($node, $links = FALSE)
{
    $gs = guifi_service_load(guifi_graphs_get_server($node->id, 'node'));
    $radios = array();
    $query = db_query("SELECT * FROM {guifi_radios} WHERE nid=%d", $node->id);
    while ($radio = db_fetch_array($query)) {
        $radios[] = $radio;
    }
    // print "Count radios: ".count($radios)."\n<br />";
    if (count($radios) > 1) {
        if (substr($gs->var['url'], 0, 3) == "fot") {
            //  graph all devices.about a node. Ferran Ot
            while ($radio = db_fetch_object($query)) {
                $ssid = get_SSID_radio($radio->id);
                $ssid = strtolower($ssid);
                $mrtg_url = substr($gs->var['url'], 3);
                $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg" target="_blank"> <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg&png=weekly"></a>');
                $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg" target="_blank"> <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg&png=weekly"></a>');
            }
            $ret = array_merge($rows);
        } else {
            $args = array('type' => 'supernode', 'node' => $node->id);
            //      $args = sprintf('type=supernode&node=%d&direction=',$node->id);
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=in') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=in') . '"></a>', 'align' => 'center'));
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=out') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=out') . '"></a>', 'align' => 'center'));
            //      $rows[] = array(
            //      guifi_cnml_call_service($gs->var['url'],'graph',$args,'direction=in'sprintf('<a href="'.base_path().'guifi/graph_detail?'.$args.'in"><img src="'.$gs->var['url'].'?'.$args.'in"></a>',$node->id));
            //      $rows[] = array(sprintf('<a href="'.base_path().'guifi/graph_detail?'.$args.'out"><img src="'.$gs->var['url'].'?'.$args.'out"></a>',$node->id));
            $ret = array_merge($rows);
        }
    } else {
        if (count($radios) == 1) {
            $ret = guifi_device_graph_overview($radios[0]);
        }
    }
    $output = theme('table', NULL, $ret);
    if ($links) {
        $node = node_load(array('nid' => $node->id));
        drupal_set_title(t('graph overview @ %node', array('%node' => $node->title)));
        drupal_set_breadcrumb(guifi_node_ariadna($node));
        $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
        print theme('page', $output, FALSE);
        return;
    }
    return $output;
}
/**
 * guifi_device_graph_overview
 * outputs an overiew graph of the device
**/
function guifi_device_graph_overview($radio)
{
    guifi_log(GUIFILOG_TRACE, 'guifi_device_graph_overview()', $radio);
    if (isset($radio['mode'])) {
        $radio['type'] = 'radio';
    }
    if ($radio['graph_server'] == -1) {
        $rows[] = array(t('This device has the graphs disabled.'));
        return array_merge($rows);
    }
    if (empty($radio['graph_server'])) {
        $gs = guifi_service_load(guifi_graphs_get_server($radio['id'], 'device'));
    } else {
        $gs = guifi_service_load($radio['graph_server']);
    }
    if (substr($server_mrtg, 0, 3) == "fot") {
        $ssid = get_SSID_radio($radio['id']);
        $ssid = strtolower($ssid);
        $mrtg_url = substr($server_mrtg, 3);
        $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg" target="_blank" > <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg&png=weekly"></a>');
        $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg" target="_blank" > <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg&png=weekly"></a>');
        return array_merge($rows);
    } else {
        $clients = db_fetch_object(db_query("SELECT count(c.id) count " . "FROM {guifi_links} c " . "WHERE c.device_id=%d " . "  AND c.link_type IN ('wds','ap/client','bridge')", $radio['id']));
        $args = array('type' => 'clients', 'node' => $radio['nid'], 'device' => $radio['id']);
        if ($clients->count > 1) {
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=in') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=in') . '"></a>', 'align' => 'center'));
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=out') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=out') . '"></a>', 'align' => 'center'));
        } else {
            if ($radio['type'] == 'radio' or $radio['variable']['mrtg_index'] != '') {
                $args['type'] = 'device';
                $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args) . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args) . '"></a>', 'align' => 'center'));
            }
        }
        $args['type'] = 'pings';
        $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args) . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args) . '"></a>', 'align' => 'center'));
        return array_merge($rows);
    }
}