Revize 388
Přidáno uživatelem Jiří Sviták před asi 15 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'error - cant delete device' => 'Chyba - nelze smazat zařízení.',
|
||
'error - cant delete interface' => 'Chyba - nelze smazat rozhraní.',
|
||
'error - cant delete ip address' => 'Chyba - nelze smazat IP adresu.',
|
||
'error - cant delete port' => 'Chyba - nelze smazat port.',
|
||
'error - cant delete user' => 'Chyba - nelze smazat uživatele.',
|
||
'error - cant delete vlan interface' => 'Chyba - nelze smazat VLAN rozhraní.',
|
||
'error - cant delete wireless setting' => 'Chyba - nelze smazat bezdrátové nastavení.',
|
||
... | ... | |
'please fill in the form with information about your association' => 'Prosím, vyplňte formulář údaji u vašem sdružení.',
|
||
'polarization' => 'Polarizace',
|
||
'port detail' => 'Detail portu',
|
||
'port is successfully saved' => 'Port byl úspěšně uložen.',
|
||
'port is successfully updated' => 'Port byl úspěšně upraven.',
|
||
'port has been successfully deleted' => 'Port byl úspěšně smazán.',
|
||
'port has been successfully saved' => 'Port byl úspěšně uložen.',
|
||
'port has been successfully updated' => 'Port byl úspěšně upraven.',
|
||
'port name' => 'Název portu',
|
||
'ports list' => 'Seznam portů',
|
||
'ports' => 'Porty',
|
||
... | ... | |
'year' => 'Rok',
|
||
'yes' => 'ano',
|
||
'you have been successfully logged out' => 'Byl jste úspěšně odhlášen.',
|
||
'zip code' => 'PSČ'
|
||
'zip code' => 'PSČ',
|
||
'zip_code' => 'PSČ'
|
||
);
|
freenetis/trunk/kohana/application/models/member.php | ||
---|---|---|
LIMIT $limit, $limit_results");
|
||
}
|
||
|
||
public function get_all_members_to_export()
|
||
{
|
||
return self::$db->query("SELECT *
|
||
FROM members");
|
||
}
|
||
|
||
/**
|
||
* Function counts all members.
|
||
* @param $filter_values
|
freenetis/trunk/kohana/application/models/port.php | ||
---|---|---|
WHERE device_id='.$device_id.'
|
||
ORDER BY id ASC');
|
||
}
|
||
|
||
/**
|
||
* Function deletes port and vlan relation from pivot table.
|
||
* @param $port_id
|
||
* @return unknown_type
|
||
*/
|
||
public function delete_from_pivot_table($port_id)
|
||
{
|
||
self::$db->query("
|
||
DELETE FROM ports_vlans
|
||
WHERE port_id = $port_id
|
||
");
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
|
||
if ($this->acl_check_new(get_class($this), 'members'))
|
||
$grid->add_new_button(url_lang::base().'members/add', url_lang::lang('texts.Add new member'));
|
||
// xls export of members is still not functional, see xls_export function for explanation
|
||
//if ($this->acl_check_new(get_class($this), 'members'))
|
||
// $grid->add_new_button(url_lang::base().'members/xls_export', url_lang::lang('texts.Export members to xls file'));
|
||
// xls export of members
|
||
if ($this->acl_check_view(get_class($this), 'members'))
|
||
$grid->add_new_button(url_lang::base().'members/xls_export', url_lang::lang('texts.Export members to xls file'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('registration')->label(url_lang::lang('texts.Reg'))->bool(array(url_lang::lang('texts.No'),url_lang::lang('texts.Yes')))->class('center');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
|
||
... | ... | |
|
||
/**
|
||
* Export list of members to xls file. Requires library PEAR.
|
||
* It looks like there is somewhere before <?php tag a space (or spaces).
|
||
* When the browser tries to post xls file, this spaces are included in the file.
|
||
* The file is corrupted and cannot be opened.
|
||
* Original version of script used for going through rows mysql_fetch_array function.
|
||
* Better solution than foreach is welcome.
|
||
* @return unknown_type
|
||
*/
|
||
function xls_export()
|
||
... | ... | |
require_once(APPPATH.'vendors/Spreadsheet/Excel/Writer.php');
|
||
// workbook represents xls file
|
||
$workbook = new Spreadsheet_Excel_Writer();
|
||
$workbook->send('database.xls');
|
||
$workbook->send(url_lang::lang('texts.Members').'.xls');
|
||
$workbook->setVersion(8);
|
||
// sets xls cells format
|
||
$format_bold =& $workbook->addFormat();
|
||
... | ... | |
|
||
// worksheet represents sheet in xls file
|
||
$worksheet =& $workbook->addWorksheet('Clenove');
|
||
//$worksheet->setInputEncoding("UTF-8");
|
||
/*
|
||
$worksheet->setInputEncoding("UTF-8");
|
||
|
||
// creates database member model
|
||
$member_model = new Member_Model();
|
||
$members = $member_model->find_all();
|
||
$members = $member_model->get_all_members_to_export();
|
||
$resultCnt = count($members);
|
||
$first = true;
|
||
$row = 0;
|
||
$line = $member_model->find(0, FALSE);
|
||
// goes through columns of header
|
||
foreach ($line as $key => $value)
|
||
{
|
||
$valLen = strlen($value);
|
||
// max array stores lenghts of columns in xls sheet
|
||
$max[$key] = $valLen;
|
||
// writes header
|
||
$worksheet->write(0, $col, url_lang::lang('texts.'.$key), $format_bold);
|
||
if ($col >= $colCnt-1)
|
||
$first = false;
|
||
if ($row>=$resultCnt-1)
|
||
$worksheet->setColumn($col, $col, $max[$key]);
|
||
$col++;
|
||
}
|
||
|
||
// goes through rows of data
|
||
foreach ($members as $key => $line)
|
||
{
|
||
$colCnt = count($line);
|
||
$col = 0;
|
||
$colCnt = count($line);
|
||
$col = 0;
|
||
if ($first)
|
||
{
|
||
// goes through columns of header
|
||
foreach ($line as $key => $value)
|
||
{
|
||
$valLen = strlen($value);
|
||
// max array stores lenghts of columns in xls sheet
|
||
$max[$key] = $valLen;
|
||
// writes header
|
||
$worksheet->write(0, $col, url_lang::lang('texts.'.$key), $format_bold);
|
||
if ($col >= $colCnt-1)
|
||
$first = false;
|
||
if ($row>=$resultCnt-1)
|
||
$worksheet->setColumn($col, $col, $max[$key]);
|
||
$col++;
|
||
}
|
||
$row++;
|
||
$colCnt = count($line);
|
||
$col = 0;
|
||
}
|
||
// goes through columns of data and writes them into the sheet
|
||
foreach ($line as $key => $value)
|
||
{
|
||
... | ... | |
}
|
||
$row++;
|
||
}
|
||
*/
|
||
$workbook->close();
|
||
//url::redirect(url_lang::base().'members/show_all');
|
||
}
|
freenetis/trunk/kohana/application/controllers/ifaces.php | ||
---|---|---|
{
|
||
// gets information from session to know where to return
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
$iface = new Iface_Model($iface_id);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'iface', $iface->device->user->member_id))
|
||
Controller::error(1);
|
||
if ($ssDevice_id)
|
||
$link_back = url_lang::base().'devices/show/'.$ssDevice_id;
|
||
else
|
||
$link_back = url_lang::base().'ifaces/show_all';
|
||
$iface = new Iface_Model($iface_id);
|
||
if (!$iface->id)
|
||
url::redirect($link_back);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'iface', $iface->device->user->member_id))
|
||
Controller::error(1);
|
||
// find ip addresses of interface, in this relation 1:n ORM works
|
||
$ips = $iface->find_related_ip_addresses();
|
||
// ORM doesn't work in this case (1:0 relation), so number of wireless settings has to be detected manually
|
freenetis/trunk/kohana/application/controllers/ports.php | ||
---|---|---|
$grid->order_field('segment_name')->label(url_lang::lang('texts.Segment name'));
|
||
$grid->order_field('vlan_count')->label(url_lang::lang('texts.Vlans'))->class('center');
|
||
if ($this->acl_check_view('Devices_Controller','port'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'ports/show') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Port'))->url(url_lang::base().'ports/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
if ($this->acl_check_edit('Devices_Controller','port'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'ports/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
|
||
//$grid->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'))->class('center');
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Port'))->url(url_lang::base().'ports/edit')->action(url_lang::lang('texts.Edit'))->class('center');
|
||
if ($this->acl_check_delete('Devices_Controller','port'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Port'))->url(url_lang::base().'ports/delete')->action(url_lang::lang('texts.Delete'))->class('center');
|
||
$grid->datasource( $query );
|
||
$this->template->content = $grid;
|
||
|
||
... | ... | |
$view->render(TRUE);
|
||
} // end of add
|
||
|
||
|
||
//=============================================================================
|
||
//----- EDIT ------------------------------------------------------------------
|
||
//=============================================================================
|
||
/**
|
||
* Function edits port.
|
||
* @param $port_id
|
||
* @return unknown_type
|
||
*/
|
||
function edit($port_id = null)
|
||
{
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
... | ... | |
}
|
||
|
||
$form->dropdown('segment_id')->label(url_lang::lang('texts.Segment name'))->options($arr_segments)->rules('required')->selected($port->segment_id);
|
||
|
||
$form->dropdown('vlan_id[]')->label(url_lang::lang('texts.Vlan name'))->options($arr_vlans)->multiple('multiple')->id('vlan_id');
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.update'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
|
||
//----- validate form and save data -----------------------------------
|
||
if($form->validate())
|
||
{
|
||
|
||
$form_data = $form->as_array();
|
||
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$arr_vlan_id = array();
|
||
if(isset($_POST['vlan_id'])) $arr_vlan_id = $_POST['vlan_id'];
|
||
|
||
... | ... | |
$port->name = $form_data['name'];
|
||
$port->device_id = $form_data['device_id'];
|
||
$port->segment_id = $form_data['segment_id'];
|
||
|
||
|
||
$ports_vlans_model = new Ports_vlan_Model();
|
||
$ports_vlans = $ports_vlans_model->find_all_by_port_id($port_id);
|
||
foreach ($ports_vlans as $vlan) {
|
||
$vlan->delete();
|
||
}
|
||
|
||
$saved = $port->save();
|
||
|
||
if ($saved) {
|
||
$vlans = new Ports_vlan_Model();
|
||
foreach ($arr_vlan_id as $vlan_id) {
|
||
... | ... | |
}
|
||
|
||
}
|
||
//----- end validate --------------------------------------------------
|
||
|
||
if ($ssDevice_id) $link_back = html::anchor(url_lang::base().'devices/show/'.$ssDevice_id, url_lang::lang('texts.Back to device parameters'));
|
||
else $link_back = html::anchor(url_lang::base().'ports/show_all', url_lang::lang('texts.Back to ports list'));
|
||
... | ... | |
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
// $view->content = new View('content', $data);
|
||
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = $link_back;
|
||
$view->content->headline = url_lang::lang('texts.Edit port').' - '.$port->name;
|
||
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->header->title = url_lang::lang('texts.Edit port').' - '.$port->name;
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->render(TRUE);
|
||
} // end of edit
|
||
|
||
/**
|
||
* Function deletes port.
|
||
* @param $port_id
|
||
* @return unknown_type
|
||
*/
|
||
function delete($port_id = null)
|
||
{
|
||
if (isset($port_id))
|
||
{
|
||
$member_id = $this->session->get('ssMember_id');
|
||
if ($member_id)
|
||
$linkback = url_lang::base()."devices/show_by_member/$member_id";
|
||
else
|
||
$linkback = url_lang::base()."devices/show_all";
|
||
// get the port
|
||
$port = new Port_Model($port_id);
|
||
if (!$port->id)
|
||
url::redirect($linkback);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'port', $port->device->user->member_id))
|
||
Controller::error(1);
|
||
// removing relation from pivot table using ORM would be better, but I could not found useful documentation
|
||
// so I have written own query
|
||
$port->delete_from_pivot_table($port_id);
|
||
if ($port->delete())
|
||
$this->session->set_flash('message', url_lang::lang('texts.Port has been successfully deleted.'));
|
||
else
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant delete port.'));
|
||
url::redirect($linkback);
|
||
}
|
||
else
|
||
{
|
||
Controller::warning(1);
|
||
}
|
||
}
|
||
//----- end EDIT --------------------------------------------------------------
|
||
//=============================================================================
|
||
|
||
}
|
||
?>
|
freenetis/trunk/kohana/application/controllers/vlan_ifaces.php | ||
---|---|---|
{
|
||
// get information from session to know where to return
|
||
$ssIface_id = $this->session->get('ssIface_id');
|
||
$vlan_iface = new Vlan_iface_Model($vlan_iface_id);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'vlan_iface', $vlan_iface->iface->device->user->member_id))
|
||
Controller::error(1);
|
||
if ($ssIface_id)
|
||
$link_back = url_lang::base().'ifaces/show/'.$ssIface_id;
|
||
else
|
||
$link_back = url_lang::base().'vlan_ifaces/show_all';
|
||
$vlan_iface = new Vlan_iface_Model($vlan_iface_id);
|
||
if (!$vlan_iface->id)
|
||
url::redirect($link_back);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'vlan_iface', $vlan_iface->iface->device->user->member_id))
|
||
Controller::error(1);
|
||
// find ip addresses of interface, in this relation 1:n ORM works
|
||
$ips = $vlan_iface->find_related_ip_addresses();
|
||
if (count($ips) == 0)
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
*/
|
||
function delete($ip_address_id = NULL)
|
||
{
|
||
|
||
$ip_address = new Ip_address_Model($ip_address_id);
|
||
|
||
if ($ip_address->id) // IP adress exists
|
||
if (isset($ip_address_id))
|
||
{
|
||
$ssIface_id = $this->session->get('ssIface_id');
|
||
$ssVlan_iface_id = $this->session->get('ssVlan_iface_id');
|
||
if ($ssVlan_iface_id)
|
||
$link_back = url_lang::base().'vlan_ifaces/show/'.$ssVlan_iface_id;
|
||
elseif ($ssIface_id)
|
||
$link_back = url_lang::base().'ifaces/show/'.$ssIface_id;
|
||
else
|
||
$link_back = url_lang::base().'ip_addresses/show_all';
|
||
$ip_address = new Ip_address_Model($ip_address_id);
|
||
if (!$ip_address->id)
|
||
url::redirect($link_back);
|
||
// identify the owner of IP_address
|
||
if ($ip_address->iface_id)
|
||
$member_id = $ip_address->iface->device->user->member_id;
|
||
else
|
||
$member_id = $ip_address->vlan_iface->iface->device->user->member_id;
|
||
|
||
if (!$this->acl_check_delete('Devices_Controller', 'ip_address', $member_id))
|
||
Controller::error(1);
|
||
|
||
$ssIface_id = $this->session->get('ssIface_id');
|
||
$ssVlan_iface_id = $this->session->get('ssVlan_iface_id');
|
||
|
||
if ($ip_address->delete())
|
||
$this->session->set_flash('message', url_lang::lang('texts.IP address has been successfully deleted.'));
|
||
else
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant delete ip address.'));
|
||
if ($ssVlan_iface_id)
|
||
$link_back = url_lang::base().'vlan_ifaces/show/'.$ssVlan_iface_id;
|
||
elseif ($ssIface_id)
|
||
$link_back = url_lang::base().'ifaces/show/'.$ssIface_id;
|
||
else
|
||
$link_back = url_lang::base().'ip_addresses/show_all';
|
||
url::redirect($link_back);
|
||
|
||
}
|
||
|
||
else
|
||
{
|
||
Controller::warning(1);
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
{
|
||
if (isset($device_id))
|
||
{
|
||
$device = new Device_Model($device_id);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'devices', $device->user->member_id))
|
||
Controller::error(1);
|
||
|
||
$member_id = $this->session->get('ssMember_id');
|
||
if ($member_id)
|
||
$linkback = url_lang::base()."devices/show_by_member/$member_id";
|
||
else
|
||
$linkback = url_lang::base()."devices/show_all";
|
||
$device = new Device_Model($device_id);
|
||
if (!$device->id)
|
||
url::redirect($linkback);
|
||
if (!$this->acl_check_delete('Devices_Controller', 'devices', $device->user->member_id))
|
||
Controller::error(1);
|
||
$ifaces = $device->find_related_ifaces();
|
||
$ports = $device->find_related_ports();
|
||
if (count($ifaces) == 0 && count($ports) == 0)
|
Také k dispozici: Unified diff
Dodelano a odladeno mazani zarizeni, rozhrani, vlan rozhrani, ip adres a portu. Pridan xls export clenu.