コード例 #1
0
function guifi_device_print_data($device)
{
    $radios = db_query('SELECT *
       FROM {guifi_radios}
       WHERE id=%d
       ORDER BY id', $device['id']);
    $rows[] = array(t($device[type]), '<b>' . $device[nick] . '</b>');
    if (count($device['funders'])) {
        $rows[] = array(count($device['funders']) == 1 ? t('Funder') : t('Funders'), implode(', ', guifi_funders_links($device['funders'])));
    }
    if (count($device['maintainers'])) {
        $rows[] = array(t('Maintenance & SLAs'), implode(', ', guifi_maintainers_links($device['maintainers'])));
    }
    // If radio, print model & firmware
    if ($device['type'] == 'radio') {
        $rows[] = array($device[manufacturer] . '-' . $device[model], $device[variable][firmware]);
        // going to list all device radios
        if (count($device['radios'])) {
            foreach ($device['radios'] as $radio_id => $radio) {
                if ($radio['fund_required'] == '') {
                    $policy = t('n/d, ask to node contacts');
                } else {
                    if ($radio['fund_required'] == 'yes') {
                        $policy = t('Fund: :fund :curr', array(':fund' => $radio['fund_amount'], ':curr' => $radio['fund_currency']));
                    } else {
                        $policy = t($radio['fund_required']);
                    }
                }
                $rowsr[] = array($radio['ssid'], $radio['mode'], $radio['protocol'], $radio['channel'], $radio['mac'], t($radio['clients_accepted']), $policy);
            }
            $rows[] = array(array('data' => theme('table', array(t('ssid'), t('mode'), t('protocol'), t('ch'), t('wireless mac'), t('clients'), t('connection policy')), $rowsr), 'colspan' => 2));
        }
    }
    // If ADSL, print characteristics
    if ($device['type'] == 'ADSL' and $device['variable'] != '') {
        $bandwidth = guifi_bandwidth_types();
        $rows[] = array(t('bandwidth'), $bandwidth[$device['variable']['download']] . '/' . $bandwidth[$device['variable']['upload']]);
        $rows[] = array(t('SNMP index to graph'), $device['variable']['mrtg_index']);
    }
    // Others with modelDescr set
    if (isset($device['variable']['modelDescr'])) {
        switch ($device['type']) {
            case 'ups':
                $vDescr = t('Power: %power', array('%power' => $device['variable']['specs']));
                break;
            case 'generator':
                $vDescr = t('Max Power: %power Watts', array('%power' => $device['variable']['specs']));
                break;
            case 'battery':
                $vDescr = t('Power: %power/Ah, Quantity: %quantity', array('%power' => $device['variable']['specs'], '%quantity' => $device['variable']['units']));
                break;
            case 'rack':
                $vDescr = t('Height: %height Us, Width: %width inches, Depth: %depth mm', array('%height' => $device['variable']['height'], '%width' => $device['variable']['width'], '%depth' => $device['variable']['depth']));
                break;
            case 'breaker':
                $vDescr = t('Protection: %cbtype, Auto-reclose: %recloser', array('%cbtype' => $device['variable']['cbtype'], '%recloser' => $device['variable']['recloser'] ? t('Yes') : t('No')));
                break;
        }
        $rows[] = array($device['variable']['modelDescr'], $vDescr);
    }
    // generic
    if ($device['type'] == 'generic' || 'confine' and !empty($device['variable']['mrtg_index'])) {
        $rows[] = array(t('SNMP index to graph'), $device['variable']['mrtg_index']);
    }
    if ($device['graph_server'] > 0) {
        $gs = node_load(array('nid' => $device['graph_server']));
    } else {
        $gs = node_load(array('nid' => guifi_graphs_get_server($device['id'], 'device')));
    }
    $rows[] = array(t('graphs provided from'), array('data' => l(guifi_service_str($device['graph_server']), $gs->l, array('attributes' => array('title' => $gs->nick . ' - ' . $gs->title))), 'colspan' => 2));
    $ip = guifi_main_ip($device[id]);
    $rows[] = array(t('IP address & MAC'), $ip[ipv4] . '/' . $ip[maskbits] . ' ' . $device[mac]);
    $status_url = guifi_cnml_availability(array('device' => $device['id'], 'format' => 'long'), $gs);
    if (!empty($ip[ipv4])) {
        $rows[] = array(t('status &#038; availability'), array('data' => t($device[flag]) . $status_url, 'class' => $device['flag']));
    }
    $rows[] = array(array('data' => theme_guifi_contacts($device), 'colspan' => 2));
    return array_merge($rows);
}
コード例 #2
0
function guifi_domain_print_data($domain)
{
    $node = node_load(array('nid' => $domain['sid']));
    $rows[] = array('<strong>' . t('Service:') . ' <a href="' . url('node/' . $node->nid) . '">' . $node->nick . '</a>');
    $rows[] = array('<strong>' . t('Domain:') . '</strong> ' . $domain['name']);
    $rows[] = array('<strong>' . t('Scope:') . '</strong> ' . $domain['scope']);
    $rows[] = array(array('data' => theme_guifi_contacts($domain), 'colspan' => 0));
    return array_merge($rows);
}
コード例 #3
0
function theme_guifi_node_data($node, $links = FALSE)
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_node_data(node)', $node);
    /*  $zone = db_fetch_object(db_query('SELECT id, title, master, zone_mode FROM {guifi_zone} WHERE id = %d',
        $node->zone_id));*/
    $zone = db_fetch_object(db_query('SELECT id, title, master FROM {guifi_zone} WHERE id = %d', $node->zone_id));
    $rows[] = array(t('node'), $node->nid . ' ' . $node->nick, '<b>' . $node->title . '</b>');
    //  $rows[] = array(t('zone (mode)'),l($zone->title,'node/'.$zone->id).' ('.t($zone->zone_mode).')',$node->zone_description);
    $rows[] = array(t('zone'), l($zone->title, 'node/' . $zone->id), $node->zone_description);
    $rows[] = array(t('position (lat/lon)'), sprintf('<a href="http://maps.guifi.net/world.phtml?Lat=%f&Lon=%f&Layers=all" target="_blank">Lat:%f<br />Lon:%f</a>', $node->lat, $node->lon, $node->lat, $node->lon), $node->elevation . '&nbsp;' . t('meters above the ground'));
    $rows[] = array(t('available for mesh &#038; status'), $node->stable, array('data' => t($node->status_flag), 'class' => $node->status_flag));
    if (count($node->funders)) {
        $rows[] = array(count($node->funders) == 1 ? t('Funder') : t('Funders'), array('data' => implode(', ', guifi_funders_links($node->funders)), 'colspan' => 2));
    }
    if (count($node->maintainers)) {
        $rows[] = array(t('Maintenance & SLAs'), array('data' => implode(', ', guifi_maintainers_links($node->maintainers)), 'colspan' => 2));
    } else {
        $radios = db_fetch_object(db_query('SELECT count(id) c FROM {guifi_radios} WHERE nid=%d', $node->id));
        if ($radios->c > 1) {
            $pmaintainers = guifi_maintainers_parents($node->zone_id);
            if (!empty($pmaintainers)) {
                $rows[] = array(t('Maintenance & SLAs') . ' ' . t('(from parents)'), implode(', ', guifi_maintainers_links($pmaintainers)));
            }
        }
    }
    if ($node->graph_server > 0) {
        $gs = node_load(array('nid' => $node->graph_server));
    } else {
        $gs = node_load(array('nid' => guifi_graphs_get_server($node->id, 'node')));
    }
    $rows[] = array(t('graphs provided from'), array('data' => l(guifi_service_str($node->graph_server), $gs->l, array('attributes' => array('title' => $gs->nick . ' - ' . $gs->title))), 'colspan' => 2));
    $output = theme('table', NULL, array_merge($rows));
    $output .= theme_guifi_contacts($node);
    if ($links) {
        $node = node_load(array('nid' => $node->id));
        drupal_set_title(t('%node data', 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 theme('box', NULL, $output);
}
コード例 #4
0
/**
 * outputs the user information data
**/
function guifi_users_node_list_form($form_state, $params = array())
{
    global $user;
    $owner = $user->uid;
    guifi_log(GUIFILOG_TRACE, 'function guifi_users_node_list_form()', $params);
    if (empty($form_state['values'])) {
        if (is_numeric($params)) {
            $node = node_load($params);
        } else {
            $node = node_load(array('nid' => $params->id));
        }
    }
    //  $form_state['#redirect'] = FALSE;
    //  if (!empty($op)) {
    //    $edit=$_POST['edit'];
    //    if ((empty($edit['user_checked'])) and ($op == t('Edit selected')))
    //      form_set_error('',t('You must select a user checkbox for editing it'));
    //    else
    //      return guifi_edit_user($edit['user_checked']);
    //  }
    drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id));
    $title = t('Users @') . ' ' . $node->title;
    drupal_set_title($title);
    if ($node->type == 'guifi_node') {
        $query = db_query("SELECT id " . "FROM {guifi_users} " . "WHERE nid = %d " . "ORDER BY lastname, firstname", $node->nid);
    } else {
        $query = db_query("SELECT id " . "FROM {guifi_users} " . "ORDER BY lastname, firstname");
    }
    $rows[] = array();
    $num_rows = FALSE;
    $f = array('#type' => 'fieldset', '#collapsible' => FALSE, '#title' => t('Users'));
    $options = array();
    while ($guserid = db_fetch_object($query)) {
        $guser = (object) guifi_user_load($guserid->id);
        $services = $guser->services;
        if ($node->type == 'guifi_service') {
            if ($node->service_type != 'Proxy' or $node->nid != $services['proxy']) {
                continue;
            }
        }
        if (!empty($guser->lastname)) {
            $realname = $guser->lastname . ', ' . $guser->firstname;
        } else {
            $realname = $guser->firstname;
        }
        $service = node_load(array('nid' => $guser->services['proxy']));
        if (user_access('administer guifi users') or $node->uid == $owner) {
            $realname2 = $realname;
            $username2 = $guser->username;
        } else {
            $realname2 = ereg_replace("_", " ", $realname);
            if (strlen($realname2) > 3) {
                $realname2 = substr($realname, 0, 3);
                $realname2 .= "..";
            }
            $username2 = $guser->username;
            if (strlen($username2) > 3) {
                $username2 = substr($guser->username, 0, 3);
                $username2 .= "..";
            }
        }
        $options[$guser->id] = $realname2 . ' (' . $username2 . ')' . l($service->nick, 'node/' . $service->id, array('attributes' => array('title' => $service->title))) . ' - ' . $guser->status . '<br />' . theme_guifi_contacts($guser, FALSE);
        if (!isset($default_user)) {
            $default_user = $guser->id;
        }
    }
    if (count($options)) {
        $f['user_id'] = array('#type' => 'radios', '#title' => $title, '#options' => $options, '#default_value' => $default_user);
        if (user_access('administer guifi users') or $node->uid == $owner) {
            $f['editUser'] = array('#type' => 'submit', '#value' => t('Edit selected user'));
        }
    } else {
        $f['empty'] = array('#type' => 'item', '#title' => t('There are no users to list at') . ' ' . $node->title);
    }
    if (user_access('administer guifi users') or $node->uid == $owner) {
        if ($node->type == 'guifi_node') {
            $f['addUser'] = array('#type' => 'submit', '#value' => t('Add user'));
        }
    }
    return $f;
}
コード例 #5
0
/**
 * outputs the zone information data
**/
function theme_guifi_service_data($node, $links = TRUE)
{
    if (!isset($node->nid)) {
        $node = node_load(array('nid' => $node->id));
    }
    guifi_log(GUIFILOG_TRACE, 'guifi_service_print_data()', $node);
    $zone = db_fetch_object(db_query('SELECT title FROM {guifi_zone} WHERE id = %d', $node->zone_id));
    $type = db_fetch_object(db_query('SELECT description FROM {guifi_types} WHERE type="service" AND text = "%s"', $node->service_type));
    $rows[] = array(t('service'), $node->nid . '-' . $node->nick, '<b>' . $node->title . '</b>');
    $rows[] = array(t('type'), $node->service_type, t($type->description));
    if ($node->device_id > 0) {
        $device = db_fetch_object(db_query('SELECT nick FROM {guifi_devices} WHERE id = %d', $node->device_id));
        $url = url('guifi/device/' . $node->device_id);
        $rows[] = array(t('device & status'), '<a href=' . $url . '>' . $device->nick . '</a>', array('data' => t($node->status_flag), 'class' => $node->status_flag));
    }
    $node->var = unserialize($node->extra);
    switch ($node->service_type) {
        case 'mail':
            $rows[] = array(t('inbound and outbound servers'), $node->var['in'], $node->var['out']);
            $rows[] = array(t('webmail and admin url'), guifi_url($node->var['webmail']), guifi_url($node->var['admin']));
            break;
        case 'Proxy':
        case 'ADSL':
            $rows[] = array(t('bandwidth (Down/Up)'), $node->var['down'], $node->var['up']);
            $rows[] = array(t('proxy name &#038; port'), $node->var['proxy'], $node->var['port']);
            $rows[] = array(t('type'), $node->var['type'], NULL);
            if (is_array($node->var['fed'])) {
                $rows[] = array(t('federation'), implode(", ", $node->var['fed']), NULL);
            } else {
                $rows[] = array(t('federation'), t('This proxy is not federated yet'), NULL);
            }
            break;
        case 'ftp':
            $rows[] = array(t('ftphost'), $node->var['ftphost'], NULL);
            $rows[] = array(t('supported protocols'), implode(", ", $node->var['protocols']), NULL);
            break;
        case 'ntp':
            $rows[] = array(t('IP address or hostname'), $node->var['ntp'], NULL);
            break;
        case 'asterisk':
            $rows[] = array(t('dial prefix and incoming calls'), $node->var['prefix'], $node->var['incoming']);
            if (isset($node->var['protocols'])) {
                $rows[] = array(t('supported protocols'), implode(", ", $node->var['protocols']), NULL);
            }
            break;
        default:
            if (!empty($node->var['url'])) {
                if (preg_match('/^http:\\/\\//', $node->var[url])) {
                    $url = $node->var[url];
                } else {
                    $url = 'http://' . $node->var[url];
                }
                $rows[] = array(t('url'), '<a href="' . $url . '">' . $node->var['url'] . '</a>', NULL);
            }
            break;
    }
    if (isset($node->var['homepages'])) {
        if (count($node->var['homepages'] > 0)) {
            $rows[] = array(t('homepages'), NULL, NULL);
            foreach ($node->var['homepages'] as $homepage) {
                if (preg_match('/^http:\\/\\//', $homepage)) {
                    $url = $homepage;
                } else {
                    $url = 'http://' . $homepage;
                }
                $rows[] = array(NULL, '<a href=' . $url . '>' . $homepage . '</a>', NULL);
            }
        }
    }
    if (isset($node->var['ircs'])) {
        if (count($node->var['ircs'] > 0)) {
            $rows[] = array(t('ircs'), NULL, NULL);
            foreach ($node->var['ircs'] as $irc) {
                $rows[] = array(NULL, $irc, NULL);
            }
        }
    }
    if (isset($node->var['domains'])) {
        if (count($node->var['domains'] > 0)) {
            $rows[] = array(t('domains'), NULL, NULL);
            foreach ($node->var['domains'] as $domain) {
                $rows[] = array(NULL, $domain, NULL);
            }
        }
    }
    $output = theme('table', NULL, $rows);
    $output .= theme_guifi_contacts($node);
    if ($links) {
        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;
}
コード例 #6
0
/**  guifi_zone_view(): zone view page
**/
function guifi_zone_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE)
{
    node_prepare($node);
    if ($teaser) {
        return $node;
    }
    if ($block) {
        return $node;
    }
    $node->content['data'] = array('#value' => theme_table(NULL, array(array(array('data' => '<small>' . theme_guifi_zone_data($node, FALSE) . '</small>' . theme_guifi_contacts($node), 'width' => '35%'), array('data' => guifi_zone_simple_map($node), 'width' => '65%'))), array('width' => '100%')), '#weight' => 1);
    $node->content['graph'] = array('#value' => theme_guifi_zone_stats($node, FALSE), '#weight' => 2);
    $node->content['nodes'] = array('#value' => theme_guifi_zone_nodes($node, FALSE), '#weight' => 3);
    return $node;
}