Revize 2155
Přidáno uživatelem David Raška před asi 11 roky(ů)
freenetis/branches/1.1/application/vendors/axo_doc/axo_doc.xml | ||
---|---|---|
</object>
|
||
<object name="settings" type="controller" comment-en="Settings" comment-cs="Nastavení">
|
||
<method name="__construct">
|
||
<!-- __construct()
|
||
{
|
||
parent::__construct();
|
||
|
||
$this->sections = array();
|
||
|
||
if ($this->acl_check_view('Settings_Controller', 'info'))
|
||
$this->sections['info'] = __('Info');
|
||
|
||
if ($this->acl_check_edit('Settings_Controller', 'system_settings'))
|
||
$this->sections['system'] = __('System');
|
||
|
||
if ($this->acl_check_edit('Settings_Controller', 'users_settings'))
|
||
$this->sections['users'] = __('Users');
|
||
|
||
// are finance enabled
|
||
if (self::isModuleEnabled('finance') &&
|
||
$this->acl_check_edit('Settings_Controller', 'finance_settings'))
|
||
$this->sections['finance'] = __('Finance');
|
||
|
||
// is approval enabled
|
||
if (self::isModuleEnabled('approval') &&
|
||
$this->acl_check_edit('Settings_Controller', 'approval_settings'))
|
||
$this->sections['approval'] = __('Approval');
|
||
|
||
// are networks enabled
|
||
if (self::isModuleEnabled('networks') &&
|
||
$this->acl_check_edit('Settings_Controller', 'networks_settings'))
|
||
$this->sections['networks'] = __('Networks');
|
||
|
||
if (self::isModuleEnabled('email') &&
|
||
$this->acl_check_edit('Settings_Controller', 'email_settings'))
|
||
$this->sections['email'] = __('Email');
|
||
|
||
// are SMS enabled
|
||
if (self::isModuleEnabled('sms') &&
|
||
$this->acl_check_edit('Settings_Controller', 'sms_settings'))
|
||
$this->sections['sms'] = __('SMS');
|
||
|
||
// is voip enabled
|
||
if (self::isModuleEnabled('voip') &&
|
||
$this->acl_check_edit('Settings_Controller', 'voip_settings'))
|
||
$this->sections['voip'] = __('VoIP');
|
||
|
||
// is notification enabled
|
||
if (self::isModuleEnabled('notification') &&
|
||
$this->acl_check_edit('Settings_Controller', 'notification_settings'))
|
||
$this->sections['notifications'] = __('Notifications');
|
||
|
||
// is QoS enabled
|
||
if (self::isModuleEnabled('qos') &&
|
||
$this->acl_check_edit('Settings_Controller', 'qos_settings'))
|
||
$this->sections['qos'] = __('QoS');
|
||
|
||
// is monitoring enabled
|
||
if (self::isModuleEnabled('monitoring') &&
|
||
$this->acl_check_edit('Settings_Controller', 'monitoring_settings'))
|
||
$this->sections['monitoring'] = __('Monitoring');
|
||
|
||
// is vtiger integration enabled
|
||
if (self::isModuleEnabled('vtiger') &&
|
||
$this->acl_check_edit('Settings_Controller', 'vtiger_settings'))
|
||
$this->sections['vtiger'] = __('Vtiger');
|
||
|
||
if ($this->acl_check_edit('Settings_Controller', 'logging_settings'))
|
||
$this->sections['logging'] = __('Logging');
|
||
|
||
if (count($this->sections) <= 1)
|
||
$this->sections = NULL;
|
||
}
|
||
|
||
/**
|
||
* Redirects to info
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="sms_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="notification_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="monitoring_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="vtiger_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="logging_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="sms_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="notification_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="monitoring_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="vtiger_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="logging_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="index">
|
||
<!-- index()
|
||
{
|
||
if ($this->acl_check_view('Settings_Controller', 'info'))
|
||
$this->info();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'system_settings'))
|
||
$this->system();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'users_settings'))
|
||
$this->users();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'finance_settings'))
|
||
$this->finance();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'approval_settings'))
|
||
$this->approval();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'networks_settings'))
|
||
$this->networks();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'email_settings'))
|
||
$this->email();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'sms_settings'))
|
||
$this->sms();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'voip_settings'))
|
||
$this->voip();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'notification_settings'))
|
||
$this->notifications();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'qos_settings'))
|
||
$this->qos();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'monitoring_settings'))
|
||
$this->monitoring();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'vtiger_settings'))
|
||
$this->vtiger();
|
||
else if ($this->acl_check_edit('Settings_Controller', 'logging_settings'))
|
||
$this->logging();
|
||
else
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
/**
|
||
* info() displays various system information
|
||
*
|
||
* @author Tomas Dulik
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="sms_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="notification_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="monitoring_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="vtiger_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="unknown" section="Settings_Controller" value="logging_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="sms_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="notification_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="monitoring_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="vtiger_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access-partial" section="Settings_Controller" value="logging_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="info">
|
||
<!-- info()
|
||
{
|
||
if (!$this->acl_check_view('Settings_Controller', 'info'))
|
||
Controller::error(ACCESS);
|
||
|
||
$data = array();
|
||
|
||
if (defined('FREENETIS_VERSION'))
|
||
{
|
||
$data['FreenetIS ' . __('version')] = FREENETIS_VERSION;
|
||
}
|
||
|
||
$data[__('DB schema revision')] = Settings::get('db_schema_version');
|
||
$data[__('CRON state')] = module::get_state('cron');
|
||
|
||
// redirection is enabled
|
||
if (Settings::get('redirection_enabled'))
|
||
$data[__('Redirection state')] = module::get_state('redirection');
|
||
|
||
if (Settings::get('qos_enabled'))
|
||
$data[__('QoS state')] = module::get_state('qos');
|
||
|
||
if (Settings::get('monitoring_enabled'))
|
||
$data[__('Monitoring state')] = module::get_state('monitoring');
|
||
|
||
if (Settings::get('logging_enabled'))
|
||
$data[__('Logging state')] = module::get_state('logging');
|
||
|
||
if (Settings::get('allowed_subnets_enabled'))
|
||
$data[__('Allowed subnet state')] = module::get_state('allowed_subnets_update');
|
||
|
||
ob_start();
|
||
|
||
$html = '';
|
||
|
||
if (function_exists('phpinfo'))
|
||
{
|
||
phpinfo();
|
||
$html = ob_get_contents();
|
||
ob_end_clean();
|
||
// Delete styles from output (credits: Moodle.org)
|
||
$html = preg_replace('#(\n?<style[^>]*?>.*?</style[^>]*?>)|(\n?<style[^>]*?/>)#is', '', $html);
|
||
$html = preg_replace('#(\n?<head[^>]*?>.*?</head[^>]*?>)|(\n?<head[^>]*?/>)#is', '', $html);
|
||
// Delete DOCTYPE from output
|
||
$html = preg_replace('/<!DOCTYPE html PUBLIC.*?>/is', '', $html);
|
||
// Delete body and html tags
|
||
$html = preg_replace('/<html.*?>.*?<body.*?>/is', '', $html);
|
||
$html = preg_replace('/<\/body><\/html>/is', '', $html);
|
||
$html = preg_replace('/table border="0"/is', 'table class="extended"', $html);
|
||
$html = preg_replace('/width="600"/is', 'width="720" style="table-layout:fixed; overflow: hidden"', $html);
|
||
}
|
||
|
||
$table = new View('table_2_columns');
|
||
$table->table_data = $data;
|
||
|
||
$view = new View('main');
|
||
$view->title = __('System') . ' - ' . __('Info');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'info';
|
||
$view->content->headline = __('Info');
|
||
$view->content->content = $table . $html;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Form to set up system variables
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="info" action="view" own="false"></axo>
|
||
</method>
|
||
<method name="system">
|
||
<!-- system()
|
||
{
|
||
// access control
|
||
if (!$this->acl_check_edit('Settings_Controller', 'system_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/system');
|
||
|
||
$this->form->set_attr('id', 'settings-system-form');
|
||
|
||
$this->form->group('System variables');
|
||
|
||
// page title
|
||
$this->form->input('title')
|
||
->label('Page title')
|
||
->rules('length[3,40]|required')
|
||
->value(Settings::get('title'));
|
||
|
||
$countries = ORM::factory('country')->select_list('id', 'country_name');
|
||
|
||
$this->form->dropdown('default_country')
|
||
->label('Country')
|
||
->rules('required')
|
||
->options($countries)
|
||
->selected(Settings::get('default_country'))
|
||
->style('width:200px');
|
||
|
||
$this->form->radio('grid_hide_on_first_load')
|
||
->label('Hide grid on its first load')
|
||
->options(arr::bool())
|
||
->default(Settings::get('grid_hide_on_first_load'))
|
||
->help('grid_hide_on_first_load');
|
||
|
||
$form_modules = array();
|
||
|
||
$this->form->group(__('Modules').' '.help::hint('modules'));
|
||
|
||
// self-registration
|
||
$form_modules['self_registration'] = $this->form->radio('self_registration')
|
||
->label('Self-registration')
|
||
->options(arr::bool())
|
||
->default(Settings::get('self_registration'));
|
||
|
||
// connection requests
|
||
$form_modules['connection_request'] = $this->form->radio('connection_request_enable')
|
||
->label('Connection requests')
|
||
->options(arr::bool())
|
||
->default(Settings::get('connection_request_enable'));
|
||
|
||
// forgotten password
|
||
$form_modules['forgotten_password'] = $this->form->radio('forgotten_password')
|
||
->label('Forgotten password')
|
||
->options(arr::bool())
|
||
->default(Settings::get('forgotten_password'));
|
||
|
||
// membership interrupts
|
||
$form_modules['membership_interrupt'] = $this->form->radio('membership_interrupt_enabled')
|
||
->label('Membership interrupt')
|
||
->options(arr::bool())
|
||
->default(Settings::get('membership_interrupt_enabled'));
|
||
|
||
// finance
|
||
$form_modules['finance'] = $this->form->radio('finance_enabled')
|
||
->label('Finance')
|
||
->options(arr::bool())
|
||
->default(Settings::get('finance_enabled'));
|
||
|
||
// approval
|
||
$form_modules['approval'] = $this->form->radio('approval_enabled')
|
||
->label('Approval')
|
||
->options(arr::bool())
|
||
->default(Settings::get('approval_enabled'));
|
||
|
||
// Works
|
||
$form_modules['works'] = $this->form->radio('works_enabled')
|
||
->label('Works')
|
||
->options(arr::bool())
|
||
->default(Settings::get('works_enabled'));
|
||
|
||
// Phone invoice
|
||
$form_modules['phone_invoices'] = $this->form->radio('phone_invoices_enabled')
|
||
->label('Phone invoices')
|
||
->options(arr::bool())
|
||
->default(Settings::get('phone_invoices_enabled'));
|
||
|
||
// e-mail
|
||
$form_modules['email'] = $this->form->radio('email_enabled')
|
||
->label('E-mail')
|
||
->options(arr::bool())
|
||
->default(Settings::get('email_enabled'));
|
||
|
||
// SMS
|
||
$form_modules['sms'] = $this->form->radio('sms_enabled')
|
||
->label('SMS')
|
||
->options(arr::bool())
|
||
->default(Settings::get('sms_enabled'));
|
||
|
||
// VoIP
|
||
$form_modules['voip'] = $this->form->radio('voip_enabled')
|
||
->label('VoIP')
|
||
->options(arr::bool())
|
||
->default(Settings::get('voip_enabled'));
|
||
|
||
// Network
|
||
$form_modules['networks'] = $this->form->radio('networks_enabled')
|
||
->label('Networks')
|
||
->options(arr::bool())
|
||
->default(Settings::get('networks_enabled'));
|
||
|
||
// SNMP
|
||
$form_modules['snmp'] = $this->form->radio('snmp_enabled')
|
||
->label('SNMP')
|
||
->options(arr::bool())
|
||
->default(Settings::get('snmp_enabled'));
|
||
|
||
// QoS
|
||
$form_modules['qos'] = $this->form->radio('qos_enabled')
|
||
->label('QoS')
|
||
->options(arr::bool())
|
||
->default(Settings::get('qos_enabled'));
|
||
|
||
// Monitoring
|
||
$form_modules['monitoring'] = $this->form->radio('monitoring_enabled')
|
||
->label('Monitoring')
|
||
->options(arr::bool())
|
||
->default(Settings::get('monitoring_enabled'));
|
||
|
||
// Redirection
|
||
$form_modules['redirection'] = $this->form->radio('redirection_enabled')
|
||
->label('Redirection')
|
||
->options(arr::bool())
|
||
->default(Settings::get('redirection_enabled'));
|
||
|
||
// Notification
|
||
$form_modules['notification'] = $this->form->radio('notification_enabled')
|
||
->label('Notifications')
|
||
->options(arr::bool())
|
||
->default(Settings::get('notification_enabled'));
|
||
|
||
// vtiger CRM integration
|
||
$form_modules['vtiger'] = $this->form->radio('vtiger_integration')
|
||
->label('Vtiger integration')
|
||
->options(arr::bool())
|
||
->default(Settings::get('vtiger_integration'));
|
||
|
||
// add info about modules dependencies
|
||
foreach ($form_modules as $module => $item)
|
||
{
|
||
// module have at least one dependency
|
||
if (count(self::$modules[$module]['dependencies']))
|
||
{
|
||
$form_modules[$module]->additional_info(
|
||
__('Require module') . ': <b>' .
|
||
implode(', ', array_map(
|
||
'__', self::$modules[$module]['dependencies'])
|
||
) . '</b>'
|
||
);
|
||
}
|
||
}
|
||
|
||
$this->form->group('Module settings');
|
||
|
||
$timeout = Settings::get('module_status_timeout');
|
||
|
||
$this->form->input('module_status_timeout')
|
||
->rules('required|valid_numeric')
|
||
->class('increase_decrease_buttons')
|
||
->value($timeout)
|
||
->style('width:30px')
|
||
->help('Time threshold in minutes, before module is shown as inactive');
|
||
|
||
$this->form->group(__('URL settings') . ' ' . help::hint('url_settings'));
|
||
|
||
$this->form->dropdown('protocol')
|
||
->rules('required|length[3,100]')
|
||
->options(array
|
||
(
|
||
'http' => 'http',
|
||
'https' => 'https'
|
||
))->selected(url::protocol());
|
||
|
||
$this->form->input('domain')
|
||
->rules('required|length[3,100]')
|
||
->value(url::domain());
|
||
|
||
$this->form->input('suffix')
|
||
->rules('required|valid_suffix')
|
||
->value(url::suffix());
|
||
|
||
// load .htaccess sample file
|
||
if (($htaccessFile = @file('.htaccess-sample')) != FALSE)
|
||
{
|
||
foreach ($htaccessFile as $line_num => $line)
|
||
{
|
||
// find line with RewriteBase
|
||
if (preg_match("/^RewriteBase (.+)/", $line, $matches))
|
||
{
|
||
// and set there our suffix (subdirectory)
|
||
$htaccessFile[$line_num] = preg_replace(
|
||
"/^(RewriteBase )(.+)/",
|
||
'${1}' . url::suffix(), $line
|
||
);
|
||
}
|
||
}
|
||
|
||
// write textarea with content of .htaccess sample file
|
||
if (!is_writable('.') && !file_exists('.htaccess'))
|
||
{
|
||
$textarea = '';
|
||
|
||
foreach ($htaccessFile as $line)
|
||
{
|
||
$textarea .= htmlentities($line);
|
||
}
|
||
|
||
$help = __('It\'s not possible to write your htacess file for clean URLS.');
|
||
$help .= ' ' . __('You must create it manually and paste the following text into it.');
|
||
|
||
$this->form->textarea('htaccess')
|
||
->label('Content of file htaccess')
|
||
->value($textarea)
|
||
->help($help);
|
||
}
|
||
}
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array();
|
||
|
||
$issaved = true;
|
||
$message = '';
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
if ($name == 'module_status_timeout')
|
||
{
|
||
$value = max($value, 1);
|
||
}
|
||
else if ($name == 'security_password_length')
|
||
{
|
||
$value = min(50, max(1, $value)); // <1..50>
|
||
}
|
||
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
foreach (self::$modules as $module => $module_info)
|
||
{
|
||
foreach ($module_info['dependencies'] as $dependency)
|
||
{
|
||
if (self::isModuleEnabled($module) && !self::isModuleEnabled($dependency))
|
||
{
|
||
status::error(__('Cannot enable module %s, enabled module %s is required.', array($module, $dependency)));
|
||
self::disableModule($module);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
{
|
||
status::success(
|
||
__('System variables have been successfully updated.').
|
||
'<br />' . $message, FALSE
|
||
);
|
||
}
|
||
else
|
||
// if not
|
||
{
|
||
status::error(
|
||
__('System variables havent been successfully updated.').
|
||
'<br />' . $message, NULL, FALSE
|
||
);
|
||
}
|
||
|
||
url::redirect('settings/system');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('System');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'system';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('System');
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Settings of users variables
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="system_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="users">
|
||
<!-- users()
|
||
{
|
||
// access control
|
||
if (!$this->acl_check_edit('Settings_Controller', 'users_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge();
|
||
|
||
$this->form->group('Security');
|
||
|
||
$this->form->input('security_password_length')
|
||
->label('Minimal password length')
|
||
->rules('required|valid_numeric')
|
||
->class('increase_decrease_buttons')
|
||
->style('width:30px')
|
||
->value(Settings::get('security_password_length'));
|
||
|
||
$pass_levels = array
|
||
(
|
||
1 => __('very weak'),
|
||
2 => __('weak'),
|
||
3 => __('good'),
|
||
4 => __('strong'),
|
||
);
|
||
|
||
$this->form->dropdown('security_password_level')
|
||
->options($pass_levels)
|
||
->label('Minimal password level')
|
||
->rules('required')
|
||
->selected(Settings::get('security_password_level'));
|
||
|
||
|
||
if (Settings::get('membership_interrupt_enabled'))
|
||
{
|
||
$this->form->group('Membership interrupt');
|
||
|
||
$this->form->input('membership_interrupt_minimum')
|
||
->label('Minimum membership interrupt period (months)')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('membership_interrupt_minimum'));
|
||
|
||
$this->form->input('membership_interrupt_maximum')
|
||
->label('Maximum membership interrupt period (months)')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('membership_interrupt_maximum'));
|
||
}
|
||
|
||
if (Settings::get('self_registration'))
|
||
{
|
||
$this->form->group('Applicant for membership');
|
||
|
||
$this->form->checkbox('self_registration_enable_approval_without_registration')
|
||
->label('Enable approval of membership without submited registration')
|
||
->checked(Settings::get('self_registration_enable_approval_without_registration'));
|
||
|
||
if (Settings::get('finance_enabled'))
|
||
{
|
||
$this->form->checkbox('self_registration_enable_additional_payment')
|
||
->label('Enable additional member fee during the approval of membership')
|
||
->checked(Settings::get('self_registration_enable_additional_payment'));
|
||
}
|
||
}
|
||
|
||
$this->form->group('Export of registration');
|
||
|
||
if (Settings::get('finance_enabled'))
|
||
{
|
||
$bank_account = new Bank_account_Model();
|
||
$concat = "CONCAT(account_nr, '/', bank_nr, IF(name IS NULL, '', CONCAT(' - ', name)))";
|
||
|
||
$this->form->dropdown('export_header_bank_account')
|
||
->label('Bank account')
|
||
->options($bank_account->where('member_id', Member_Model::ASSOCIATION)->select_list('id', $concat))
|
||
->selected(Settings::get('export_header_bank_account'))
|
||
->rules('required');
|
||
}
|
||
|
||
// directory is writable
|
||
if (is_writable('upload'))
|
||
{
|
||
$additional_info = '';
|
||
$logo = Settings::get('registration_logo');
|
||
|
||
if (file_exists($logo))
|
||
{
|
||
$additional_info = '<img src="'. url_lang::base().'export/logo" style="margin-left:10%;height:50px;vertical-align:middle"/>';
|
||
}
|
||
|
||
$this->form->upload('registration_logo')
|
||
->label('Logo')
|
||
->rules('allow[jpg]')
|
||
->new_name('registration_logo.jpg')
|
||
->help(help::hint('registration_logo'))
|
||
->additional_info($additional_info);
|
||
}
|
||
|
||
$this->form->html_textarea('registration_info')
|
||
->label('Info')
|
||
->rows(5)
|
||
->cols(100)
|
||
->value(Settings::get('registration_info'));
|
||
|
||
$this->form->html_textarea('registration_license')
|
||
->label('License')
|
||
->rows(5)
|
||
->cols(100)
|
||
->value(Settings::get('registration_license'));
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
{
|
||
status::success('System variables have been successfully updated.');
|
||
}
|
||
else
|
||
// if not
|
||
{
|
||
status::error('System variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/users');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('Users');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'users';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('Users');
|
||
|
||
// directory is not writable
|
||
if (!is_writable('upload'))
|
||
{
|
||
$view->content->warning = __(
|
||
'Directory "upload" is not writable, change access ' .
|
||
'rights to be able upload your own logo.'
|
||
);
|
||
}
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Settings of finance variables
|
||
*
|
||
* @author Ondrej Fibich
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="users_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="finance">
|
||
<!-- finance()
|
||
{
|
||
// access control
|
||
if (!module::e('finance') ||
|
||
!$this->acl_check_edit('Settings_Controller', 'finance_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge();
|
||
|
||
$this->form->group('Finance settings');
|
||
|
||
$this->form->input('currency')
|
||
->rules('length[3,40]|required')
|
||
->value(Settings::get('currency'));
|
||
|
||
$this->form->group('Automatic actions');
|
||
|
||
$deduct_day = Settings::get('deduct_day');
|
||
|
||
$this->form->checkbox('deduct_fees_automatically_enabled')
|
||
->value('1')
|
||
->checked(Settings::get('deduct_fees_automatically_enabled'))
|
||
->label(__('Deduct fees automatically') . ' ' .
|
||
help::hint('deduct_fees_automatically_enabled', $deduct_day));
|
||
|
||
$this->form->group('Variable symbol settings');
|
||
|
||
$this->form->dropdown('variable_key_generator_id')
|
||
->options(array(NULL => '') + Variable_Key_Generator::get_drivers_for_dropdown())
|
||
->label('Algorithm for generation of variable symbols')
|
||
->selected(Variable_Key_Generator::get_active_driver())
|
||
->style('width:200px');
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
{
|
||
status::success('System variables have been successfully updated.');
|
||
}
|
||
else
|
||
// if not
|
||
{
|
||
status::error('System variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/finance');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('Finance');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'finance';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('Finance');
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Settings for QoS
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="finance_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="qos">
|
||
<!-- qos()
|
||
{
|
||
// access control
|
||
if (!module::e('qos') ||
|
||
!$this->acl_check_edit('Settings_Controller', 'qos_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/qos');
|
||
|
||
$this->form->group('Variables for QoS');
|
||
|
||
$this->form->input('qos_total_speed')
|
||
->rules('valid_speed_size')
|
||
->label(__('Total speed') . ': '.help::hint('qos_total_speed'))
|
||
->value(Settings::get('qos_total_speed'));
|
||
|
||
if (Settings::get('ulogd_enabled'))
|
||
{
|
||
$this->form->input('qos_active_speed')
|
||
->label(__('Speed for active members') . ': '.help::hint('qos_active_speed'))
|
||
->rules('valid_speed_size')
|
||
->value(Settings::get('qos_active_speed'));
|
||
}
|
||
|
||
$this->form->input('qos_high_priority_speed')
|
||
->rules('valid_speed_size')
|
||
->label(__('Speed for high priority IP addresses') . ': '.help::hint('qos_high_priority_speed'))
|
||
->value(Settings::get('qos_high_priority_speed'));
|
||
|
||
$this->form->textarea('qos_high_priority_ip_addresses')
|
||
->rules('valid_ip_address')
|
||
->label(__('High priority IP addresses'). ': '.help::hint('qos_high_priority_ip_addresses'))
|
||
->value(str_replace(",","\n",Settings::get('qos_high_priority_ip_addresses')));
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array();
|
||
|
||
// transform lines to one line
|
||
$form_data["qos_high_priority_ip_addresses"] = implode(
|
||
",",
|
||
array_map("long2ip",
|
||
arr::sort(
|
||
array_map("ip2long",
|
||
array_unique(
|
||
explode(
|
||
",",
|
||
str_replace(
|
||
"\n",
|
||
",",
|
||
$form_data["qos_high_priority_ip_addresses"]
|
||
)
|
||
)
|
||
)
|
||
)
|
||
)
|
||
)
|
||
);
|
||
|
||
$issaved = true;
|
||
|
||
if (isset($form_data['qos_enabled']) &&
|
||
$form_data['qos_enabled'] == 1)
|
||
{
|
||
$qos_enabled = '1';
|
||
}
|
||
else
|
||
{
|
||
$qos_enabled = '0';
|
||
}
|
||
|
||
$issaved = $issaved && Settings::set('qos_enabled', $qos_enabled);
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
if ($name == 'qos_enabled')
|
||
continue;
|
||
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
{
|
||
status::success('QoS variables have been successfully updated.');
|
||
}
|
||
else
|
||
// if not
|
||
{
|
||
status::error('QoS variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/qos');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('QoS');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'qos';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('QoS');
|
||
$view->content->description = module::get_state('qos', TRUE);
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Settings of email variables
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="qos_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="email">
|
||
<!-- email()
|
||
{
|
||
// access control
|
||
if (!module::e('email') ||
|
||
!$this->acl_check_edit('Settings_Controller', 'email_settings'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/email');
|
||
|
||
$this->form->group('E-mail settings');
|
||
|
||
$this->form->input('email_default_email')
|
||
->label('Default e-mail')
|
||
->rules('length[3,100]|valid_email')
|
||
->value(Settings::get('email_default_email'));
|
||
|
||
$this->form->group('E-mail variables');
|
||
|
||
$this->form->dropdown('email_driver')
|
||
->label('Driver')
|
||
->options(array
|
||
(
|
||
'native' => __('Native'),
|
||
'smtp' => __('SMTP'),
|
||
'sendmail' => __('Sendmail')
|
||
))->selected(Settings::get('email_driver'));
|
||
|
||
$this->form->input('email_hostname')
|
||
->label('Hostname')
|
||
->value(Settings::get('email_hostname'))
|
||
->help('For SMTP settings only.');
|
||
|
||
$this->form->input('email_port')
|
||
->label('Port')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('email_port'))
|
||
->help('For SMTP settings only.');
|
||
|
||
$this->form->input('email_username')
|
||
->label('User name')
|
||
->value(Settings::get('email_username'))
|
||
->help('For SMTP settings only.');
|
||
|
||
$this->form->input('email_password')
|
||
->label('Password')
|
||
->value(Settings::get('email_password'))
|
||
->help('For SMTP settings only.');
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
{
|
||
status::success('E-mail variables have been successfully updated.');
|
||
}
|
||
else
|
||
// if not
|
||
{
|
||
status::error('E-mail variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/email');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('E-mail');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'email';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('E-mail');
|
||
|
||
if (!empty($message))
|
||
$view->content->message = $message;
|
||
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Approval settings
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="email_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="approval">
|
||
<!-- approval()
|
||
{
|
||
// access control
|
||
if (!module::e('approval') ||
|
||
!$this->acl_check_edit('Settings_Controller', 'approval_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
$approval_templates = ORM::factory('approval_template')->select_list('id', 'name');
|
||
|
||
$arr_approval_templates = array
|
||
(
|
||
NULL => '- ' . __('Select approval template') . ' -'
|
||
) + $approval_templates;
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/approval');
|
||
|
||
if (Settings::get('works_enabled'))
|
||
{
|
||
$this->form->group('Work');
|
||
|
||
$this->form->dropdown('default_work_approval_template')
|
||
->label('Default approval template')
|
||
->options($arr_approval_templates)
|
||
->selected(Settings::get('default_work_approval_template'))
|
||
->rules('required');
|
||
|
||
$this->form->group('Work report');
|
||
|
||
$this->form->dropdown('default_work_report_approval_template')
|
||
->label('Default approval template')
|
||
->options($arr_approval_templates)
|
||
->selected(Settings::get('default_work_report_approval_template'))
|
||
->rules('required');
|
||
}
|
||
|
||
$this->form->group('Request');
|
||
|
||
$this->form->dropdown('default_request_approval_template')
|
||
->label('Default approval template')
|
||
->options($arr_approval_templates)
|
||
->selected(Settings::get('default_request_approval_template'))
|
||
->rules('required');
|
||
|
||
$this->form->submit('Save');
|
||
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
{
|
||
status::success('System variables have been successfully updated.');
|
||
}
|
||
else
|
||
{
|
||
status::error('System variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/approval');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('Approval');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'approval';
|
||
$view->content->headline = __('Approval');
|
||
$view->content->link_back = $this->links;
|
||
$view->content->content = $this->form->html();
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* Networks settings
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="approval_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="networks">
|
||
<!-- networks()
|
||
{
|
||
// access control
|
||
if (!module::e('networks') ||
|
||
!$this->acl_check_edit('Settings_Controller', 'networks_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge();
|
||
|
||
$this->form->group('Network settings');
|
||
|
||
$this->form->textarea('address_ranges')
|
||
->help('address_ranges')
|
||
->rules('valid_address_ranges')
|
||
->value(str_replace(",","\n", Settings::get('address_ranges')))
|
||
->class('autosize');
|
||
|
||
$this->form->textarea('dns_servers')
|
||
->help('dns_servers')
|
||
->rules('valid_ip_address')
|
||
->value(str_replace(",","\n", Settings::get('dns_servers')))
|
||
->class('autosize');
|
||
|
||
$this->form->input('dhcp_server_reload_timeout')
|
||
->label('DHCP server maximal timeout')
|
||
->rules('required|valid_numeric')
|
||
->class('increase_decrease_buttons')
|
||
->value(Settings::get('dhcp_server_reload_timeout'))
|
||
->style('width:50px')
|
||
->help('dhcp_server_reload_timeout');
|
||
|
||
if (Settings::get('connection_request_enable'))
|
||
{
|
||
$this->form->group('Connection requests');
|
||
|
||
// enum types for device
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::DEVICE_TYPE_ID);
|
||
|
||
$allowed_types = explode(':', Settings::get('connection_request_device_types'));
|
||
$default_types = $types;
|
||
|
||
// throw away unallowed types
|
||
if (Settings::get('connection_request_device_types'))
|
||
{
|
||
foreach ($default_types as $key => $val)
|
||
{
|
||
if (array_search($key, $allowed_types) === FALSE)
|
||
{
|
||
unset($default_types[$key]);
|
||
}
|
||
}
|
||
}
|
||
|
||
$default_types[NULL] = '- ' . __('Select type') . ' -';
|
||
asort($default_types);
|
||
|
||
$this->form->dropdown('connection_request_device_default_type')
|
||
->label('Default device type')
|
||
->options($default_types)
|
||
->selected(Settings::get('connection_request_device_default_type'))
|
||
->style('width:200px');
|
||
|
||
$this->form->dropdown('connection_request_device_types[]')
|
||
->label('Allowed device types')
|
||
->options($types)
|
||
->selected($allowed_types)
|
||
->multiple('multiple')
|
||
->size(10);
|
||
|
||
$this->form->html_textarea('connection_request_info')
|
||
->label('Add form information')
|
||
->help(help::hint('connection_request_info_form'))
|
||
->rows(5)
|
||
->cols(100)
|
||
->value(Settings::get('connection_request_info'));
|
||
}
|
||
|
||
$this->form->group('Other settings');
|
||
|
||
$this->form->checkbox('device_add_auto_link_enabled')
|
||
->label('Enable automatic loading of "connected to" field during adding of device')
|
||
->checked(Settings::get('device_add_auto_link_enabled'));
|
||
|
||
$this->form->submit('Save');
|
||
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
if ($name == 'address_ranges')
|
||
{
|
||
$value = str_replace("\n", ",", $value);
|
||
}
|
||
else if ($name == 'connection_request_device_types')
|
||
{
|
||
$value = empty($value) ? '' : implode(':', $value);
|
||
}
|
||
else if ($name == 'dns_servers')
|
||
{
|
||
$old_value = Settings::get('dns_servers');
|
||
// expire DHCP? (#472)
|
||
if (trim($value) != trim($old_value))
|
||
{
|
||
ORM::factory('subnet')->set_expired_all_subnets();
|
||
}
|
||
}
|
||
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if ($issaved)
|
||
{
|
||
status::success('System variables have been successfully updated.');
|
||
}
|
||
else
|
||
{
|
||
status::error('System variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/networks');
|
||
}
|
||
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('Networks');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'networks';
|
||
$view->content->headline = __('Networks');
|
||
$view->content->link_back = $this->links;
|
||
$view->content->content = $this->form->html();
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* VOIP settings
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="networks_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="voip">
|
||
<!-- voip()
|
||
{
|
||
// access control
|
||
if (!module::e('voip') ||
|
||
!$this->acl_check_edit(get_class($this), 'voip_settings'))
|
||
Controller::error(ACCESS);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/voip');
|
||
|
||
$this->form->group('VoIP settings');
|
||
|
||
// page title
|
||
$this->form->input('voip_number_interval')
|
||
->label('Number interval')
|
||
->rules('length[19,19]|required')
|
||
->value(addslashes(Settings::get('voip_number_interval')))
|
||
->callback(array($this, 'valid_voip_number_interval'));
|
||
|
||
$this->form->input('voip_number_exclude')
|
||
->label('Exclude numbers')
|
||
->rules('length[9,100]')
|
||
->value(addslashes(Settings::get('voip_number_exclude')))
|
||
->callback(array($this, 'valid_voip_number_exclude'));
|
||
|
||
$this->form->input('voip_sip_server')
|
||
->label('SIP server')
|
||
->rules('length[1,30]|required')
|
||
->value(addslashes(Settings::get('voip_sip_server')));
|
||
|
||
$this->form->group('Asterisk manager settings');
|
||
|
||
$this->form->input('voip_asterisk_hostname')
|
||
->label('Hostname')
|
||
->rules('length[1,50]')
|
||
->value(Settings::get('voip_asterisk_hostname'));
|
||
|
||
$this->form->input('voip_asterisk_user')
|
||
->label('User')
|
||
->rules('length[1,50]')
|
||
->value(Settings::get('voip_asterisk_user'));
|
||
|
||
$this->form->input('voip_asterisk_pass')
|
||
->label('Password')
|
||
->rules('length[1,50]')
|
||
->value(Settings::get('voip_asterisk_pass'));
|
||
|
||
|
||
$this->form->group('Billing settings');
|
||
|
||
$this->form->dropdown('voip_billing_driver')
|
||
->label('Driver')
|
||
->rules('required')
|
||
->options(array
|
||
(
|
||
Billing::INACTIVE => __('Inactive'),
|
||
Billing::NFX_LBILLING => 'lBilling - NFX'
|
||
))->selected(Settings::get('voip_billing_driver'));
|
||
|
||
$this->form->input('voip_billing_partner')
|
||
->label('Partner')
|
||
->rules('length[1,50]')
|
||
->value(Settings::get('voip_billing_partner'));
|
||
|
||
$this->form->input('voip_billing_password')
|
||
->label('Password')
|
||
->rules('length[1,50]')
|
||
->value(Settings::get('voip_billing_password'));
|
||
|
||
|
||
$this->form->group('Actual price of calls');
|
||
|
||
$this->form->input('voip_tariff_fixed')
|
||
->label('Fixed line number')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('voip_tariff_fixed'));
|
||
|
||
$this->form->input('voip_tariff_cellphone')
|
||
->label('Cellphone number')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('voip_tariff_cellphone'));
|
||
|
||
$this->form->input('voip_tariff_voip')
|
||
->label('VoIP number')
|
||
->rules('valid_numeric')
|
||
->value(Settings::get('voip_tariff_voip'));
|
||
|
||
$this->form->submit('Save');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array(FALSE);
|
||
$issaved = true;
|
||
$driver = true;
|
||
|
||
// enable VoIP driver
|
||
if ($form_data['voip_billing_driver'] != Billing::INACTIVE)
|
||
{
|
||
$voip_sip = new Voip_sip_Model();
|
||
|
||
// Check pre requirements of VoIP
|
||
if (!$voip_sip->check_pre_requirements())
|
||
{
|
||
// Make pre requirements
|
||
try
|
||
{
|
||
// creates helper functions
|
||
$voip_sip->create_functions();
|
||
// create views
|
||
$voip_sip->create_views();
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
// unset driver
|
||
Settings::set('voip_billing_driver', Billing::INACTIVE);
|
||
// don't change in next foreach
|
||
unset($form_data['voip_billing_driver']);
|
||
// error flad
|
||
$driver = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
$issaved = $issaved && Settings::set($name, $value);
|
||
}
|
||
|
||
if (!$driver)
|
||
{ // driver error
|
||
status::error(__(
|
||
'Cannot enable VoIP driver, allow `%s` rights for MySQL user',
|
||
array('CREATE ROUTINE')
|
||
) . '.',NULL, FALSE);
|
||
}
|
||
else if ($issaved)
|
||
{
|
||
status::success('System variables have been successfully updated.');
|
||
}
|
||
else
|
||
{
|
||
status::success('System variables havent been successfully updated.');
|
||
}
|
||
|
||
url::redirect('settings/voip');
|
||
}
|
||
|
||
// drover informations
|
||
$ai = null;
|
||
|
||
if (Billing::instance()->has_driver())
|
||
{
|
||
if (Billing::instance()->test_conn())
|
||
{
|
||
$ai = __('Testing driver');
|
||
$ai .= ': lBilling - NFX......<span style="color:green">OK</span>';
|
||
}
|
||
else
|
||
{
|
||
$ai = __('Testing driver');
|
||
$ai .= ': lBilling - NFX......<span style="color:red">';
|
||
$ai .= __('Failed') . '</span>';
|
||
}
|
||
}
|
||
|
||
// create view for this template
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('VoIP');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'voip';
|
||
$view->content->content = $this->form->html();
|
||
$view->content->headline = __('VoIP');
|
||
$view->content->additional_info = $ai;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
/**
|
||
* SMS settings
|
||
*/
|
||
public -->
|
||
<axo usage_type="unknown" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
<axo usage_type="access" section="Settings_Controller" value="voip_settings" action="edit" own="false"></axo>
|
||
</method>
|
||
<method name="sms">
|
||
<!-- sms()
|
||
{
|
||
// access control
|
||
if (!module::e('sms') ||
|
||
!$this->acl_check_edit(get_class($this), 'sms_settings'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
// enabled SMS?
|
||
if (!Sms::enabled())
|
||
{
|
||
$view = new View('main');
|
||
$view->title = __('Settings') . ' - ' . __('SMS');
|
||
$view->content = new View('settings/main');
|
||
$view->content->current = 'sms';
|
||
$view->content->content = new View('sms/not_enabled');
|
||
$view->content->headline = __('Error - SMS not enabled');
|
||
$view->render(TRUE);
|
||
exit;
|
||
}
|
||
|
||
$drivers = Sms::get_active_drivers();
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge('settings/sms');
|
||
|
||
$this->form->group('SMS settings');
|
||
|
||
// page title
|
||
$this->form->input('sms_sender_number')
|
||
->label('Number of the sender')
|
||
->rules('length[12,12]|required|valid_phone')
|
||
->value(Settings::get('sms_sender_number'));
|
||
|
||
$this->form->dropdown('sms_driver')
|
||
->label('Default driver')
|
||
->options($drivers)
|
||
->selected(Settings::get('sms_driver'));
|
||
|
||
/* Forms for all drivers */
|
||
|
||
$aditional_info = '';
|
||
$drivers = Sms::get_drivers();
|
||
|
||
foreach ($drivers as $driver)
|
||
{
|
||
$key = $driver['id'];
|
||
|
||
/* Build form */
|
||
|
||
$this->form->group(Sms::get_driver_name($key));
|
||
|
||
$this->form->dropdown('sms_driver_state' . $key)
|
||
->label('Driver state')
|
||
->options(array
|
||
(
|
||
Sms::DRIVER_INACTIVE => __('Inactive'),
|
||
Sms::DRIVER_ACTIVE => __('Active')
|
Také k dispozici: Unified diff
Upravy:
- refs #563: dokumentace k AXO (controllery S)