Merge branch 'feature/allow-to-disable-stacktraces-9113'
resolves #9113
This commit is contained in:
commit
0bf701a373
|
@ -25,6 +25,20 @@ class ApplicationConfigForm extends Form
|
||||||
*/
|
*/
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'global_show_stacktraces',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'value' => true,
|
||||||
|
'label' => $this->translate('Show Stacktraces'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Set whether to show an exception\'s stacktrace by default. This can also'
|
||||||
|
. ' be set in a user\'s preferences with the appropriate permission.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'global_module_path',
|
'global_module_path',
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Icinga\Forms;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Authentication\Auth;
|
use Icinga\Authentication\Auth;
|
||||||
use Icinga\User\Preferences;
|
use Icinga\User\Preferences;
|
||||||
|
@ -178,6 +179,19 @@ class PreferenceForm extends Form
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (Auth::getInstance()->hasPermission('application/stacktraces')) {
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'show_stacktraces',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'value' => $this->getDefaultShowStacktraces(),
|
||||||
|
'label' => $this->translate('Show Stacktraces'),
|
||||||
|
'description' => $this->translate('Set whether to show an exception\'s stacktrace.')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'checkbox',
|
'checkbox',
|
||||||
'show_benchmark',
|
'show_benchmark',
|
||||||
|
@ -269,4 +283,14 @@ class PreferenceForm extends Form
|
||||||
$locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
$locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
return $locale;
|
return $locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default global setting for show_stacktraces
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function getDefaultShowStacktraces()
|
||||||
|
{
|
||||||
|
return Config::app()->get('global', 'show_stacktraces', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,35 +20,7 @@ class RoleForm extends ConfigForm
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $providedPermissions = array(
|
protected $providedPermissions;
|
||||||
'*' => 'Allow everything (*)',
|
|
||||||
'config/*' => 'Allow config access (config/*)',
|
|
||||||
/*
|
|
||||||
// [tg] seems excessive for me, hidden for rc1, tbd
|
|
||||||
'config/application/*' => 'config/application/*',
|
|
||||||
'config/application/general' => 'config/application/general',
|
|
||||||
'config/application/resources' => 'config/application/resources',
|
|
||||||
'config/application/userbackend' => 'config/application/userbackend',
|
|
||||||
'config/application/usergroupbackend' => 'config/application/usergroupbackend',
|
|
||||||
'config/authentication/*' => 'config/authentication/*',
|
|
||||||
'config/authentication/users/*' => 'config/authentication/users/*',
|
|
||||||
'config/authentication/users/show' => 'config/authentication/users/show',
|
|
||||||
'config/authentication/users/add' => 'config/authentication/users/add',
|
|
||||||
'config/authentication/users/edit' => 'config/authentication/users/edit',
|
|
||||||
'config/authentication/users/remove' => 'config/authentication/users/remove',
|
|
||||||
'config/authentication/groups/*' => 'config/authentication/groups/*',
|
|
||||||
'config/authentication/groups/show' => 'config/authentication/groups/show',
|
|
||||||
'config/authentication/groups/add' => 'config/authentication/groups/add',
|
|
||||||
'config/authentication/groups/edit' => 'config/authentication/groups/edit',
|
|
||||||
'config/authentication/groups/remove' => 'config/authentication/groups/remove',
|
|
||||||
'config/authentication/roles/*' => 'config/authentication/roles/*',
|
|
||||||
'config/authentication/roles/show' => 'config/authentication/roles/show',
|
|
||||||
'config/authentication/roles/add' => 'config/authentication/roles/add',
|
|
||||||
'config/authentication/roles/edit' => 'config/authentication/roles/edit',
|
|
||||||
'config/authentication/roles/remove' => 'config/authentication/roles/remove',
|
|
||||||
'config/modules' => 'config/modules'
|
|
||||||
*/
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provided restrictions by currently loaded modules
|
* Provided restrictions by currently loaded modules
|
||||||
|
@ -62,6 +34,40 @@ class RoleForm extends ConfigForm
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
$this->providedPermissions = array(
|
||||||
|
'*' => $this->translate('Allow everything') . ' (*)',
|
||||||
|
'application/stacktraces' => $this->translate(
|
||||||
|
'Allow to adjust in the preferences whether to show stacktraces'
|
||||||
|
) . ' (application/stacktraces)',
|
||||||
|
'config/*' => $this->translate('Allow config access') . ' (config/*)',
|
||||||
|
/*
|
||||||
|
// [tg] seems excessive for me, hidden for rc1, tbd
|
||||||
|
'config/application/*' => 'config/application/*',
|
||||||
|
'config/application/general' => 'config/application/general',
|
||||||
|
'config/application/resources' => 'config/application/resources',
|
||||||
|
'config/application/userbackend' => 'config/application/userbackend',
|
||||||
|
'config/application/usergroupbackend' => 'config/application/usergroupbackend',
|
||||||
|
'config/authentication/*' => 'config/authentication/*',
|
||||||
|
'config/authentication/users/*' => 'config/authentication/users/*',
|
||||||
|
'config/authentication/users/show' => 'config/authentication/users/show',
|
||||||
|
'config/authentication/users/add' => 'config/authentication/users/add',
|
||||||
|
'config/authentication/users/edit' => 'config/authentication/users/edit',
|
||||||
|
'config/authentication/users/remove' => 'config/authentication/users/remove',
|
||||||
|
'config/authentication/groups/*' => 'config/authentication/groups/*',
|
||||||
|
'config/authentication/groups/show' => 'config/authentication/groups/show',
|
||||||
|
'config/authentication/groups/add' => 'config/authentication/groups/add',
|
||||||
|
'config/authentication/groups/edit' => 'config/authentication/groups/edit',
|
||||||
|
'config/authentication/groups/remove' => 'config/authentication/groups/remove',
|
||||||
|
'config/authentication/roles/*' => 'config/authentication/roles/*',
|
||||||
|
'config/authentication/roles/show' => 'config/authentication/roles/show',
|
||||||
|
'config/authentication/roles/add' => 'config/authentication/roles/add',
|
||||||
|
'config/authentication/roles/edit' => 'config/authentication/roles/edit',
|
||||||
|
'config/authentication/roles/remove' => 'config/authentication/roles/remove',
|
||||||
|
'config/modules' => 'config/modules'
|
||||||
|
*/
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$helper = new Zend_Form_Element('bogus');
|
$helper = new Zend_Form_Element('bogus');
|
||||||
$mm = Icinga::app()->getModuleManager();
|
$mm = Icinga::app()->getModuleManager();
|
||||||
foreach ($mm->listInstalledModules() as $moduleName) {
|
foreach ($mm->listInstalledModules() as $moduleName) {
|
||||||
|
|
|
@ -212,9 +212,19 @@ class Web extends EmbeddedWeb
|
||||||
$this->frontController = Zend_Controller_Front::getInstance();
|
$this->frontController = Zend_Controller_Front::getInstance();
|
||||||
$this->frontController->setRequest($this->getRequest());
|
$this->frontController->setRequest($this->getRequest());
|
||||||
$this->frontController->setControllerDirectory($this->getApplicationDir('/controllers'));
|
$this->frontController->setControllerDirectory($this->getApplicationDir('/controllers'));
|
||||||
|
|
||||||
|
$displayExceptions = $this->config->get('global', 'show_stacktraces', true);
|
||||||
|
if ($this->user !== null && $this->user->can('application/stacktraces')) {
|
||||||
|
$displayExceptions = $this->user->getPreferences()->getValue(
|
||||||
|
'icingaweb',
|
||||||
|
'show_stacktraces',
|
||||||
|
$displayExceptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->frontController->setParams(
|
$this->frontController->setParams(
|
||||||
array(
|
array(
|
||||||
'displayExceptions' => true
|
'displayExceptions' => $displayExceptions
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -53,6 +53,10 @@ class GeneralConfigStep extends Step
|
||||||
|
|
||||||
$generalHtml = ''
|
$generalHtml = ''
|
||||||
. '<ul>'
|
. '<ul>'
|
||||||
|
. '<li>' . ($this->data['generalConfig']['global_show_stacktraces']
|
||||||
|
? t('An exception\'s stacktrace is shown to every user by default.')
|
||||||
|
: t('An exception\'s stacktrace is hidden from every user by default.')
|
||||||
|
) . '</li>'
|
||||||
. '<li>' . sprintf(
|
. '<li>' . sprintf(
|
||||||
$this->data['generalConfig']['global_config_backend'] === 'ini' ? sprintf(
|
$this->data['generalConfig']['global_config_backend'] === 'ini' ? sprintf(
|
||||||
t('Preferences will be stored per user account in INI files at: %s'),
|
t('Preferences will be stored per user account in INI files at: %s'),
|
||||||
|
|
Loading…
Reference in New Issue