Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 607

Přidáno uživatelem Jiří Sviták před téměř 15 roky(ů)

Uprava pridavani zarizeni - jmeno zarizeni neni povinne, ve vetsine pripadu techniky zdrzuje. Nemenit. Z pridavani celeho zarizeni je vynechano bezdratove rozhrani - nepouziva se casto, zdrzuje. Zakomentovano rovnez nastaveni smokeping, pokud vim, smokeping ma byt vazan na IP adresu a vubec ne na zarizeni, ktere obecne muze mit vice IP adres.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/controllers/devices.php
if(isset($user_id))
{
$user = new User_Model($user_id);
if ($user->id == 0)
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
if ($user->id == 0)
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
$selected_GPS = $user->member->address_point->GPS;
$selected_street_id = $user->member->address_point->street_id;
$selected_street_number = $user->member->address_point->street_number;
......
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic data'));
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required')->selected($selected);
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[1,50]');
// name is not required, it is useful to name routers, access points, etc. only
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('length[1,50]');
$form->input('trade_name')->label(url_lang::lang('texts.Trade name').':')->rules('length[1,50]');
$form->dropdown('type')->label(url_lang::lang('texts.Type').':')->options($types)->rules('required');
$form->checkbox('PPPoE_logging_in')->label(url_lang::lang('texts.PPPoE'))->value('1');
if ($this->acl_check_new(get_class($this),'login'))
$form->input('login')->label(url_lang::lang('texts.username').':')->rules('length[0,30]');
if ($this->acl_check_new(get_class($this),'password'))
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
if ($this->acl_check_new(get_class($this),'login'))
$form->input('login')->label(url_lang::lang('texts.username').':')->rules('length[0,30]');
if ($this->acl_check_new(get_class($this),'password'))
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($selected_GPS);
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id);
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($selected_street_number);
......
$device_model->trade_name = htmlspecialchars($form_data["trade_name"]);
$device_model->type = htmlspecialchars($form_data["type"]);
$device_model->PPPoE_logging_in = htmlspecialchars($form_data["PPPoE_logging_in"]);
if ($this->acl_check_new(get_class($this),'login'))
$device_model->login = htmlspecialchars($form_data["login"]);
if ($this->acl_check_new(get_class($this),'password'))
$device_model->password = htmlspecialchars($form_data["password"]);
if ($this->acl_check_new(get_class($this),'login'))
$device_model->login = htmlspecialchars($form_data["login"]);
if ($this->acl_check_new(get_class($this),'password'))
$device_model->password = htmlspecialchars($form_data["password"]);
$device_model->comment = htmlspecialchars($form_data["comment"]);
$address_point_model = new Address_point_Model();
......
if(isset($user_id))
{
$user = new User_Model($user_id);
if ($user->id == 0)
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
if ($user->id == 0)
Controller::error(RECORD);
if (!$this->acl_check_new('Devices_Controller', 'devices', $user->member_id))
Controller::error(ACCESS);
$selected = $user->id;
$selected_GPS = $user->member->address_point->GPS;
$selected_street_id = $user->member->address_point->street_id;
$selected_street_number = $user->member->address_point->street_number;
......
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Device'));
$form->dropdown('user_id')->label(url_lang::lang('texts.user').':')->rules('required')->options($arr_users)->selected($selected);
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[2,50]');
// name is not required, it is useful to name routers, access points, etc. only
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('length[2,50]');
$form->input('trade_name')->label(url_lang::lang('texts.Trade name').':')->rules('length[2,50]');
$form->dropdown('type')->label(url_lang::lang('texts.Type').':')->options($types)->rules('required');
$form->checkbox('PPPoE_logging_in')->label(url_lang::lang('texts.PPPoE').':')->value('1');
if ($this->acl_check_new(get_class($this),'login'))
$form->input('login')->label(url_lang::lang('texts.username').':')->rules('length[0,30]');
if ($this->acl_check_new(get_class($this),'password'))
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($selected_GPS);
if ($this->acl_check_new(get_class($this),'login'))
$form->input('login')->label(url_lang::lang('texts.username').':')->rules('length[0,30]');
if ($this->acl_check_new(get_class($this),'password'))
$form->input('password')->label(url_lang::lang('texts.password').':')->rules('length[0,30]');
$form->input('GPS')->label(url_lang::lang('texts.GPS').':')->rules('length[3,100]')->value($selected_GPS);
$form->dropdown('street_id')->label(url_lang::lang('texts.street').':')->options($arr_streets)->selected($selected_street_id);
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('length[1,50]|valid_numeric')->value($selected_street_number);
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->selected($selected_town_id);
......
$form->input('mac')->label(url_lang::lang('texts.MAC').':')->rules('required|length[3,250]');
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name').':')->options($arr_segments)->rules('required')->selected($selected_segment);
// wireless settings of interface
/*
$form->checkbox('add_wireless')->label(url_lang::lang('texts.Save wireless setting'))->value(1);
$form->input('ssid')->label(url_lang::lang('texts.SSID').':');
$form->dropdown('wmode')->label(url_lang::lang('texts.Mode').':')->options($arr_modes)->callback(array($this, 'valid_mode'));
......
$form->input('frequence')->label(url_lang::lang('texts.Frequence').':');
$form->input('channel')->label(url_lang::lang('texts.Channel').':');
$form->dropdown('antenna')->label(url_lang::lang('texts.Antenna').':')->options($arr_antennas)->callback(array($this, 'valid_antenna'));
$form->dropdown('polarization')->label(url_lang::lang('texts.Polarization').':')->options($arr_polarizations)->callback(array($this, 'valid_polarization'));
$form->dropdown('polarization')->label(url_lang::lang('texts.Polarization').':')->options($arr_polarizations)->callback(array($this, 'valid_polarization'));
*/
// adding ip address
$form->group('')->label(url_lang::lang('texts.IP address'));
$form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required|length[7,15]')
->callback(array($this, 'valid_ip'));
$form->dropdown('subnet_id')->label(url_lang::lang('texts.Select subnet name').':')->rules('required')
->options($arr_subnets_names)->selected($selected_subnet);
//smokeping parents
/*
$smokeping = new Smokeping_Model();
$total_parents = $smokeping->count_parents();
$all_parents = $smokeping->get_parents();
$parent_level[0] = '----- '.url_lang::lang('texts.Select parent').' -----';
foreach ($all_parents as $row){
$parent_level[$row->id]=$row->title.' ('.$row->level.')';
}
}
//monitoring
$form->group('')->label(url_lang::lang('texts.Device monitoring'));
$form->checkbox('smokeping')->label(url_lang::lang('texts.Smokeping monitoring'))->value(1);
$form->dropdown('smokeping_parent')->label(url_lang::lang('texts.Smokeping menu parent').':')->options($parent_level);
*/
// submit button
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
......
$iface_model_saved = $iface_model->save();
// wireless setting of interface
/*
$wireless_model_saved = true;
if ($form_data['add_wireless'])
{
......
$wireless_model->polarization = $form_data['polarization'];
$wireless_model_saved = $wireless_model->save();
}
*/
// ip address model
$ip_address_model = new ip_address_Model();
......
$ip_address_saved = $ip_address_model->save();
// monitoring
/*
if ($form_data["smokeping"]==1){
$smokeping_model = new Smokeping_Model();
$smokeping->ip_address = $form_data['ip_address'];
......
$smokeping->level = ($smokeping_parent->level)+1;
$smokeping->save();
}
*/
unset($form_data);
// has been everything saved successfully?
if ($device_saved && $device_engineer_saved && $iface_model_saved && $wireless_model_saved && $ip_address_saved)
if ($device_saved && $device_engineer_saved && $iface_model_saved /*&& $wireless_model_saved*/ && $ip_address_saved)
{
$this->session->set_flash('message', url_lang::lang('texts.Device has been successfully saved.'));
url::redirect(url_lang::base().'devices/show/'.$device_model->id);

Také k dispozici: Unified diff