function guifi_node_form(&$node, $form_state)
{
    global $user;
    $form_weight = 0;
    $type = node_get_types('type', $node);
    if (!empty($node->zone_id)) {
        drupal_set_breadcrumb(guifi_node_ariadna($node));
    } else {
        drupal_set_breadcrumb(NULL);
    }
    // ----
    // El títol el primer de tot
    // ------------------------------------------------
    if ($type->has_title) {
        $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title);
    }
    $form_weight = 2;
    /*
     * maintainers fieldset
     */
    $form_weight = -3;
    $form['maintainers'] = guifi_maintainers_form($node, $form_weight);
    /*
     * funders fieldset
     */
    $form_weight = -4;
    $form['funders'] = guifi_funders_form($node, $form_weight);
    $form_weight = 0;
    $form['nick'] = array('#type' => 'textfield', '#title' => t('Nick'), '#required' => FALSE, '#size' => 20, '#maxlength' => 20, '#element_validate' => array('guifi_node_nick_validate'), '#default_value' => $node->nick, '#description' => t("Unique identifier for this node. Avoid generic names such 'MyNode', use something that really identifies your node.<br />Short name, single word with no spaces, 7-bit chars only, will be used for  hostname, reports, etc."), '#weight' => $form_weight++);
    $form['notification'] = array('#type' => 'textfield', '#title' => t('Contact'), '#required' => FALSE, '#size' => 60, '#maxlength' => 1024, '#element_validate' => array('guifi_emails_validate'), '#default_value' => $node->notification, '#description' => t("Who did possible this node or who to contact with regarding this node if it is distinct of the owner of this page. Use valid emails, if you like to have more than one, separated by commas.'"), '#weight' => $form_weight++);
    $form['settings'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#weight' => $form_weight++, '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Si ets administrador pots definir el servidor de dades
    if (user_access('administer guifi zones')) {
        $graphstr = guifi_service_str($node->graph_server);
        $form['settings']['graph_serverstr'] = array('#type' => 'textfield', '#title' => t('default graphs server'), '#maxlength' => 60, '#required' => FALSE, '#default_value' => $graphstr, '#autocomplete_path' => 'guifi/js/select-service/SNPgraphs', '#element_validate' => array('guifi_service_name_validate', 'guifi_zone_service_validate'), '#description' => t('Select the <em>graph server</em> to be used at this node.<br />You can find the <em>graph server</em> by introducing part of the id number, zone name or graph server name. A list with all matching values with a maximum of 50 values will be created.<br />You can refine the text to find your choice.'));
        $form['settings']['graph_server'] = array('#type' => 'hidden', '#value' => $node->graph_server);
    }
    $form['settings']['stable'] = array('#type' => 'select', '#title' => t("It's supposed to be a stable online node?"), '#required' => FALSE, '#default_value' => $node->stable ? $node->stable : 'Yes', '#options' => array('Yes' => t('Yes, is intended to be kept always on,  avalable for extending the mesh'), 'No' => t("I'm sorry. Will be connected just when I'm online")), '#description' => t("That helps while planning a mesh network. We should know which locations are likely available to provide stable links."), '#weight' => 1);
    // Ask for a license agreement if is a new node
    if (empty($node->nid)) {
        $form['license'] = array('#type' => 'item', '#title' => t('License and usage agreement'), '#value' => t(variable_get('guifi_license', NULL)), '#description' => t('You must accept this agreement to be authorized to create new nodes.'), '#weight' => 1);
        if (empty($node->agreement)) {
            $agreement = 'No';
        } else {
            $agreement = $node->agreement;
        }
        $form['agreement'] = array('#type' => 'radios', '#default_value' => $agreement, '#options' => array('Yes' => t('Yes, I have read this and accepted')), '#element_validate' => array('guifi_node_agreement_validate'), '#weight' => 2);
    } else {
        $form['agreement'] = array('#type' => 'hidden', '#default_value' => 'Yes');
    }
    if (empty($node->nid)) {
        if (empty($node->ndfzone)) {
            if (empty($node->zone_id)) {
                if (!empty($user->guifi_default_zone)) {
                    $zone_id = $user->guifi_default_zone;
                }
            } else {
                $zone_id = $node->zone_id;
            }
        } else {
            $zone_id = $node->ndfzone;
        }
    } else {
        $zone_id = $node->zone_id;
    }
    $form['zone_id'] = guifi_zone_autocomplete_field($zone_id, 'zone_id');
    //  $form['zone_id'] = guifi_zone_select_field($zone_id,'zone_id');
    $form['zone_id']['#weight'] = 3;
    // ----
    // position
    // ------------------------------------------------
    $form['position'] = array('#type' => 'fieldset', '#title' => t('Node position settings'), '#weight' => 4, '#collapsible' => FALSE);
    if (guifi_gmap_key()) {
        drupal_add_js(drupal_get_path('module', 'guifi') . '/js/guifi_gmap_node.js', 'module');
        $form['position']['GMAP'] = array('#type' => 'item', '#title' => t('Map'), '#description' => t('Select the point where the node has to be placed.'), '#suffix' => '<input style="width: 240px;" id="mapSearch" type="text" /><div id="map" style="width: 100%; height: 437px; margin:5px;"></div>', '#weight' => 0);
        $form['guifi_wms'] = array('#type' => 'hidden', '#value' => variable_get('guifi_wms_service', ''));
        $form['lat'] = array('#type' => 'hidden', '#value' => $node->lat);
        $form['lon'] = array('#type' => 'hidden', '#value' => $node->lon);
    }
    $form['position']['longitude'] = array('#type' => 'item', '#title' => t('Longitude'), '#prefix' => '<table><tr><th>&nbsp;</th><th>' . t('degrees (decimal values allowed)') . '</th><th>' . t('minutes') . '</th><th>' . t('seconds') . '</th></tr><tr><td>', '#suffix' => '</td>', '#weight' => 1);
    $form['position']['londeg'] = array('#type' => 'textfield', '#default_value' => $node->londeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lon_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 2);
    $form['position']['lonmin'] = array('#type' => 'textfield', '#default_value' => $node->lonmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 3);
    $form['position']['lonseg'] = array('#type' => 'textfield', '#default_value' => $node->lonseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr>', '#weight' => 4);
    $form['position']['latitude'] = array('#type' => 'item', '#title' => t('Latitude'), '#prefix' => '<tr><td>', '#suffix' => '</td>', '#weight' => 5);
    $form['position']['latdeg'] = array('#type' => 'textfield', '#default_value' => $node->latdeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lat_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 6);
    $form['position']['latmin'] = array('#type' => 'textfield', '#default_value' => $node->latmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 7);
    $form['position']['latseg'] = array('#type' => 'textfield', '#default_value' => $node->latseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr></table>', '#weight' => 8);
    $form['position']['zone_description'] = array('#type' => 'textfield', '#title' => t('Zone description'), '#required' => FALSE, '#size' => 60, '#maxlength' => 128, '#default_value' => $node->zone_description, '#description' => t("Zone, address, neighborhood. Something that describes your area within your location.<br />If you don't know your lat/lon, please provide street and number or crossing street."), '#weight' => 9);
    $form['position']['elevation'] = array('#type' => 'textfield', '#title' => t('Antenna elevation'), '#required' => FALSE, '#size' => 5, '#length' => 20, '#maxlength' => 20, '#default_value' => $node->elevation, '#element_validate' => array('guifi_elevation_validate'), '#description' => t("Antenna height over the floor level."), '#weight' => 10);
    if ($type->has_body) {
        $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    }
    $radios = array();
    $query = db_query("SELECT * FROM {guifi_radios} WHERE nid=%d", $node->id);
    while ($radio = db_fetch_array($query)) {
        $radios[] = $radio;
    }
    if (count($radios) < 1) {
        $form['status_flag'] = array('#type' => 'select', '#title' => t("Node status"), '#default_value' => $node->status_flag ? $node->status_flag : 'Planned', '#required' => FALSE, '#options' => array('Reserved' => t('Reserved'), 'Inactive' => t('Inactive'), 'Planned' => t('Planned')));
    } else {
        $form['status_flag'] = array('#type' => 'hidden', '#default_value' => $node->status_flag);
    }
    return $form;
}
function guifi_device_form($form_state, $params = array())
{
    global $user;
    $form = array();
    //$form['#suffix'] = '<script type="text/javascript">'
    //               . 'jQuery(\'input#edit-funders-0-user\').focus();'
    //               . '</script>';
    guifi_log(GUIFILOG_TRACE, 'function guifi_device_form()', $params);
    // Local javascript validations not actve because of bug in Firefox
    // Errors are not displayed when fieldset folder is collapsed
    // guifi_validate_js("#guifi-device-form");
    // $form['#attributes'] = array('onsubmit' => 'kk');
    if (empty($form_state['values'])) {
        $form_state['values'] = $params;
    }
    $form_state['#redirect'] = FALSE;
    // if new device, initializing variables
    if ($form_state['values']['nid'] == NULL && $params['add'] != NULL) {
        $form_state['values']['nid'] = $params['add'];
        $form_state['values']['new'] = TRUE;
        $form_state['values']['type'] = $params['type'];
        $form_state['values']['links'] = array();
        $form_state['values']['netmask'] = '255.255.255.224';
        if ($form_state['values']['type'] == 'radio') {
            $form_state['values']['variable']['firmware_id'] = '23';
            $form_state['values']['variable']['model_id'] = '70';
        }
    }
    drupal_set_breadcrumb(guifi_node_ariadna($form_state['values']['nid']));
    // Check permissions
    if ($params['edit']) {
        if (!guifi_device_access('update', $params['edit'])) {
            drupal_set_message(t('You are not authorized to edit this device', 'error'));
            return;
        }
    }
    // Loading node & zone where the device belongs to (some information will be used)
    $node = node_load(array('nid' => $form_state['values']['nid']));
    $zone = node_load($node->zone_id);
    // Setting the breadcrumb
    drupal_set_breadcrumb(guifi_node_ariadna($form_state['values']['nid']));
    // if contact is NULL, then get it from the node or the user logged in drupal
    if (is_null($form_state['values']['notification'])) {
        if (guifi_notification_validate($node->notification)) {
            $form_state['values']['notification'] = $node->notification;
        } else {
            drupal_set_message(t('The node has not a valid email address as a contact. Using your email as a default. Change the contact mail address if necessary.'));
            $form_state['values']['notification'] = $user->mail;
        }
    }
    // if nick is NULL, get a default name
    if ($form_state['values']['nick'] == "") {
        $form_state['values']['nick'] = guifi_device_get_default_nick($node, $form_state['values']['type'], $form_state['values']['nid']);
    }
    if (isset($form_state['action'])) {
        guifi_log(GUIFILOG_TRACE, 'action', $form_state['action']);
        if (function_exists($form_state['action'])) {
            if (!call_user_func_array($form_state['action'], array(&$form, &$form_state))) {
                return $form;
            }
        }
    }
    $form_weight = 0;
    if ($form_state['values']['id']) {
        $form['id'] = array('#type' => 'hidden', '#name' => 'id', '#value' => $form_state['values']['id'], '#weight' => $form_weight++);
    } else {
        $form['new'] = array('#type' => 'hidden', '#name' => 'new', '#weight' => $form_weight++, '#value' => TRUE);
    }
    $form['type'] = array('#type' => 'hidden', '#name' => 'type', '#weight' => $form_weight++, '#value' => $form_state['values']['type']);
    if ($params['add'] != NULL) {
        drupal_set_title(t('adding a new %device at %node', array('%node' => $node->nick, '%device' => $form_state['values']['type'])));
    } else {
        drupal_set_title(t('edit device %dname', array('%dname' => $form_state['values']['nick'])));
    }
    // All preprocess is complete, now going to create the form
    $form['main'] = array('#type' => 'fieldset', '#title' => t('Device name, status and main settings') . ' (' . $form_state['values']['nick'] . ') - ' . $form_state['values']['flag'], '#weight' => $form_weight++, '#collapsible' => TRUE, '#attributes' => array('class' => 'fieldset-device-main'), '#collapsed' => is_null($params['edit']));
    $form['main']['movenode'] = array('#type' => 'textfield', '#title' => t('Node'), '#maxlength' => 60, '#weight' => $form_weight++, '#default_value' => $form_state['values']['nid'] . '-' . guifi_get_zone_nick(guifi_get_zone_of_node($form_state['values']['nid'])) . ', ' . guifi_get_nodename($form_state['values']['nid']), '#autocomplete_path' => 'guifi/js/select-node', '#element_validate' => array('guifi_nodename_validate'), '#description' => t('Select the node where the device is.<br />' . 'You can find the node by introducing part of the node id number, ' . 'zone name or node name. A list with all matching values ' . 'with a maximum of 50 values will be created.<br />' . 'You can refine the text to find your choice.'), '#prefix' => '<div class"form-newline">', '#suffix' => '</div>');
    $form['main']['nid'] = array('#type' => 'hidden', '#weight' => $form_weight++, '#value' => $form_state['values']['nid']);
    $form['main']['nick'] = array('#type' => 'textfield', '#size' => 20, '#maxlength' => 128, '#title' => t('nick'), '#required' => TRUE, '#attributes' => array('class' => 'required'), '#default_value' => $form_state['values']['nick'], '#weight' => $form_weight++, '#description' => t('The name of the device.<br />Used as a hostname, SSID, etc...'));
    $form['main']['flag'] = array('#type' => 'select', '#title' => t("Status"), '#required' => TRUE, '#default_value' => $form_state['values']['flag'], '#options' => guifi_types('status'), '#weight' => $form_weight++, '#description' => t("Current status of this device."));
    $form['main']['notification'] = array('#type' => 'textfield', '#size' => 60, '#maxlength' => 1024, '#title' => t('contact'), '#required' => TRUE, '#element_validate' => array('guifi_emails_validate'), '#default_value' => $form_state['values']['notification'], '#weight' => $form_weight++, '#description' => t('Mailid where changes on the device will be notified, ' . 'if many, separated by \',\'<br />' . 'used for network administration.'));
    if (!empty($form_state['values']['ipv4'])) {
        $form['main']['mainipv4'] = array('#type' => 'select', '#title' => t('Main IPv4'), '#options' => guifi_get_currentDeviceIpv4s($form_state['values']), '#default_value' => $form_state['values']['mainipv4'], '#weight' => $form_weight++, '#description' => t('Used for monitoring.<br>Save and continue to refresh available addresses'));
    }
    $form['main']['logserver'] = array('#type' => 'textfield', '#size' => 60, '#maxlength' => 60, '#title' => t('Log Server'), '#default_value' => $form_state['values']['logserver'], '#weight' => $form_weight++, '#description' => t('If you have a log server for mikrotik (dude), add your ip.'));
    $form['main']['graph_server'] = array('#type' => 'select', '#title' => t("Server which collects traffic and availability data"), '#required' => FALSE, '#default_value' => $node->graph_server ? $node->graph_server : 0, '#options' => array('0' => t('Default'), '-1' => t('None')) + guifi_services_select('SNPgraphs'), '#weight' => $form_weight++, '#description' => t("If not specified, inherits zone properties."));
    if (!user_access('administer guifi zones') || $device['user_created'] == $user->uid and $form_state['values']['type'] == 'radio') {
        $form['main']['graph_server']['#disabled'] = true;
        $form['main']['graph_server']['#description'] .= '<br>' . t('To change the value, you are required for maintainer privilege.');
    }
    /*
     * maintainers fieldset
     */
    $form['maintainers'] = guifi_maintainers_form(array2object($form_state['values']), $form_weight);
    guifi_log(GUIFILOG_TRACE, 'function guifi_device_form(maintainers)', $form_state['values']['maintainers']);
    /*
     * funders fieldset
     */
    $form['funders'] = guifi_funders_form(array2object($form_state['values']), $form_weight);
    guifi_log(GUIFILOG_TRACE, 'function guifi_device_form(funders)', $form_state['values']['funders']);
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans type)'), $form_weight);
    // create the device-type depenedent form
    // looking for a "guifi_"<device_type>"_form()" function
    if (function_exists('guifi_' . $form_state['values']['type'] . '_form')) {
        $form = array_merge($form, call_user_func_array('guifi_' . $form_state['values']['type'] . '_form', array($form_state['values'], &$form_weight)));
    }
    // Cable interfaces/networking
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if cable links)'), $form_weight);
    $form['if'] = guifi_interfaces_cable_form($form_state['values'], $form_weight);
    $form['if']['#weight'] = $form_weight++;
    // Cable interfaces/ports
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if ports)'), $form_weight);
    if (isset($form_state['values']['interfaces'])) {
        foreach ($form_state['values']['interfaces'] as $k => $v) {
            unset($form_state['values']['interfaces'][$k]['ipv4']);
        }
        guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if ports)'), $form_state['values']['interfaces']);
        $form['interfaces'] = guifi_ports_form($form_state['values'], $form_weight);
        $form['interfaces']['#weight'] = $form_weight++;
    }
    // VLANs (VLans, VRRPs, WDS...)
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if vLANs)'), $form_weight);
    $form['vlans'] = guifi_vinterfaces_form('vlans', $form_state['values'], $form_weight);
    $form['vlans']['#weight'] = $form_weight++;
    // Aggregations (Bridges & Bondings)
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if Aggregations)'), $form_weight);
    $form['aggregations'] = guifi_vinterfaces_form('aggregations', $form_state['values'], $form_weight);
    $form['aggregations']['#weight'] = $form_weight++;
    // ipv4
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans if ipv4)'), $form_weight);
    $form['ipv4'] = guifi_ipv4s_form($form_state['values'], $form_weight);
    $form['ipv4']['#weight'] = $form_weight++;
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans comments)'), $form_weight);
    // Comments
    $form['comment'] = array('#type' => 'textarea', '#title' => t('Comments'), '#default_value' => $form_state['values']['comment'], '#description' => t('This text will be displayed as an information of the device.'), '#cols' => 60, '#rows' => 5, '#weight' => $form_weight++);
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(abans buttons)'), $form_weight);
    //  save/validate/reset buttons
    $form['dbuttons'] = guifi_device_buttons(FALSE, '', 0, $form_weight);
    $form['dbuttons']['#weight'] = $form_weight++;
    guifi_log(GUIFILOG_TRACE, sprintf('function guifi_device_form(form_final)'), $form);
    return $form;
}
/** guifi_zone_form(): Present the guifi zone editing form.
 */
function guifi_zone_form(&$node, &$param)
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_zone_form()', $node);
    drupal_set_breadcrumb(guifi_zone_ariadna($node->id));
    $form_weight = -20;
    $type = node_get_types('type', $node);
    if ($type->has_title) {
        $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => $form_weight++);
    }
    $form['jspath'] = array('#type' => 'hidden', '#value' => base_path() . drupal_get_path('module', 'guifi') . '/js/');
    $form['master'] = guifi_zone_autocomplete_field($node->master, 'master');
    $form['master']['#weight'] = $form_weight++;
    if ($type->has_body) {
        $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
        $form['body_field']['#weight'] = $form_weight++;
    }
    // This is for non-admin users, they don't need to edit more information
    if (!user_access('administer guifi zones')) {
        return $form;
    }
    $form['nick'] = array('#type' => 'textfield', '#title' => t('Short abreviation'), '#required' => FALSE, '#default_value' => $node->nick, '#size' => 8, '#maxlength' => 10, '#element_validate' => array('guifi_zone_nick_validate'), '#description' => t('Single word, 7-bits characters. Used while default values as hostname, SSID, etc...'), '#weight' => $form_weight++);
    /*
     * maintainers fieldset
     */
    $form['maintainers'] = guifi_maintainers_form($node, $form_weight);
    $form['time_zone'] = array('#type' => 'select', '#title' => t('Time zone'), '#required' => FALSE, '#default_value' => $node->time_zone, '#options' => guifi_types('tz'), '#weight' => $form_weight++);
    $form['homepage'] = array('#type' => 'textfield', '#title' => t('Zone homepage'), '#required' => FALSE, '#default_value' => $node->homepage, '#size' => 60, '#maxlength' => 128, '#description' => t('URL of the local community homepage, if exists. Useful for those who want to use this site just for network administration, but have their own portal.'), '#weight' => $form_weight++);
    $form['notification'] = array('#type' => 'textfield', '#title' => t('email notification'), '#required' => TRUE, '#default_value' => $node->notification, '#size' => 60, '#maxlength' => 1024, '#element_validate' => array('guifi_emails_validate'), '#description' => t('Mails where changes at the zone will be notified. Useful for decentralized administration. If more than one, separated by \',\''), '#weight' => $form_weight++);
    // Service parameters
    $form['zone_services'] = array('#type' => 'fieldset', '#title' => t('Zone services'), '#weight' => $form_weight++, '#collapsible' => FALSE, '#collapsed' => TRUE, '#prefix' => '<div>');
    $proxystr = guifi_service_str($node->proxy_id);
    function _service_descr($type)
    {
        return t('Select the default %type to be used at this ' . 'zone.<br />' . 'You can find the %type by introducing part of the id number, ' . 'zone name or proxy name. A list with all matching values ' . 'with a maximum of 50 values will be created.<br />' . 'You can refine the text to find your choice.', array('%type' => $type));
    }
    $form['zone_services']['proxystr'] = array('#type' => 'textfield', '#title' => t('default proxy'), '#maxlength' => 80, '#default_value' => $proxystr, '#autocomplete_path' => 'guifi/js/select-service/proxy', '#element_validate' => array('guifi_service_name_validate', 'guifi_zone_service_validate'), '#description' => _service_descr('proxy'));
    $form['zone_services']['proxy_id'] = array('#type' => 'hidden', '#value' => $node->proxy_id);
    $graphstr = guifi_service_str($node->graph_server);
    $form['zone_services']['graph_serverstr'] = array('#type' => 'textfield', '#title' => t('default graphs server'), '#maxlength' => 80, '#required' => FALSE, '#default_value' => $graphstr, '#autocomplete_path' => 'guifi/js/select-service/SNPgraphs', '#element_validate' => array('guifi_service_name_validate', 'guifi_zone_service_validate'), '#description' => _service_descr('graph server'));
    $form['zone_services']['graph_server'] = array('#type' => 'hidden', '#value' => $node->graph_server, '#suffix' => '</div>');
    // Separació Paràmetre globals de xarxa
    $form['zone_network_settings'] = array('#type' => 'fieldset', '#title' => t('Zone global network parameters'), '#weight' => $form_weight++, '#collapsible' => TRUE, '#collapsed' => TRUE, '#preffix' => '<div>');
    $form['zone_network_settings']['sep-global-param'] = array('#value' => '<hr /><h2>' . t('zone global network parameters') . '</h2>', '#weight' => $form_weight++);
    $form['zone_network_settings']['dns_servers'] = array('#type' => 'textfield', '#title' => t('DNS Servers'), '#required' => FALSE, '#default_value' => $node->dns_servers, '#size' => 60, '#maxlength' => 128, '#description' => t('The Name Servers of this zone, will inherit parent DNS servers if blank. Separated by ",".'), '#weight' => $form_weight++);
    $form['zone_network_settings']['ntp_servers'] = array('#type' => 'textfield', '#title' => t('NTP Servers'), '#required' => FALSE, '#default_value' => $node->ntp_servers, '#size' => 60, '#maxlength' => 128, '#description' => t('The network time protocol (clock) servers of this zone, will inherit parent NTP servers if blank. Separated by ",".'), '#weight' => $form_weight++);
    $form['zone_network_settings']['ospf_zone'] = array('#type' => 'textfield', '#title' => t('OSPF zone id'), '#required' => FALSE, '#default_value' => $node->ospf_zone, '#size' => 60, '#maxlength' => 128, '#element_validate' => array('guifi_zone_ospf_validate'), '#description' => t('The id that will be used when creating configuration files for the OSPF routing protocol so all the routers within the zone will share a dynamic routing table.'), '#weight' => $form_weight++, '#suffix' => '</div>');
    // Separació Paràmetres dels mapes
    $form['zone_mapping'] = array('#type' => 'fieldset', '#title' => t('Zone mapping parameters'), '#weight' => $form_weight++, '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['zone_mapping']['sep-maps-param'] = array('#value' => '<hr /><h2>' . t('zone mapping parameters') . '</h2>', '#weight' => $form_weight++);
    // if gmap key defined, prepare scripts anf launch google maps integration
    if (guifi_gmap_key()) {
        drupal_add_js(drupal_get_path('module', 'guifi') . '/js/guifi_gmap_zonelimits.js', 'module');
        $form['zone_mapping']['GMAP'] = array('#type' => 'item', '#title' => t('Map'), '#description' => t('Drag the South-West/North-East corners over the map to change the zone boundaries.'), '#suffix' => '<div id="map" style="width: 100%; height: 437px; margin:5px;"></div>', '#weight' => $form_weight++);
        $form['guifi_wms'] = array('#type' => 'hidden', '#value' => variable_get('guifi_wms_service', ''));
    }
    $form['zone_mapping']['MIN_help'] = array('#type' => 'item', '#title' => t('Bottom-left (SW) corner'), '#description' => t('Coordinates (Lon/Lat) of the bottom-left (South-West) corner of the map.'), '#weight' => $form_weight++);
    $form['zone_mapping']['minx'] = array('#type' => 'textfield', '#default_value' => $node->minx, '#size' => 12, '#maxlength' => 24, '#prefix' => '<table style="width: 32em"><tr><td style="width: 12em">', '#suffix' => '</td>', '#element_validate' => array('guifi_lon_validate'), '#description' => t('Longitude'), '#weight' => $form_weight++);
    $form['zone_mapping']['miny'] = array('#type' => 'textfield', '#default_value' => $node->miny, '#size' => 12, '#prefix' => '<td style="width: 12em">', '#suffix' => '</td></tr></table>', '#element_validate' => array('guifi_lat_validate'), '#description' => t('Latitude'), '#maxlength' => 24, '#weight' => $form_weight++);
    $form['zone_mapping']['MAX_help'] = array('#type' => 'item', '#title' => t('Upper-right (NE) corner'), '#description' => t('Coordinates (Lon/Lat) of the upper-right (North-East) corner of the map.'), '#weight' => $form_weight++);
    $form['zone_mapping']['maxx'] = array('#type' => 'textfield', '#default_value' => $node->maxx, '#size' => 12, '#maxlength' => 24, '#prefix' => '<table style="width: 32em"><tr><td style="width: 12em">', '#suffix' => '</td>', '#element_validate' => array('guifi_lon_validate'), '#description' => t('Longitude'), '#weight' => $form_weight++);
    $form['zone_mapping']['maxy'] = array('#type' => 'textfield', '#default_value' => $node->maxy, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td style="width: 12em">', '#suffix' => '</td></tr></table>', '#element_validate' => array('guifi_lat_validate'), '#description' => t('Latitude'), '#weight' => $form_weight++);
    $form['#attributes'] = array('class' => zone_form);
    return $form;
}