Revize 601
Přidáno uživatelem harryhk před téměř 15 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'add new bank account of association' => 'Přidat nový bankovní účet sdružení',
|
||
'add new bank transfer' => 'Přidat novou bankovní platbu',
|
||
'add new bank transfer without counteraccount' => 'Přidat novou bankovní platbu bez protiúčtu',
|
||
'add new cloud' => 'Přidat novou oblast',
|
||
'add new contact' => 'Přidat nový kontakt',
|
||
'add new credit account' => 'Přidat nový kreditní účet',
|
||
'add new device' => 'Přidat nové zařízení',
|
||
... | ... | |
'application password' => 'Aplikační heslo',
|
||
'are you sure you want to deduct all entrance fees' => 'Jste si jistí, že chcete strhnout všechny vstupní příspěvky',
|
||
'are you sure you want to recount fees of this member' => 'Jste si jistí, že chcete přepočítat členské příspěvky tohoto člena',
|
||
'area' => 'Oblast',
|
||
'arrival' => 'Příchozí',
|
||
'assign' => 'Přiřadit',
|
||
'assign free subnet' => 'Přiřaď volnou podsíť',
|
||
'assign free subnet to cloud' => 'Přiřaď volnou podsíť',
|
||
'assign transfer' => 'Přiřadit převod',
|
||
'assigning of transfer' => 'Přiřazení platby',
|
||
'assigning of unidentified payment' => 'Přiřazení neidentifikované platby',
|
||
... | ... | |
'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 the cloud list' => 'Zpět na seznam oblastí',
|
||
'back to the double-entry accounts' => 'Zpět na podvojné účty',
|
||
'back to the invoice' => 'Zpět na fakturu',
|
||
'back to the invoice item' => 'Zpět na položku faktury',
|
||
... | ... | |
'cash drawn' => 'Výběry hotovosti',
|
||
'certified engineers' => 'Certifikovaní technici',
|
||
'choose format of export' => 'Vyberte formát exportu',
|
||
'cloud' => 'Oblast',
|
||
'code' => 'Kód',
|
||
'collateral' => 'Vedlejší',
|
||
'column headers' => 'Hlavičky sloupců',
|
||
... | ... | |
'device id' => 'ID zařízení',
|
||
'device information' => 'Informace o zařízení',
|
||
'device list of user' => 'Seznam zařízení uživatele',
|
||
'device monitoring' => 'Monitoring zařízení',
|
||
'device name' => 'Název zařízení',
|
||
'device still has at least one interface' => 'Zařízení má ještě nejméně jedno rozhraní.',
|
||
'device still has at least one port' => 'Zařízení má ještě nejméně jeden port.',
|
||
... | ... | |
'edit' => 'Upravit',
|
||
'edit account' => 'Upravit účet',
|
||
'edit address point' => 'Upravit adresní bod',
|
||
'edit cloud' => 'Upravit oblast',
|
||
'edit device' => 'Upravit zařízení',
|
||
'edit device admin' => 'Upravit správce zařízení',
|
||
'edit enum type' => 'Upravit výčet',
|
||
... | ... | |
'change application password' => 'Změnit aplikační heslo',
|
||
'change password' => 'Změnit heslo',
|
||
'channel' => 'Kanál',
|
||
// Interrupt -> Preruseni
|
||
'i' => 'P',
|
||
'i accept this message and i want to cancel this redirection' => 'Beru na vědomí tuto zprávu a chci zrušit toto přesměrování',
|
||
'id' => 'ID',
|
||
'id of member' => 'ID člena',
|
||
... | ... | |
'ip address detail' => 'Detail IP adresy',
|
||
'ip address does not match the subnet/mask' => 'IP adresa neodpovídá podsíti/masce.',
|
||
'ip address has been successfully deleted' => 'IP adresa byla úspěšně smazána.',
|
||
'ip address id' => 'ID IP adresy',
|
||
'ip address is required' => 'IP adresa je vyžadována.',
|
||
'ip address is successfully saved' => 'IP adresa byla úspěšně uložena.',
|
||
'ip address is successfully updated' => 'IP adresa byla úspěšně upravena.',
|
||
... | ... | |
'linenr' => 'Počet řádků',
|
||
'list of all address points' => 'Seznam všech adresních bodů',
|
||
'list of all backups' => 'Seznam všech záloh konfigurací',
|
||
'list of all clouds' => 'Seznam všech oblastí',
|
||
'list of all confirmed works' => 'Seznam všech potvrzených prací',
|
||
'list of all invoices' => 'Seznam všech faktur',
|
||
'list of all members' => 'Seznam všech členů',
|
||
... | ... | |
'my transfers' => 'Moje převody',
|
||
'my users' => 'Moji uživatelé',
|
||
'my works' => 'Moje práce',
|
||
// Notice -> Upozorneni
|
||
'n' => 'U',
|
||
'name' => 'Jméno',
|
||
'name of the association' => 'Název sdružení',
|
||
'name of organization' => 'Název organizace',
|
||
... | ... | |
'number interval' => 'Rozsah čísel',
|
||
'number of months' => 'Počet měsíců',
|
||
'number of the hours' => 'počet hodin',
|
||
// Optional -> Volitelna
|
||
'o' => 'V',
|
||
'old password' => 'Staré heslo',
|
||
'operating account' => 'Provozní účet',
|
||
'optional' => 'nepovinné',
|
||
... | ... | |
'select destination web' => 'Vyber cíl přesměrování',
|
||
'select device' => 'Vyber zařízení',
|
||
'select duration' => 'Vyber trvání přesměrování',
|
||
'select free subnet' => 'Vyber volnou podsíť',
|
||
'select interface' => 'Vyber rozhraní',
|
||
'select member' => 'Vyber člena',
|
||
'select vlan interface' => 'Vyber VLAN rozhraní',
|
||
... | ... | |
'show all confirmed works' => 'Zobraz všechnny potvrzené práce',
|
||
'show all transfers on the account' => 'Ukaž všechny převody tohoto účtu',
|
||
'show all unconfirmed works' => 'Zobraz všechnny nepotvrzené práce',
|
||
'show clouds' => 'Zobrazit oblasti',
|
||
'show devices' => 'Zobrazit zařízení',
|
||
'show invoice' => 'Zobrazit fakturu',
|
||
'show invoice item' => 'Zobrazit položku faktury',
|
||
... | ... | |
'show works' => 'Zobrazit práce',
|
||
'signature of applicant member' => 'podpis žadatele - člena',
|
||
'signature and stamp' => 'Podpis a razítko',
|
||
'smokeping menu parent' => 'Rodič v menu smokepingu',
|
||
'smokeping monitoring' => 'Monitorování smokepingem',
|
||
'smokeping record has been successfully added' => 'Záznam smokepingu byl úspěšně přidán',
|
||
'smokeping record has been successfully deleted' => 'Záznam smokepingu byl úspěšně smazán',
|
||
'smokeping record has been successfully updated' => 'Záznam smokepingu byl úspěšně aktualizován',
|
freenetis/trunk/kohana/application/models/subnet.php | ||
---|---|---|
$where .= ' AND '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
return self::$db->query("SELECT s.*
|
||
return self::$db->query("SELECT s.*, c.name AS cloud
|
||
FROM subnets s
|
||
LEFT JOIN clouds c ON s.cloud_id = c.id
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Author: Lubomir Buben
|
||
* Function tries to find subnet of cloud. Used in clouds/show, clouds/edit.
|
||
* @param $cloud_id
|
||
* @return unknown_type
|
||
*/
|
||
public function get_subnet_of_cloud($cloud_id){
|
||
return self::$db->query("SELECT s.id, s.name, s.network_address, s.netmask
|
||
FROM subnets s
|
||
WHERE s.cloud_id = $cloud_id"
|
||
);
|
||
}
|
||
|
||
/**
|
||
* Function gets items of subnet to export.
|
||
* @param $subnet_id
|
||
* @return unknown_type
|
||
... | ... | |
ORDER BY inet_aton(ip_address)
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Author: Lubomir Buben
|
||
* Function finds all free subnets (without cloud assigned)
|
||
* @param none
|
||
* @return unknown_type
|
||
*/
|
||
public function get_free_subnets(){
|
||
return self::$db->query("SELECT
|
||
s.id, s.name
|
||
FROM subnets s
|
||
WHERE s.cloud_id = null OR s.cloud_id = 0"
|
||
);
|
||
}
|
||
|
||
/**
|
||
* Author: Lubomir Buben
|
||
* Function counts all free subnets (without cloud assigned)
|
||
* @param none
|
||
* @return $total_free_subnets
|
||
*/
|
||
public function count_free_subnets(){
|
||
$records = self::$db->query("SELECT
|
||
s.id
|
||
FROM subnets s
|
||
WHERE s.cloud_id = null OR s.cloud_id = 0"
|
||
);
|
||
return count($records);
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/cloud_admin.php | ||
---|---|---|
<?php
|
||
|
||
/**
|
||
* @author Lubomir Buben
|
||
*/
|
||
|
||
class Cloud_admin_Model extends ORM {
|
||
public $arr_sql = array('id' => 'ca.id', 'cloud_id' => 'ca.cloud_id', 'admin_id' => 'ca.admin_id');
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/cloud.php | ||
---|---|---|
<?php
|
||
|
||
/**
|
||
* @author Lubomir Buben
|
||
*/
|
||
|
||
class Cloud_Model extends ORM {
|
||
public $arr_sql = array('id' => 'c.id', 'name' => 'c.name');
|
||
|
||
/**
|
||
* Function gets all cloud's names and ids
|
||
* @return unknown_type
|
||
*/
|
||
public function get_all_clouds($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'ASC', $user_id = null, $filters = array()){
|
||
if (in_array($order_by, $this->arr_sql))
|
||
$order_by = $this->arr_sql[$order_by];
|
||
$where = '';
|
||
if(count($filters) > 0)
|
||
$where .= 'WHERE ';
|
||
foreach($filters as $key => $value)
|
||
{
|
||
if($key!='submit')
|
||
{
|
||
if($where!='WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= $this->arr_sql[$key].' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
|
||
return self::$db->query("SELECT
|
||
c.id, c.name, u.login
|
||
FROM clouds c
|
||
LEFT JOIN cloud_admins ca ON c.id = ca.cloud_id
|
||
LEFT JOIN users u ON u.id = ca.admin_id
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results"
|
||
);
|
||
}
|
||
|
||
public function count_all_clouds($limit_from = 0, $limit_results = 20, $order_by = 'id', $order_by_direction = 'ASC', $user_id = null, $filters = array()){
|
||
if (in_array($order_by, $this->arr_sql))
|
||
$order_by = $this->arr_sql[$order_by];
|
||
$where = '';
|
||
if(count($filters) > 0)
|
||
$where .= 'WHERE ';
|
||
foreach($filters as $key => $value)
|
||
{
|
||
if($key!='submit')
|
||
{
|
||
if($where!='WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= $this->arr_sql[$key].' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
|
||
$clouds = self::$db->query("SELECT
|
||
c.id
|
||
FROM clouds c
|
||
LEFT JOIN cloud_admins ca ON c.id = ca.cloud_id
|
||
LEFT JOIN users u ON u.id = ca.admin_id
|
||
$where"
|
||
);
|
||
return count($clouds);
|
||
}
|
||
|
||
public function get_cloud_admin($cloud_id){
|
||
return self::$db->query("SELECT
|
||
u.login
|
||
FROM clouds c
|
||
LEFT JOIN cloud_admins ca ON c.id = ca.cloud_id
|
||
LEFT JOIN users u ON u.id = ca.admin_id
|
||
WHERE c.id=$cloud_id"
|
||
);
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/user.php | ||
---|---|---|
) di
|
||
")->current()->total;
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/clouds.php | ||
---|---|---|
<?php
|
||
/**
|
||
* @author Lubomir Buben
|
||
*/
|
||
class Clouds_Controller extends Controller{
|
||
private $links;
|
||
|
||
function __construct(){
|
||
parent::__construct();
|
||
$array[] = html::anchor(url_lang::base().'clouds/add', url_lang::lang('texts.Add new cloud'));
|
||
$this->links = implode(' | ', $array);
|
||
}
|
||
|
||
function index(){
|
||
url::redirect(url_lang::base().'clouds/show_all');
|
||
}
|
||
|
||
function show_all($limit_results = 20, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1){
|
||
//if (!$this->acl_check_view(get_class($this),'redirection'))
|
||
// Controller::error(ACCESS);
|
||
|
||
$filter=new Table_Form(url_lang::base()."clouds/show_all", "get", array(
|
||
new Table_Form_Item('text','name','Name'),
|
||
new Table_Form_Item('text','admin','Admin'),
|
||
"tr",
|
||
"td",
|
||
new Table_Form_Item('submit','submit','Filter')
|
||
)
|
||
);
|
||
$filter_values = $filter->values();
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
$cloud_model = new Cloud_Model();
|
||
$total_clouds = $cloud_model->count_all_clouds($filter_values);
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_clouds)
|
||
$sql_offset = 0;
|
||
|
||
$query = $cloud_model->get_all_clouds($sql_offset, (int)$limit_results, $order_by, $order_by_direction, NULL, $filter_values);
|
||
|
||
$grid = new Grid(url_lang::base().'clouds', null,array(
|
||
//'separator' => '<br />-----------',
|
||
'use_paginator' => true,
|
||
'use_selector' => true,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 20, // increace
|
||
'selector_min' => 20, // minimum where selector start
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::item('locale.lang').'/clouds/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_vlan' => 'page', // pass a string as uri_vlan to trigger former 'label' functionality
|
||
'total_items' => $total_clouds, // use db count query here of course
|
||
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
//'query_string' => $query_string,
|
||
'filter' => $filter->view
|
||
));
|
||
|
||
//if ($this->acl_check_new('Devices_Controller','vlan')){
|
||
$grid->add_new_button(url_lang::base().'clouds/add', url_lang::lang('texts.Add new cloud'));
|
||
//}
|
||
|
||
$grid->order_field('id')->label('ID')->class('center');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
|
||
$grid->order_field('login')->label(url_lang::lang('texts.Admin'))->class('center');
|
||
//if ($this->acl_check_view('Devices_Controller','vlan'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'clouds/show') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','vlan'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'clouds/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','vlan'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'clouds/delete')->action(url_lang::lang('texts.Delete'))->class('center')->script('onclick="return potvrd(\''.url_lang::lang('texts.Do you want to delete this cloud').'\');"');
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'redirection/delete')->action(url_lang::lang('texts.Delete'))->script('onclick="return potvrd(\''.url_lang::lang('texts.Do you want to delete this user').'\');"');
|
||
$grid->datasource( $query );
|
||
$this->template->content = $grid;
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.List of all clouds');
|
||
$view->content = new View('show_all');
|
||
$view->content->headline = url_lang::lang('texts.List of all clouds');
|
||
$view->content->table = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function show($cloud_id = NULL){
|
||
//if (!$this->acl_check_view(get_class($this),'redirection'))
|
||
// Controller::error(ACCESS);
|
||
|
||
$cloud = new Cloud_Model($cloud_id);
|
||
if (!$cloud_id || !$cloud->id){
|
||
Controller::error(RECORD);
|
||
url::redirect(url_lang::base().'clouds/show_all');
|
||
}
|
||
|
||
//get cloud admin
|
||
$result = $cloud->get_cloud_admin($cloud_id);
|
||
foreach ($result as $row){
|
||
$admin = $row->login;
|
||
}
|
||
|
||
//get cloud subnets
|
||
$subnet_model = new Subnet_Model();
|
||
$query = $subnet_model->get_subnet_of_cloud($cloud_id);
|
||
|
||
$grid = new Grid(url_lang::base().'clouds', null,array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
//find all free subnets
|
||
$subnet_model = new Subnet_Model();
|
||
$total_free_subnets = $subnet_model->count_free_subnets();
|
||
|
||
//if ($this->acl_check_new(get_class($this),'iface',$member_id))
|
||
$grid->add_new_button(url_lang::base().'subnets/add/'.$cloud_id, url_lang::lang('texts.Add new subnet'));
|
||
if($total_free_subnets>0)
|
||
$grid->add_new_button(url_lang::base().'clouds/add_subnet/'.$cloud_id, url_lang::lang('texts.Assign free subnet'));
|
||
$grid->field('id')->label('ID')->class('center');
|
||
$grid->field('name')->label(url_lang::lang('texts.Name'));
|
||
$grid->field('network_address')->label(url_lang::lang('texts.Address network'));
|
||
$grid->field('netmask')->label(url_lang::lang('texts.Netmask'));
|
||
//if ($this->acl_check_view(get_class($this),'iface',$member_id))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Subnets')) ->url(url_lang::base().'subnets/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
//if ($this->acl_check_edit(get_class($this),'iface',$member_id))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Subnets')) ->url(url_lang::base().'subnets/edit')->action(url_lang::lang('texts.Edit'))->class('center');
|
||
//if ($this->acl_check_delete('Devices_Controller', 'iface', $member_id))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Subnets')) ->url(url_lang::base().'subnets/delete')->action(url_lang::lang('texts.Delete'))->class('center')->script('onclick="return potvrd(\''.url_lang::lang('texts.Do you want to delete this subnet').'\');"');
|
||
$grid->datasource($query);
|
||
$subnets = $grid;
|
||
unset($grid);
|
||
|
||
|
||
$link_back = html::anchor(url_lang::base().'clouds/show_all', url_lang::lang('texts.Back to the cloud list'));
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Show cloud');
|
||
$view->content = new View('show_clouds');
|
||
$view->content->cloud = $cloud;
|
||
$view->content->admin = $admin;
|
||
$view->content->subnets = $subnets;
|
||
$view->content->link_back = $link_back;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function add(){
|
||
//if (!$this->acl_check_new(get_class($this),'monitoring'))
|
||
// Controller::error(ACCESS);
|
||
|
||
//find all free subnets
|
||
$subnet_model = new Subnet_Model();
|
||
$total_free_subnets = $subnet_model->count_free_subnets();
|
||
if($total_free_subnets>0){
|
||
$all_free_subnets = $subnet_model->get_free_subnets();
|
||
$subnet[0] = '----- '.url_lang::lang('texts.Select free subnet').' -----';
|
||
foreach ($all_free_subnets as $row){
|
||
$subnet[$row->id]=$row->name;
|
||
}
|
||
}
|
||
|
||
$this->form = new Forge(url_lang::base()."clouds/add", '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$this->form->group('')->label(url_lang::lang('texts.Basic information'));
|
||
$this->form->input('name')->label(url_lang::lang('texts.Name').':')->rules('required');
|
||
$this->form->input('admin')->label(url_lang::lang('texts.Admin').'(ID):')->rules('required');
|
||
if($total_free_subnets>0){
|
||
$this->form->dropdown('subnet')->label(url_lang::lang('texts.Subnet').':')->options($subnet);
|
||
}
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Insert'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
|
||
//----- validate form and save data -----------------------------------
|
||
if($this->form->validate()){
|
||
$form_data = $this->form->as_array();
|
||
foreach($form_data as $key => $value){
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$cloud = new Cloud_Model();
|
||
$cloud->name = $form_data['name'];
|
||
|
||
if ($cloud->save()){
|
||
//save admin
|
||
$cloud_admin = new Cloud_admin_Model();
|
||
$cloud_admin->cloud_id = $cloud->id;
|
||
$cloud_admin->admin_id = $form_data['admin'];
|
||
unset($form_data);
|
||
if ($cloud_admin->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Cloud has been successfully added.'));
|
||
url::redirect(url_lang::base().'clouds/show_all');
|
||
exit;
|
||
}
|
||
}
|
||
}
|
||
//----- end validate --------------------------------------------------
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Add new cloud');
|
||
$view->content = new View('form');
|
||
$view->content->link_back = html::anchor(url_lang::base().'clouds/show_all', url_lang::lang('texts.Back to the cloud list'));
|
||
$view->content->headline = url_lang::lang('texts.Add new cloud');
|
||
$view->content->form = $this->form->html();
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function add_subnet($cloud_id = null){
|
||
//if (!$this->acl_check_new(get_class($this),'monitoring'))
|
||
// Controller::error(ACCESS);
|
||
|
||
if (!isset($cloud_id))
|
||
Controller::warning(PARAMETER);
|
||
$cloud = new Cloud_Model($cloud_id);
|
||
if ($cloud->id == 0)
|
||
Controller::error(RECORD);
|
||
|
||
//find all free subnets
|
||
$subnet_model = new Subnet_Model();
|
||
$total_free_subnets = $subnet_model->count_free_subnets();
|
||
if($total_free_subnets>0){
|
||
$all_free_subnets = $subnet_model->get_free_subnets();
|
||
$arr_subnet[0] = '----- '.url_lang::lang('texts.Select free subnet').' -----';
|
||
foreach ($all_free_subnets as $row){
|
||
$arr_subnet[$row->id]=$row->name;
|
||
}
|
||
}
|
||
|
||
//are there any unassigned subnets?
|
||
if($total_free_subnets==0){
|
||
$this->session->set_flash('message', url_lang::lang('texts.There are not any unassigned subnets.'));
|
||
url::redirect(url_lang::base().'clouds/show_all');
|
||
}
|
||
|
||
$this->form = new Forge(url_lang::base()."clouds/add_subnet/".$cloud_id, '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$this->form->dropdown('subnet')->label(url_lang::lang('texts.Subnet').':')->options($arr_subnet);
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Insert'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
|
||
//----- validate form and save data -----------------------------------
|
||
if($this->form->validate()){
|
||
$form_data = $this->form->as_array();
|
||
foreach($form_data as $key => $value){
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$subnet = new Subnet_Model($form_data['subnet']);
|
||
$subnet->cloud_id = $cloud->id;
|
||
|
||
unset($form_data);
|
||
if ($subnet->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Subnet has been successfully assigned to cloud'));
|
||
} else {
|
||
$this->session->set_flash('message', url_lang::lang('texts.An error has occured'));
|
||
}
|
||
url::redirect(url_lang::base().'clouds/show_all');
|
||
exit;
|
||
|
||
}
|
||
//----- end validate --------------------------------------------------
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Assign free subnet to cloud');
|
||
$view->content = new View('form');
|
||
$view->content->link_back = html::anchor(url_lang::base().'clouds/show_all', url_lang::lang('texts.Back to the cloud list'));
|
||
$view->content->headline = url_lang::lang('texts.Assign free subnet to cloud').' - '.$cloud->name;;
|
||
$view->content->form = $this->form->html();
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function edit($cloud_id = NULL){
|
||
//if (!$this->acl_check_edit(get_class($this),'redirection'))
|
||
// Controller::error(ACCESS);
|
||
|
||
if (!isset($cloud_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$cloud = new Cloud_Model($cloud_id);
|
||
if ($cloud->id == 0)
|
||
Controller::error(RECORD);
|
||
|
||
//get cloud admin
|
||
$result = $cloud->get_cloud_admin($cloud_id);
|
||
foreach ($result as $row){
|
||
$admin = $row->login;
|
||
}
|
||
|
||
$this->form = new Forge(url_lang::base()."clouds/edit/".$cloud_id, '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$this->form->group('')->label(url_lang::lang('texts.Basic information'));
|
||
$this->form->input('name')->label(url_lang::lang('texts.Name').':')->rules('required')->value($cloud->name);
|
||
$this->form->input('admin')->label(url_lang::lang('texts.Admin').':')->rules('required')->value($admin);
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Insert'));
|
||
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
|
||
//----- validate form and save data -----------------------------------
|
||
if($this->form->validate()){
|
||
$form_data = $this->form->as_array();
|
||
foreach($form_data as $key => $value){
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$cloud = new Cloud_Model($cloud_id);
|
||
$cloud->name = $form_data['name'];
|
||
$cloud->admin_id = $form_data['admin'];
|
||
|
||
unset($form_data);
|
||
if ($cloud->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Cloud has been successfully updated.'));
|
||
url::redirect(url_lang::base().'clouds/show_all/');
|
||
exit;
|
||
}
|
||
}
|
||
//----- end validate --------------------------------------------------
|
||
//find all free subnets
|
||
$subnet_model = new Subnet_Model();
|
||
$free_subnets = $subnet_model->count_free_subnets();
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Edit cloud');
|
||
$view->content = new View('clouds_form');
|
||
$view->content->form = $this->form->html();
|
||
$view->content->link_back = html::anchor(url_lang::base().'clouds/show_all', url_lang::lang('texts.Back to the cloud list'));
|
||
$view->content->link_to_free_subnets = html::anchor(url_lang::base().'clouds/add_subnet/'.$cloud_id, url_lang::lang('texts.Assign free subnet'));
|
||
$view->content->free_subnets = $free_subnets;
|
||
$view->content->headline = url_lang::lang('texts.Edit cloud');
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function delete($cloud_id = NULL){
|
||
//if (!$this->acl_check_delete(get_class($this),'smokeping'))
|
||
// Controller::error(ACCESS);
|
||
|
||
if (!isset($cloud_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$cloud_model = new Cloud_Model($cloud_id);
|
||
$linkback = url_lang::base()."clouds/show_all/";
|
||
|
||
if ($cloud_model->delete()){
|
||
$this->session->set_flash('message', url_lang::lang('texts.cloud has been successfully deleted.'));
|
||
} else {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant delete this cloud.'));
|
||
}
|
||
url::redirect($linkback);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
?>
|
||
|
freenetis/trunk/kohana/application/controllers/subnets.php | ||
---|---|---|
$grid->add_new_button(url_lang::base().'subnets/add', url_lang::lang('texts.Add new subnet'));
|
||
if ($this->acl_check_view('Devices_Controller', 'subnet'))
|
||
$grid->add_new_button(url_lang::base().'subnets/address_map', url_lang::lang('texts.Address map'));
|
||
|
||
$grid->order_field('id')->label('ID')->class('center');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.name'));
|
||
$grid->order_field('network_address')->label(url_lang::lang('texts.Network address'));
|
||
$grid->order_field('netmask')->label(url_lang::lang('texts.Netmask'));
|
||
$grid->order_field('redirect')->label(url_lang::lang('texts.Redir').'.')->bool(array(url_lang::lang('texts.No'),url_lang::lang('texts.Yes')))->class('center');
|
||
$grid->order_field('cloud')->label(url_lang::lang('texts.Cloud'))->class('center');
|
||
//$grid->order_field('OSPF_area_id')->label(url_lang::lang('texts.OSPF area ID'));
|
||
//$grid->order_field('segment')->label(url_lang::lang('texts.Segment'));
|
||
if ($this->acl_check_view('Devices_Controller', 'subnet'))
|
||
... | ... | |
* @param $subnet_id
|
||
* @return unknown_type
|
||
*/
|
||
function show($subnet_id = NULL)
|
||
function show($subnet_id)
|
||
{
|
||
if (!isset($subnet_id))
|
||
Controller::warning(PARAMETER);
|
||
... | ... | |
Controller::error(RECORD);
|
||
if (!$this->acl_check_view('Devices_Controller', 'subnet'))
|
||
Controller::error(ACCESS);
|
||
|
||
$area = new Cloud_Model($subnet->cloud_id);
|
||
|
||
// ip addresses of subnet
|
||
$ip_model = new Ip_address_Model();
|
||
... | ... | |
$view->title = $headline;
|
||
$view->content = new View('subnets_show');
|
||
$view->content->subnet = $subnet;
|
||
$view->content->area = $area;
|
||
$view->content->grid = $grid;
|
||
$view->content->link_back = html::anchor(url_lang::base().'subnets/show_all', url_lang::lang('texts.Back to all subnets'));
|
||
$view->content->headline = $headline;
|
||
... | ... | |
* Function adds subnet.
|
||
* @return unknown_type
|
||
*/
|
||
function add()
|
||
function add($cloud_id = null)
|
||
{
|
||
$subnet = new Subnet_Model();
|
||
if (!$this->acl_check_new('Devices_Controller', 'subnet'))
|
||
... | ... | |
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Basic data'));
|
||
$form->input('name')->label(url_lang::lang('texts.Subnet name').':')->rules('required|length[3,250]');
|
||
$form->input('network_address')->label(url_lang::lang('texts.Network address').':')
|
||
->rules('required')->callback(array($this, 'valid_netip'));
|
||
$form->input('netmask')->label(url_lang::lang('texts.Netmask').':')
|
||
->rules('required|length[1,250]');
|
||
$form->input('network_address')->label(url_lang::lang('texts.Network address').':')->rules('required')->callback(array($this, 'valid_netip'));
|
||
$form->input('netmask')->label(url_lang::lang('texts.Netmask').':')->rules('required|length[1,250]');
|
||
$form->input('OSPF_area_id')->label(url_lang::lang('texts.OSPF area ID').':')->rules('valid_digit');
|
||
if ($this->acl_check_new('Devices_Controller', 'redirect'))
|
||
$form->dropdown('redirect')->label(url_lang::lang('texts.Redirection enabled'))->options($redirect)->selected(0);
|
||
|
||
//clouds (prirazeni subnetu k oblasti)
|
||
if (isset($cloud_id)){
|
||
$cloud = new Cloud_Model($cloud_id);
|
||
if ($cloud->id == 0)
|
||
Controller::error(RECORD);
|
||
$form->dropdown('cloud')->label(url_lang::lang('texts.Cloud'))->options(array($cloud_id => $cloud->name))->rules('required');
|
||
}else{
|
||
$cloud = new Cloud_Model();
|
||
$all_clouds = $cloud->get_all_clouds();
|
||
$arr_clouds[0] = '----- '.url_lang::lang('texts.Select area').' -----';
|
||
foreach ($all_clouds as $row){
|
||
$arr_clouds[$row->id]=$row->name;
|
||
}
|
||
$form->dropdown('cloud')->label(url_lang::lang('texts.Cloud'))->options($arr_clouds);
|
||
}
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
... | ... | |
$subnet->OSPF_area_id = $form_data['OSPF_area_id'];
|
||
if ($this->acl_check_new('Devices_Controller', 'redirect'))
|
||
$subnet->redirect = $form_data['redirect'];
|
||
|
||
$subnet->cloud_id = $form_data['cloud'];
|
||
|
||
unset($form_data);
|
||
|
||
if ($subnet->save())
|
||
... | ... | |
$form->input('OSPF_area_id')->label(url_lang::lang('texts.OSPF area ID').':')->rules('valid_digit')->value($subnet->OSPF_area_id);
|
||
if ($this->acl_check_edit('Devices_Controller', 'redirect'))
|
||
$form->dropdown('redirect')->label(url_lang::lang('texts.Redirection enabled'))->options($redirect)->selected($subnet->redirect);
|
||
|
||
$cloud_model = new Cloud_Model();
|
||
$all_clouds = $cloud_model->get_all_clouds();
|
||
$arr_clouds[0] = '----- '.url_lang::lang('texts.Select area').' -----';
|
||
foreach ($all_clouds as $row){
|
||
$arr_clouds[$row->id]=$row->name;
|
||
}
|
||
$form->dropdown('cloud')->label(url_lang::lang('texts.Cloud'))->options($arr_clouds)->selected($subnet->cloud_id);
|
||
$form->submit('submit')->value(url_lang::lang('texts.update'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
... | ... | |
$subnet->OSPF_area_id = $form_data['OSPF_area_id'];
|
||
if ($this->acl_check_edit('Devices_Controller', 'redirect'))
|
||
$subnet->redirect = $form_data['redirect'];
|
||
$subnet->cloud_id = $form_data['cloud'];
|
||
|
||
unset($form_data);
|
||
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
|
||
// array of sql queries that upgrade database
|
||
$upgrade_sql[get_SVN_rev()] = array(
|
||
"ALTER TABLE `smokeping` RENAME TO `smokepings`;"
|
||
"CREATE TABLE `clouds` (
|
||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||
`name` VARCHAR(50) NOT NULL,
|
||
PRIMARY KEY (`id`)
|
||
)
|
||
ENGINE = InnoDB
|
||
CHARACTER SET utf8 COLLATE utf8_general_ci;",
|
||
|
||
"CREATE TABLE `cloud_admins` (
|
||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||
`cloud_id` INTEGER UNSIGNED NOT NULL,
|
||
`admin_id` INTEGER UNSIGNED NOT NULL,
|
||
PRIMARY KEY (`id`)
|
||
)
|
||
ENGINE = InnoDB
|
||
CHARACTER SET utf8 COLLATE utf8_general_ci;",
|
||
|
||
"ALTER TABLE `subnets` ADD COLUMN `cloud_id` INTEGER UNSIGNED AFTER `redirect`;",
|
||
);
|
||
?>
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_599.php | ||
---|---|---|
<?php
|
||
|
||
// array of sql queries that upgrade database
|
||
$upgrade_sql[599] = array(
|
||
"ALTER TABLE `smokeping` RENAME TO `smokepings`;"
|
||
);
|
||
?>
|
freenetis/trunk/kohana/application/views/show_clouds.php | ||
---|---|---|
<h2><?php echo url_lang::lang('texts.Show clouds') ?></h2>
|
||
<?php
|
||
$links = array();
|
||
$links[] = $link_back;
|
||
//if ($this->acl_check_edit('Users_Controller','work',$work->user->member_id) && !$work->confirmed_by_id)
|
||
$links[] = html::anchor(url_lang::base().'clouds/edit/'.$cloud->id,url_lang::lang('texts.Edit'));
|
||
|
||
echo implode(' | ',$links);
|
||
|
||
?><br /><br />
|
||
|
||
<table class="extended" cellspacing="0">
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.ID') ?></th>
|
||
<td><?php echo $cloud->id ?></td>
|
||
</tr>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Name') ?></th>
|
||
<td><?php echo $cloud->name ?></td>
|
||
</tr>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Admin') ?></th>
|
||
<td><?php echo $admin ?></td>
|
||
</tr>
|
||
</table>
|
||
<br class="clear" />
|
||
<br />
|
||
|
||
<!-- subnets -->
|
||
<?php //if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
|
||
<h3><?php echo url_lang::lang('texts.Subnets') ?></h3>
|
||
<?php echo $subnets ?>
|
||
<br />
|
||
<?php //} ?>
|
freenetis/trunk/kohana/application/views/menu.php | ||
---|---|---|
<?php if ($this->acl_check_view('VoIP_Controller', 'voip')) { ?>
|
||
<li><?php echo html::anchor(url_lang::base().'voip', url_lang::lang('texts.VoIP')) ?></li>
|
||
<?php } ?>
|
||
<li><?php echo html::anchor(url_lang::base().'clouds', url_lang::lang('texts.Clouds')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'config_files', url_lang::lang('texts.Configuration files')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'monitoring', url_lang::lang('texts.Monitoring')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'tools', url_lang::lang('texts.Tools')) ?></li>
|
freenetis/trunk/kohana/application/views/clouds_form.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<?php echo (isset($message)) ? '<div class="message">'.$message.'</div>' : '' ?>
|
||
<?php if ($free_subnets>0) echo $link_back.' | '.$link_to_free_subnets;
|
||
else echo $link_back;?>
|
||
<br /><br />
|
||
<?php echo $form ?>
|
freenetis/trunk/kohana/application/views/subnets_show.php | ||
---|---|---|
<th><?php echo url_lang::lang('texts.Redirection enabled') ?></th>
|
||
<td><?php echo ($subnet->redirect == 1) ? url_lang::lang('texts.Yes') : url_lang::lang('texts.No') ?></td>
|
||
</tr>
|
||
<tr>
|
||
<th><?php echo url_lang::lang('texts.Area') ?></th>
|
||
<td><?php echo $area->name ?></td>
|
||
</tr>
|
||
</table>
|
||
<br /><br />
|
||
<?php echo $grid ?>
|
Také k dispozici: Unified diff
Pridana struktura Clouds/oblasti. Oblast muze mit libovolny pocet subnetu a jednoho spravce. Struktura oblasti bude v nejblizsi dobe slouzit pro
definovani zonovych souboru pri generovani DNS. V podsitich pribyla volba priradit k oblasti. V clouds/add_subnet je moznost pridelit k oblasti
volny (neprideleny) subnet, pokud takovy existuje.