Source

Target

Commits (5)
Showing with 185 additions and 0 deletions
+185 -0
.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
##
## 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
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
<?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