function guifi_devices_select($filters, $action = '') { guifi_log(GUIFILOG_TRACE, 'function guifi_devices_select()', $filters); $var = array(); $found = FALSE; if ($filters['type'] == 'cable') { if ($filters['mode'] != 'cable-router') { $query = sprintf("\n SELECT\n l.lat, l.lon, r.nick ssid, r.id, r.nid, z.id zone_id\n FROM {guifi_devices} r,{guifi_location} l, {guifi_zone} z\n WHERE\n l.id=%d\n AND r.nid=l.id\n AND l.zone_id=z.id", $filters['from_node']); } else { $query = sprintf("\n SELECT\n l.lat, l.lon, r.nick ssid, r.id r.nid, z.id zone_id, r.type,\n r.fund_required, r.fund_amount, r.fund_currency\n FROM {guifi_devices} r,{guifi_location} l, {guifi_zone} z\n WHERE r.type IN ('radio','nat')\n AND l.id=%d AND r.nid=l.id\n AND l.zone_id=z.id", $filters['from_node']); } } else { $query = sprintf("\n SELECT\n l.lat, l.lon, r.id, r.clients_accepted, r.nid, z.id zone_id,\n r.radiodev_counter, r.ssid, r.mode, r.antenna_mode,\n r.fund_required, r.fund_amount, r.fund_currency\n FROM {guifi_radios} r,{guifi_location} l, {guifi_zone} z\n WHERE l.id<>%d\n AND r.nid=l.id\n AND l.zone_id=z.id", $filters['from_node']); } $devdist = array(); $devarr = array(); $k = 0; $devsq = db_query($query); while ($device = db_fetch_object($devsq)) { $k++; $l = FALSE; if ($filters['type'] != 'cable') { $oGC = new GeoCalc(); $node = db_fetch_object(db_query(' SELECT lat, lon FROM {guifi_location} WHERE id=%d', $filters['from_node'])); $distance = round($oGC->EllipsoidDistance($device->lat, $device->lon, $node->lat, $node->lon), 3); if ($distance > $filters['dmax'] or $distance < $filters['dmin']) { continue; } if ($filters['azimuth']) { foreach (explode('-', $filters['azimuth']) as $minmax) { list($min, $max) = explode(',', $minmax); $Az = round($oGC->GCAzimuth($device->lat, $device->lon, $node->lat, $node->lon)); if ($Az <= $max and $Az >= $min) { $l = TRUE; } } } else { $l = TRUE; } } if ($l) { $devdist[$k] = $distance; $devarr[$k] = $device; $devarr[$k]->distance = $distance; } } asort($devdist); // ob_start(); // print "Query: $query \n<br />"; // print_r($devdist); // $txt = ob_get_contents(); // ob_end_clean(); if (!empty($devdist)) { foreach ($devdist as $id => $foo) { $device = $devarr[$id]; switch ($filters['type']) { case 'ap/client': if ($filters['mode'] == 'ap' and $device->mode == 'client') { $cr = guifi_count_radio_links($device->id); if ($cr['ap'] < 1) { _set_value($device, $node, $var, $filters['from_device'], $filters['from_radio'], $filters['search']); } } else { if ($filters['mode'] == 'client' and $device->mode == 'ap') { _set_value($device, $node, $var, $filters['from_device'], $filters['from_radio'], $filters['search']); } } break; case 'wds': if ($device->mode == 'ap') { _set_value($device, $node, $var, $filters['from_device'], $filters['from_radio'], $filters['search']); } break; case 'cable': _set_value($device, $node, $var, $filters['from_device'], $filters['from_radio'], $filters['search']); break; } // eof switch link_type } } // eof while query device,node,zone $form = array('#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, '#prefix' => '<div id="list-devices">', '#suffix' => '</div>'); if (count($var) == 0) { $form['d'] = array('#type' => 'item', '#parents' => array('dummy'), '#title' => t('No devices available'), '#value' => t('There are no devices to link within the given criteria, you can use the filters to get more results.')); $form['dbuttons'] = guifi_device_buttons(TRUE, $action, 0); return $form; } $form['d'] = array('#type' => 'radios', '#parents' => array('linked'), '#title' => t('select the device which do you like to link with'), '#options' => $var, '#attributes' => array('class' => 'required')); $form['dbuttons'] = guifi_device_buttons(TRUE, $action, 1); return $form; }
public static function set_value($object, $key, $value) { if (!isset(UTF8::$called[__FUNCTION__])) { require JsonApiApplication::find_file("utf8", __FUNCTION__); // Function has been called UTF8::$called[__FUNCTION__] = TRUE; } return _set_value($object, $key, $value); }
?> </td> </tr> <tr><td></td><td><?php echo form_error('ui-lang'); ?> </td></tr> <tr> <th><?php echo $this->lang->line('user_time_zone') . ' <span class="required">*</span> : '; ?> </th> <td> <?php echo timezone_menu(_set_value($userdata, 'time-zone', 'UP2'), '', 'time-zone'); ?> </td> </tr> <tr><td></td><td><?php echo form_error('time-zone'); ?> </td></tr> <tr><td></td><td> </td></tr> <?php if (!$userdata) { ?> <tr> <th><?php