From aa6002ea44f6baa0aaddddda193ee1a32e4c77e2 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Thu, 10 Nov 2022 17:13:54 +0000 Subject: [PATCH] :sparkles: Feat(Tasks) - Dashboard v0.9 Includes tasks config backend. Allows spam protection management. --- contrib/openldap/core-fd.schema | 28 +++++++ plugins/admin/tasks/class_tasksColumn.inc | 1 - plugins/admin/tasks/class_tasksDashboard.inc | 2 +- plugins/config/class_tasksConfig.inc | 78 ++++++++++++++++++++ 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 plugins/config/class_tasksConfig.inc diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index 854f9ff0a..9195dcea0 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -374,6 +374,28 @@ attributetype ( 1.3.6.1.4.1.38414.89.1.16 NAME 'fdTasksGranularRef' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) +##### Tasks Conf ##### + +attributetype ( 1.3.6.1.4.1.38414.89.1.17 NAME 'fdTasksRDN' + DESC 'FusionDirectory - Tasks RDN' + EQUALITY caseExactIA5Match + SUBSTR caseExactIA5SubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE) + +attributetype ( 1.3.6.1.4.1.38414.89.1.18 NAME 'fdTasksConfLastExecTime' + DESC 'Store time of last mail tasks success - secure spam interval' + EQUALITY caseExactIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.19 NAME 'fdTasksConfMaxEmails' + DESC 'FusionDirectory maximum emails to be processed by Orchestrator - secure spam' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.20 NAME 'fdTasksConfIntervalEmails' + DESC 'FusionDirectory maximum emails to be processed by Orchestrator - secure spam' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) + ##### Classes ##### objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.4 NAME 'gosaDepartment' SUP top AUXILIARY @@ -473,3 +495,9 @@ objectclass (1.3.6.1.4.1.38414.89.2.3 NAME 'fdTasksGranular' DESC 'FusionDirectory - Tasks granular objects' MUST ( fdTasksGranularMaster $ cn $ fdTasksGranularMail $ fdTasksGranularMailFrom $ fdTasksGranularRef $ fdTasksGranularType $ fdTasksGranularSchedule $ fdTasksGranularStatus )) + +objectclass (1.3.6.1.4.1.38414.89.2.4 NAME 'fdTasksConf' + DESC 'FusionDirectory - Tasks objects Configuration' + SUP top AUXILIARY + MUST ( cn ) + MAY ( fdTasksRDN $ fdTasksConfLastExecTime $ fdTasksConfMaxEmails $ fdTasksConfIntervalEmails)) diff --git a/plugins/admin/tasks/class_tasksColumn.inc b/plugins/admin/tasks/class_tasksColumn.inc index 847b7a24f..85a7fa3b0 100644 --- a/plugins/admin/tasks/class_tasksColumn.inc +++ b/plugins/admin/tasks/class_tasksColumn.inc @@ -85,7 +85,6 @@ class TasksColumn extends Column $rmDn = preg_replace('/(?=,).*/', '', $value); // only take the cn without dc preg_match('/cn=(.*)/', $rmDn, $matches); - return $matches[1]; } diff --git a/plugins/admin/tasks/class_tasksDashboard.inc b/plugins/admin/tasks/class_tasksDashboard.inc index f4d73cf7b..735a07e88 100644 --- a/plugins/admin/tasks/class_tasksDashboard.inc +++ b/plugins/admin/tasks/class_tasksDashboard.inc @@ -37,7 +37,7 @@ class tasksDashboard extends management ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], ['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], ['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], - ['ActionsColumn', ['label' => 'Actions']], + ['ActionsColumn', ['label' => 'Actions']], ]; // No modification tools are required. diff --git a/plugins/config/class_tasksConfig.inc b/plugins/config/class_tasksConfig.inc new file mode 100644 index 000000000..313a9925b --- /dev/null +++ b/plugins/config/class_tasksConfig.inc @@ -0,0 +1,78 @@ +<?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 Directory Base, Tasks will be stored'), + 'fdTasksRDN', TRUE, + 'ou=tasks' + ), + ] + ], + 'Mail' => [ + 'name' => _('Mail Anti-Spam Configuration'), + 'attrs' => [ + new DateTimeAttribute( + _('Schedule'), '', + 'fdTasksConfLastExecTime', FALSE + ), + new IntAttribute( + _('Maximum number of e-mails processed per time'), _('Select max e-mails to be proccesse'), + '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); + + } + +} + -- GitLab