Revize 1413
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/network/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'add new project account' => 'Přidat nový projektový účet',
|
||
'add new redirection message' => 'Přidat novou zprávu přesměrování',
|
||
'add new rule' => 'Přidat nové pravidlo',
|
||
'add new segment' => 'Přidat nový segment',
|
||
'add new link' => 'Přidat novou linku',
|
||
'add new ssh key' => 'Přidat nový SSH klíč',
|
||
'add new ssh key to user' => 'Přidat nový SSH klíč uživateli',
|
||
'add new street' => 'Přidat novou ulici',
|
||
... | ... | |
'asterisk manager settings' => 'Nastavení Asterisk manažeru',
|
||
'at least one address point uses this street' => 'Alespoň jeden adresní bod používá tuto ulici.',
|
||
'at least one address point uses this town' => 'Alespoň jeden adresní bod používá toto město.',
|
||
'at least one interface or port still uses this segment' => 'Ještě nejméně jedno rozhraní nebo port používá tento segment.',
|
||
'at least one interface or port still uses this link' => 'Ještě nejméně jedno rozhraní nebo port používá tuto linku.',
|
||
'at least one item still has this address point' => 'Ještě nejméně jedna položka používá tento adresní bod.',
|
||
'at least one member still has this address point' => 'Alespoň jeden člen má tento adresní bod.',
|
||
'auditing comittee' => 'Revizní komise',
|
||
... | ... | |
'back to ports list' => 'Zpět na seznam portů',
|
||
'back to profile of association' => 'Zpět na profil sdružení',
|
||
'back to project accounts' => 'Zpět na projektové účty',
|
||
'back to segments list' => 'Zpět na seznam segmentů',
|
||
'back to links list' => 'Zpět na seznam linek',
|
||
'back to the approval template' => 'Zpátky k hlasovací šabloně',
|
||
'back to the approval type' => 'Zpátky k hlasovacímu typu',
|
||
'back to the cloud list' => 'Zpět na seznam oblastí',
|
||
... | ... | |
'edit redirection message' => 'Úprava zprávy přesměrování',
|
||
'edit registrations' => 'Upravit přihlášky',
|
||
'edit routerboard backup' => 'Upravit zálohu routerboardu',
|
||
'edit segment' => 'Úprava segmentu',
|
||
'edit link' => 'Úprava linku',
|
||
'edit smokeping record' => 'Upravit záznam smokepingu',
|
||
'edit the work' => 'Upravit práci',
|
||
'edit ssh key' => 'Upravit SSH klíč',
|
||
... | ... | |
'for' => 'Za',
|
||
'for all items' => 'Pro všechny položky',
|
||
'for all type' => 'Pro všechny typy',
|
||
'fiber optical multi-mode' => 'vlákno - optické vícevidové',
|
||
'fiber optical single-mode' => 'vlákno - optické jednovidové',
|
||
'filter queries' => 'Dotazy filtru',
|
||
'fixed calls' => 'Volání na pevnou linku',
|
||
'fixed line' => 'Pevná linka',
|
||
'fixed line number' => 'Číslo v pevné lince',
|
||
'for smtp settings only' => 'Pouze pro nastavení SMTP.',
|
||
... | ... | |
'fourth-degree certified engineers' => 'Certifikování technici čtvrtého stupně',
|
||
'free' => 'Volná',
|
||
'frequence' => 'Frekvence',
|
||
'frequency' => 'Frekvence',
|
||
'from/to' => 'Od/komu',
|
||
'from' => 'Od',
|
||
'from2' => 'z',
|
||
'fiber optical multi-mode' => 'vlákno - optické vícevidové',
|
||
'fiber optical single-mode' => 'vlákno - optické jednovidové',
|
||
'filter queries' => 'Dotazy filtru',
|
||
'fixed calls' => 'Volání na pevnou linku',
|
||
'gateway' => 'Brána',
|
||
'gateway information' => 'Informace o bráně',
|
||
'gateway ip address' => 'IP adresa brány',
|
||
... | ... | |
'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.',
|
||
'in this link interface in mode ap already exists' => 'V tomto linku již existuje rozhraní v módu AP.',
|
||
'inactive' => 'Neaktivní',
|
||
'inbound' => 'Příchozí',
|
||
'incomes' => 'Příjmy',
|
||
... | ... | |
'send' => 'Odeslat',
|
||
'send mail warning to users related with invoice' => 'Odeslat upozornění uživatelům spojených s fakturou',
|
||
'send message' => 'Odeslat zprávu',
|
||
'segment detail' => 'Detail segmentu',
|
||
'segment has been successfully deleted' => 'Segment byl úspěšně smazán.',
|
||
'segment has been successfully saved' => 'Segment byl úspěšně uložen.',
|
||
'segment has been successfully updated' => 'Segment byl úspěšně upraven.',
|
||
'segment is invalid - its medium has to in relation with type of interface' => 'Segment je neplatný - jeho médium musí odpovídat typu rozhraní.',
|
||
'segment name' => 'Název segmentu',
|
||
'segment with roaming can exists only once' => 'Segment s roamingem smí existovat pouze jednou.',
|
||
'segment_name' => 'Název segmentu',
|
||
'segments list' => 'Seznam segmentů',
|
||
'segments' => 'Segmenty',
|
||
'link detail' => 'Detail linky',
|
||
'link has been successfully deleted' => 'Lynka byla úspěšně smazán.',
|
||
'link has been successfully saved' => 'Lynka byla úspěšně uložen.',
|
||
'link has been successfully updated' => 'Lynka byla úspěšně upraven.',
|
||
'link is invalid - its medium has to in relation with type of interface' => 'Linka je neplatná - její médium musí odpovídat typu rozhraní.',
|
||
'link name' => 'Název linky',
|
||
'link with roaming can exists only once' => 'Linka s roamingem smí existovat pouze jednou.',
|
||
'link_name' => 'Název linky',
|
||
'links list' => 'Seznam linek',
|
||
'links' => 'Linky',
|
||
'select' => 'Vyber',
|
||
'select account type' => 'Vyber typ účtu',
|
||
'select action' => 'Vyber činnost',
|
||
... | ... | |
'select platform' => 'Vyber platformu',
|
||
'select polarization' => 'Vyber polarizaci',
|
||
'select port' => 'Vyber port',
|
||
'select segment' => 'Vyber segment',
|
||
'select link' => 'Vyber linku',
|
||
'select street' => 'Vyber ulici',
|
||
'select subnet' => 'Vyber podsíť',
|
||
'select subnet ip' => 'Vyber IP adresu podsítě',
|
freenetis/branches/network/application/helpers/callback.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Callback function to print bitrate of segment
|
||
* Callback function to print bitrate of link
|
||
*
|
||
* @author Michal Kliment
|
||
* @param object $item
|
||
... | ... | |
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function segment_item_field ($item, $name)
|
||
public static function link_item_field ($item, $name)
|
||
{
|
||
switch ($item->type)
|
||
{
|
||
... | ... | |
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function segment_item_type_field ($item, $name)
|
||
public static function link_item_type_field ($item, $name)
|
||
{
|
||
switch ($item->type)
|
||
{
|
||
... | ... | |
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function segment_medium_field ($item, $name)
|
||
public static function link_medium_field ($item, $name)
|
||
{
|
||
echo Link_Model::get_medium_type($item->medium);
|
||
}
|
||
... | ... | |
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function wireless_segment_norm ($item, $name)
|
||
public static function wireless_link_norm ($item, $name)
|
||
{
|
||
echo Wireless_segment_Model::get_norm($item->norm);
|
||
echo Link_Model::get_wireless_norm($item->wireless_norm);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @param object $item
|
||
* @param string $name
|
||
*/
|
||
public static function wireless_iface_mode ($item, $name)
|
||
public static function wireless_mode ($item, $name)
|
||
{
|
||
echo Wireless_iface_Model::get_mode($item->wmode);
|
||
echo Link_Model::get_wireless_norm($item->wireless_mode);
|
||
}
|
||
|
||
/**
|
freenetis/branches/network/application/models/link.php | ||
---|---|---|
/**
|
||
* Link is providing connection between two interfaces. Type is given by
|
||
* medium (e.g. wifi, cable). Link may be specified by attributed such as
|
||
* bitrate, dupley, GPS line, etc. Moreover ink of wifi type may be also
|
||
* bitrate, duplex, GPS line, etc. Moreover ink of wifi type may be also
|
||
* specified by several other attributes (norm, frequence, channel, ssid, etc.).
|
||
*
|
||
* @package Model
|
||
... | ... | |
{
|
||
if (!$norm && isset($this))
|
||
{
|
||
$norm = $this->norm;
|
||
$norm = $this->wireless_norm;
|
||
}
|
||
|
||
if (array_key_exists($norm, self::$wireless_norms))
|
||
... | ... | |
{
|
||
if (!$polarization)
|
||
{
|
||
$polarization = $this->polarization;
|
||
$polarization = $this->wireless_polarization;
|
||
}
|
||
|
||
if (array_key_exists($polarization, self::$wireless_polarizations))
|
||
{
|
||
return url_lang::lang('texts.'.self::$wireless_polarizations[$polarization]);
|
||
return __(self::$wireless_polarizations[$polarization]);
|
||
}
|
||
|
||
return NULL;
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Counts all segments
|
||
* Counts all links
|
||
*
|
||
* @param array $filter_values
|
||
* @param array $filter_sql
|
||
* @return integer
|
||
*/
|
||
public function count_all_segments($filter_sql = '')
|
||
public function count_all_links($filter_sql = '')
|
||
{
|
||
$where = '';
|
||
|
||
... | ... | |
SELECT COUNT(*) AS total
|
||
FROM
|
||
(
|
||
SELECT s.id, s.name, medium 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,
|
||
IFNULL(ws.ssid,'') AS ssid, ws.norm
|
||
FROM segments s
|
||
SELECT s.id, s.name, s.medium, s.duplex, s.comment, s.bitrate,
|
||
IFNULL(s.wireless_ssid,'') AS ssid, s.wireless_norm,
|
||
(SELECT COUNT(*) FROM ifaces WHERE link_id = s.id) as items_count
|
||
FROM links s
|
||
LEFT JOIN enum_types e ON s.medium = e.id
|
||
LEFT JOIN (
|
||
SELECT *
|
||
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;
|
||
}
|
||
|
||
/**
|
||
* Gets all segments
|
||
* Gets all linkss
|
||
*
|
||
* @param integer $limit_from
|
||
* @param integer $limit_results
|
||
... | ... | |
* @param array $filter_values
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_segments(
|
||
public function get_all_links(
|
||
$limit_from = 0, $limit_results = 20,
|
||
$order_by = 'id', $order_by_direction = 'asc',
|
||
$filter_sql = '')
|
||
... | ... | |
return $this->db->query("
|
||
SELECT * FROM
|
||
(
|
||
SELECT s.id, s.name, medium 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,
|
||
IFNULL(ws.ssid,'') AS ssid, ws.norm
|
||
FROM segments s
|
||
SELECT s.id, s.name, s.medium, s.duplex, s.comment, s.bitrate,
|
||
IFNULL(s.wireless_ssid,'') AS ssid, s.wireless_norm,
|
||
(SELECT COUNT(*) FROM ifaces WHERE link_id = s.id) as items_count
|
||
FROM links s
|
||
LEFT JOIN enum_types e ON s.medium = e.id
|
||
LEFT JOIN (
|
||
SELECT *
|
||
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
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Function tries to find segment where user's device is connected to. Used in devices/add.
|
||
* Function tries to find link where user's device is connected to. Used in devices/add.
|
||
*
|
||
* @param integer $user_id
|
||
* @return Database_Result
|
||
*/
|
||
public function get_segment_of_user($user_id)
|
||
public function get_link_of_user($user_id)
|
||
{
|
||
$result = $this->db->query("
|
||
SELECT DISTINCT s.id, s.name
|
||
FROM segments s
|
||
JOIN ifaces i ON i.segment_id = s.id
|
||
FROM links s
|
||
JOIN ifaces i ON i.link_id = s.id
|
||
JOIN devices d ON d.id = i.device_id
|
||
WHERE d.user_id = ?
|
||
", $user_id);
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Returns roaming segment
|
||
* Returns roaming link. This function changes current object values.
|
||
*
|
||
* @author Michal Kliment
|
||
* @return integer
|
||
*/
|
||
public function get_roaming ()
|
||
public function get_roaming()
|
||
{
|
||
$roaming = $this->where('medium', self::ROAMING)->find();
|
||
return ($roaming && $roaming->id) ? $roaming->id : NULL;
|
||
}
|
||
|
||
/**
|
||
* get segment by IP address
|
||
* Get link by IP address
|
||
*
|
||
* @param integer $ip_address
|
||
* @return Link_Model
|
||
*/
|
||
public function get_by_ip_address ($ip_address)
|
||
public function get_by_ip_address($ip_address)
|
||
{
|
||
$result = $this->db->query("
|
||
SELECT s.* FROM
|
||
(
|
||
SELECT IFNULL(i1.segment_id,i2.segment_id) AS segment_id
|
||
FROM ip_addresses ip
|
||
LEFT JOIN ifaces i1 ON ip.iface_id = i1.id
|
||
LEFT JOIN vlan_ifaces vi ON ip.vlan_iface_id = vi.id
|
||
LEFT JOIN ifaces i2 ON vi.iface_id = i2.id
|
||
WHERE ip.ip_address = ?
|
||
) AS q
|
||
JOIN segments s ON q.segment_id = s.id
|
||
", array($ip_address));
|
||
SELECT s.*
|
||
FROM ip_addresses ip
|
||
JOIN ifaces i ON ip.iface_id = i.id
|
||
JOIN links s ON i.link_id = s.id
|
||
WHERE ip.ip_address = ?
|
||
", $ip_address);
|
||
|
||
if ($result && $result->count() > 0)
|
||
{
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Returns all segments to dropdown as array
|
||
* Returns all links to dropdown as array
|
||
*
|
||
* @author Michal Kliment
|
||
* @return array
|
||
*/
|
||
public function get_all_segments_to_dropdown ()
|
||
{
|
||
return $this->select_list('id', 'name');
|
||
}
|
||
|
||
/**
|
||
* Returns all segments to dropdown as array
|
||
*
|
||
* @author Michal Kliment
|
||
* @return array
|
||
*/
|
||
public function get_all_segments_to_iface_dropdown ()
|
||
public function get_all_links_to_iface_dropdown()
|
||
{
|
||
$segments = $this->db->query("
|
||
$links = $this->db->query("
|
||
SELECT s.id, s.name
|
||
FROM segments s
|
||
FROM links s
|
||
WHERE medium = ? OR medium = ? OR medium = ?
|
||
ORDER BY s.name
|
||
", array(self::AIR, self::CABLE, self::ROAMING));
|
||
|
||
$arr_segments = array();
|
||
$arr_links = array();
|
||
|
||
foreach ($segments as $segment)
|
||
foreach ($links as $link)
|
||
{
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
$arr_links[$link->id] = $link->name;
|
||
}
|
||
|
||
return $arr_segments;
|
||
return $arr_links;
|
||
}
|
||
|
||
/**
|
||
* Returns all segments to dropdown as array
|
||
* Returns all links to dropdown as array
|
||
*
|
||
* @author Michal Kliment
|
||
* @return array
|
||
*/
|
||
public function get_all_segments_to_port_dropdown ()
|
||
public function get_all_links_to_port_dropdown()
|
||
{
|
||
$segments = $this->db->query("
|
||
$links = $this->db->query("
|
||
SELECT s.id, s.name
|
||
FROM segments s
|
||
FROM links s
|
||
WHERE medium = ? OR medium = ? OR medium = ? OR medium = ?
|
||
ORDER BY s.name
|
||
", array(self::SINGLE_FIBER, self::MULTI_FIBER, self::CABLE, self::ROAMING));
|
||
|
||
$arr_segments = array();
|
||
$arr_links = array();
|
||
|
||
foreach ($segments as $segment)
|
||
foreach ($links as $link)
|
||
{
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
$arr_links[$link->id] = $link->name;
|
||
}
|
||
|
||
return $arr_segments;
|
||
return $arr_links;
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @param integer $type_id
|
||
* @return string
|
||
*/
|
||
public static function get_medium_type ($medium_type_id)
|
||
public static function get_medium_type($medium_type_id)
|
||
{
|
||
if (isset(self::$medium_types[$medium_type_id]))
|
||
{
|
||
... | ... | |
* @author Michal Kliment
|
||
* @return array
|
||
*/
|
||
public static function get_medium_types ()
|
||
{
|
||
$medium_types = array();
|
||
|
||
foreach (self::$medium_types as $medium_type_id => $medium_type)
|
||
{
|
||
$medium_types[$medium_type_id] = _($medium_type);
|
||
}
|
||
|
||
return $medium_types;
|
||
public static function get_medium_types()
|
||
{
|
||
return array_map('__', self::$medium_types);
|
||
}
|
||
|
||
/**
|
||
* Returns all items (interfaces and ports) which belong to given segment
|
||
* Returns all items (interfaces) which belong to given link
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $segment_id
|
||
* @param integer $link_id
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_items ($segment_id = NULL)
|
||
public function get_items($link_id = NULL)
|
||
{
|
||
if (!$segment_id)
|
||
if (!$link_id)
|
||
{
|
||
$segment_id = $this->id;
|
||
$link_id = $this->id;
|
||
}
|
||
|
||
return $this->db->query("
|
||
SELECT q.*, d.name AS device_name, m.name AS member_name,
|
||
m.id AS member_id, wi.wmode
|
||
FROM
|
||
(
|
||
SELECT id, device_id, mac, name, ? AS type
|
||
FROM ifaces i
|
||
WHERE i.segment_id = ?
|
||
UNION
|
||
SELECT id, device_id, NULL AS mac, name, ? AS type
|
||
FROM ports p
|
||
WHERE p.segment_id = ?
|
||
) AS q
|
||
JOIN devices d ON q.device_id = d.id
|
||
SELECT i.*, d.name AS device_name, m.name AS member_name,
|
||
m.id AS member_id, i.wireless_mode
|
||
FROM ifaces i
|
||
JOIN devices d ON i.device_id = d.id
|
||
JOIN users u ON d.user_id = u.id
|
||
JOIN members m ON u.member_id = m.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);
|
||
WHERE i.link_id = ?
|
||
ORDER BY i.wireless_mode
|
||
", $link_id);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @param integer $type
|
||
* @return array
|
||
*/
|
||
public function get_all_segments_by_iface_type ($type)
|
||
public function get_all_links_by_iface_type ($type)
|
||
{
|
||
switch ($type)
|
||
{
|
freenetis/branches/network/application/controllers/segments.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/
|
||
*
|
||
*/
|
||
|
||
/**
|
||
* Controller performs actions over segments of network.
|
||
*
|
||
* @package Controller
|
||
*/
|
||
class Segments_Controller extends Controller
|
||
{
|
||
|
||
/**
|
||
* ID of working segment
|
||
*
|
||
* @var integer
|
||
*/
|
||
private $segment_id = NULL;
|
||
|
||
/**
|
||
* Redirects to show all
|
||
*/
|
||
public function index()
|
||
{
|
||
url::redirect('segments/show_all');
|
||
}
|
||
|
||
/**
|
||
* Function shows all segments.
|
||
*
|
||
* @param integer $limit_results
|
||
* @param string $order_by
|
||
* @param string $order_by_direction
|
||
* @param integer $page_word
|
||
* @param integer $page
|
||
*/
|
||
public function show_all(
|
||
$limit_results = 200, $order_by = 'id', $order_by_direction = 'asc',
|
||
$page_word = null, $page = 1)
|
||
{
|
||
|
||
if (!$this->acl_check_view('Devices_Controller','segment'))
|
||
Controller::error(ACCESS);
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
$segment_model = new Link_Model();
|
||
|
||
$filter_form = new Filter_form('s');
|
||
|
||
$filter_form->add('name')
|
||
->callback('json/segment_name');
|
||
|
||
$filter_form->add('medium')
|
||
->type('select')
|
||
->values($segment_model->get_medium_types());
|
||
|
||
$filter_form->add('bitrate')
|
||
->type('number');
|
||
|
||
$filter_form->add('duplex')
|
||
->type('select')
|
||
->values(array
|
||
(
|
||
1 => __('Yes'),
|
||
0 => __('No')
|
||
));
|
||
|
||
$filter_form->add('comment');
|
||
|
||
$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 Link_Model();
|
||
$total_segments = $segment_model->count_all_segments($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_segments)
|
||
$sql_offset = 0;
|
||
|
||
$segments = $segment_model->get_all_segments(
|
||
$sql_offset, (int)$limit_results, $order_by,
|
||
$order_by_direction, $filter_form->as_sql()
|
||
);
|
||
|
||
$grid = new Grid(url_lang::base().'segments', null, array
|
||
(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 200,
|
||
'selector_min' => 200,
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::get('lang').'/segments/show_all/'
|
||
. $limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page',
|
||
'total_items' => $total_segments,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form
|
||
));
|
||
|
||
if ($this->acl_check_new('Devices_Controller','segment'))
|
||
{
|
||
$grid->add_new_button('segments/add', __('Add new segment'));
|
||
}
|
||
|
||
$grid->order_field('id')
|
||
->label('ID')
|
||
->class('center');
|
||
|
||
$grid->order_field('name')
|
||
->label(__('Name'));
|
||
|
||
$grid->order_callback_field('medium_id')
|
||
->label(__('Medium'))
|
||
->callback('callback::segment_medium_field');
|
||
|
||
$grid->order_callback_field('bitrate')
|
||
->label(__('Bitrate'))
|
||
->callback('callback::bitrate_field');
|
||
|
||
$grid->order_field('duplex')
|
||
->label(__('Duplex'))
|
||
->bool(array
|
||
(
|
||
__('No'),
|
||
__('Yes')
|
||
))->class('center');
|
||
|
||
$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'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('show')
|
||
->url('segments/show');
|
||
}
|
||
|
||
if ($this->acl_check_edit('Devices_Controller','segment'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('edit')
|
||
->url('segments/edit');
|
||
}
|
||
|
||
if ($this->acl_check_delete('Devices_Controller','segment'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('delete')
|
||
->url('segments/delete')
|
||
->class('delete_link');
|
||
}
|
||
|
||
$this->template = new stdClass();
|
||
$grid->datasource($segments);
|
||
$this->template->content = $grid;
|
||
|
||
$view = new View('main');
|
||
$view->breadcrumbs = __('Segments');
|
||
$view->title = __('Segments list');
|
||
$view->content = new View('show_all');
|
||
$view->content->table = $this->template->content;
|
||
$view->content->headline = __('Segments list');
|
||
$view->render(TRUE);
|
||
} // end of show_all
|
||
|
||
/**
|
||
* Function shows segment information.
|
||
*
|
||
* @param integer $segment_id
|
||
*/
|
||
public function show($segment_id = null)
|
||
{
|
||
if (!$segment_id || !is_numeric($segment_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$segment = new Link_Model($segment_id);
|
||
|
||
if (!$segment || !$segment->id)
|
||
Controller::warning(ACCESS);
|
||
|
||
if (!$this->acl_check_view('Devices_Controller', 'segment'))
|
||
Controller::error(ACCESS);
|
||
|
||
$duplex_value = array
|
||
(
|
||
'0' => __('No'),
|
||
'1' => __('Yes')
|
||
);
|
||
|
||
$duplex = $duplex_value[(bool)$segment->duplex];
|
||
|
||
// segment media
|
||
$medium = Link_Model::get_medium_type($segment->medium_id);
|
||
|
||
if ($segment->medium_id != Link_Model::AIR)
|
||
$headline = __('Interfaces').' / '.__('Ports');
|
||
else
|
||
$headline = __('Interfaces');
|
||
|
||
|
||
$grid = new Grid(
|
||
url_lang::base().'subnets/show/'.$segment_id,
|
||
$headline, array
|
||
(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
$grid->field('id')
|
||
->label(__('ID'));
|
||
|
||
$grid->callback_field('name')
|
||
->label(__('Name'))
|
||
->callback('callback::segment_item_field');
|
||
|
||
if ($segment->medium_id != Link_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'));
|
||
|
||
$grid->callback_field('device_id')
|
||
->label(__('Device name'))
|
||
->callback('callback::device_field');
|
||
|
||
$grid->callback_field('member_id')
|
||
->label(__('member'))
|
||
->callback('callback::member_field');
|
||
|
||
$grid->datasource($segment->get_items());
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('segments/show_all', 'Segments',
|
||
$this->acl_check_view('Devices_Controller','segment'))
|
||
->text($segment->name . ' (' . $segment->id . ')');
|
||
|
||
$links = array();
|
||
|
||
if($this->acl_check_edit('Devices_Controller','segment'))
|
||
{
|
||
$links[] = html::anchor('segments/edit/'.$segment->id, __('Edit'));
|
||
}
|
||
|
||
if($this->acl_check_delete('Devices_Controller','segment'))
|
||
{
|
||
$links[] = html::anchor(
|
||
'segments/delete/'.$segment->id, __('Delete'),
|
||
array('class' => 'delete_link')
|
||
);
|
||
}
|
||
|
||
$headline = __('Segment detail').' - '.$segment->name;
|
||
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('segments/show');
|
||
$view->content->segment = $segment;
|
||
$view->content->duplex = $duplex;
|
||
$view->content->medium = $medium;
|
||
$view->content->grid = $grid;
|
||
$view->content->links = implode(' | ',$links);
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
} // end of show
|
||
|
||
/**
|
||
* Function adds segment.
|
||
*/
|
||
public function add()
|
||
{
|
||
if(!$this->acl_check_new('Devices_Controller','segment'))
|
||
Controller::error(ACCESS);
|
||
|
||
$roaming = ORM::factory('segment')->get_roaming();
|
||
|
||
$media = array();
|
||
|
||
foreach (Link_Model::get_medium_types() as $id => $type)
|
||
{
|
||
if ($id != Link_Model::ROAMING || !$roaming)
|
||
{
|
||
$media[$id] = __(''.$type);
|
||
}
|
||
}
|
||
asort($media);
|
||
|
||
$media = array
|
||
(
|
||
NULL => '----- '.__('Select medium').' -----'
|
||
) + $media;
|
||
|
||
$form = new Forge();
|
||
|
||
$form->group('Basic data');
|
||
|
||
$form->input('name')
|
||
->label(__('name').':')
|
||
->rules('required')
|
||
->style('width: 600px');;
|
||
|
||
$form->dropdown('medium_id')
|
||
->label(__('Medium').':')
|
||
->options($media)
|
||
->rules('required')
|
||
->callback(array($this, 'valid_medium'));
|
||
|
||
$form->input('bitrate')
|
||
->label(__('bitrate').':')
|
||
->rules('valid_numeric')
|
||
->class('join1')
|
||
->style('width:100px; margin-right:5px;');
|
||
|
||
$arr_unit = array
|
||
(
|
||
'1' => 'bps',
|
||
'1024' => 'kbps',
|
||
'1048576' => 'Mbps',
|
||
'1073741824' => 'Gbps'
|
||
);
|
||
|
||
$form->dropdown('bit_unit')
|
||
->options($arr_unit)
|
||
->class('join2')
|
||
->selected(1048576)
|
||
->callback(array($this, 'valid_bitrate'));
|
||
|
||
$form->checkbox('duplex')
|
||
->label(__('duplex'))
|
||
->value('1');
|
||
|
||
$form->textarea('comment')
|
||
->label(__('comment').':')
|
||
->rules('length[0,254]')
|
||
->cols('20')
|
||
->rows('5');
|
||
|
||
$form->group('Wireless setting');
|
||
|
||
$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('Save');
|
||
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
|
||
$segment = new Link_Model();
|
||
$segment->name = $form_data['name'];
|
||
$segment->medium_id = $form_data['medium_id'];
|
||
$segment->bitrate = $form_data['bitrate']*$form_data['bit_unit'];
|
||
$segment->duplex = $form_data['duplex'];
|
||
$segment->comment = $form_data['comment'];
|
||
|
||
if ($segment->save())
|
||
{
|
||
if ($segment->medium_id == Link_Model::AIR)
|
||
{
|
||
$segment->wireless->ssid = $form_data['ssid'];
|
||
$segment->wireless->norm = $form_data['norm'];
|
||
$segment->wireless->frequence = $form_data['frequence'];
|
||
$segment->wireless->channel = $form_data['channel'];
|
||
$segment->wireless->channel_width = $form_data['channel_width'];
|
||
$segment->wireless->polarization = $form_data['polarization'];
|
||
|
||
$segment->wireless->segment_id = $segment->id;
|
||
$segment->wireless->save();
|
||
}
|
||
else
|
||
$segment->wireless->delete();
|
||
|
||
status::success('Segment has been successfully saved.');
|
||
}
|
||
|
||
unset($form_data);
|
||
|
||
$this->redirect('show', $segment->id);
|
||
}
|
||
else
|
||
{
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('segments/show_all', 'Segments',
|
||
$this->acl_check_view('Devices_Controller','segment'))
|
||
->text('Add new segment');
|
||
|
||
$headline = __('Add new segment');
|
||
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = $headline;
|
||
$view->segment = isset($segment) && $segment->id ? $segment : NULL;
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = '';
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
} // end of add
|
||
|
||
/**
|
||
* Function edits segment.
|
||
*
|
||
* @param integer $segment_id
|
||
*/
|
||
public function edit($segment_id = null)
|
||
{
|
||
if (!$segment_id || !is_numeric($segment_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$segment = new Link_Model($segment_id);
|
||
|
||
if (!$segment || !$segment->id)
|
||
Controller::warning(ACCESS);
|
||
|
||
if(!$this->acl_check_edit('Devices_Controller','segment'))
|
||
Controller::error(ACCESS);
|
||
|
||
$this->segment_id = $segment_id;
|
||
|
||
$roaming = ORM::factory('segment')->get_roaming();
|
||
|
||
$media = array();
|
||
foreach (Link_Model::get_medium_types() as $id => $type)
|
||
{
|
||
if ($roaming == $segment->id || $id != Link_Model::ROAMING || !$roaming)
|
||
{
|
||
$media[$id] = __(''.$type);
|
||
}
|
||
}
|
||
asort($media);
|
||
|
||
$media = array
|
||
(
|
||
NULL => '----- '.__('Select medium').' -----'
|
||
) + $media;
|
||
|
||
// form
|
||
$form = new Forge('segments/edit/'.$segment_id);
|
||
|
||
$form->group('Basic data');
|
||
|
||
$form->input('name')
|
||
->label(__('name').':')
|
||
->rules('required|length[3,100]')
|
||
->style('width: 600px')
|
||
->value($segment->name);
|
||
|
||
$form->dropdown('medium_id')
|
||
->label(__('Medium').':')
|
||
->options($media)->rules('required')
|
||
->selected($segment->medium_id)
|
||
->callback(array($this, 'valid_medium'));
|
||
|
||
$form->input('bitrate')
|
||
->label(__('bitrate').':')
|
||
->rules('valid_numeric')
|
||
->value($segment->bitrate / 1048576)
|
||
->class('join1')
|
||
->style('width:100px; margin-right:5px;');
|
||
|
||
$arr_unit = array
|
||
(
|
||
'1' => 'bps',
|
||
'1024' => 'kbps',
|
||
'1048576' => 'Mbps',
|
||
'1073741824' => 'Gbps'
|
||
);
|
||
|
||
$form->dropdown('bit_unit')
|
||
->options($arr_unit)
|
||
->class('join2')
|
||
->selected(1048576)
|
||
->callback(array($this, 'valid_bitrate'));
|
||
|
||
$form->checkbox('duplex')
|
||
->label(__('duplex'))
|
||
->value('1')
|
||
->checked($segment->duplex);
|
||
|
||
$form->textarea('comment')
|
||
->label(__('comment').':')
|
||
->rules('length[0,254]')
|
||
->value($segment->comment)
|
||
->cols('20')
|
||
->rows('5');
|
||
|
||
$form->group('Wireless setting');
|
||
|
||
$form->input('ssid')
|
||
->label(__('SSID').':')
|
||
->value($segment->wireless->ssid);
|
||
|
||
$norms = array
|
||
(
|
||
NULL => '----- '.__('Select norm').' -----'
|
||
) + Wireless_segment_Model::get_norms();
|
||
|
||
$form->dropdown('norm')
|
||
->label(__('Norm').':')
|
||
->options($norms)
|
||
->selected($segment->wireless->norm);
|
||
|
||
$form->input('frequence')
|
||
->label(__('Frequence').':')
|
||
->value($segment->wireless->frequence);
|
||
|
||
$form->input('channel')
|
||
->label(__('Channel').':')
|
||
->value($segment->wireless->channel);
|
||
|
||
$form->input('channel_width')
|
||
->label(__('Channel width').':')
|
||
->value($segment->wireless->channel_width);
|
||
|
||
$polarizations = array
|
||
(
|
||
NULL => '----- '.__('Select polarization').' -----'
|
||
) + Wireless_segment_Model::get_polarizations();
|
||
|
||
$form->dropdown('polarization')
|
||
->label(__('Polarization').':')
|
||
->options($polarizations)
|
||
->selected($segment->wireless->polarization);
|
||
|
||
$form->submit('submit')
|
||
->value(__('update'));
|
||
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
// validation
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
|
||
$segment = new Link_Model($segment_id);
|
||
$segment->name = $form_data['name'];
|
||
$segment->medium_id = $form_data['medium_id'];
|
||
$segment->bitrate = $form_data['bitrate'] * $form_data['bit_unit'];
|
||
$segment->duplex = $form_data['duplex'];
|
||
$segment->comment = $form_data['comment'];
|
||
|
||
if ($segment->medium_id == Link_Model::AIR)
|
||
{
|
||
$segment->wireless->ssid = $form_data['ssid'];
|
||
$segment->wireless->norm = $form_data['norm'];
|
||
$segment->wireless->frequence = $form_data['frequence'];
|
||
$segment->wireless->channel = $form_data['channel'];
|
||
$segment->wireless->channel_width = $form_data['channel_width'];
|
||
$segment->wireless->polarization = $form_data['polarization'];
|
||
|
||
$segment->wireless->segment_id = $segment->id;
|
||
$segment->wireless->save();
|
||
}
|
||
else
|
||
$segment->wireless->delete();
|
||
|
||
unset($form_data);
|
||
|
||
if ($segment->save())
|
||
{
|
||
status::success('Segment has been successfully updated.');
|
||
url::redirect('segments/show/'.$segment->id);
|
||
}
|
||
|
||
}
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('segments/show_all', 'Segments',
|
||
$this->acl_check_view('Devices_Controller','segment'))
|
||
->link('segments/show/' . $segment->id,
|
||
$segment->name . ' (' . $segment->id . ')',
|
||
$this->acl_check_view('Devices_Controller','segment'))
|
||
->text('Edit');
|
||
|
||
$headline = __('Edit segment').' - '.$segment->name;
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = '';
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
} // end of edit
|
||
|
||
/**
|
||
* Function deletes segment
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $segment_id
|
||
*/
|
||
public function delete($segment_id = NULL)
|
||
{
|
||
// access control
|
||
if (!$this->acl_check_delete('Devices_Controller', 'segment'))
|
||
Controller::error(ACCESS);
|
||
|
||
// bad parameter
|
||
if (!$segment_id || !is_numeric($segment_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$segment = new Link_Model($segment_id);
|
||
|
||
// record doesn't exist
|
||
if (!$segment->id)
|
||
Controller::error(RECORD);
|
||
|
||
// interface and port test
|
||
if (count($segment->ifaces) + count($segment->ports))
|
||
{
|
||
status::warning('At least one interface or port still uses this segment.');
|
||
url::redirect(Path::instance()->previous()->current());
|
||
}
|
||
|
||
// successfully deleted
|
||
if ($segment->wireless->delete() && $segment->delete())
|
||
{
|
||
status::success('Segment has been successfully deleted.');
|
||
}
|
||
|
||
url::redirect(Path::instance()->previous()->current());
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @staticvar Device_Model $device_model
|
||
* @staticvar Segment_Model $segment_model
|
||
* @staticvar Iface_Model $iface_model
|
||
* @staticvar Member_Model $member_model
|
||
* @staticvar array $devices
|
||
* @param integer $device_id
|
||
* @param integer $parent_device_id
|
||
* @return integer
|
||
*/
|
||
private function draw_map($device_id, $parent_device_id = 0)
|
||
{
|
||
static $device_model, $segment_model, $iface_model, $member_model, $devices;
|
||
|
||
if (!$device_model)
|
||
$device_model = new Device_Model();
|
||
|
||
if (!$segment_model)
|
||
$segment_model = new Link_Model();
|
||
|
||
if (!$iface_model)
|
||
$iface_model = new Iface_Model();
|
||
|
||
if (!$member_model)
|
||
$member_model = new Member_Model();
|
||
|
||
if (!$devices)
|
||
$devices = array();
|
||
|
||
$device = $device_model->where('id', $device_id)->find();
|
||
|
||
$devices[] = $device_id;
|
||
|
||
$this->sums[$device_id] = 0;
|
||
|
||
$this->parents[$device_id] = $parent_device_id;
|
||
|
||
$device_ifaces = $iface_model->get_all_ifaces_of_device_without_parent($device_id);
|
||
|
||
foreach ($device_ifaces as $device_iface)
|
||
{
|
||
echo "$device_id - $device_iface->name<br />";
|
||
|
||
$assoc_ifaces = $iface_model->get_all_by_member_segment(
|
||
1, $device_iface->segment_id
|
||
);
|
||
|
||
$members = $member_model->get_all_by_segment(
|
||
$device_iface->segment_id, FALSE
|
||
);
|
||
|
||
if (count($assoc_ifaces) > 1 && count($members) < 3)
|
||
{
|
||
foreach ($assoc_ifaces as $assoc_iface)
|
||
{
|
||
if ($device_iface->id == $assoc_iface->id ||
|
||
in_array($assoc_iface->device_id, $devices))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
$this->sums[$device_id] += $this->draw_map(
|
||
$assoc_iface->device_id, $device_iface->device_id
|
||
);
|
||
}
|
||
}
|
||
else
|
||
$this->sums[$device_id] += count($members);
|
||
}
|
||
return $this->sums[$device_id];
|
||
}
|
||
|
||
/**
|
||
* @todo WTF?
|
||
*/
|
||
public function map()
|
||
{
|
||
$this->sums = array();
|
||
$this->parents = array();
|
||
|
||
$device_model = new Device_Model();
|
||
|
||
$ip = '10.143.128.11';
|
||
|
||
$device = $device_model->get_by_ip_address($ip);
|
||
|
||
if ($device)
|
||
{
|
||
$this->draw_map($device->id);
|
||
}
|
||
|
||
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 Link_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 Link_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 Link_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 Link_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 Link_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 Link_Model($segment_id);
|
||
|
||
if (!$segment->id)
|
||
return;
|
||
|
||
echo $segment->wireless->polarization;
|
||
}
|
||
|
||
/**
|
||
* Callback function to valid medium of segment
|
||
*
|
||
* @author Michal Kliment
|
||
* @param object $input
|
||
*/
|
||
public function valid_medium($input = NULL)
|
||
{
|
||
// validators cannot be accessed
|
||
if (empty($input) || !is_object($input))
|
||
{
|
||
self::error(PAGE);
|
||
}
|
||
|
||
$roaming = ORM::factory('segment')->get_roaming();
|
||
|
||
if ($this->input->post('medium_id') == Link_Model::ROAMING &&
|
||
$roaming && ($this->segment_id && $roaming != $this->segment_id))
|
||
{
|
||
$input->add_error('required', __(
|
||
'Segment with roaming can exists only once.'
|
||
));
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Callback function to valid bitrate of segment
|
||
*
|
||
* @author Michal Kliment
|
||
* @param object $input
|
||
*/
|
||
public function valid_bitrate($input = NULL)
|
||
{
|
||
// validators cannot be accessed
|
||
if (empty($input) || !is_object($input))
|
||
{
|
||
self::error(PAGE);
|
||
}
|
||
|
||
if ($this->input->post('medium_id') != Link_Model::ROAMING &&
|
||
$this->input->post('bitrate') == '')
|
||
{
|
||
$input->add_error('required', __('Bitrate is required.'));
|
||
}
|
||
|
||
$norm = $this->input->post('norm');
|
||
|
||
if ($this->input->post('medium_id') == Link_Model::AIR && $norm
|
||
&& ($max_bitrate = Wireless_segment_Model::get_max_bitrate($norm)))
|
||
{
|
||
$bitrate = $this->input->post('bitrate') * $this->input->post('bit_unit');
|
||
|
||
if ($bitrate > ($max_bitrate * 1024 * 1024))
|
||
{
|
Také k dispozici: Unified diff
Upravy:
- pridani linku a uprava kontroleru JSON pro #185