Revize 2142
Přidáno uživatelem David Raška před asi 11 roky(ů)
freenetis/branches/1.1/application/vendors/axo_doc/axo_doc.xml | ||
---|---|---|
<method name="index"></method>
|
||
<method name="change"></method>
|
||
</object>
|
||
<object name="links" type="controller">
|
||
<object name="links" type="controller"
|
||
comment-en="Links - enables to manage links of between ifaces"
|
||
comment-cs="Linky - umožňuje spravovat linky mezi rozhraními">
|
||
<method name="__construct"></method>
|
||
<method name="index"></method>
|
||
<method name="show_all">
|
||
<!-- show_all($limit_results = 50, $order_by = 'id',
|
||
$order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
|
||
if (!$this->acl_check_view('Links_Controller', 'link'))
|
||
Controller::error(ACCESS);
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
|
||
$link_model = new Link_Model();
|
||
|
||
$filter_form = new Filter_form('s');
|
||
|
||
$filter_form->add('name')
|
||
->callback('json/link_name');
|
||
|
||
$filter_form->add('medium')
|
||
->type('select')
|
||
->values($link_model->get_medium_types());
|
||
|
||
$filter_form->add('bitrate')
|
||
->type('number');
|
||
|
||
$filter_form->add('duplex')
|
||
->type('select')
|
||
->values(arr::rbool());
|
||
|
||
$filter_form->add('comment');
|
||
|
||
$filter_form->add('items_count')
|
||
->type('number');
|
||
|
||
$filter_form->add('wireless_norm')
|
||
->label('norm')
|
||
->type('select')
|
||
->values(Link_Model::get_wireless_norms());
|
||
|
||
$filter_form->add('ssid')
|
||
->label('SSID')
|
||
->callback('json/ssid');
|
||
|
||
// model
|
||
$link_model = new Link_Model();
|
||
$total_links = $link_model->count_all_links($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_links)
|
||
$sql_offset = 0;
|
||
|
||
$links = $link_model->get_all_links(
|
||
$sql_offset, $limit_results, $order_by,
|
||
$order_by_direction, $filter_form->as_sql()
|
||
);
|
||
|
||
$grid = new Grid('links', null, array
|
||
(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 50,
|
||
'selector_min' => 50,
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::get('lang').'/links/show_all/'
|
||
. $limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page',
|
||
'total_items' => $total_links,
|
||
'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('Links_Controller', 'link'))
|
||
{
|
||
$grid->add_new_button('links/add', 'Add new link');
|
||
}
|
||
|
||
$grid->order_field('id')
|
||
->label('ID')
|
||
->class('center');
|
||
|
||
$grid->order_field('name');
|
||
|
||
$grid->order_callback_field('medium')
|
||
->callback('callback::link_medium_field');
|
||
|
||
$grid->order_callback_field('bitrate')
|
||
->callback('callback::bitrate_field');
|
||
|
||
$grid->order_field('duplex')
|
||
->bool(arr::rbool())
|
||
->class('center');
|
||
|
||
$grid->order_field('items_count');
|
||
|
||
$grid->order_field('ssid')
|
||
->label('SSID');
|
||
|
||
$grid->order_callback_field('wireless_norm')
|
||
->label('norm')
|
||
->callback('callback::wireless_link_norm');
|
||
|
||
$actions = $grid->grouped_action_field();
|
||
|
||
if ($this->acl_check_view('Links_Controller', 'link'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('show')
|
||
->url('links/show');
|
||
}
|
||
|
||
if ($this->acl_check_edit('Links_Controller', 'link'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('edit')
|
||
->url('links/edit');
|
||
}
|
||
|
||
if ($this->acl_check_delete('Links_Controller', 'link'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('delete')
|
||
->url('links/delete')
|
||
->class('delete_link');
|
||
}
|
||
|
||
$grid->datasource($links);
|
||
|
||
$view = new View('main');
|
||
$view->breadcrumbs = __('Links');
|
||
$view->title = __('Links list');
|
||
$view->content = new View('show_all');
|
||
$view->content->table = $grid;
|
||
$view->content->headline = __('Links list');
|
||
$view->render(TRUE);
|
||
} // end of show_all
|
||
|
||
/**
|
||
* Function shows link information.
|
||
*
|
||
* @param integer $link_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="new" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
<axo usage_type="access" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="links" section="Links_Controller" value="link" action="new" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
</method>
|
||
<method name="show">
|
||
<!-- show($link_id = null)
|
||
{
|
||
if (!$link_id || !is_numeric($link_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$link = new Link_Model($link_id);
|
||
|
||
if (!$link || !$link->id)
|
||
Controller::error(RECORD);
|
||
|
||
if (!$this->acl_check_view('Links_Controller', 'link'))
|
||
Controller::error(ACCESS);
|
||
|
||
$duplex_value = arr::rbool();
|
||
|
||
$duplex = $duplex_value[(bool) $link->duplex];
|
||
|
||
// link media
|
||
$medium = Link_Model::get_medium_type($link->medium);
|
||
|
||
$headline = __('Interfaces');
|
||
|
||
if ($link->medium != Link_Model::MEDIUM_AIR)
|
||
$headline .= ' / ' . __('Ports');
|
||
|
||
$grid = new Grid('subnets/show/'.$link_id, $headline, array
|
||
(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
if ($link->medium == Link_Model::MEDIUM_ROAMING &&
|
||
$this->acl_check_edit('Ifaces_Controller', 'iface'))
|
||
{
|
||
$grid->add_new_button(
|
||
'ifaces/add_iface_to_link/' . $link->id,
|
||
__('Append interface to link'),
|
||
array('class' => 'popup_link')
|
||
);
|
||
}
|
||
|
||
$grid->field('id')
|
||
->label('ID');
|
||
|
||
$grid->callback_field('name')
|
||
->label('Name')
|
||
->callback('callback::link_item_field');
|
||
|
||
$grid->callback_field('type')
|
||
->label('Type')
|
||
->callback('callback::iface_type_field');
|
||
|
||
if ($link->medium == Link_Model::MEDIUM_AIR)
|
||
{
|
||
$grid->callback_field('wireless_mode')
|
||
->label('Mode')
|
||
->callback('callback::wireless_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');
|
||
|
||
$actions = $grid->grouped_action_field();
|
||
|
||
if ($this->acl_check_view('Ifaces_Controller', 'iface'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('show')
|
||
->url('ifaces/show');
|
||
}
|
||
|
||
if ($this->acl_check_edit('Ifaces_Controller', 'iface'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('edit')
|
||
->url('ifaces/edit');
|
||
}
|
||
|
||
if ($this->acl_check_edit('Ifaces_Controller', 'link'))
|
||
{
|
||
$actions->add_action()
|
||
->icon_action('delete')
|
||
->url('ifaces/remove_from_link')
|
||
->class('delete_link')
|
||
->label('Remove interface from link');
|
||
}
|
||
|
||
|
||
$grid->datasource($link->get_items());
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('links/show_all', 'Links',
|
||
$this->acl_check_view('Links_Controller', 'link'))
|
||
->disable_translation()
|
||
->text($link->name . ' (' . $link->id . ')');
|
||
|
||
$links = array();
|
||
|
||
if($this->acl_check_edit('Links_Controller', 'link'))
|
||
{
|
||
$links[] = html::anchor('links/edit/'.$link->id, __('Edit'));
|
||
}
|
||
|
||
if($this->acl_check_delete('Links_Controller', 'link'))
|
||
{
|
||
$links[] = html::anchor(
|
||
'links/delete/'.$link->id, __('Delete'),
|
||
array('class' => 'delete_link')
|
||
);
|
||
}
|
||
|
||
$headline = __('Link detail').' - '.$link->name;
|
||
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('links/show');
|
||
$view->content->link = $link;
|
||
$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 link.
|
||
*
|
||
* @param integer $iface_type Pre-fill available mediums by type [optional]
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Ifaces_Controller" value="iface" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Ifaces_Controller" value="iface" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Ifaces_Controller" value="iface" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Ifaces_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
<axo usage_type="access" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="links" section="Ifaces_Controller" value="iface" action="edit" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Ifaces_Controller" value="iface" action="view" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Ifaces_Controller" value="iface" action="edit" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Ifaces_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="breadcrumbs" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="links" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="links" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
</method>
|
||
<method name="add">
|
||
<!-- add($iface_type = NULL)
|
||
{
|
||
if(!$this->acl_check_new('Links_Controller', 'link'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
$roaming = ORM::factory('link')->get_roaming();
|
||
$medias = array();
|
||
$selected_medium = 1;
|
||
|
||
if (is_numeric($iface_type))
|
||
{
|
||
$all_mediums = Iface_Model::get_types_has_link_with_medium($iface_type);
|
||
|
||
if ($iface_type == Iface_Model::TYPE_PORT ||
|
||
$iface_type == Iface_Model::TYPE_ETHERNET)
|
||
{
|
||
$selected_medium = Link_Model::MEDIUM_CABLE;
|
||
}
|
||
else if ($iface_type == Iface_Model::TYPE_WIRELESS)
|
||
{
|
||
$selected_medium = Link_Model::MEDIUM_AIR;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$all_mediums = Link_Model::get_medium_types();
|
||
}
|
||
|
||
foreach ($all_mediums as $id => $type)
|
||
{
|
||
if ($id != Link_Model::MEDIUM_ROAMING || !$roaming)
|
||
{
|
||
$medias[$id] = $type;
|
||
}
|
||
}
|
||
|
||
asort($medias);
|
||
|
||
$medias = array
|
||
(
|
||
NULL => '- '.__('Select medium').' -'
|
||
) + $medias;
|
||
|
||
$wireless_norms = array
|
||
(
|
||
NULL => '- '.__('Select norm').' -'
|
||
) + Link_Model::get_wireless_norms();
|
||
|
||
$polarizations = array
|
||
(
|
||
NULL => '- '.__('Select polarization').' -'
|
||
) + Link_Model::get_wireless_polarizations();
|
||
|
||
$arr_unit = array
|
||
(
|
||
'1' => 'bps',
|
||
'1024' => 'kbps',
|
||
'1048576' => 'Mbps',
|
||
'1073741824' => 'Gbps'
|
||
);
|
||
|
||
$form = new Forge();
|
||
|
||
$form->group('Basic data');
|
||
|
||
$form->input('name')
|
||
->style('width: 600px');
|
||
|
||
$form->dropdown('medium')
|
||
->options($medias)
|
||
->rules('required')
|
||
->selected($selected_medium)
|
||
->callback(array($this, 'valid_medium'));
|
||
|
||
$form->input('bitrate')
|
||
->rules('valid_numeric')
|
||
->class('join1')
|
||
->style('width:100px; margin-right:5px;');
|
||
|
||
$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')
|
||
->rules('length[0,254]')
|
||
->cols('20')
|
||
->rows('5');
|
||
|
||
$form->group('Wireless setting');
|
||
|
||
$form->input('wireless_ssid')
|
||
->label('SSID');
|
||
|
||
$form->dropdown('wireless_norm')
|
||
->label('Norm')
|
||
->options($wireless_norms)
|
||
->style('width: 200px');
|
||
|
||
$form->input('wireless_frequency')
|
||
->label('Frequency');
|
||
|
||
$form->input('wireless_channel')
|
||
->label('Channel');
|
||
|
||
$form->input('wireless_channel_width')
|
||
->label('Channel width');
|
||
|
||
$form->dropdown('wireless_polarization')
|
||
->label('Polarization')
|
||
->options($polarizations)
|
||
->style('width: 200px');
|
||
|
||
$form->submit('Save');
|
||
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
|
||
$link_model = new Link_Model();
|
||
$link_model->name = $form_data['name'];
|
||
$link_model->medium = $form_data['medium'];
|
||
$link_model->bitrate = $form_data['bitrate'] * $form_data['bit_unit'];
|
||
$link_model->duplex = $form_data['duplex'];
|
||
$link_model->comment = $form_data['comment'];
|
||
|
||
if ($link_model->medium == Link_Model::MEDIUM_AIR)
|
||
{
|
||
$link_model->wireless_ssid = $form_data['wireless_ssid'];
|
||
$link_model->wireless_norm = $form_data['wireless_norm'];
|
||
$link_model->wireless_frequency = $form_data['wireless_frequency'];
|
||
$link_model->wireless_channel = $form_data['wireless_channel'];
|
||
$link_model->wireless_channel_width = $form_data['wireless_channel_width'];
|
||
$link_model->wireless_polarization = $form_data['wireless_polarization'];
|
||
}
|
||
|
||
unset($form_data);
|
||
|
||
$link_model->save();
|
||
|
||
status::success('Link has been successfully saved.');
|
||
|
||
$this->redirect('links/show/', $link_model->id);
|
||
}
|
||
else
|
||
{
|
||
$headline = __('Add new link');
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('links/show_all', 'Links',
|
||
$this->acl_check_view('Links_Controller', 'link'))
|
||
->text($headline);
|
||
|
||
$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 add
|
||
|
||
/**
|
||
* Function edits link.
|
||
*
|
||
* @param integer $link_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="new" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Links_Controller" value="link" action="new" own="false"></axo>
|
||
<axo usage_type="breadcrumbs" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="edit">
|
||
<!-- edit($link_id = null)
|
||
{
|
||
if (!$link_id || !is_numeric($link_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$link = new Link_Model($link_id);
|
||
|
||
if (!$link || !$link->id)
|
||
Controller::warning(ACCESS);
|
||
|
||
if(!$this->acl_check_edit('Links_Controller', 'link'))
|
||
Controller::error(ACCESS);
|
||
|
||
$this->link_id = $link_id;
|
||
|
||
$roaming = ORM::factory('link')->get_roaming();
|
||
|
||
$media = array();
|
||
|
||
foreach (Link_Model::get_medium_types() as $id => $type)
|
||
{
|
||
if ($roaming == $link->id || $id != Link_Model::MEDIUM_ROAMING || !$roaming)
|
||
{
|
||
$media[$id] = $type;
|
||
}
|
||
}
|
||
asort($media);
|
||
|
||
$media = array
|
||
(
|
||
NULL => '- '.__('Select medium').' -'
|
||
) + $media;
|
||
|
||
$polarizations = array
|
||
(
|
||
NULL => '- '.__('Select polarization').' -'
|
||
) + Link_Model::get_wireless_polarizations();
|
||
|
||
$norms = array
|
||
(
|
||
NULL => '- '.__('Select norm').' -'
|
||
) + Link_Model::get_wireless_norms();
|
||
|
||
$arr_unit = array
|
||
(
|
||
'1' => 'bps',
|
||
'1024' => 'kbps',
|
||
'1048576' => 'Mbps',
|
||
'1073741824' => 'Gbps'
|
||
);
|
||
|
||
// form
|
||
$form = new Forge('links/edit/'.$link_id);
|
||
|
||
$form->group('Basic data');
|
||
|
||
$form->input('name')
|
||
->style('width: 600px')
|
||
->value($link->name);
|
||
|
||
$form->dropdown('medium')
|
||
->options($media)
|
||
->rules('required')
|
||
->selected($link->medium)
|
||
->callback(array($this, 'valid_medium'));
|
||
|
||
$form->input('bitrate')
|
||
->rules('valid_numeric')
|
||
->value($link->bitrate / 1048576)
|
||
->class('join1')
|
||
->style('width:100px; margin-right:5px;');
|
||
|
||
$form->dropdown('bit_unit')
|
||
->options($arr_unit)
|
||
->class('join2')
|
||
->selected(1048576)
|
||
->callback(array($this, 'valid_bitrate'));
|
||
|
||
$form->checkbox('duplex')
|
||
->label('Duplex')
|
||
->value('1')
|
||
->checked($link->duplex);
|
||
|
||
$form->textarea('comment')
|
||
->rules('length[0,254]')
|
||
->value($link->comment)
|
||
->cols('20')
|
||
->rows('5');
|
||
|
||
$form->group('Wireless setting');
|
||
|
||
$form->input('wireless_ssid')
|
||
->label('SSID')
|
||
->value($link->wireless_ssid);
|
||
|
||
$form->dropdown('wireless_norm')
|
||
->label('Norm')
|
||
->options($norms)
|
||
->selected($link->wireless_norm)
|
||
->style('width: 200px');
|
||
|
||
$form->input('wireless_frequency')
|
||
->label('Frequency')
|
||
->value($link->wireless_frequency);
|
||
|
||
$form->input('wireless_channel')
|
||
->label('Channel')
|
||
->value($link->wireless_channel);
|
||
|
||
$form->input('wireless_channel_width')
|
||
->label('Channel width')
|
||
->value($link->wireless_channel_width);
|
||
|
||
$form->dropdown('wireless_polarization')
|
||
->label('Polarization')
|
||
->options($polarizations)
|
||
->selected($link->wireless_polarization)
|
||
->style('width: 200px');
|
||
|
||
$form->submit('submit')
|
||
->value(__('Update'));
|
||
|
||
// validation
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
|
||
$link->name = $form_data['name'];
|
||
$link->medium = $form_data['medium'];
|
||
$link->bitrate = $form_data['bitrate'] * $form_data['bit_unit'];
|
||
$link->duplex = $form_data['duplex'];
|
||
$link->comment = $form_data['comment'];
|
||
|
||
if ($link->medium == Link_Model::MEDIUM_AIR)
|
||
{
|
||
$link->wireless_ssid = $form_data['wireless_ssid'];
|
||
$link->wireless_norm = $form_data['wireless_norm'];
|
||
$link->wireless_frequency = $form_data['wireless_frequency'];
|
||
$link->wireless_channel = $form_data['wireless_channel'];
|
||
$link->wireless_channel_width = $form_data['wireless_channel_width'];
|
||
$link->wireless_polarization = $form_data['wireless_polarization'];
|
||
}
|
||
|
||
unset($form_data);
|
||
|
||
if ($link->save())
|
||
{
|
||
status::success('Link has been successfully updated.');
|
||
url::redirect('links/show/'.$link->id);
|
||
}
|
||
|
||
}
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('links/show_all', 'Links',
|
||
$this->acl_check_view('Links_Controller', 'link'))
|
||
->link('links/show/' . $link->id,
|
||
$link->name . ' (' . $link->id . ')',
|
||
$this->acl_check_view('Links_Controller', 'link'))
|
||
->text('Edit');
|
||
|
||
$headline = __('Edit link') . ' - ' . $link->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 link
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $link_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Links_Controller" value="link" action="edit" own="false"></axo>
|
||
<axo usage_type="breadcrumbs" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
<axo usage_type="breadcrumbs" section="Links_Controller" value="link" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="delete">
|
||
<!-- delete($link_id = NULL)
|
||
{
|
||
// access control
|
||
if (!$this->acl_check_delete('Links_Controller', 'link'))
|
||
Controller::error(ACCESS);
|
||
|
||
// bad parameter
|
||
if (!$link_id || !is_numeric($link_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$link = new Link_Model($link_id);
|
||
|
||
// record doesn't exist
|
||
if (!$link->id)
|
||
Controller::error(RECORD);
|
||
|
||
// interface and port test
|
||
if (count($link->ifaces))
|
||
{
|
||
status::warning('At least one interface or port still uses this link.');
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
|
||
// successfully deleted
|
||
if ($link->delete())
|
||
{
|
||
status::success('Link has been successfully deleted.');
|
||
}
|
||
|
||
if (url::slice(url_lang::uri(Path::instance()->previous()), 0, 2) == 'links/show')
|
||
{
|
||
url::redirect('links/show_all');
|
||
}
|
||
else
|
||
{
|
||
url::redirect(Path::instance()->previous());
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Callback function to valid medium of segment
|
||
*
|
||
* @author Michal Kliment
|
||
* @param object $input
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
<axo usage_type="access" section="Links_Controller" value="link" action="delete" own="false"></axo>
|
||
</method>
|
||
</object>
|
||
<object name="log_queues" type="controller">
|
||
<object name="log_queues" type="controller"
|
||
comment-en="Log queues - manages errors and logs in system"
|
||
comment-cs="Záznamy činnosti - spravuje chyby a záznamy činnosti v systému">
|
||
<method name="index"></method>
|
||
<method name="show_all">
|
||
<!-- show_all(
|
||
$limit_results = 50, $order_by = 'id',
|
||
$order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
{
|
||
if (!$this->acl_check_view('Log_queues_Controller', 'log_queue'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
{
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
}
|
||
|
||
$allowed_order_type = array
|
||
(
|
||
'id', 'user_name', 'created_at', 'type', 'status', 'closed_at',
|
||
'description'
|
||
);
|
||
|
||
if (!in_array(strtolower($order_by), $allowed_order_type))
|
||
{
|
||
$order_by = 'id';
|
||
}
|
||
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
{
|
||
$order_by_direction = 'asc';
|
||
}
|
||
|
||
// filter
|
||
$filter_form = new Filter_form();
|
||
|
||
$filter_form->add('type')
|
||
->type('select')
|
||
->values(Log_queue_Model::get_types());
|
||
|
||
$filter_form->add('state')
|
||
->type('select')
|
||
->values(Log_queue_Model::get_states());
|
||
|
||
$filter_form->add('created_at')
|
||
->label('Recorded')
|
||
->type('date');
|
||
|
||
$filter_form->add('closed_at')
|
||
->type('date');
|
||
|
||
$filter_form->add('user_name')
|
||
->label('Closed by')
|
||
->callback('json/user_name');
|
||
|
||
$filter_form->add('description');
|
||
|
||
// get data
|
||
$lq_model = new Log_queue_Model();
|
||
|
||
$total = $lq_model->count_all_logs($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total)
|
||
$sql_offset = 0;
|
||
|
||
$logs = $lq_model->get_all_logs(
|
||
$sql_offset, $limit_results, $order_by, $order_by_direction,
|
||
$filter_form->as_sql()
|
||
);
|
||
|
||
$headline = __('Errors and logs');
|
||
|
||
$grid = new Grid('log_queue', null, array
|
||
(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 50,
|
||
'selector_min' => 50,
|
||
'selector_max_multiplier' => 10,
|
||
'base_url' => Config::get('lang')
|
||
. '/log_queues/show_all/' . $limit_results
|
||
. '/' . $order_by . '/' . $order_by_direction,
|
||
'uri_segment' => 'page',
|
||
'total_items' => $total,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form->html()
|
||
));
|
||
|
||
$grid->add_new_button(
|
||
'log_queues/close_logs/'.server::query_string(), 'Set state closed'
|
||
);
|
||
|
||
$grid->order_field('id')
|
||
->label('ID');
|
||
|
||
$grid->order_callback_field('type')
|
||
->callback('callback::log_queues_type_field');
|
||
|
||
$grid->order_callback_field('state')
|
||
->callback('callback::log_queues_state_field');
|
||
|
||
$grid->order_field('created_at')
|
||
->label('Recorded');
|
||
|
||
$grid->order_callback_field('description')
|
||
->callback('callback::limited_text');
|
||
|
||
$grid->order_field('closed_at');
|
||
|
||
$grid->order_link_field('user_id')
|
||
->link('users/show', 'user_name')
|
||
->label('Closed by');
|
||
|
||
$actions = $grid->grouped_action_field();
|
||
|
||
$actions->add_conditional_action()
|
||
->condition('is_log_queue_unclosed')
|
||
->icon_action('activate')
|
||
->url('log_queues/close_log')
|
||
->label('Set state closed');
|
||
|
||
$actions->add_action()
|
||
->icon_action('show')
|
||
->url('log_queues/show');
|
||
|
||
$grid->datasource($logs);
|
||
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $headline;
|
||
$view->content = new View('show_all');
|
||
$view->content->headline = $headline;
|
||
$view->content->table = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Shows a log queue.
|
||
*
|
||
* @param integer $log_queue_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="log_queue" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Log_queues_Controller" value="log_queue" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="show">
|
||
<!-- show($log_queue_id = NULL)
|
||
{
|
||
if (!is_numeric($log_queue_id))
|
||
{
|
||
Controller::warning(PARAMETER);
|
||
}
|
||
|
||
$lq_model = new Log_queue_Model($log_queue_id);
|
||
|
||
if (!$lq_model || !$lq_model->id)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_view('Log_queues_Controller', 'log_queue'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// comments grid
|
||
$comment_model = new Comment_Model();
|
||
|
||
$comments = $comment_model->get_all_comments_by_comments_thread(
|
||
$lq_model->comments_thread_id
|
||
);
|
||
|
||
$comments_grid = new Grid('comments', NULL, array
|
||
(
|
||
'separator' => '<br /><br />',
|
||
'use_paginator' => FALSE,
|
||
'use_selector' => FALSE,
|
||
));
|
||
|
||
if ($this->acl_check_new('Log_queues_Controller', 'comments'))
|
||
{
|
||
$url = ($lq_model->comments_thread_id) ?
|
||
'comments/add/'.$lq_model->comments_thread_id :
|
||
'comments_threads/add/log_queue/'.$lq_model->id;
|
||
|
||
$comments_grid->add_new_button(
|
||
$url, 'Add comment',
|
||
array('class' => 'popup_link')
|
||
);
|
||
}
|
||
|
||
$comments_grid->field('text');
|
||
|
||
if ($this->acl_check_view('Users_Controller', 'users'))
|
||
{
|
||
$comments_grid->link_field('user_id')
|
||
->link('users/show', 'user_name')
|
||
->label('User');
|
||
}
|
||
else
|
||
{
|
||
$comments_grid->field('user_name')
|
||
->label('User');
|
||
}
|
||
|
||
$comments_grid->field('datetime')
|
||
->label('Time');
|
||
|
||
$actions = $comments_grid->grouped_action_field();
|
||
|
||
if ($this->acl_check_edit('Log_queues_Controller', 'comments'))
|
||
{
|
||
$actions->add_conditional_action()
|
||
->icon_action('edit')
|
||
->url('comments/edit')
|
||
->condition('is_own')
|
||
->class('popup_link');
|
||
}
|
||
|
||
if ($this->acl_check_delete('Log_queues_Controller', 'comments'))
|
||
{
|
||
$actions->add_conditional_action()
|
||
->icon_action('delete')
|
||
->url('comments/delete')
|
||
->condition('is_own')
|
||
->class('delete_link');
|
||
}
|
||
|
||
$comments_grid->datasource($comments);
|
||
|
||
$headline = __('Error and log');
|
||
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('log_queues/show_all', 'Errors and logs')
|
||
->disable_translation()
|
||
->text(Log_queue_Model::get_type_name($lq_model->type) . ' (' . $lq_model->id . ')');
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('log_queues/show');
|
||
$view->content->headline = $headline;
|
||
$view->content->log_queue = $lq_model;
|
||
$view->content->comments_grid = $comments_grid;
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Close a log queue.
|
||
*
|
||
* @param integer $log_queue_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="log_queue" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="comments" action="new" own="false"></axo>
|
||
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="comments" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="comments" action="delete" own="false"></axo>
|
||
<axo usage_type="access" section="Log_queues_Controller" value="log_queue" action="view" own="false"></axo>
|
||
<axo usage_type="links" section="Log_queues_Controller" value="comments" action="new" own="false"></axo>
|
||
<axo usage_type="links" section="Users_Controller" value="users" action="view" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Log_queues_Controller" value="comments" action="edit" own="false"></axo>
|
||
<axo usage_type="grid-action" section="Log_queues_Controller" value="comments" action="delete" own="false"></axo>
|
||
</method>
|
||
<method name="close_log">
|
||
<!-- close_log($log_queue_id = NULL)
|
||
{
|
||
if (!is_numeric($log_queue_id))
|
||
{
|
||
Controller::warning(PARAMETER);
|
||
}
|
||
|
||
$lq_model = new Log_queue_Model($log_queue_id);
|
||
|
||
if (!$lq_model || !$lq_model->id)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
if (!$this->acl_check_edit('Log_queues_Controller', 'log_queue'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
if ($lq_model->state == Log_queue_Model::STATE_CLOSED)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
try
|
||
{
|
||
$lq_model->transaction_start();
|
||
|
||
// set data
|
||
$lq_model->state = Log_queue_Model::STATE_CLOSED;
|
||
$lq_model->closed_at = date('Y-m-d H:i:s');
|
||
$lq_model->closed_by_user_id = $this->user_id;
|
||
$lq_model->save_throwable();
|
||
|
||
$lq_model->transaction_commit();
|
||
|
||
status::success('Log queue has been closed.');
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
$lq_model->transaction_rollback();
|
||
Log::add_exception($e);
|
||
status::error('Cannot close log queue.', $e);
|
||
}
|
||
|
||
$this->redirect('log_queues/show/', $log_queue_id);
|
||
}
|
||
|
||
/**
|
||
* Closes filtered logs
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Log_queues_Controller" value="log_queue" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Log_queues_Controller" value="log_queue" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="close_logs"></method>
|
||
</object>
|
||
... | ... | |
<method name="index"></method>
|
||
<method name="logout"></method>
|
||
</object>
|
||
<object name="login_logs" type="controller">
|
||
<object name="login_logs" type="controller"
|
||
comment-en="Login logs - who and when logged in"
|
||
comment-cs="Logy přihlášení - kdo a kdy se přihlásil">
|
||
<method name="index"></method>
|
||
<method name="show_all">
|
||
<!-- show_all($limit_results = 50, $order_by = 'last_time',
|
||
$order_by_direction = 'DESC', $page_word = null, $page = 1)
|
||
{
|
||
// access
|
||
if (!$this->acl_check_view('Login_logs_Controller', 'logs'))
|
||
Controller::error(ACCESS);
|
||
|
||
// filter
|
||
$filter_form = new Filter_form();
|
||
|
||
$filter_form->add('name')
|
||
->callback('json/user_name');
|
||
|
||
$filter_form->add('id')
|
||
->label('ID')
|
||
->type('number');
|
||
|
||
$filter_form->add('last_time')
|
||
->label('Time of login')
|
||
->type('date');
|
||
|
||
// gets new selector
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
|
||
$login_log_model = new Login_log_Model();
|
||
|
||
$total_login_logs = $login_log_model->count_all_login_logs($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_login_logs)
|
||
$sql_offset = 0;
|
||
|
||
$login_logs = $login_log_model->get_all_login_logs(
|
||
$sql_offset, (int) $limit_results, $order_by,
|
||
$order_by_direction, $filter_form->as_sql()
|
||
);
|
||
|
||
// create grid
|
||
$grid = new Grid('login_logs/show_all', __('Login logs'), array
|
||
(
|
||
'use_paginator' => true,
|
||
'use_selector' => true,
|
||
'current' => $limit_results,
|
||
'selector_increace' => 50,
|
||
'selector_min' => 50,
|
||
'selector_max_multiplier' => 10,
|
||
'uri_segment' => 'page',
|
||
'base_url' => Config::get('lang') . '/login_logs/show_all/'
|
||
. $limit_results.'/'.$order_by.'/'.$order_by_direction,
|
||
'total_items' => $total_login_logs,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form->html()
|
||
));
|
||
|
||
$grid->order_field('id');
|
||
|
||
$grid->order_field('name');
|
||
|
||
$grid->order_field('last_time')
|
||
->label('Last time login');
|
||
|
||
$actions = $grid->grouped_action_field();
|
||
|
||
$actions->add_action()
|
||
->icon_action('member')
|
||
->url('users/show')
|
||
->label('Show user');
|
||
|
||
$actions->add_action()
|
||
->icon_action('login')
|
||
->url('login_logs/show_by_user')
|
||
->label('Show logins of user');
|
||
|
||
$grid->datasource($login_logs);
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Login logs');
|
||
$view->breadcrumbs = __('Login logs');
|
||
$view->content = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Show login logs of user
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer $user_id
|
||
* @param integer $limit_results
|
||
* @param string $order_by
|
||
* @param string $order_by_direction
|
||
* @param integer $page_word
|
||
* @param integer $page
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Login_logs_Controller" value="logs" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Login_logs_Controller" value="logs" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="show_by_user">
|
||
<!-- show_by_user(
|
||
$user_id = null, $limit_results = 200, $order_by = 'time',
|
||
$order_by_direction = 'desc', $page_word = null, $page = 1)
|
||
{
|
||
if (!isset($user_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
$user = new User_Model((int) $user_id);
|
||
|
||
if (!$user->id)
|
||
Controller::error(RECORD);
|
||
|
||
// access
|
||
if (!$this->acl_check_view('Login_logs_Controller', 'logs', $user->member_id))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// filter
|
||
$filter_form = new Filter_form();
|
||
|
||
$filter_form->add('time')
|
||
->label('Time of login')
|
||
->type('date');
|
||
|
||
$filter_form->add('ip_address');
|
||
|
||
// gets new selector
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
|
||
$login_log_model = new Login_log_Model();
|
||
|
||
$total_login_logs = $login_log_model->count_all_login_logs_by_user(
|
||
$user->id, $filter_form->as_sql()
|
||
);
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_login_logs)
|
||
$sql_offset = 0;
|
||
|
||
$login_logs = $login_log_model->get_all_login_logs_by_user(
|
||
$user->id, $sql_offset, (int) $limit_results,
|
||
$order_by, $order_by_direction, $filter_form->as_sql()
|
||
);
|
||
|
||
$headline = __('Login logs of user') . ' ' . $user->get_full_name();
|
||
|
||
// create grid
|
||
$grid = new Grid('login_logs/show_by_user', null, array
|
||
(
|
||
'current' => $limit_results,
|
||
'selector_increace' => 200,
|
||
'selector_min' => 200,
|
||
'selector_max_multiplier' => 10,
|
||
'uri_segment' => 'page',
|
||
'base_url' => Config::get('lang') . '/login_logs/show_by_user/'
|
||
. $user->id . '/' . $limit_results . '/'
|
||
. $order_by . '/' . $order_by_direction,
|
||
'total_items' => $total_login_logs,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'variables' => $user->id . '/',
|
||
'url_array_ofset' => 1,
|
||
'filter' => $filter_form->html()
|
||
));
|
||
|
||
$grid->order_field('id')
|
||
->label('ID');
|
||
|
||
$grid->order_field('time');
|
||
|
||
$grid->order_field('ip_address')
|
||
->label('IP address');
|
||
|
||
$grid->datasource($login_logs);
|
||
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('members/show_all', 'Members',
|
||
$this->acl_check_view('Members_Controller', 'members'))
|
||
->link('members/show/' . $user->member->id,
|
||
'ID ' . $user->member->id . ' - ' . $user->member->name,
|
||
$this->acl_check_view('Members_Controller', 'members', $user->member->id))
|
||
->link('users/show_by_member/' . $user->member_id, 'Users',
|
||
$this->acl_check_view('Users_Controller', 'users', $user->member_id))
|
||
->link('users/show/' . $user->id,
|
||
$user->name . ' ' . $user->surname . ' (' . $user->login . ')',
|
||
$this->acl_check_view('Users_Controller', 'users', $user->member_id))
|
||
->text('Login logs');
|
||
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->title = $headline;
|
||
$view->content = new View('show_all');
|
||
$view->content->headline = $headline;
|
||
$view->content->table = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
}
|
||
-->
|
||
<axo usage_type="unknown" section="Login_logs_Controller" value="logs" action="view" own="true"></axo>
|
||
<axo usage_type="unknown" section="Members_Controller" value="members" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Members_Controller" value="members" action="view" own="true"></axo>
|
||
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="true"></axo>
|
||
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="true"></axo>
|
||
<axo usage_type="access" section="Login_logs_Controller" value="logs" action="view" own="true"></axo>
|
||
<axo usage_type="breadcrumbs" section="Members_Controller" value="members" action="view" own="false"></axo>
|
||
<axo usage_type="breadcrumbs" section="Members_Controller" value="members" action="view" own="true"></axo>
|
||
<axo usage_type="breadcrumbs" section="Users_Controller" value="users" action="view" own="true"></axo>
|
||
<axo usage_type="breadcrumbs" section="Users_Controller" value="users" action="view" own="true"></axo>
|
||
</method>
|
||
</object>
|
||
<object name="logs" type="controller">
|
||
<object name="logs" type="controller"
|
||
comment-en="Logs - manages last modifications of objects"
|
||
comment-cs="Logy akcí - spravuje poslední úpravy objektů">
|
||
<method name="index"></method>
|
||
<method name="show_all">
|
||
<!-- show_all($limit_results = 50, $page_word = null, $page = 1)
|
||
{
|
||
if (!$this->acl_check_view('Logs_Controller', 'logs'))
|
||
Controller::error(ACCESS);
|
||
|
||
if (Settings::get('action_logs_active') != 1)
|
||
url::redirect('settings/logging');
|
||
|
||
// gets new selector
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
|
||
$filter_form = new Filter_form('l');
|
||
|
||
$filter_form->add('table_name');
|
||
|
||
$filter_form->add('time')
|
||
->type('date');
|
||
|
||
$filter_form->add('user_name')
|
||
->type('combo')
|
||
->label('Firstname of user')
|
||
->callback('json/user_name');
|
||
|
||
$filter_form->add('user_surname')
|
||
->type('combo')
|
||
->label('Surname of user')
|
||
->callback('json/user_surname');
|
||
|
||
$filter_form->add('member_name')
|
||
->callback('json/member_name');
|
||
|
||
$filter_form->add('action')
|
||
->type('select')
|
||
->values(array
|
||
(
|
||
Log_Model::ACTION_ADD => __('Added'),
|
||
Log_Model::ACTION_DELETE => __('Deleted'),
|
||
Log_Model::ACTION_UPDATE => __('Updated')
|
||
));
|
||
|
||
$filter_form->add('object_id')
|
||
->type('number');
|
||
|
||
$log_model = new Log_Model();
|
||
|
||
$total_logs = $log_model->count_all_logs($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_logs)
|
||
$sql_offset = 0;
|
||
|
||
// load logs
|
||
$logs = $log_model->get_all_logs(
|
||
$sql_offset, (int) $limit_results, $filter_form->as_sql()
|
||
);
|
||
|
||
// title of view
|
||
$title = __('Action logs');
|
||
|
||
// create grid
|
||
$grid = new Grid('logs/show_all', $title, array
|
||
(
|
||
'use_paginator' => true,
|
||
'use_selector' => true,
|
||
'current' => $limit_results,
|
||
'selector_increace' => 50,
|
||
'selector_min' => 50,
|
||
'selector_max_multiplier' => 10,
|
||
'uri_segment' => 'page',
|
||
'base_url' => Config::get('lang')
|
||
. '/logs/show_all/' . $limit_results,
|
||
'total_items' => $total_logs,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => 'id',
|
||
'order_by_direction' => 'DESC',
|
||
'limit_results' => $limit_results,
|
||
'filter' => $filter_form
|
||
));
|
||
|
||
$grid->field('id');
|
||
|
||
$grid->callback_field('user_id')
|
||
->label('User')
|
||
->callback('callback::user_id_log_field');
|
||
|
||
$grid->callback_field('action')
|
||
->callback('callback::log_action_field');
|
||
|
||
$grid->field('table_name')
|
||
->label('Table');
|
||
|
||
$grid->callback_field('object_id')
|
||
->label('Object')
|
||
->callback('callback::object_log_field');
|
||
|
||
$grid->field('time');
|
||
|
||
$grid->datasource($logs);
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Action logs');
|
||
$view->breadcrumbs = __('Action logs');
|
||
$view->content = $grid;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Show logs of user
|
||
*
|
||
* @author Ondřej Fibich
|
||
* @param integer $user_id
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Logs_Controller" value="logs" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Logs_Controller" value="logs" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="show_by_user">
|
||
<!-- show_by_user($user_id = null, $limit_results = 200,
|
||
$page_word = null, $page = 1)
|
||
{
|
||
if (!$this->acl_check_view('Logs_Controller', 'logs'))
|
||
Controller::error(ACCESS);
|
||
|
||
if (!isset($user_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
if (Settings::get('action_logs_active') != 1)
|
||
url::redirect('settings/logging');
|
||
|
||
$user = new User_Model((int) $user_id);
|
||
|
||
if (!$user->id)
|
||
Controller::error(RECORD);
|
||
|
||
// gets new selector
|
||
if (is_numeric($this->input->post('record_per_page')))
|
||
$limit_results = (int) $this->input->post('record_per_page');
|
||
|
||
$log_model = new Log_Model();
|
||
|
||
$total_logs = $log_model->count_all_users_logs($user_id);
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_logs)
|
||
$sql_offset = 0;
|
||
|
||
$title = __('Action logs of user')
|
||
. ' ' . $user->name . ' ' . $user->surname;
|
||
|
||
// load logs
|
||
$logs = $log_model->get_all_users_logs(
|
||
$user->id, $sql_offset, (int) $limit_results
|
||
);
|
||
|
||
// create grid
|
||
$grid = new Grid('logs/show_all', '', array
|
||
(
|
||
'use_paginator' => true,
|
||
'use_selector' => true,
|
||
'current' => $limit_results,
|
||
'selector_increace' => 200,
|
||
'selector_min' => 200,
|
||
'selector_max_multiplier' => 10,
|
||
'uri_segment' => 'page',
|
||
'base_url' => Config::get('lang')
|
||
. '/logs/show_by_user/' . $user_id . '/'
|
||
. $limit_results,
|
||
'total_items' => $total_logs,
|
||
'items_per_page' => $limit_results,
|
||
'style' => 'classic',
|
||
'order_by' => 'id',
|
||
'order_by_direction' => 'DESC',
|
||
'limit_results' => $limit_results
|
||
));
|
||
|
||
$grid->field('id');
|
||
|
||
$grid->callback_field('user_id')
|
||
->label('User')
|
||
->callback('callback::user_id_log_field');
|
||
|
||
$grid->callback_field('action')
|
||
->label('Action')
|
||
->callback('callback::log_action_field');
|
||
|
||
$grid->field('table_name')
|
||
->label('Table');
|
||
|
Také k dispozici: Unified diff
Upravy:
- dokumentace AXO: controllery L