Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2048

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

Opravy:
- fixes #676: Topologie zarizeni v siti

Zobrazit rozdíly:

freenetis/branches/1.1/application/controllers/devices.php
$input->add_error('required', __('Must be greater than zero'));
}
}
}
/**
* Displays topology of device in network
*
* @author Michal Kliment
* @param integer $device_id
*/
public function topology($device_id = NULL)
{
// bad parameter
if (!$device_id || !is_numeric($device_id))
Controller::warning (PARAMETER);
$device = new Device_Model($device_id);
// record doesn't exist
if (!$device->id)
Controller::error(RECORD);
// access control
if (!$this->acl_check_view(get_class($this), 'topology', $device->user->member_id))
Controller::error(ACCESS);
$device_topology = new stdClass();
$device_topology->ifaces = array();
$numbers = array();
$names = array();
// iterate over all ifaces of device
foreach ($device->ifaces as $iface)
{
// only iface which can be connected to other
if (!Iface_Model::type_has_link($iface->type))
{
continue;
}
$numbers[] = $iface->number;
$names[] = $iface->name;
$device_topology->ifaces[$iface->id] = arr::to_object(array
(
'id' => $iface->id,
'name' => $iface->name,
'type' => $iface->type,
'mac' => $iface->mac,
));
$device_topology->ifaces[$iface->id]->connected_devices = NULL;
// find all ifaces which are connected to this iface
$connected_ifaces = $iface->get_ifaces_connected_to_iface();
if (count($connected_ifaces))
{
$connected_devices = array();
$device_names = array();
foreach ($connected_ifaces as $connected_iface)
{
$connected_devices[] = arr::to_object(array
(
'id' => $connected_iface->device_id,
'name' => $connected_iface->device->name,
'type' => $connected_iface->device->type,
'member_id' => $connected_iface->device->user->member_id
));
$device_names[] = $connected_iface->device->name;
}
// sort connected devices by name
array_multisort($device_names, $connected_devices);
$device_topology->ifaces[$iface->id]->connected_devices = $connected_devices;
}
// sort ifaces by port number, then by name
array_multisort($numbers, $names, $device_topology->ifaces);
}
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller','members'))
->disable_translation()
->link('members/show/' . $device->user->member->id,
'ID ' . $device->user->member->id . ' - ' . $device->user->member->name,
$this->acl_check_view('Members_Controller','members', $device->user->member->id))
->enable_translation()
->link('users/show_by_member/' . $device->user->member_id, 'Users',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->disable_translation()
->link('users/show/' . $device->user->id,
$device->user->name . ' ' . $device->user->surname . ' (' . $device->user->login . ')',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->enable_translation()
->link('devices/show_by_user/' . $device->user->id, 'Devices',
$this->acl_check_view(
get_class($this), 'devices',
$device->user->member_id
)
)->disable_translation()
->link('devices/show/' . $device_id, $device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $device->user->member_id))
->enable_translation()
->text('Topology');
$title = __('Topology of device').' '.$device->name;
$view = new View('main');
$view->breadcrumbs = $breadcrumbs;
$view->title = $title;
$view->content = new View('devices/topology');
$view->content->device = $device;
$view->content->device_topology = $device_topology;
$view->render(TRUE);
}
}
freenetis/branches/1.1/application/controllers/js.php
$this->views['devices_map']->name = $name;
}
private function _js_devices_topology($device_id)
{
$this->views['devices_add'] = View::factory('js/devices_topology');
$this->views['devices_add']->device_id = $device_id;
}
private function _js_ifaces_add($device_id = null, $itype = null,
$add_button = FALSE, $connect_type = NULL)
{
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'disagree' => 'Nesouhlas',
'discount private services from phone keepers credit account' => 'Strhnout soukromé služby z kreditního účtu držitelů telefonů',
'discounted from credit accounts' => 'Strženo z kreditních účtů',
'display detail of device' => 'Zobrazit podrobnosti o zařízení',
'display detail of interface' => 'Zobrazit podrobnosti o rozhraní',
'display member' => 'Zobraz člena',
'display topology of device' => 'Zobrazit topologii zařízení',
'display user' => 'Zobraz uživatele',
'dns configuration' => 'Konfigurace DNS',
'dns configuration files were successfully generated' => 'Konfigurační soubory pro DNS byly úspěšně vygenerovány',
......
'show subdevices tree' => 'Zobrazit strom podzařízení',
'show tariffs' => 'Zobrazit tarify',
'show this table' => 'Zobrazit tuto tabulku',
'show topology' => 'Zobrazit topologii',
'show traffic' => 'Zobrazit provoz',
'show transfer' => 'ukaž transakci',
'show transfers' => 'Zobrazit převody',
......
'too short' => 'Příliš krátké',
'tools' => 'Nástroje',
'top' => 'Nahoru',
'topology' => 'Topologie',
'topology of device' => 'Topologie zařízení',
'total' => 'Celkem',
'total count' => 'Celkový počet',
'total download' => 'Celkový download',
freenetis/branches/1.1/application/models/iface.php
}
/**
* Gets all interfaces connected to interface via link.
*
* @param Iface_Model $iface
* @return Iface_Model
*/
public function get_ifaces_connected_to_iface($iface = NULL)
{
if ($iface === NULL)
{
$iface = $this;
}
$ifaces = array();
if ($iface && $iface->id)
{
$can_connect = self::get_can_connect_to($iface->type);
foreach ($iface->link->ifaces as $connected_iface)
{
// only if can connect to this type, is not self and if wlan then
// prserve rules AP -> client, client -> AP
if ($connected_iface->id != $iface->id &&
in_array($connected_iface->type, $can_connect) && (
$iface->type != self::TYPE_WIRELESS ||
$iface->wireless_mode != $connected_iface->wireless_mode
))
{
$ifaces[] = $connected_iface;
}
}
}
return $ifaces;
}
/**
* Tries to find best suitable interface for connecting of a new device of user.
*
* @author Ondrej Fibich
freenetis/branches/1.1/application/views/devices/show.php
if ($this->acl_check_view('Devices_Controller', 'map', $device->user->member_id))
$links[] = html::anchor('devices/map/'.$device->id, __('Show subdevices tree'));
$links[] = html::anchor('devices/topology/'.$device->id, __('Show topology'));
if (Settings::get('monitoring_enabled'))
{
$links[] = html::anchor('monitoring/action/'.$device->id, __('Monitoring'), array
freenetis/branches/1.1/application/views/devices/topology.php
<h2><?php echo __('Topology of device').' '.$device->name ?></h2>
<ul class="topology" id="topology-<?php echo $device->id ?>">
<?php foreach ($device_topology->ifaces as $iface): ?>
<li>
<?php echo html::anchor(
'ifaces/show/'.$iface->id,
$iface->name,
array
(
'title' => __('Display detail of interface'),
'class' => 'popup_link'
)
) ?>:
<?php if ($iface->connected_devices): ?>
<?php if (count($iface->connected_devices) > 0): ?>
<?php if (count($iface->connected_devices) > 1): ?>
<?php echo count($iface->connected_devices)?> <?php echo __('devices') ?>
<ul>
<?php endif ?>
<?php foreach ($iface->connected_devices as $connected_device): ?>
<?php echo count($iface->connected_devices) > 1 ? '<li>' : '' ?>
<h3><?php if ($this->acl_check_view('Devices_Controller', 'topology', $connected_device->member_id)): ?>
<?php echo html::anchor(
'devices/topology/'.$connected_device->id,
$connected_device->name,
array
(
'title' => __('Display topology of device').' '.$connected_device->name,
'class' => 'topology-link',
'id' => 'topology-link-'.$connected_device->id
)
);
?>
<?php else: ?>
<?php echo $connected_device->name ?>
<?php endif?>
<?php echo html::anchor(
'devices/show/'.$connected_device->id,
html::image(array('src' => 'media/images/icons/grid_action/show.png')),
array
(
'title' => __('Display detail of device'),
'class' => 'popup_link'
)
) ?></h3>
<?php echo count($iface->connected_devices) > 1 ? '</li>' : '' ?>
<?php endforeach ?>
<?php if (count($iface->connected_devices) > 1): ?>
</ul>
<?php endif ?>
<?php endif ?>
<?php else: ?>
<span style="color: green"><?php echo __('Not connected') ?></span>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
freenetis/branches/1.1/application/views/js/devices_topology.php
<?php
/**
* Devices show all javascript view.
*
* @author Michal Kliment, Ondřej Fibich
*/
// IDE complementation
if (FALSE): ?><script type="text/javascript"><?php endif
?>
var ids = [<?php echo $device_id ?>];
states = {<?php echo $device_id ?>: 1}
$(".topology-link").live('click', function (){
$this = $(this);
var id = $this.attr('id').replace('topology-link-', '');
if (!in_array(id, ids))
{
$.ajax({
async: false,
type: 'POST',
url: $(this).attr('href'),
success: function (data){
data = $(data).find(".topology");
if (data[0] !== undefined)
$this.parent().parent().append(data[0].outerHTML);
}
});
$this.parent().parent().find('li .topology-link').each (function (){
var id = $(this).attr('id').replace('topology-link-', '');
if (in_array(id, ids))
{
$(this).parent().replaceWith($(this).text());
}
});
ids.push(id);
states[id] = 0;
$this.parent().parent().find('.topology').hide();
}
states[id] = (states[id] == 0) ? 1 : 0;
$this.parent().parent().find('.topology').toggle('slow');
return false;
});
freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha41.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* This upgrade is not equal to any of previos upgrades
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_equal_to['1.1.0~alpha41'] = array();
/**
* ACL records for topology of device
*
* @author Michal Kliment
*/
$upgrade_sql['1.1.0~alpha41'] = array
(
"INSERT INTO axo SELECT MAX(id)+1, 'Devices_Controller', 'topology', 'Topology of device' FROM axo",
"INSERT INTO axo_map (acl_id, section_value, value) VALUES ('38', 'Devices_Controller', 'topology');"
);
freenetis/branches/1.1/media/css/style.css
padding-bottom: .5em;
}
ul.topology {
margin-top: 10px;
margin-bottom: 10px;
}
ul.topology li {
margin-left: 40px;
}
ul.topology h3 {
display: inline;
}
freenetis/branches/1.1/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.1.0~alpha40');
define('FREENETIS_VERSION', '1.1.0~alpha41');

Také k dispozici: Unified diff