Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1222

Přidáno uživatelem Michal Kliment před asi 13 roky(ů)

Oprava chyb u posilani e-mailu - posilaly se i byvalym clenum.

Vylepsena prace s wifi rozhranemi. Nyni lze menit wifi informace segmentu primo u editace rozhrani APcka.
Pridana kontrola pouze jedineho rozhrani v modu AP v segmentu.
Wifi informace pridany na seznam vsech segmentu a i do filtru.

U filtru pridany 2 nove operace pro porovnani - je prazdny a neni prazdny.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'in' => 'v',
'in normal' => 'v normálu',
'in hours' => 'V hodinách',
'in this segment interface in mode ap already exists' => 'V tomto segmentu již existuje rozhraní v módu AP.',
'inactive' => 'Neaktivní',
'inbound' => 'Příchozí',
'incomes' => 'Příjmy',
......
'ip addresses' => 'IP adresy',
'ip_address' => 'IP adresa',
'is' => 'je',
'is empty' => 'je prázdný',
'is in' => 'je v',
'is not' => 'není',
'is not empty' => 'není prázdný',
'is not in' => 'není v',
'it can means that username/password/host are bad or host is unavailable' => 'To může znamenat, že uživatelské jméno/heslo/hostitel je špatné nebo je hostitel nedostupný.',
'it is not possible activate e-mail notification for this message' => 'Není možné aktivovat e-mail upozornění pro tuto zprávu.',
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml
<input></input>
</values>
</method>
<method name="ssid" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
</controller>
<controller name="languages">
<method name="index" autogenerate="on">
......
<input></input>
</values>
</method>
<method name="get_ssid_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_norm_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_frequence_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_channel_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_channel_width_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_polarization_by_segment" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="valid_medium" autogenerate="off">
<attributes>
<attribute name="input" default_value=""/>
......
</input>
</values>
</method>
<method name="count_ws_of_iface" autogenerate="on">
<attributes>
<attribute name="iface_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="count_all_ifaces" autogenerate="on">
<attributes>
<attribute name="filter_sql" default_value="" />
......
<input></input>
</values>
</method>
<method name="count_items_by_mode_and_segment" autogenerate="on">
<attributes>
<attribute name="mode" default_value="" />
<attribute name="segment_id" default_value="" />
<attribute name="iface_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
</model>
<model name="wireless_segment">
<method name="get_norm" autogenerate="on">
......
</attributes>
<values>
</values>
</method>
<method name="wireless_segment_norm" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
</values>
</method>
<method name="wireless_iface_mode" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
</values>
</method></helper>
<helper name="cookie">
<method name="set" autogenerate="on">
freenetis/branches/testing/application/helpers/callback.php
break;
}
}
/**
* Callback function to print norm of wireless segment
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function wireless_segment_norm ($item, $name)
{
echo Wireless_segment_Model::get_norm($item->norm);
}
/**
* Callback function to print mode of wireless interface
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function wireless_iface_mode ($item, $name)
{
echo Wireless_iface_Model::get_mode($item->wmode);
}
}
freenetis/branches/testing/application/models/wireless_segment.php
*/
public function get_norm ($norm = NULL)
{
if (!$norm)
if (!$norm && isset($this))
$norm = $this->norm;
if (array_key_exists($norm, self::$norms))
freenetis/branches/testing/application/models/users_contacts.php
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE uc.whitelisted = ? AND m.type <> 15 AND m.id NOT IN
WHERE uc.whitelisted = ? AND m.type <> ? AND m.id NOT IN
(
SELECT m.id
FROM members m
......
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) AND a.balance < ".intval($debtor_boundary)
, $type, self::NO_WHITELIST);
, $type, self::NO_WHITELIST, Member_Model::TYPE_FORMER);
}
/**
......
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE uc.whitelisted = ? AND m.type <> 15 AND m.id NOT IN
WHERE uc.whitelisted = ? AND m.type <> ? AND m.id NOT IN
(
SELECT m.id
FROM members m
......
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) AND a.balance >= ".intval($debtor_boundary)." AND a.balance < ".intval($payment_notice_boundary)
, $type, self::NO_WHITELIST);
, $type, self::NO_WHITELIST, Member_Model::TYPE_FORMER);
}
/**
......
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
JOIN accounts a ON a.member_id = m.id
WHERE c.type = ?
", $type);
WHERE m.type <> ? AND c.type = ?
", array(Member_Model::TYPE_FORMER, $type));
}
}
freenetis/branches/testing/application/models/segment.php
(
SELECT s.id, s.name, medium_id AS medium, s.duplex, s.comment,
s.bitrate, (SELECT COUNT(*) FROM ifaces WHERE segment_id = s.id) +
(SELECT COUNT(*) FROM ports WHERE segment_id = s.id) as items_count
(SELECT COUNT(*) FROM ports WHERE segment_id = s.id) as items_count,
IFNULL(ws.ssid,'') AS ssid, ws.norm
FROM segments s
LEFT JOIN enum_types e ON s.medium_id = e.id
LEFT JOIN (
......
FROM translations
WHERE lang = ?
) f ON e.value = f.original_term
LEFT JOIN wireless_segments ws ON ws.segment_id = s.id
) s
$where
", Config::get('lang'))->current()->total;
......
(
SELECT s.id, s.name, medium_id AS medium, s.duplex, s.comment,
s.bitrate, (SELECT COUNT(*) FROM ifaces WHERE segment_id = s.id) +
(SELECT COUNT(*) FROM ports WHERE segment_id = s.id) as items_count
(SELECT COUNT(*) FROM ports WHERE segment_id = s.id) as items_count,
IFNULL(ws.ssid,'') AS ssid, ws.norm
FROM segments s
LEFT JOIN enum_types e ON s.medium_id = e.id
LEFT JOIN (
......
FROM translations
WHERE lang = ?
) f ON e.value = f.original_term
LEFT JOIN wireless_segments ws ON ws.segment_id = s.id
) s
$where
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
......
return $this->db->query("
SELECT q.*, d.name AS device_name, m.name AS member_name,
m.id AS member_id
m.id AS member_id, wi.wmode
FROM
(
SELECT id, device_id, mac, name, ? AS type
......
JOIN devices d ON q.device_id = d.id
JOIN users u ON d.user_id = u.id
JOIN members m ON u.member_id = m.id
", self::IFACE, $segment_id, self::PORT, $segment_id);
LEFT JOIN wireless_ifaces wi ON wi.iface_id = q.id AND q.type = ?
ORDER BY wi.wmode
", self::IFACE, $segment_id, self::PORT, $segment_id, self::IFACE);
}
/**
freenetis/branches/testing/application/models/wireless_iface.php
*/
public function get_mode ($mode = NULL)
{
if (!$mode)
if (!$mode && isset($this))
$mode = $this->wmode;
if (array_key_exists($mode, self::$modes))
......
return $antennas;
}
/**
* Counts items by wireless mode and segment
*
* @author Michal Kliment
* @param integer $mode
* @param integer $segment_id
* @return boolean
*/
public function count_items_by_mode_and_segment ($mode, $segment_id, $iface_id = NULL)
{
$where = '';
if ($iface_id)
$where = 'AND i.id <> '.intval($iface_id);
$result = $this->db->query("
SELECT COUNT(*) AS total
FROM wireless_ifaces wi
LEFT JOIN ifaces i on wi.iface_id = i.id
WHERE wi.wmode = ? AND i.segment_id = ? $where
", array($mode, $segment_id));
if ($result && $result->current())
return (bool) $result->current()->total;
else
return false;
}
}
freenetis/branches/testing/application/controllers/ifaces.php
*/
class Ifaces_Controller extends Controller
{
private $iface_id = NULL;
/**
* Index redirect to show all
*/
......
->label(__('Antenna').':')
->options($antennas);
$form->input('ssid')
->label(__('SSID').':');
$norms = array
(
NULL => '----- '.__('Select norm').' -----'
) + Wireless_segment_Model::get_norms();
$form->dropdown('norm')
->label(__('Norm').':')
->options($norms);
$form->input('frequence')
->label(__('Frequence').':');
$form->input('channel')
->label(__('Channel').':');
$form->input('channel_width')
->label(__('Channel width').':');
$polarizations = array
(
NULL => '----- '.__('Select polarization').' -----'
) + Wireless_segment_Model::get_polarizations();
$form->dropdown('polarization')
->label(__('Polarization').':')
->options($polarizations);
$form->submit('submit')
->value(__('Save'));
......
$iface->wireless->iface_id = $iface->id;
$iface->wireless->save();
if ($iface->wireless->wmode = Wireless_iface_Model::MODE_AP)
{
$iface->segment->wireless->ssid = $form_data['ssid'];
$iface->segment->wireless->norm = $form_data['norm'];
$iface->segment->wireless->frequence = $form_data['frequence'];
$iface->segment->wireless->channel = $form_data['channel'];
$iface->segment->wireless->channel_width = $form_data['channel_width'];
$iface->segment->wireless->polarization = $form_data['polarization'];
$iface->segment->wireless->segment_id = $iface->segment->id;
$iface->segment->wireless->save();
}
}
unset($form_data);
......
if (!$iface->id)
Controller::error(RECORD);
$this->iface_id = $iface->id;
// access control
if (!$this->acl_check_edit(
'Devices_Controller','iface', $iface->device->user->member_id))
......
->options($antennas)
->selected($iface->wireless->antenna);
$form->input('ssid')
->label(__('SSID').':')
->value($iface->segment->wireless->ssid);
$norms = array
(
NULL => '----- '.__('Select norm').' -----'
) + Wireless_segment_Model::get_norms();
$form->dropdown('norm')
->label(__('Norm').':')
->options($norms)
->selected($iface->segment->wireless->norm);
$form->input('frequence')
->label(__('Frequence').':')
->value($iface->segment->wireless->frequence);
$form->input('channel')
->label(__('Channel').':')
->value($iface->segment->wireless->channel);
$form->input('channel_width')
->label(__('Channel width').':')
->value($iface->segment->wireless->channel_width);
$polarizations = array
(
NULL => '----- '.__('Select polarization').' -----'
) + Wireless_segment_Model::get_polarizations();
$form->dropdown('polarization')
->label(__('Polarization').':')
->options($polarizations)
->selected($iface->segment->wireless->polarization);
$form->submit('submit')
->value(__('update'));
......
$iface->wireless->iface_id = $iface->id;
$iface->wireless->save();
if ($iface->wireless->wmode = Wireless_iface_Model::MODE_AP)
{
$iface->segment->wireless->ssid = $form_data['ssid'];
$iface->segment->wireless->norm = $form_data['norm'];
$iface->segment->wireless->frequence = $form_data['frequence'];
$iface->segment->wireless->channel = $form_data['channel'];
$iface->segment->wireless->channel_width = $form_data['channel_width'];
$iface->segment->wireless->polarization = $form_data['polarization'];
$iface->segment->wireless->segment_id = $iface->segment->id;
$iface->segment->wireless->save();
}
}
else
$iface->wireless->delete();
......
*/
public function valid_mode($input)
{
if ($this->input->post('itype') == Iface_Model::TYPE_WIRELESS
&& trim($input->value) == '')
if ($this->input->post('itype') == Iface_Model::TYPE_WIRELESS)
{
$input->add_error('required', __('Mode is required.'));
if (trim($input->value) == '')
{
$input->add_error('required', __('Mode is required.'));
}
if ($input->value == Wireless_iface_Model::MODE_AP
&& ORM::factory('wireless_iface')
->count_items_by_mode_and_segment (
Wireless_iface_Model::MODE_AP, $this->input->post('segment_id'),
$this->iface_id
))
{
$input->add_error('required', __('In this segment interface in mode AP already exists.'));
}
}
}
freenetis/branches/testing/application/controllers/segments.php
$filter_form->add('items_count')
->type('number');
$filter_form->add('norm')
->type('select')
->values(Wireless_segment_Model::get_norms());
$filter_form->add('ssid')
->label('SSID')
->callback('json/ssid');
// model
$segment_model = new Segment_Model();
$total_segments = $segment_model->count_all_segments($filter_form->as_sql());
......
$grid->order_field('items_count')
->label(__('Items count'));
$grid->order_field('ssid')
->label(__('SSID'));
$grid->order_callback_field('norm')
->label(__('Norm'))
->callback('callback::wireless_segment_norm');
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller','segment'))
......
// segment media
$medium = Segment_Model::get_medium_type($segment->medium_id);
if ($segment->medium_id != Segment_Model::AIR)
$headline = __('Interfaces').' / '.__('Ports');
else
$headline = __('Interfaces');
$grid = new Grid(
url_lang::base().'subnets/show/'.$segment_id,
__('Interfaces').' / '.__('Ports'), array
$headline, array
(
'use_paginator' => false,
'use_selector' => false
......
->label(__('Name'))
->callback('callback::segment_item_field');
$grid->callback_field('type')
if ($segment->medium_id != Segment_Model::AIR)
{
$grid->callback_field('type')
->label(__('Type'))
->callback('callback::segment_item_type_field');
}
else
{
$grid->callback_field('wmode')
->label(__('Mode'))
->callback('callback::wireless_iface_mode');
}
$grid->field('mac')
->label(__('MAC'));
......
echo "<pre>";
print_r($this->sums);
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_ssid_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->ssid;
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_norm_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->norm;
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_frequence_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->frequence;
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_channel_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->channel;
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_channel_width_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->channel_width;
}
/**
* Helper function to javascript
*
* @author Michal Kliment
*/
public function get_polarization_by_segment ()
{
$segment_id = (int) $this->input->get('segment_id');
if (!$segment_id || !is_numeric($segment_id))
return;
$segment = new Segment_Model($segment_id);
if (!$segment->id)
return;
echo $segment->wireless->polarization;
}
/**
* Callback function to valid medium of segment
freenetis/branches/testing/application/controllers/json.php
echo json_encode($segments);
}
/**
* Callback AJAX function to filter's whisper for SSID
*
* @author Michal Kliment
*/
public function ssid()
{
$term = $this->input->get('term');
$wireless_segment_model = new Wireless_segment_Model();
$ssids = $wireless_segment_model->like('ssid',$term)
->orderby('ssid')
->find_all();
$arr_ssids = array();
foreach ($ssids as $ssid)
$arr_ssids[] = $ssid->ssid;
echo json_encode($arr_ssids);
}
}
freenetis/branches/testing/application/libraries/Filter_form.php
const OPER_BIT_IS_NOT = 12;
const OPER_NETWORK_IS_IN = 13;
const OPER_NETWORK_IS_NOT_IN = 14;
const OPER_IS_EMPTY = 15;
const OPER_IS_NOT_EMPTY = 16;
/**
* Array with definition of all operations
......
'pattern' => '/^(?P<VALUE1>((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9]))\/(?P<VALUE2>(3[0-2])|(2[0-9])|(1[0-9])|([0-9]))$/',
'sql' => "& (0xffffffff<<(32-{VALUE2}) & 0xffffffff) <> inet_aton('{VALUE1}')",
'function' => 'inet_aton'
),
self::OPER_IS_EMPTY => array
(
'name' => 'is empty',
'sql' => 'LIKE ""',
'null' => TRUE
),
self::OPER_IS_NOT_EMPTY => array
(
'name' => 'is not empty',
'sql' => 'NOT LIKE ""',
'null' => TRUE
)
);
......
self::OPER_CONTAINS,
self::OPER_CONTAINS_NOT,
self::OPER_IS,
self::OPER_IS_NOT
self::OPER_IS_NOT,
self::OPER_IS_EMPTY,
self::OPER_IS_NOT_EMPTY
),
'number' => array
(
......
foreach ($values as $i => $value)
{
$value = trim($value);
if ($value != '')
if ($value != '' || (isset($this->opers[$operations[$i]]['null']) && $this->opers[$operations[$i]]['null']))
{
$this->values[] = $value;
$this->types[] = $types[$i];
freenetis/branches/testing/application/views/js/__pieces/segment_iface.php
$("#wmode").addClass('required');
$("#wmode").parent().parent().show();
$("#antenna").parent().parent().show();
// $("#ssid").parent().parent().show();
$("#norm").parent().parent().show();
$("#frequence").parent().parent().show();
$("#channel").parent().parent().show();
$("#channel_width").parent().parent().show();
$("#polarization").parent().parent().show();
}
else
{
......
$("#wmode").removeClass('required');
$("#wmode").parent().parent().hide();
$("#antenna").parent().parent().hide();
// $("#ssid").parent().parent().hide();
$("#norm").parent().parent().hide();
$("#frequence").parent().parent().hide();
$("#channel").parent().parent().hide();
$("#channel_width").parent().parent().hide();
$("#polarization").parent().parent().hide();
}
old_type = $(this).val();
$("#wmode").trigger('change');
})
$("#wmode").change(function () {
if ($(this).val() == <?php echo Wireless_iface_Model::MODE_AP ?>)
{
$("#ssid").parent().parent().show();
$("#norm").parent().parent().show();
$("#frequence").parent().parent().show();
$("#channel").parent().parent().show();
$("#channel_width").parent().parent().show();
$("#polarization").parent().parent().show();
}
else
{
$("#ssid").parent().parent().hide();
$("#norm").parent().parent().hide();
$("#frequence").parent().parent().hide();
$("#channel").parent().parent().hide();
$("#channel_width").parent().parent().hide();
$("#polarization").parent().parent().hide();
}
});
$("#segment_id").change(function (){
$.get("<?php echo url_lang::base() ?>segments/get_ssid_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#ssid").val(data);
});
$.get("<?php echo url_lang::base() ?>segments/get_norm_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#norm").val(data);
});
$.get("<?php echo url_lang::base() ?>segments/get_frequence_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#frequence").val(data);
});
$.get("<?php echo url_lang::base() ?>segments/get_channel_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#channel").val(data);
});
$.get("<?php echo url_lang::base() ?>segments/get_channel_width_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#channel_width").val(data);
});
$.get("<?php echo url_lang::base() ?>segments/get_polarization_by_segment/",
{
"segment_id": $(this).val()
}, function(data)
{
if (data != "")
$("#polarization").val(data);
});
})
$("#itype").trigger('change');

Také k dispozici: Unified diff