Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1495

Přidáno uživatelem David Raška před více než 12 roky(ů)

Upravy:
- Pridany detaily o VLANu a bridge k rozhrani

Zobrazit rozdíly:

freenetis/branches/network/application/i18n/cs_CZ/texts.php
'error - cant change limit' => 'Chyba - nelze změnit limit.',
'error - cant parse invoice' => 'Chyba - nelze parsovat fakturu.',
'error - cant change voicemail' => 'Chyba - nelze změnit hlasovou schránku.',
'error - cant remove interface' => 'Chyba - nelze odstranit rozhraní.',
'error - cant restore membership' => 'Chyba - nelze obnovit členství.',
'error - cant set redirection' => 'Chyba - nelze nastavit přesměrování.',
'error - cant update account' => 'Chyba - nelze upravit účet.',
......
'interface has been successfully saved' => 'Rozhraní bylo úspěšně uloženo.',
'interface has been successfully updated' => 'Rozhraní bylo úspěšně upraveno.',
'interface has been successfully deleted' => 'Rozhraní bylo úspěšně smazáno.',
'interface has been successfully removed' => 'Rozhraní bylo úspěšně odstraněno.',
'interface has not been selected' => 'Rozhraní nebylo vybráno.',
'interface name' => 'Název rozhraní',
'interface parameters' => 'Parametry rozhraní',
......
'remove broadcast ip address' => 'Odebrat IP adresu broadcastu',
'remove device from monitoring' => 'Odebrat zařízení z monitoringu',
'remove items' => 'Odstranit položky',
'remove interface from bridge' => 'Odstranit rozhraní z bridge',
'remove network ip address' => 'Odebrat IP adresu sítě',
'remove this work' => 'Odstranit tuto práci',
'reply' => 'Odpovědět',
freenetis/branches/network/application/models/iface.php
}
/**
* Returns name or MAC address of device
*
* @author David Raska
* @return array
*/
public function __toString()
{
if (!$this || !$this->id)
{
return NULL;
}
$name = $this->name;
$mac = $this->mac;
if (!empty($name) && !empty($mac))
{
return $name.' ('.$mac.')';
}
if (empty($name) && empty($name))
{
return $this->id;
}
if (empty($name))
{
return $mac;
}
else
{
return $name;
}
return "";
}
/**
* Returns default name of current type of interface
*
* @author Michal Kliment
freenetis/branches/network/application/models/ifaces_vlan.php
return $this->db->count_records('vlan_ifaces');
}
/**
* Function returns all bridged interfaces of interface
*
* @param integer $iface
* @return integer
*/
public function get_all_bridged_ifaces_of_iface($iface = null)
{
return $this->db->query("
SELECT i.*
FROM ifaces_relationships ir
JOIN ifaces i ON i.id = ir.iface_id
WHERE parent_iface_id = ?
", $iface);
}
/**
* Function removes iface from bridge
*
* @param integer $bridge_iface_id
* @param integer $iface_id
* @return integer
*/
public function remove_iface_from_bridge($bridge_iface_id = null, $iface_id = null)
{
return $this->db->query("
DELETE
FROM `ifaces_relationships`
WHERE `parent_iface_id` = ?
AND `iface_id` = ?
", $bridge_iface_id, $iface_id);
}
}
freenetis/branches/network/application/controllers/ifaces.php
$detail = new View('ifaces/detail');
$detail->ip_addresses = $grid_ip_addresses;
break;
case Iface_Model::TYPE_BRIDGE:
$iv = new Ifaces_vlan_Model();
$ifaces = $iv->get_all_bridged_ifaces_of_iface($iface_id);
$member_id = $iface->device->user->member_id;
// grid
$grid = new Grid('devices', null, array
(
'use_paginator' => false,
'use_selector' => false,
'total_items' => count($ifaces)
));
if ($this->acl_check_new(get_class($this), 'iface', $member_id))
{
$grid->add_new_button(
'ifaces/add/' . $device->id, 'Add new interface'
);
}
$grid->callback_field('type')
->callback('callback::iface_type_field')
->class('center');
$grid->field('name');
$grid->callback_field('mac')
->callback('callback::not_empty')
->label('MAC')
->class('center');
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller', 'iface', $member_id))
{
$actions->add_action('id')
->icon_action('show')
->url('devices/show_iface')
->class('popup_link');
}
if ($this->acl_check_delete('Devices_Controller', 'iface', $member_id))
{
$actions->add_action('id')
->icon_action('delete')
->url('ifaces/remove_from_bridge/'.$iface->id)
->class('delete_link')
->label('Remove interface from bridge');
}
$grid->datasource($ifaces);
$detail = $grid;
break;
};
$view->content->iface = $iface;
......
}
/**
* Function removes iface from bridge
*
* @param integer $bridge_iface_id
* @param integer $iface_id
*/
public function remove_from_bridge($bridge_iface_id = null, $iface_id = null)
{
// bad parameter
if (!$bridge_iface_id || !is_numeric($bridge_iface_id) || !$iface_id || !is_numeric($iface_id))
{
Controller::warning(PARAMETER);
}
$iface = new Iface_Model($bridge_iface_id);
$sub_iface = new Iface_Model($iface_id);
// iface doesn't exist
if (!$iface->id || !$sub_iface->id)
{
Controller::error(RECORD);
}
//remove iface from bridge
$iv = new Ifaces_vlan_Model();
$delete_state = $iv->remove_iface_from_bridge($bridge_iface_id,$iface_id);
if ($delete_state)
{
status::success('Interface has been successfully removed.');
}
else
{
status::error('Error - cant remove interface.');
}
$this->redirect(Path::instance()->previous());
}
/**
* Checks validity of mac address, if already exists in database
*
* @param Form_Field $input
freenetis/branches/network/application/views/ifaces/show.php
?>
<br /><br />
<table class="extended" style="float:left" cellspacing="0">
<table class="extended" style="float:left; width:360px;" cellspacing="0">
<tr>
<th colspan="2"><?php echo __('Interface')?></th>
</tr>
......
</tr>
<?php endif; ?>
</table>
<?php if ($iface->type == Iface_model::TYPE_VLAN): ?>
<table class="extended" style="float:left; margin-left:10px; width:360px;" cellspacing="0">
<tr>
<th colspan="2"><?php echo __('VLAN detail')?></th>
</tr>
<?php
$parents = $iface->ifaces_relationships;
$vlans = $iface->ifaces_vlans;
foreach ($parents AS $parent): ?>
<tr>
<th><?php echo __('Parent interface') ?></th>
<td><?php echo html::anchor('ifaces/show/'.$parent->parent_iface->id, $parent->parent_iface) ?></td>
</tr>
<?php endforeach;
foreach ($vlans AS $vlan): ?>
<tr>
<th><?php echo __('VLAN') ?></th>
<td><?php echo html::anchor('vlans/show/'.$vlan->vlan->id, $vlan->vlan->name) ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<br class="clear" />
<br />
<?php if (Iface_Model::type_has_ip_address($iface->type))
echo $detail ?>
<?php echo $detail ?>
<br class="clear" />
<br />
freenetis/branches/network/application/views/links/show.php
</table>
<?php if ($link->medium == Link_Model::MEDIUM_AIR): ?>
<table class="extended" style="float: left; margin-left:65px" cellspacing="0">
<table class="extended" style="float:left; margin-left:10px; width:360px;" cellspacing="0">
<tr>
<th colspan="2"><?php echo __('Wireless setting') ?></th>
</tr>

Také k dispozici: Unified diff