Commit 919785d4 authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '5937-hooks-should-be-moved-to-a-config-tab' into '1.4-dev'

Resolve "Hooks should be moved to a config tab"

See merge request fusiondirectory/fd!595
parents b426f184 fd385981
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Debug level is an OR combination of several values */
class DebugLevelAttribute extends SetAttribute
{
protected function loadAttrValue (array $attrs)
{
if (isset($attrs[$this->getLdapName()])) {
$value = $attrs[$this->getLdapName()][0];
$this->value = [];
foreach ($this->attribute->getChoices() as $choice) {
if ($value & $choice) {
$this->value[] = $choice;
}
}
} else {
$this->resetToDefault();
}
}
function computeLdapValue ()
{
$value = 0;
foreach ($this->value as $v) {
$value |= $v;
}
return $value;
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2016 FusionDirectory
Copyright (C) 2012-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -18,34 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Debug level is an OR combination of several values */
class DebugLevelAttribute extends SetAttribute
{
protected function loadAttrValue (array $attrs)
{
if (isset($attrs[$this->getLdapName()])) {
$value = $attrs[$this->getLdapName()][0];
$this->value = [];
foreach ($this->attribute->getChoices() as $choice) {
if ($value & $choice) {
$this->value[] = $choice;
}
}
} else {
$this->resetToDefault();
}
}
function computeLdapValue ()
{
$value = 0;
foreach ($this->value as $v) {
$value |= $v;
}
return $value;
}
}
class configInLdap extends simplePlugin
{
static function plInfo (): array
......@@ -77,11 +50,7 @@ class configInLdap extends simplePlugin
static function getAttributesInfo (): array
{
global $config;
$plugins = [];
if (session::global_is_set('plist')) {
$plugins = array_keys(session::global_get('plist')->info);
}
sort($plugins);
return [
'look_n_feel' => [
'name' => _('Look and feel'),
......@@ -392,48 +361,6 @@ class configInLdap extends simplePlugin
new HiddenAttribute('fdManagementConfig'),
]
],
'hooks' => [
'name' => _('Hooks'),
'class' => ['fullwidth'],
'attrs' => [
new OrderedArrayAttribute(
new CompositeAttribute(
_('Hooks that are called when specific actions happens'),
'fdTabHook',
[
new SelectAttribute(
_('Tab'), _('The tab that this hook concerns'),
'hookTab', TRUE,
$plugins
),
new SelectAttribute(
_('Mode'), _('When to call this command'),
'hookMode', TRUE,
['postcreate', 'postremove', 'postmodify',
'precreate', 'preremove', 'premodify', 'check',
'prelock', 'postlock', 'preunlock', 'postunlock']
),
new TextAreaAttribute(
_('Command'), _('The command that will be called'),
'hookCmd', TRUE
)
],
'/^([^\\|]+)\\|([^\\|]+)\\|(.*)$/',
'%s|%s|%s',
'', // acl
_('Hooks')
),
FALSE, // non-ordered
[],
TRUE // edition
),
new BooleanAttribute(
_('Display hook output'),
_('When enabled successful hook execution output is displayed to the user using a dialog.'),
'fdDisplayHookOutput'
),
]
],
];
}
......@@ -514,8 +441,6 @@ class configInLdap extends simplePlugin
]
);
$this->attributesAccess['fdTabHook']->setLinearRendering(FALSE);
$this->attributesAccess['fdForceSSL']->setManagedAttributes(
[
'disable' => [
......
......@@ -28,6 +28,7 @@ class dashboardConfig extends simplePlugin
'plCategory' => ['configuration'],
'plObjectClass' => ['fdDashboardPluginConf'],
'plObjectType' => ['smallConfig'],
'plPriority' => 2,
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class hooksConfig extends simplePlugin
{
static function plInfo (): array
{
return [
'plShortName' => _('Hooks'),
'plTitle' => _('Hooks configuration'),
'plPriority' => 1,
'plObjectType' => ['configuration'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
global $config;
$plugins = [];
if (session::global_is_set('plist')) {
$plugins = array_keys(session::global_get('plist')->info);
}
sort($plugins);
return [
'hooks' => [
'name' => _('Hooks'),
'class' => ['fullwidth'],
'attrs' => [
new BooleanAttribute(
_('Display hook output'),
_('When enabled successful hook execution output is displayed to the user using a dialog.'),
'fdDisplayHookOutput'
),
new OrderedArrayAttribute(
new CompositeAttribute(
_('Hooks that are called when specific actions happens'),
'fdTabHook',
[
new SelectAttribute(
_('Tab'), _('The tab that this hook concerns'),
'hookTab', TRUE,
$plugins
),
new SelectAttribute(
_('Mode'), _('When to call this command'),
'hookMode', TRUE,
['postcreate', 'postremove', 'postmodify',
'precreate', 'preremove', 'premodify', 'check',
'prelock', 'postlock', 'preunlock', 'postunlock']
),
new TextAreaAttribute(
_('Command'), _('The command that will be called'),
'hookCmd', TRUE
)
],
'/^([^\\|]+)\\|([^\\|]+)\\|(.*)$/',
'%s|%s|%s',
'', // acl
_('Hooks')
),
FALSE, // non-ordered
[],
TRUE // edition
),
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['fdTabHook']->setLinearRendering(FALSE);
}
}
......@@ -28,6 +28,7 @@ class mainPluginsConfig extends simplePlugin
'plCategory' => ['configuration'],
'plObjectClass' => ['fusionDirectoryPluginsConf'],
'plObjectType' => ['smallConfig'],
'plPriority' => 1,
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment