Revize 1498
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/network/application/models/ifaces_vlan.php | ||
---|---|---|
* Function returns all bridged interfaces of interface
|
||
*
|
||
* @param integer $iface
|
||
* @return integer
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_bridged_ifaces_of_iface($iface = null)
|
||
{
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Gets all VLANs of iface
|
||
*
|
||
* @param integer $iface_id
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_vlans_of_iface($iface_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT v.*, iv.tagged, iv.port_vlan
|
||
FROM vlans v
|
||
JOIN ifaces_vlans iv ON iv.vlan_id = v.id
|
||
WHERE iv.iface_id = ?
|
||
", $iface_id);
|
||
}
|
||
|
||
/**
|
||
* Function removes iface from bridge
|
||
*
|
||
* @param integer $bridge_iface_id
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Rmove relation between VLANs and iface
|
||
*
|
||
* @param integer $iface_id
|
||
*/
|
||
public function delete_relation_vlans_to_iface($iface_id)
|
||
{
|
||
$this->db->query("
|
||
DELETE FROM ifaces_vlans
|
||
WHERE iface_id = ?
|
||
", $iface_id);
|
||
}
|
||
|
||
/**
|
||
* Function removes vlan from port
|
||
*
|
||
* @param integer $port_iface_id
|
||
... | ... | |
AND `iface_id` = ?
|
||
", $vlan_id, $port_iface_id);
|
||
}
|
||
|
||
}
|
freenetis/branches/network/application/controllers/ifaces.php | ||
---|---|---|
->rules('required')
|
||
->style('width:200px');
|
||
|
||
$form->dropdown('port_vlan_id')
|
||
$port_form->dropdown('port_vlan_id')
|
||
->options($default_vlans)
|
||
->selected($default_vlan->id)
|
||
->rules('required')
|
||
... | ... | |
->style('width:200px')
|
||
->add_button('vlans');
|
||
|
||
$form->dropdown('tagged_vlan_id[]')
|
||
$port_form->dropdown('tagged_vlan_id[]')
|
||
->label('Tagged VLANs')
|
||
->options($arr_vlans)
|
||
->multiple('multiple')
|
||
->size(30)
|
||
->add_button('vlans');
|
||
|
||
$form->dropdown('untagged_vlan_id[]')
|
||
$port_form->dropdown('untagged_vlan_id[]')
|
||
->label('Untagged VLANs')
|
||
->options($arr_vlans)
|
||
->selected($default_vlan->id)
|
||
... | ... | |
// print port fields only if type is port
|
||
if ($type == Iface_Model::TYPE_PORT)
|
||
{
|
||
$modes = array
|
||
(
|
||
NULL => '------- '.__('Select mode').' -------'
|
||
) + Iface_Model::get_port_modes();
|
||
$modes = array
|
||
(
|
||
NULL => '------- '.__('Select mode').' -------'
|
||
) + Iface_Model::get_port_modes();
|
||
|
||
$vlan_model = new Vlan_Model();
|
||
$arr_vlans = $vlan_model->select_list();
|
||
|
||
$default_vlans = array
|
||
(
|
||
NULL => '----- ' . __('Select VLAN') . ' -----'
|
||
) + $arr_vlans;
|
||
|
||
$vlans = ORM::factory('ifaces_vlan')->get_all_vlans_of_iface($iface->id);
|
||
$default_vlan_id = null;
|
||
$tagged_vlans_ids = array();
|
||
$untagged_vlans_ids = array();
|
||
|
||
foreach ($vlans as $vlan)
|
||
{
|
||
if ($vlan->tagged)
|
||
{
|
||
$tagged_vlans_ids[] = $vlan->id;
|
||
}
|
||
else
|
||
{
|
||
$untagged_vlans_ids[] = $vlan->id;
|
||
}
|
||
|
||
if ($vlan->port_vlan)
|
||
{
|
||
$default_vlan_id = $vlan->id;
|
||
}
|
||
}
|
||
|
||
$port_form = $form->group('Port setting');
|
||
|
||
$port_form->input('number')
|
||
... | ... | |
|
||
$port_form->dropdown('port_mode')
|
||
->options($modes)
|
||
->rules('required')
|
||
->style('width:200px')
|
||
->selected($iface->port_mode);
|
||
|
||
$port_form->dropdown('port_vlan_id')
|
||
->options($default_vlans)
|
||
->selected($default_vlan_id)
|
||
->rules('required')
|
||
->label('Port VLAN')
|
||
->help('port_vlan')
|
||
->callback(array($this, 'valid_port_vlan'))
|
||
->style('width:200px')
|
||
->add_button('vlans');
|
||
|
||
$port_form->dropdown('tagged_vlan_id[]')
|
||
->label('Tagged VLANs')
|
||
->options($arr_vlans)
|
||
->selected($tagged_vlans_ids)
|
||
->multiple('multiple')
|
||
->size(30)
|
||
->add_button('vlans');
|
||
|
||
$port_form->dropdown('untagged_vlan_id[]')
|
||
->label('Untagged VLANs')
|
||
->options($arr_vlans)
|
||
->selected($untagged_vlans_ids)
|
||
->callback(array($this, 'valid_vlans'))
|
||
->multiple('multiple')
|
||
->size(30)
|
||
->add_button('vlans');
|
||
}
|
||
|
||
// print wireless fields only if type is wireless
|
||
... | ... | |
$connecte_to_iface_id = null;
|
||
$connecte_to_iface_device_id = null;
|
||
|
||
if ($connecte_to_iface->id)
|
||
if ($connecte_to_iface && $connecte_to_iface->id)
|
||
{
|
||
$connecte_to_iface_id = $connecte_to_iface->id;
|
||
$connecte_to_iface_device_id = $connecte_to_iface->device_id;
|
||
... | ... | |
{
|
||
$iface->number = $form_data['number'];
|
||
$iface->port_mode = $form_data['port_mode'];
|
||
|
||
// vlan relations
|
||
$vlan_ifaces = new Ifaces_vlan_Model();
|
||
// remove current
|
||
$vlan_ifaces->delete_relation_vlans_to_iface($iface->id);
|
||
|
||
if ($iface->port_mode == Iface_Model::PORT_MODE_TRUNK ||
|
||
$iface->port_mode == Iface_Model::PORT_MODE_HYBRID)
|
||
{
|
||
foreach ((array) $form_data['tagged_vlan_id'] as $vlan_id)
|
||
{
|
||
if (intval($vlan_id))
|
||
{
|
||
$vlan_ifaces->clear();
|
||
$vlan_ifaces->vlan_id = $vlan_id;
|
||
$vlan_ifaces->iface_id = $iface->id;
|
||
$vlan_ifaces->tagged = TRUE;
|
||
$vlan_ifaces->port_vlan = ($vlan_id == $form_data['port_vlan_id']);
|
||
$vlan_ifaces->save_throwable();
|
||
}
|
||
}
|
||
}
|
||
|
||
if ($iface->port_mode == Iface_Model::PORT_MODE_ACCESS ||
|
||
$iface->port_mode == Iface_Model::PORT_MODE_HYBRID)
|
||
{
|
||
foreach ((array) $form_data['untagged_vlan_id'] as $vlan_id)
|
||
{
|
||
if (intval($vlan_id))
|
||
{
|
||
$vlan_ifaces->clear();
|
||
$vlan_ifaces->vlan_id = $vlan_id;
|
||
$vlan_ifaces->iface_id = $iface->id;
|
||
$vlan_ifaces->tagged = FALSE;
|
||
$vlan_ifaces->port_vlan = ($vlan_id == $form_data['port_vlan_id']);
|
||
$vlan_ifaces->save_throwable();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if ($iface->type == Iface_Model::TYPE_VLAN)
|
||
{
|
||
... | ... | |
'ID '.$iface->device->user->member->id.
|
||
' - '.$iface->device->user->member->name,
|
||
$this->acl_check_view(
|
||
'Members_Controller',
|
||
'members',
|
||
'Members_Controller', 'members',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
->link(
|
||
'users/show_by_member/'.$iface->device->user->member_id,
|
||
'Users', $this->acl_check_view(
|
||
'Users_Controller',
|
||
'users',$iface->device->user->member_id
|
||
'Users_Controller', 'users',
|
||
$iface->device->user->member_id
|
||
)
|
||
)
|
||
->link(
|
||
... | ... | |
'Interfaces',
|
||
$this->acl_check_view('Devices_Controller','iface')
|
||
)->link(
|
||
'ifaces/show/'.$iface->id,
|
||
$name,
|
||
'ifaces/show/'.$iface->id, $name,
|
||
$this->acl_check_view(
|
||
'Devices_Controller',
|
||
'iface',
|
||
'Devices_Controller', 'iface',
|
||
$iface->device->user->member->id
|
||
)
|
||
)->text('Edit')
|
freenetis/branches/network/application/views/js/ifaces_add.php | ||
---|---|---|
$connected_to_iface.html('<option value=""><?php echo __('Loading data, please wait') ?>...</option>');
|
||
|
||
$.getJSON('<?php echo url_lang::base() ?>json/get_ifaces', {
|
||
data: val, itype: <?php echo $itype ?>
|
||
data: val, itype: '<?php echo $itype ?>'
|
||
}, function (data)
|
||
{
|
||
var options = ['<option value="">---- <?php echo __('Select interface') ?> ---</option>'];
|
Také k dispozici: Unified diff
Upravy:
- editace portu (#185)