Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2159

Přidáno uživatelem Michal Kliment před asi 11 roky(ů)

Upravy:
- refs #563: dokumentace k AXO (controllery V)

Zobrazit rozdíly:

freenetis/branches/1.1/application/vendors/axo_doc/axo_doc.xml
<axo usage_type="access" section="Users_Controller" value="keys" action="new" own="true"></axo>
</method>
</object>
<object name="variable_symbols" type="controller">
<object name="variable_symbols" type="controller" comment-en="Variable symbols of double-entry accounts" comment-cs="Variabilní symboly podvojných účtů">
<method name="__construct"></method>
<method name="show_by_account">
<!-- show_by_account(
$account_id = NULL)
{
if (empty($account_id) || !is_numeric($account_id))
{
Controller::error(RECORD);
}
$account = new Account_Model($account_id);
$variable_symbol_model = new Variable_Symbol_Model();
$view = new View('main');
$view->title = __('Administration of variable symbols');
// rights
if (!$this->acl_check_view(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
Controller::error(ACCESS);
}
$grid_variable_symbols = new Grid(url::current(true), null, array
(
'use_paginator' => false,
'use_selector' => false
));
$grid_variable_symbols->field('id')
->label(__('ID'));
$grid_variable_symbols->field('variable_symbol')
->label(__('Variable symbol'));
$actions = $grid_variable_symbols->grouped_action_field();
if ($this->acl_check_edit(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
$actions->add_action()
->icon_action('edit')
->url('variable_symbols/edit/'.$account_id)
->class('popup_link');
}
if ($this->acl_check_delete(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
$actions->add_action()
->icon_action('delete')
->url('variable_symbols/delete/'.$account_id)
->class('delete_link');
}
$grid_variable_symbols->datasource($variable_symbol_model->find_account_variable_symbols($account_id));
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller','members'))
->disable_translation()
->link('members/show/' . $account->member->id,
"ID ".$account->member->id." - ".$account->member->name,
$this->acl_check_view(
'Members_Controller','members', $account->member_id
))
->enable_translation()
->text('Variable symbols');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('variable_symbols/show_by_account');
$view->content->grid_variable_symbols = $grid_variable_symbols;
$view->content->account_id = $account_id;
$view->content->can_add = $this->acl_check_new(
'Variable_Symbols_Controller', 'variable_symbols', $account->member_id
);
$view->render(TRUE);
} // end of show_by_account function
/**
* Adds new variable symbol to account
*
* @author David Raška
* @param type $account_id
*/
public -->
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="delete" 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="Variable_Symbols_Controller" value="variable_symbols" action="new" own="true"></axo>
<axo usage_type="access" section="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
<axo usage_type="grid-action" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" own="true"></axo>
<axo usage_type="grid-action" section="Variable_Symbols_Controller" value="variable_symbols" action="delete" 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="access-partial" section="Variable_Symbols_Controller" value="variable_symbols" action="new" own="true"></axo>
</method>
<method name="add">
<!-- add(
$account_id = NULL)
{
if (empty($account_id) || !is_numeric($account_id))
{
Controller::error(RECORD);
}
$account = new Account_Model($account_id);
if (!$account || !$account->id)
{
Controller::error (RECORD);
}
$view = new View('main');
$view->title = __('Administration of variable symbols');
// rights
if (!$this->acl_check_edit(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
Controller::error(ACCESS);
}
$form = new Forge();
$form->input('variable_symbol')
->rules('length[1,10]')
->callback(array($this,'valid_var_sym'));
if (Variable_Key_Generator::get_active_driver())
{
$form->checkbox('variable_symbol_generate')
->label('Generate automatically');
}
else
{
$form->variable_symbol->rules('required|length[1,10]');
}
$form->submit('Add');
if ($form->validate())
{
$form_data = $form->as_array();
$variable_symbol_model = new Variable_Symbol_Model();
if (isset($form_data['variable_symbol_generate']) &&
$form_data['variable_symbol_generate'])
{
$var_sym = Variable_Key_Generator::factory()->generate($account->member_id);
}
else
{
$var_sym = $form_data['variable_symbol'];
}
if (empty($var_sym))
{
status::warning('Empty variable symbol.');
}
else if ($variable_symbol_model->get_variable_symbol_id($var_sym))
{
status::warning('Variable symbol already exists in database.');
}
else
{
$variable_symbol_model->variable_symbol = $var_sym;
$variable_symbol_model->account_id = $account_id;
$issaved = $variable_symbol_model->save();
if ($issaved)
{
status::success('Variable symbol has been successfully added');
}
else
{
status::error('Error - cant update variable symbols');
}
}
$this->redirect('show_by_account/', $account_id);
}
else
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller','members'))
->disable_translation()
->link('members/show/' . $account->member->id,
"ID ".$account->member->id." - ".$account->member->name,
$this->acl_check_view(
'Members_Controller','members', $account->member_id
))
->enable_translation()
->link('variable_symbols/show_by_account/' . $account->id, 'Variable symbols',
$this->acl_check_view(
'Variable_Symbols_Controller','variable_symbols', $account->member_id
))
->text('Add');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Add variable symbol');
$view->content->form = $form->html();
$view->render(TRUE);
}
} // end of add function
/**
* Edits variable symbol of account
*
* @author David Raška
* @param type $account_id
* @param type $id
*/
public -->
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" 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="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
<axo usage_type="access" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" 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="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
</method>
<method name="edit">
<!-- edit(
$account_id = NULL, $id = NULL)
{
if (empty($account_id) || !is_numeric($account_id))
{
Controller::error(RECORD);
}
$account = new Account_Model($account_id);
if (!$account || !$account->id)
{
Controller::error(RECORD);
}
$variable_symbol_model = new Variable_Symbol_Model($id);
if (empty($id) || !is_numeric($id))
{
Controller::warning(PARAMETER);
}
if (!$variable_symbol_model->id)
{
Controller::error(RECORD);
}
$view = new View('main');
$view->title = __('Administration of variable symbols');
// rights
if (!$this->acl_check_edit(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
Controller::error(ACCESS);
}
$form = new Forge();
$form->input('value')
->label(__('Variable symbol') . ':')
->rules('required|length[1,10]')
->value($variable_symbol_model->variable_symbol)
->callback(array($this,'valid_var_sym'));
$form->submit('submit')
->value(__('Update'));
if ($form->validate())
{
$form_data = $form->as_array();
if ($variable_symbol_model->variable_symbol != $form_data['value'] &&
$variable_symbol_model->get_variable_symbol_id($form_data['value']))
{
status::warning('Variable symbol already exists in database.');
}
elseif ($variable_symbol_model->variable_symbol_used ($id))
{
status::warning('Cannot edit, there are other records depending on this one.');
}
else
{
try
{
$variable_symbol_model->transaction_start();
$variable_symbol_model->variable_symbol = $form_data['value'];
$variable_symbol_model->save_throwable();
$variable_symbol_model->transaction_commit();
status::success('Variable symbol has been successfully updated');
}
catch (Exception $e)
{
$variable_symbol_model->transaction_rollback();
Log::add_exception($e);
status::error('Error - cant update variable symbols', $e);
}
}
$this->redirect('show_by_account/', $account_id);
}
else
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller','members'))
->disable_translation()
->link('members/show/' . $account->member_id,
"ID ".$account->member_id." - ".$account->member->name,
$this->acl_check_view(
'Members_Controller','members', $account->member_id
))
->enable_translation()
->link('variable_symbols/show_by_account/' . $account->id, 'Variable symbols',
$this->acl_check_view(
'Variable_Symbols_Controller','variable_symbols', $account->member_id
)
)->disable_translation()
->text("ID ".$variable_symbol_model->id." - ".$variable_symbol_model->variable_symbol)
->enable_translation()
->text('Edit');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('variable_symbols/edit');
$view->content->form = $form->html();
$view->render(TRUE);
}
} // end of edit function
/**
* Deletes contact of user
*
* @author David Raška
* @param type $account_id
* @param type $id
*/
public -->
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" 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="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
<axo usage_type="access" section="Variable_Symbols_Controller" value="variable_symbols" action="edit" 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="Variable_Symbols_Controller" value="variable_symbols" action="view" own="true"></axo>
</method>
<method name="delete">
<!-- delete(
$account_id = NULL,$id = NULL)
{
if (empty($account_id) || !is_numeric($account_id))
{
Controller::error(RECORD);
}
$account = new Account_Model($account_id);
if (!$account || !$account->id)
{
Controller::error (RECORD);
}
// rights
if (!$this->acl_check_delete(
'Variable_Symbols_Controller', 'variable_symbols',
$account->member_id
))
{
Controller::error(ACCESS);
}
$variable_symbol_model = new Variable_Symbol_Model($id);
if (empty($id) || !is_numeric($id))
{
Controller::warning(PARAMETER);
}
if (!$variable_symbol_model->id)
{
Controller::error(RECORD);
}
if (!$variable_symbol_model->variable_symbol_used($id))
{
$variable_symbol_model->remove($account);
$variable_symbol_model->save();
$variable_symbol_model->delete();
status::success('Variable symbol has been deleted');
}
else
{
status::warning('Cannot delete, there are other records depending on this one.');
}
$this->redirect('show_by_account/', $account_id);
} // end of delete function
/**
* Check validity of variable symbol
*
* @param object $input
*/
public static -->
<axo usage_type="unknown" section="Variable_Symbols_Controller" value="variable_symbols" action="delete" own="true"></axo>
<axo usage_type="access" section="Variable_Symbols_Controller" value="variable_symbols" action="delete" own="true"></axo>
</method>
</object>
<object name="vlans" type="controller">
<object name="vlans" type="controller"
comment-en="VLANs - enable to management virtual LAN networks"
comment-cs="VLANy - umožňuje správu virtuálních LAN sítí">
<method name="__construct"></method>
<method name="index"></method>
<method name="show_all">
<!-- show_all(
$limit_results = 50, $order_by = 'tag_802_1q', $order_by_direction = 'asc',
$page_word = null, $page = 1)
{
if (!$this->acl_check_view('Vlans_Controller', 'vlan'))
Controller::error(ACCESS);
// get new selector
if (is_numeric($this->input->post('record_per_page')))
$limit_results = (int) $this->input->post('record_per_page');
$vlan_model = new Vlan_Model();
$total_vlans = $vlan_model->count_all_vlans();
if (($sql_offset = ($page - 1) * $limit_results) > $total_vlans)
$sql_offset = 0;
$query = $vlan_model->get_all_vlans(
$sql_offset, (int) $limit_results, $order_by,
$order_by_direction
);
$grid = new Grid('vlans', null, array
(
'current' => $limit_results,
'selector_increace' => 10,
'selector_min' => 10,
'selector_max_multiplier' => 5,
'base_url' => Config::get('lang') . '/vlans/show_all/'
. $limit_results . '/' . $order_by
. '/' . $order_by_direction,
'uri_segment' => 'page',
'total_items' => $total_vlans,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results
));
if ($this->acl_check_new('Vlans_Controller', 'vlan'))
{
$grid->add_new_button('vlans/add', 'Add new vlan');
}
$grid->order_field('id')
->label('ID')
->class('center');
$grid->order_field('name')
->label('Vlan name');
$grid->order_field('tag_802_1q');
$grid->order_callback_field('devices_count')
->label('Devices count')
->callback('callback::devices_field');
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Vlans_Controller', 'vlan'))
{
$actions->add_action()
->icon_action('show')
->url('vlans/show');
}
if ($this->acl_check_edit('Vlans_Controller', 'vlan'))
{
$actions->add_action()
->icon_action('edit')
->url('vlans/edit');
}
if ($this->acl_check_delete('Vlans_Controller', 'vlan'))
{
$actions->add_action()
->icon_action('delete')
->url('vlans/delete')
->class('delete_link');
}
$grid->datasource($query);
$view = new View('main');
$view->title = __('Vlans list');
$view->breadcrumbs = __('Vlans');
$view->content = new View('show_all');
$view->content->table = $grid;
$view->content->headline = __('Vlans list');
$view->render(TRUE);
}
/**
* Shows VLAN
*
* @param integer $vlan_id
*/
public -->
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="new" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="delete" own="false"></axo>
<axo usage_type="access" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="links" section="Vlans_Controller" value="vlan" action="new" own="false"></axo>
<axo usage_type="grid-action" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="grid-action" section="Vlans_Controller" value="vlan" action="edit" own="false"></axo>
<axo usage_type="grid-action" section="Vlans_Controller" value="vlan" action="delete" own="false"></axo>
</method>
<method name="show">
<!-- show($vlan_id = null)
{
if (!$vlan_id)
{
Controller::warning(PARAMETER);
}
$vlan = new Vlan_Model($vlan_id);
if (!$vlan->id)
{
Controller::error(RECORD);
}
if (!$this->acl_check_view('Vlans_Controller', 'vlan'))
{
Controller::error(ACCESS);
}
$grid = new Grid('vlans', null, array
(
'separator' => '',
'use_paginator' => false,
'use_selector' => false
));
$grid->field('id')
->label('ID')
->class('center');
$grid->field('name')
->label('Device name');
$grid->callback_field('ports_count')
->label('Ports count')
->callback('callback::ports_field');
$grid->callback_field('ip_address')
->label('IP address')
->callback('callback::ip_address_field');
$grid->datasource($vlan->get_devices_of_vlan());
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller','devices'))
{
$actions->add_action('id')
->icon_action('show')
->url('devices/show');
}
if ($this->acl_check_edit('Devices_Controller','devices'))
{
$actions->add_action('id')
->icon_action('edit')
->url('devices/edit');
}
if ($this->acl_check_delete('Devices_Controller', 'devices'))
{
$actions->add_action('id')
->icon_action('delete')
->url('devices/delete')
->class('delete_link');
}
$breadcrumbs = breadcrumbs::add()
->link('vlans/show_all', 'VLANs')
->disable_translation()
->text($vlan->name);
$view = new View('main');
$view->title = __('Vlan detail') . ' - ' . $vlan->name;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('vlans/show');
$view->content->vlan = $vlan;
$view->content->grid = $grid;
$view->content->headline = __('Vlan detail') . ' - ' . $vlan->name;
$view->render(TRUE);
}
/**
* Add VLAN
*/
public -->
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="unknown" section="Devices_Controller" value="devices" action="view" own="false"></axo>
<axo usage_type="unknown" section="Devices_Controller" value="devices" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Devices_Controller" value="devices" action="delete" own="false"></axo>
<axo usage_type="access" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="grid-action" section="Devices_Controller" value="devices" action="view" own="false"></axo>
<axo usage_type="grid-action" section="Devices_Controller" value="devices" action="edit" own="false"></axo>
<axo usage_type="grid-action" section="Devices_Controller" value="devices" action="delete" own="false"></axo>
</method>
<method name="add">
<!-- add()
{
if (!$this->acl_check_new('Vlans_Controller', 'vlan'))
Controller::error(ACCESS);
$vlan = new Vlan_Model();
$form = new Forge();
$form->group('Basic data');
$form->input('name')
->rules('required|length[3,250]');
$form->input('tag_802_1q')
->rules('required|valid_digit')
->class('increase_decrease_buttons')
->callback(array($this, 'valid_tag_802_1q'));
$form->textarea('comment')
->rules('length[0,254]')
->cols('20')
->rows('5');
$form->submit('Save');
// validate form and save data
if ($form->validate())
{
$form_data = $form->as_array();
$vlan = new Vlan_Model();
try
{
$vlan->transaction_start();
$vlan->name = $form_data['name'];
$vlan->tag_802_1q = $form_data['tag_802_1q'];
$vlan->comment = $form_data['comment'];
$vlan->save_throwable();
$vlan->transaction_commit();
status::success('Vlan has been successfully saved.');
$this->redirect('show', $vlan->id);
}
catch (Exception $e)
{
$vlan->transaction_rollback();
Log::add_exception($e);
status::error('Error - Cannot add new VLAN.', $e);
$this->redirect('show_all');
}
}
else
{
// end validate-
$breadcrumbs = breadcrumbs::add()
->link('vlans/show_all', 'VLANs',
$this->acl_check_view('Vlans_Controller', 'vlan'))
->text('Add');
$view = new View('main');
$view->title = __('Add new vlan');
$view->breadcrumbs = $breadcrumbs->html();
$view->vlan = isset($vlan) && $vlan->id ? $vlan : NULL;
$view->content = new View('form');
$view->content->form = $form->html();
$view->content->headline = __('Add new vlan');
$view->render(TRUE);
}
}
/**
* Edits VLAN
*
* @param integer $vlan_id
*/
public -->
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="new" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="access" section="Vlans_Controller" value="vlan" action="new" own="false"></axo>
<axo usage_type="breadcrumbs" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
</method>
<method name="edit">
<!-- edit($vlan_id = null)
{
if (!$vlan_id)
{
Controller::warning(PARAMETER);
}
$vlan = new Vlan_Model($vlan_id);
if (!$vlan->id)
{
Controller::warning(RECORD);
}
if (!$this->acl_check_edit('Vlans_Controller', 'vlan'))
{
Controller::error(1);
}
$this->_vlan_id = $vlan_id;
$form = new Forge();
$form->group('Basic data');
$form->input('name')
->rules('required|length[3,250]')
->value($vlan->name);
$form->input('tag_802_1q')
->rules('valid_digit')
->value($vlan->tag_802_1q)
->class('increase_decrease_buttons')
->callback(array($this, 'valid_tag_802_1q'));
$form->textarea('comment')
->rules('length[0,254]')
->value($vlan->comment)
->cols('20')
->rows('5');
$form->submit('Update');
// validate form and save data
if ($form->validate())
{
$form_data = $form->as_array();
$vlan = new vlan_Model($vlan_id);
try
{
$vlan->transaction_start();
$vlan->name = $form_data['name'];
$vlan->tag_802_1q = $form_data['tag_802_1q'];
$vlan->comment = $form_data['comment'];
$vlan->save_throwable();
$vlan->transaction_commit();
status::success('Vlan has been successfully updated.');
$this->redirect('show', $vlan->id);
}
catch(Exception $e)
{
$vlan->transaction_rollback();
status::error('Error - Cannot update VLAN.', $e);
$this->redirect('show_all');
}
}
// end validate
else
{
$breadcrumbs = breadcrumbs::add()
->link('vlans/show_all', 'VLANs',
$this->acl_check_view('Vlans_Controller', 'vlan'))
->disable_translation()
->link('vlans/show/' . $vlan->id, $vlan->name,
$this->acl_check_view('Vlans_Controller', 'vlan'))
->enable_translation()
->text('Edit');
$view = new View('main');
$view->title = __('Edit vlan') . ' - ' . $vlan->name;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->form = $form->html();
$view->content->headline = __('Edit vlan') . ' - ' . $vlan->name;
$view->render(TRUE);
}
}
/**
* Deletes VLAN
*
* @author Michal Kliment
* @param integer $vlan_id
*/
public -->
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="access" section="Vlans_Controller" value="vlan" action="edit" own="false"></axo>
<axo usage_type="breadcrumbs" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
<axo usage_type="breadcrumbs" section="Vlans_Controller" value="vlan" action="view" own="false"></axo>
</method>
<method name="delete">
<!-- delete($vlan_id = NULL)
{
// bad parameter
if (!$vlan_id || !is_numeric($vlan_id))
Controller::warning(PARAMETER);
$vlan = new Vlan_Model($vlan_id);
// record doesn't exist
if (!$vlan->id)
Controller::error(RECORD);
// access control
if (!$this->acl_check_delete('Vlans_Controller', 'vlan'))
Controller::error(ACCESS);
if ($vlan->delete())
status::success ('Vlan has been successfully deleted.');
else
status::error ('Vlan hasn\'t been deleted');
url::redirect('vlans/show_all');
}
/**
* Function removes vlan from port
*
* @param integer $bridge_iface_id
* @param integer $iface_id
*/
public -->
<axo usage_type="unknown" section="Vlans_Controller" value="vlan" action="delete" own="false"></axo>
<axo usage_type="access" section="Vlans_Controller" value="vlan" action="delete" own="false"></axo>
</method>
<method name="remove_from_port"></method>
</object>
<object name="voip" type="controller">
<object name="voip" type="controller"
comment-en="VoIP - enable to management VoIP manager"
comment-cs="VoIP - umožňuje spravovat VoIP ústřednu">
<method name="__construct"></method>
<method name="index"></method>
<method name="show_all">
<!-- show_all(
$limit_results = 100, $order_by = 'user_id', $order_by_direction = 'asc',
$page_word = null, $page = 1)
{
if (!$this->acl_check_view('VoIP_Controller', 'voip'))
Controller::error(ACCESS);
// get new selector
if (is_numeric($this->input->post('record_per_page')))
$limit_results = (int) $this->input->post('record_per_page');
// parameters control
$allowed_order_type = array('id', 'name', 'user_id');
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'user_id';
if (strtolower($order_by_direction) != 'desc')
$order_by_direction = 'asc';
$model_voip_sip = new Voip_sip_Model();
$total_voip_sip = $model_voip_sip->count_all_records();
if (($sql_offset = ($page - 1) * $limit_results) > $total_voip_sip)
$sql_offset = 0;
$all_voip_sip = $model_voip_sip->get_all_records(
$sql_offset, (int) $limit_results, $order_by, $order_by_direction
);
$headline = __('VoIP');
$grid = new Grid('voip', $headline, array
(
'use_paginator' => true,
'use_selector' => true,
'current' => $limit_results,
'selector_increace' => 100,
'selector_min' => 100,
'selector_max_multiplier' => 10,
'base_url' => Config::get('lang') . '/voip/show_all/'
. $limit_results . '/' . $order_by . '/'
. $order_by_direction,
'uri_segment' => 'page',
'total_items' => $total_voip_sip,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results
));
$grid->add_new_button('voip_calls/show_all', __('List of all calls'));
$grid->callback_field('locked')
->label('State')
->order(false)
->callback(array($this, 'locked'))
->class('center');
$grid->order_link_field('user_id')
->link('voip/show', 'name')
->label('Number');
$grid->order_link_field('user_id')
->link('users/show', 'ufname')
->label('User');
$grid->order_link_field('member_id')
->link('users/show', 'mname')
->label('User');
$grid->callback_field('regseconds')
->label('')
->order(false)
->callback(array($this, 'regseconds'))
->class('center');
$grid->datasource($all_voip_sip);
$view = new View('main');
$view->title = $headline;
$view->breadcrumbs = $headline;
$view->content = $grid;
$view->render(TRUE);
}
/**
* Show VOIP
*
* @param integer $user_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="access" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
</method>
<method name="show">
<!-- show($user_id = NULL)
{
if (!$user_id)
Controller::warning(PARAMETER);
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
if (!$this->acl_check_view('VoIP_Controller', 'voip', $user->member_id))
Controller::error(ACCESS);
$voip_sip = new Voip_sip_Model();
//check existence of number
$voip = $voip_sip->get_record_by_user_limited($user_id);
if ($voip->count() == 0)
Controller::error(RECORD);
$voip = $voip_sip->get_record_by_user($user_id);
if ($voip->count() == 0)
Controller::error(RECORD);
$sip_server = Settings::get('voip_sip_server', FALSE);
$voip = $voip_sip->get_record_by_user($user_id);
$voip = $voip->current();
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->where('customer_id', $voip->mailbox)->find();
$link_status = (($voip->regseconds - time()) > 1);
$billing = Billing::instance();
$has_driver = $billing->has_driver();
$b_account = $billing->get_account($user->member_id);
$void_account_enabled = $has_driver && ($b_account != null);
$links[] = html::anchor(
'voip/edit_voicemail/' . $voip->user_id, __('Edit voicemail')
);
if ($void_account_enabled)
{
$links[] = html::anchor(
'voip_calls/show_by_user/' . $user_id, __('List of calls')
);
}
$regseconds = ($voip->regseconds - time() < 0 ) ? '0' : $voip->regseconds - time();
$links = implode(' | ', $links);
$breadcrumbs = breadcrumbs::add()
->link('voip/show_all', 'VoIP')
->disable_translation()
->text($voip->name);
// prices of calls
$fixed_price = null;
$cellphone_price = null;
$voip_price = null;
if ($void_account_enabled)
{
if (Settings::get('voip_tariff_fixed'))
{
$fixed_price = $billing->get_price_of_minute_call(
$voip->name, Settings::get('voip_tariff_fixed')
);
}
if (Settings::get('voip_tariff_cellphone'))
{
$cellphone_price = $billing->get_price_of_minute_call(
$voip->name, Settings::get('voip_tariff_cellphone')
);
}
if (Settings::get('voip_tariff_voip'))
{
$voip_price = $billing->get_price_of_minute_call(
$voip->name, Settings::get('voip_tariff_voip')
);
}
}
$view = new View('main');
$view->title = __('Show VoIP account');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('voip/show');
$view->content->headline = __('Show VoIP');
$view->content->links = $links;
$view->content->voip = $voip;
$view->content->sip_server = $sip_server;
$view->content->link_status = $link_status;
$view->content->ipaddr = $voip->ipaddr;
$view->content->port = $voip->port;
$view->content->regseconds = $regseconds;
$view->content->voice_email = $voicemail->email;
$view->content->voice_status = $voicemail->active;
$view->content->fixed_price = $fixed_price;
$view->content->cellphone_price = $cellphone_price;
$view->content->voip_price = $voip_price;
$view->content->void_account_enabled = $void_account_enabled;
$view->render(true);
}
/**
* Changes password
*
* @param integer $user_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="access" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
</method>
<method name="change_password">
<!-- change_password($user_id = NULL)
{
if (!$user_id)
Controller::warning(PARAMETER);
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
if (!$this->acl_check_edit('VoIP_Controller', 'voip_password', $user->member_id))
Controller::error(ACCESS);
$voip = ORM::factory('voip_sip')->where('user_id', $user_id)->find();
if ($voip->id == null)
Controller::error(RECORD);
$form = new Forge('voip/change_password/' . $user_id);
$form->password('password')
->label(__('New password') . ':')
->rules('required|length[6,20]');
$form->password('confirm_password')
->label(__('Confirm new password') . ':')
->rules('required|length[6,20]')
->matches($form->password);
$form->submit('Change');
if ($form->validate())
{
$form_data = $form->as_array(FALSE);
$voip_sip = new Voip_sip_Model();
$voip = $voip_sip->where('user_id', $user_id)->find();
$user = ORM::factory('user')->where('id', $user_id)->find();
$username = text::cs_utf2ascii($user->name . ' ' . $user->surname);
$voip->callerid = $username . ' <' . $voip->name . '>';
$voip->secret = $form_data['password'];
if ($voip->save())
{
status::success('Password has been successfully changed.');
}
else
{
status::error('Error - cant change password.');
}
url::redirect('voip/change_password/' . $user_id);
}
else
{
$breadcrumbs = breadcrumbs::add()
->link('voip/show_all', 'VoIP',
$this->acl_check_view('VoIP_Controller', 'voip'))
->disable_translation()
->link('voip/show/' . $voip->user_id, $voip->name,
$this->acl_check_view(
'VoIP_Controller', 'voip', $user->member_id
)
)->enable_translation()
->text('Change password');
$view = new View('main');
$view->title = __('Change password');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Password for VoIP account');
$view->content->form = $form->html();
$view->render(TRUE);
}
}
/**
* Chenges voice mail password
*
* @param integer $user_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="access" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
</method>
<method name="change_voicemail_password">
<!-- change_voicemail_password($user_id = NULL)
{
if (!isset($user_id))
Controller::warning(PARAMETER);
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
if (!$this->acl_check_edit('VoIP_Controller', 'voip_password', $user->member_id))
Controller::error(ACCESS);
$voip = ORM::factory('voip_sip')->where('user_id', $user_id)->find();
if (!$voip->id)
Controller::error(RECORD);
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->where('customer_id', $voip->mailbox)->find();
$form = new Forge('voip/change_voicemail_password/' . $user_id);
$form->password('password')
->label(__('New password') . ':')
->rules('required|length[4,4]|valid_digit');
$form->password('confirm_password')
->label(__('Confirm new password') . ':')
->rules('required|length[4,4]|valid_digit')
->matches($form->password);
$form->submit('submit')->value(__('Change'));
if ($form->validate())
{
$form_data = $form->as_array(FALSE);
$voip_sip = new Voip_sip_Model();
$voip = $voip_sip->where('user_id', $user_id)->find();
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->where('customer_id', $voip->mailbox)->find();
$voicemail->password = $form_data['password'];
if ($voicemail->save())
{
status::success('Password has been successfully changed.');
}
else
{
status::error('Error - cant change password.');
}
url::redirect('voip/change_voicemail_password/' . $user_id);
}
else
{
$breadcrumbs = breadcrumbs::add()
->link('voip/show_all', 'VoIP',
$this->acl_check_view('VoIP_Controller', 'voip'))
->disable_translation()
->link('voip/show/' . $voip->user_id, $voip->name,
$this->acl_check_view(
'VoIP_Controller', 'voip', $user->member_id
)
)->enable_translation()
->text('Change voicemail password');
$view = new View('main');
$view->title = __('Change voicemail password');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Voicemail password for VoIP account');
$view->content->form = $form->html();
$view->render(TRUE);
}
}
/**
* Edits voice mail
*
* @param integer $user_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="access" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
</method>
<method name="edit_voicemail">
<!-- edit_voicemail($user_id = NULL)
{
if (!isset($user_id))
Controller::warning(PARAMETER);
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
if (!$this->acl_check_edit('VoIP_Controller', 'voip_password', $user->member_id))
Controller::error(ACCESS);
$voip = ORM::factory('voip_sip')->where('user_id', $user_id)->find();
if ($voip->id == null)
Controller::error(RECORD);
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->where('customer_id', $voip->mailbox)->find();
$form = new Forge('voip/edit_voicemail/' . $user_id);
$form->dropdown('status')
->label(__('State'))
->options(array
(
'0' => __('Inactive'),
'1' => __('Active')
))->selected($voicemail->active);
$form->input('email')
->label(__('email') . ':')
->rules('length[6,50]|valid_email')
->value($voicemail->email);
$form->submit('Edit');
if ($form->validate())
{
$form_data = $form->as_array();
$voip_sip = new Voip_sip_Model();
$voip = $voip_sip->where('user_id', $user_id)->find();
$voicemail_model = new Voip_voicemail_user_Model();
$voicemail = $voicemail_model->where('customer_id', $voip->mailbox)->find();
$voicemail->email = $form_data['email'];
$voicemail->active = $form_data['status'];
if ($voicemail->save())
{
status::success('Voicemail has been successfully changed.');
}
else
{
status::error('Error - cant change voicemail.');
}
url::redirect('voip/edit_voicemail/' . $user_id);
}
else
{
$breadcrumbs = breadcrumbs::add()
->link('voip/show_all', 'VoIP',
$this->acl_check_view('VoIP_Controller', 'voip'))
->disable_translation()
->link('voip/show/' . $voip->user_id, $voip->name,
$this->acl_check_view(
'VoIP_Controller', 'voip', $user->member_id
)
)->enable_translation()
->text('Edit voicemail');
$view = new View('main');
$view->title = __('Edit voicemail');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = __('Voicemail for VoIP account');
$view->content->form = $form->html();
$view->render(TRUE);
}
}
/**
* Changes member limit
*
* @param integer $member_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="access" section="VoIP_Controller" value="voip_password" action="edit" own="true"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="false"></axo>
<axo usage_type="breadcrumbs" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
</method>
<method name="change_member_limit">
<!-- change_member_limit($member_id = NULL)
{
if (!isset($member_id))
Controller::warning(PARAMETER);
if (!is_numeric($member_id))
Controller::error(RECORD);
if (!$this->acl_check_edit('VoIP_Controller', 'voip_password', $member_id))
Controller::error(ACCESS);
$member = new Member_Model($member_id);
if (!$member->id)
Controller::error(RECORD);
$billing = Billing::instance();
$has_driver = $billing->has_driver();
$b_account = $billing->get_account($member_id);
if (!$has_driver || ($b_account == null))
Controller::error(RECORD);
$form = new Forge('voip/change_member_limit/' . $member_id);
$form->input('limit')
->rules('length[1,6]|valid_digit')
->value($member->voip_billing_limit)
->callback(array($this, 'valid_limit'));
$form->submit('Change');
if ($form->validate())
{
$form_data = $form->as_array();
$member->voip_billing_limit = $form_data['limit'];
if ($member->save())
{
status::success('Limit has been successfully changed.');
}
else
{
status::error('Error - cant change limit.');
}
url::redirect('voip/change_member_limit/' . $member_id);
}
else
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller', 'members'))
->disable_translation()
->link('members/show/'.$member->id,
"ID $member->id - $member->name",
$this->acl_check_view(
'Members_Controller', 'members', $member->id
)
)
->enable_translation()
->text('Change member limit');
$view = new View('main');
$view->title = __('Change member limit');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content->headline = 'VoIP' . __('Limit of member');
$view->content->form = $form->html();
$view->render(TRUE);
}
}
/**
* Adds VoIP for user
*
* @param integer $user_id
*/
public -->
<axo usage_type="unknown" section="VoIP_Controller" value="voip_password" action="edit" 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="access" section="VoIP_Controller" value="voip_password" action="edit" 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>
</method>
<method name="add">
<!-- add($user_id = NULL)
{
if (!isset($user_id))
Controller::warning(PARAMETER);
$user = new User_Model($user_id);
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff