Verified Commit 701657fb authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: (CORE) - New directory structure

Config to backend
Showing with 1312 additions and 0 deletions
+1312 -0
<?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;
}
}
This diff is collapsed.
<?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 configInLdapTabs extends simpleTabs
{
function save ()
{
global $config;
$errors = parent::save();
/* check_and_reload */
$config->check_and_reload(TRUE);
/* reload plist as well as some plInfo might use $config or get_ou */
session::un_set('plist');
pluglist::load();
session::un_set('passwordMethod::get_available_methods');
return $errors;
}
}
<?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' => _('Triggers'),
'plTitle' => _('Triggers configuration'),
'plPriority' => 1,
'plObjectType' => ['configuration'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
global $config;
$plugins = [];
if (session::is_set('plist')) {
$plugins = array_keys(session::get('plist')->info);
}
sort($plugins);
return [
'triggers' => [
'name' => _('Triggers'),
'class' => ['fullwidth'],
'attrs' => [
new BooleanAttribute(
_('Display trigger output'),
_('When enabled successful trigger execution output is displayed to the user using a dialog.'),
'fdDisplayHookOutput'
),
new OrderedArrayAttribute(
new CompositeAttribute(
_('Triggers that are called when specific actions happens'),
'fdTabHook',
[
new SelectAttribute(
_('Tab'), _('The tab that this trigger concerns'),
'triggerTab', TRUE,
$plugins
),
new SelectAttribute(
_('Mode'), _('When to call this command'),
'triggerMode', TRUE,
['postcreate', 'postremove', 'postmodify',
'precreate', 'preremove', 'premodify', 'check',
'prelock', 'postlock', 'preunlock', 'postunlock']
),
new BooleanAttribute(
_('Deactivated'), _('Use this to temporarily deactivate a trigger'),
'triggerDecativate', TRUE,
FALSE, '',
'#', ''
),
new TextAreaAttribute(
_('Command'), _('The command that will be called'),
'triggerCmd', TRUE
)
],
'/^([^\\|]+)\\|([^\\|]+)\\|(#?)(.*)$/',
'%s|%s|%s%s',
'', // acl
_('Triggers')
),
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);
$this->attributesAccess['fdTabHook']->setHeaders([
_('Tab'),
_('Mode'),
_('Deactivated'),
_('Command'),
'',
]);
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2022 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 mailTemplateConfig extends multiPluginSection
{
static function plInfo (): array
{
return [
'plShortName' => _('mail template configuration'),
'plDescription' => _('FusionDirectory mail template plugin configuration'),
'plObjectClass' => ['fdMailTemplateConf'],
'plCategory' => ['configuration'],
'plObjectType' => ['smallConfig'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'mailTemplateConf' => [
'name' => _('Mail Template'),
'attrs' => [
new StringAttribute(
_('Mail Template RDN'), _('Branch in which mails templates will be stored'),
'fdMailTemplateRDN', TRUE,
'ou=mailTemplate'
),
]
],
];
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2017 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 mainPluginsConfig extends multiPluginSection
{
static function plInfo (): array
{
return [
'plShortName' => _('Plugins configuration'),
'plDescription' => _('FusionDirectory plugins configuration'),
'plCategory' => ['configuration'],
'plObjectClass' => ['fusionDirectoryPluginsConf'],
'plObjectType' => ['smallConfig'],
'plPriority' => 1,
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'ogroups' => [
'name' => _('Object groups'),
'attrs' => [
new StringAttribute(
_('Groups RDN'), _('Branch in which object groups will be stored'),
'fdOGroupRDN', TRUE,
'ou=groups'
),
]
],
'sasl' => [
'name' => _('SASL'),
'attrs' => [
new BooleanAttribute(
_('Force asking for a password'), _('Useful if you add a trigger using password value when SASL user passwords are edited'),
'fdForceSaslPasswordAsk', TRUE,
FALSE
),
]
],
];
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2018 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 pluginsConfigInLdap extends multiPlugin
{
protected static $tabClass = 'SMALLCONFIGTABS';
static function plInfo (): array
{
return [
'plShortName' => _('Plugins'),
'plDescription' => _('Configuration for plugins'),
'plPriority' => 2,
'plObjectType' => ['configuration'],
'plSubTabs' => 'SMALLCONFIGTABS',
/* This is incomplete because of dynamic loading, but is enough to generate a filter for this tab */
'plObjectClass' => ['fusionDirectoryPluginsConf'],
'plProvidedAcls' => []
];
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2016 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 recoveryConfig extends simplePlugin
{
static function plInfo (): array
{
return [
'plShortName' => _('Recovery'),
'plTitle' => _('Password recovery'),
'plDescription' => _('Settings for the password recovery feature'),
'plObjectClass' => ['fdPasswordRecoveryConf'],
'plPriority' => 14,
'plObjectType' => ['configuration'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'settings' => [
'name' => _('Password recovery settings'),
'class' => ['alone'],
'template' => get_template_path('simpleplugin_section_alone.tpl'),
'attrs' => [
new BooleanAttribute(
_('Activate password recovery'),
_('Whether to activate the password recovery feature or not'),
'fdPasswordRecoveryActivated',
FALSE
),
new MailAttribute(
_('Sender email address'),
_('Email address from which mails will be sent'),
'fdPasswordRecoveryEmail',
TRUE,
'to.be@chang.ed'
),
new IntAttribute(
_('Link validity (minutes)'),
_('Number of minutes before a recovery link expires'),
'fdPasswordRecoveryValidity',
TRUE,
0, FALSE, 10
),
new StringAttribute(
_('Salt for tokens'),
_('Just a security measure, you can put anything in there, even random characters'),
'fdPasswordRecoverySalt',
TRUE,
"SomethingSecretAndVeryLong"
),
new BooleanAttribute(
_('Allow the use of alternate addresses'),
_('Users will also be able to enter one of their alternate addresses to recover their password'),
'fdPasswordRecoveryUseAlternate',
FALSE
),
new StringAttribute(
_('Login attribute'), _('Usually uid, but you can use something else for instance in case of SSO'),
'fdPasswordRecoveryLoginAttribute', TRUE,
'uid'
),
]
],
'first_email' => [
'name' => _('First email'),
'attrs' => [
new StringAttribute(
_('Subject'),
_('Subject of the first email'),
'fdPasswordRecoveryMailSubject',
TRUE,
_("[FusionDirectory] Password recovery link")
),
new TextAreaAttribute(
_('Body (first %s is login, second is link)'),
_('Body of the first email, sent when the user ask for a new password. Use %s for the login and the recovery link.'),
'fdPasswordRecoveryMailBody',
TRUE,
_("Hello,\n\nHere is your information: \n - Login : %s\n - Link : %s\n\nThis link is only valid for 10 minutes.")
)
]
],
'second_email' => [
'name' => _('Second email'),
'attrs' => [
new StringAttribute(
_('Subject'),
_('Subject of the second email'),
'fdPasswordRecoveryMail2Subject',
TRUE,
_("[FusionDirectory] Password recovery successful")
),
new TextAreaAttribute(
_('Body (%s is login)'),
_('Body of the second email, sent to confirm the password has been changed. Use %s for the user login.'),
'fdPasswordRecoveryMail2Body',
TRUE,
_("Hello,\n\nYour password has been changed.\nYour login is still %s.")
)
]
]
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
// Check if token branch is here
$ldap = $config->get_ldap_link();
$tokenBranch = get_ou('recoveryTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'];
$ldap->cat($tokenBranch, ['dn']);
if (!$ldap->count()) {
$ldap->cd($config->current['BASE']);
try {
$ldap->create_missing_trees($tokenBranch);
} catch (FusionDirectoryError $error) {
$error->display();
}
fusiondirectory_log('Created token branch '.$tokenBranch);
}
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['fdPasswordRecoveryActivated']->setManagedAttributes(
[
'disable' => [
FALSE => [
'fdPasswordRecoveryEmail','fdPasswordRecoveryValidity','fdPasswordRecoverySalt',
'fdPasswordRecoveryMailSubject','fdPasswordRecoveryMailBody',
'fdPasswordRecoveryMail2Subject','fdPasswordRecoveryMail2Body'
]
]
]
);
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2023 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 snapshotsConfig extends simplePlugin
{
static function plInfo (): array
{
return [
'plShortName' => _('Snapshots'),
'plDescription' => _('FusionDirectory Snapshot Configuration'),
'plObjectClass' => ['fusionDirectoryConf'],
'plObjectType' => ['configuration'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
global $config;
return [
'snapshotsConf' => [
'name' => _('Snapshots Configuration'),
'attrs' => [
new BooleanAttribute(
_('Enable snapshots'), _('This enables you to save certain states of entries and restore them later on.'),
'fdEnableSnapshots', FALSE,
TRUE
),
new BooleanAttribute(
_('Enable automatic snapshots'), _('This enables you to automatically create a snapshot upon saving if any modifications have been found.'),
'fdEnableAutomaticSnapshots', FALSE,
FALSE
),
new StringAttribute(
_('Snapshot base'), _('The base where snapshots should be stored inside the LDAP directory.'),
'fdSnapshotBase', FALSE,
'ou=snapshots,'.$config->current['BASE']
),
]
],
'snapshotsAdvanceConf' => [
'name' => _('Snapshots Advance Configuration'),
'attrs' => [
new IntAttribute(
_('Minimum number of snapshots to be kept'), _('Set the minimum number of snapshots to be kept'),
'fdSnapshotMinRetention', FALSE, '', FALSE, ''
),
new IntAttribute(
_('Retention time in days'), _('Set the retention time in days for a snapshots to be kept'),
'fdSnapshotRetentionDays', FALSE, '', FALSE, ''
),
]
],
'OriginDataSource' => [
'name' => _('List of available sources / origin of data'),
'attrs' => [
new SetAttribute(
new StringAttribute(
_('Origin / source of data'), _('Origin / Source of data'),
'fdSnapshotSourceData', FALSE,
)
),
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['fdEnableSnapshots']->setManagedAttributes(
[
'disable' => [
FALSE => [
'fdSnapshotBase',
'fdEnableAutomaticSnapshots',
'fdSnapshotMinRetention',
'fdSnapshotRetentionDays',
]
]
]
);
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2022 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 tasksConfig extends simplePlugin
{
static function plInfo (): array
{
return [
'plShortName' => _('Tasks'),
'plDescription' => _('FusionDirectory Tasks Configuration'),
'plObjectClass' => ['fdTasksConf'],
'plObjectType' => ['configuration'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'tasksConf' => [
'name' => _('Tasks Configuration'),
'attrs' => [
new StringAttribute(
_('Tasks RDN'), _('Branch in which Tasks will be stored'),
'fdTasksRDN', TRUE,
'ou=tasks'
),
]
],
'Mail' => [
'name' => _('Mail Anti-Spam Configuration'),
'attrs' => [
new IntAttribute(
_('Last Sent Mail'), '_(Last timestamp in Unix format when last email was sent succesfully)',
'fdTasksConfLastExecTime', FALSE, '', FALSE, ''
),
new IntAttribute(
_('Maximum number of e-mails processed per time'), _('Select max emails to be proccessed'),
'fdTasksConfMaxEmails', FALSE, '', FALSE, ''
),
new IntAttribute(
_('Time interval between e-mails processing (Minutes) '), _('Select min interval time between emails processing'),
'fdTasksConfIntervalEmails', FALSE, '', FALSE, ''
),
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
// This attribute will be updated and verified by Orchestrator
$this->attributesAccess['fdTasksConfLastExecTime']->setVisible(FALSE);
}
}
Supports Markdown
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