diff --git a/.gitignore b/.gitignore index 6ef5c6d096f1f589bdd1959215d22d14de08cf2a..3d254de604955baadb3bc03d76b426da4fa4c0d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,12 @@ .directory +.idea/deployment.xml +.idea/fd-plugins.iml +.idea/modules.xml +.idea/php.xml +.idea/sshConfigs.xml +.idea/vcs.xml +.idea/webServers.xml +.idea/workspace.xml +.gitignore +filelist diff --git a/extractor/contrib/openldap/extractor-fd.schema b/extractor/contrib/openldap/extractor-fd.schema new file mode 100644 index 0000000000000000000000000000000000000000..d4f0ae02ab263b0114fd17888858c818e2477cea --- /dev/null +++ b/extractor/contrib/openldap/extractor-fd.schema @@ -0,0 +1,32 @@ +## +## extractor-fd.schema - Needed by Fusion Directory for extractor plugin +## +## Allows extracting LDAP data based on selected members or groups and a chosen format. +## + +# Attributes + +attributetype ( 1.3.6.1.4.1.38414.93.1.1 NAME 'fdExtractorTaskMembers' + DESC 'Fusion Directory - List of members or groups for extraction tasks' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.93.1.2 NAME 'fdExtractorTaskListOfDN' + DESC 'Fusion Directory - DNs derived from the selected members/groups' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.93.1.3 NAME 'fdExtractorTaskFormat' + DESC 'Fusion Directory - Format used for data extraction (CSV for now, extensible later)' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +# Object Class + +objectclass ( 1.3.6.1.4.1.38414.93.2.1 NAME 'fdExtractorTasks' + DESC 'Fusion Directory - Extractor tasks plugin object class' + SUP top + AUXILIARY + MUST ( fdExtractorTaskMembers $ fdExtractorTaskFormat ) + MAY ( fdExtractorTaskListOfDN ) ) \ No newline at end of file diff --git a/extractor/contrib/yaml/description.yaml b/extractor/contrib/yaml/description.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c4a8f9fd0025b6cc103694ba775d2a51eaeee567 --- /dev/null +++ b/extractor/contrib/yaml/description.yaml @@ -0,0 +1,27 @@ +information: + authors: + - FusionDirectory + description: LDAP data extraction plugin for FusionDirectory + license: GPLv2 + logoUrl: https://raw.githubusercontent.com/fusiondirectory/fusiondirectory-plugins/dev/extractor/html/themes/breezy/icons/48/apps/extractor.png + name: extractor + origin: package + screenshotUrl: + - https://raw.githubusercontent.com/fusiondirectory/fusiondirectory-plugins/dev/extractor/contrib/screenshots/extractor-task.png + status: Stable + tags: + - user + - group + - automation + - extraction + version: '1.0' +requirement: + fdVersion: 1.5 + phpVersion: 7.4 +support: + contractUrl: https://www.fusiondirectory.org/abonnements-fusiondirectory/ + documentationUrl: https://fusiondirectory-user-manual.readthedocs.io/ + homeUrl: https://gitlab.fusiondirectory.org/fusiondirectory/fd-plugins + provider: fusiondirectory + schemaUrl: https://schemas.fusiondirectory.org/ + ticketUrl: https://gitlab.fusiondirectory.org/fusiondirectory/fd-plugins/-/issues \ No newline at end of file diff --git a/extractor/html/themes/breezy/icons/48/apps/extractor-task.png b/extractor/html/themes/breezy/icons/48/apps/extractor-task.png new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/extractor/locale/en/fusiondirectory.po b/extractor/locale/en/fusiondirectory.po new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/extractor/workflow/class_extractorTask.inc b/extractor/workflow/class_extractorTask.inc new file mode 100644 index 0000000000000000000000000000000000000000..7041431d313a780be871be96d27efb86361021d5 --- /dev/null +++ b/extractor/workflow/class_extractorTask.inc @@ -0,0 +1,116 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org) + + Copyright (C) 2025 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 extractorTask extends simplePlugin +{ + protected $displayHeader = TRUE; + + static function plInfo (): array + { + return [ + 'plShortName' => _('Tasks Extractor'), + 'plDescription' => _('Tasks Extractor Object'), + 'plIcon' => 'geticon.php?context=mimetypes&icon=application-vnd.ms-excel&size=48', + 'plPriority' => 42, + 'plObjectClass' => ['fdExtractorTasks'], + 'plFilter' => '(objectClass=fdExtractorTasks)', + 'plObjectType' => ['tasks'], + 'plConflicts' => ['tasksMail', 'tasksLifeCycle', 'tasksNotifications', 'auditTasks', 'tasksArchive'], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()), + 'plForeignKeys' => [], + ]; + } + + static function getAttributesInfo (): array + { + return [ + 'section1' => [ + 'name' => _('Members to Extract'), + 'attrs' => [ + new UsersGroupsRolesAttribute( + _('Selected Members'), _('Users or Groups to extract data from.'), + 'fdExtractorTaskMembers', TRUE + ), + new HiddenAttribute( + 'fdExtractorTaskListOfDN' + ), + ], + ], + 'section2' => [ + 'name' => _('Extraction Settings'), + 'attrs' => [ + new SelectAttribute( + _('Format'), _('Output format for extracted data'), + 'fdExtractorTaskFormat', TRUE, + ['CSV'], // Array of choices/keys + 'CSV', // Default value + [_('CSV (Comma Separated Values)')], // Array of display values corresponding to choices + '' // ACL (empty string means use its own) + ), + ] + ], + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + parent::__construct($dn, $object, $parent, $mainTab); + } + + /** + * Generate slave tasks for extraction + */ + function generateSlaveTasks () + { + $selectedMembers = $this->attributesAccess['fdExtractorTaskMembers']->getValue(); + $listOfDN = tasks::extractMembersFromGroups($selectedMembers); + + // Store the list of DNs for future use + $this->attributesAccess['fdExtractorTaskListOfDN']->setValue($listOfDN); + + // Call the method from parent tasks object (first tab) to create sub-tasks + $this->parent->getBaseObject()->createSlaveTasks($listOfDN, 'fdTasksGranularDN', NULL, 'extract'); + } + + /** + * @return bool + */ + function update (): bool + { + parent::update(); + return TRUE; + } + + /** + * @return array + */ + function save (): array + { + // Verify if this task has to be executed upon saving + $execTasks = $this->parent->getBaseObject()->fdSubTasksActivation ?? NULL; + + if ($execTasks) { + $this->generateSlaveTasks(); + } + + return parent::save(); + } +} \ No newline at end of file