diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36e7b4b32edecaf9bb385eb032523b24ad18052b..7290edaf3ddd2ab495c9bbe2e2c0249c68d8881b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,6 +76,7 @@ create_phpstan_rapport: - git clone --depth 1 https://gitlab.fusiondirectory.org/fusiondirectory/dev-tools.git ../dev-tools - composer global require phpstan/phpstan=0.12.94 - cp ../dev-tools/phpstan/fusiondirectory/1.4-dev/*.neon . + - composer global require phpstan/phpstan=0.12.94 - /root/.composer/vendor/bin/phpstan analyse -c phpstan.neon # fusiondirectory-update-locale @@ -131,3 +132,4 @@ trigger-plugins: trigger: project: fusiondirectory/fd-plugins branch: $CI_COMMIT_REF_NAME + diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index 792d5c80ecca3dce8648eb97f8211db41a26632a..9195dcea02d1816cf93a1a1b2a83ccf2b6cbba37 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -92,8 +92,311 @@ attributetype ( 1.3.6.1.4.1.38414.62.11.4 NAME 'fdSubscriptionContractId' attributetype ( 1.3.6.1.4.1.38414.62.11.5 NAME 'fdSubscriptionName' DESC 'FusionDirectory - Subscription client name' SUP name ) + +#Macro Attributes -# Classes +attributetype ( 1.3.6.1.4.1.38414.90.1.1 NAME 'fdMacroRDN' + DESC 'FusionDirectory - Macro 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.90.1.2 NAME 'fdMacroMail' + DESC 'FusionDirectory - Macro RDN' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + SINGLE-VALUE) + +attributetype ( 1.3.6.1.4.1.38414.90.1.3 NAME 'fdMacroInvitations' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.90.1.4 NAME 'fdMacroUserRecovery' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.90.1.5 NAME 'fdMacroUserReminder' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +### Mail Template Related Attributes ### + +attributetype ( 1.3.6.1.4.1.38414.88.1.1 NAME 'fdMailTemplateBody' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.2 NAME 'fdMailTemplateRDN' + DESC 'FusionDirectory - template Mail 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.88.1.3 NAME 'fdMTPasswordRecoveryMailSubject' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + + +attributetype ( 1.3.6.1.4.1.38414.88.1.4 NAME 'fdMTPasswordRecoveryMailBody' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.5 NAME 'fdMTPasswordRecoveryMail2Subject' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.6 NAME 'fdMTPasswordRecoveryMail2Body' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + + +attributetype ( 1.3.6.1.4.1.38414.88.1.8 NAME 'fdMailTemplateSignature' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.9 NAME 'fdMailTemplateAttachment' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.10 NAME 'fdMailTemplateReadReceipt' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +attributetype ( 1.3.6.1.4.1.38414.88.1.11 NAME 'fdMailTemplateSubject' + DESC 'FusionDirectory - template mail field' + EQUALITY octetStringMatch + SUBSTR caseIgnoreSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) + +# Attributes for mail template user reminder + +attributetype ( 1.3.6.1.4.1.38414.88.1.12 NAME 'fdMTUserReminderForwardAlert' + DESC 'FusionDirectory - Forward alerts to manager' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.13 NAME 'fdMTUserReminderForwardConfirmation' + DESC 'FusionDirectory - Forward postpone confirmations to manager' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.14 NAME 'fdMTUserReminderAlertSubject' + DESC 'Fusion Directory - User reminder alert email subject' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.15 NAME 'fdMTUserReminderAlertBody' + DESC 'Fusion Directory - User reminder alert email body' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.16 NAME 'fdMTUserReminderConfirmationSubject' + DESC 'Fusion Directory - User reminder confirmation email subject' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.17 NAME 'fdMTUserReminderConfirmationBody' + DESC 'Fusion Directory - User reminder confirmation email body' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.18 NAME 'fdMTUserReminderForwardPpolicyAlert' + DESC 'FusionDirectory - Forward ppolicy alerts to manager' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.19 NAME 'fdMTUserReminderPpolicyAlertSubject' + DESC 'Fusion Directory - User reminder ppolicy alert email subject' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.20 NAME 'fdMTUserReminderPpolicyAlertBody' + DESC 'Fusion Directory - User reminder ppolicy alert email body' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.21 NAME 'fdMTUserReminderExpirationSubject' + DESC 'Fusion Directory - User reminder expired email subject' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.22 NAME 'fdMTUserReminderExpirationBody' + DESC 'Fusion Directory - User reminder expired email body' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.23 NAME 'fdMTUserReminderForwardExpiration' + DESC 'FusionDirectory - User reminder, forward expiration emails to manager' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) + +# Attributes for mail template invitations + +attributetype ( 1.3.6.1.4.1.38414.88.1.24 NAME 'fdMTInvitationEmailSubject' + DESC 'FusionDirectory - Email Subject - Invitations' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.25 NAME 'fdMTInvitationEmailContent' + DESC 'FusionDirectory - Email Content - Invitation' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.88.1.26 NAME 'fdMTInvitationReplyTo' + DESC 'FusionDirectory - Email Address - Whom to Reply to invitations' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +##### Tasks Attributes ##### + +attributetype ( 1.3.6.1.4.1.38414.89.1.1 NAME 'fdTasksMailObject' + DESC 'Fusion Directory - Tasks for mail template objects' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.2 NAME 'fdTasksScheduleDate' + DESC 'Scheduling of the Task - required processed date' + EQUALITY caseExactIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.3 NAME 'fdTasksMailUsers' + DESC 'Fusion Directory - Tasks Mail Users Recipient' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.4 NAME 'fdTasksStatus' + DESC 'Fusion Directory - Task Status' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.5 NAME 'fdTasksEndDate' + DESC 'Fusion Directory - Task End Date' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.6 NAME 'fdTasksCreationDate' + DESC 'Fusion Directory - Task Start Date' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.7 NAME 'fdTasksEmailsFromDN' + DESC 'Fusion Directory - Emails derived from DN' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.8 NAME 'fdTasksEmailSender' + DESC 'Fusion Directory - Emails derived from DN' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.9 NAME 'fdTasksMailType' + DESC 'Fusion Directory - Type of Mail attribute required' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +##### Tasks Granular ##### + +attributetype ( 1.3.6.1.4.1.38414.89.1.10 NAME 'fdTasksGranularStatus' + DESC 'Fusion Directory - Task Status' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.11 NAME 'fdTasksGranularSchedule' + DESC 'Scheduling of the Task - required processed date' + EQUALITY caseExactIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.12 NAME 'fdTasksGranularMaster' + DESC 'Fusion Directory - Tasks Master objects' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.13 NAME 'fdTasksGranularType' + DESC 'Fusion Directory - Tasks Type' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.14 NAME 'fdTasksGranularMail' + DESC 'Fusion Directory - Emails recipients if object mail' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.15 NAME 'fdTasksGranularMailFrom' + DESC 'Fusion Directory - Emails sender if object mail' + EQUALITY caseExactMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) + +attributetype ( 1.3.6.1.4.1.38414.89.1.16 NAME 'fdTasksGranularRef' + DESC 'Fusion Directory - Reference towards a CN (E.g Mail Template)' + EQUALITY caseExactMatch + 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 DESC 'GOsa - Class to mark Departments for GOsa' @@ -130,3 +433,71 @@ objectclass ( 1.3.6.1.4.1.38414.62.2.2 NAME 'fdSubscriptionInformation' SUP top DESC 'FusionDirectory - Information about current subscription' MUST ( cn ) MAY ( uid $ fdSubscriptionStartDate $ fdSubscriptionEndDate $ fdSubscriptionType $ fdSubscriptionContractId $ fdSubscriptionName )) + +# Classes Macros Related + +objectclass ( 1.3.6.1.4.1.38414.90.2.1 NAME 'fdMacroConf' + DESC 'FusionDirectory Macro Configuration' + SUP top AUXILIARY + MUST ( cn ) + MAY ( fdMacroRDN $ fdMacroMail $ fdMacroInvitations $ fdMacroUserRecovery $ fdMacroUserReminder ) ) + +### Mail Template Related Object Class ### + +objectclass (1.3.6.1.4.1.38414.88.2.1 NAME 'fdMailTemplate' + DESC 'FusionDirectory - template mail object' + MUST ( cn $ fdMailTemplateBody $ fdMailTemplateSubject ) + MAY ( fdMailTemplateSignature $ fdMailTemplateReadReceipt $ fdMailTemplateAttachment ) ) + +objectclass (1.3.6.1.4.1.38414.88.2.2 NAME 'fdMailTemplateUserRecovery' + DESC 'FusionDirectory - template mail object Recovery' + SUP top AUXILIARY + MUST ( cn ) + MAY ( fdMTPasswordRecoveryMailSubject $ fdMTPasswordRecoveryMailBody $ fdMTPasswordRecoveryMail2Subject $ fdMTPasswordRecoveryMail2Body) ) + +objectclass ( 1.3.6.1.4.1.38414.88.2.3 NAME 'fdMailTemplateConf' + DESC 'FusionDirectory Mail Template Configuration' + SUP top AUXILIARY + MUST ( cn ) + MAY ( fdMailTemplateRDN ) ) + +objectclass ( 1.3.6.1.4.1.38414.88.2.4 NAME 'fdMailTemplateUserReminder' + DESC 'FusionDirectory mail template user-reminder' + SUP top AUXILIARY + MUST ( cn $ fdMTUserReminderForwardConfirmation $ fdMTUserReminderForwardAlert) + MAY ( + fdMTUserReminderConfirmationSubject $ fdMTUserReminderConfirmationBody $ + fdMTUserReminderAlertSubject $ fdMTUserReminderAlertBody $ + fdMTUserReminderPpolicyAlertSubject $ fdMTUserReminderPpolicyAlertBody $ + fdMTUserReminderForwardPpolicyAlert $ fdMTUserReminderExpirationSubject $ + fdMTUserReminderExpirationBody $ fdMTUserReminderForwardExpiration) ) + +objectclass ( 1.3.6.1.4.1.38414.88.2.5 NAME 'fdMailTemplateInvitations' + DESC 'FusionDirectory mail template Invitations' + SUP top AUXILIARY + MUST ( cn $ fdMTInvitationEmailSubject $ fdMTInvitationEmailContent) + MAY ( fdMTInvitationReplyTo ) ) + +### Tasks Related Object Class ### + +objectclass (1.3.6.1.4.1.38414.89.2.1 NAME 'fdTasks' + DESC 'FusionDirectory - Tasks objects' + MUST ( cn $ fdTasksStatus $ fdTasksCreationDate ) + MAY ( fdTasksScheduleDate $ fdTasksEndDate) ) + +objectclass (1.3.6.1.4.1.38414.89.2.2 NAME 'fdTasksMail' + DESC 'FusionDirectory - Tasks objects Mail' + SUP top AUXILIARY + MUST ( fdTasksMailObject $ fdTasksEmailSender ) + MAY ( fdTasksMailUsers $ fdTasksEmailsFromDN $ fdTasksMailType ) ) + +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/addons/dashboard/class_dashboard.inc b/plugins/addons/dashboard/class_dashboard.inc index 7de55de5f2b4c5dcc845e1b04cc4f53e81b93819..0b958b9c4f8a6a586c9bc9822f6472119bfec176 100644 --- a/plugins/addons/dashboard/class_dashboard.inc +++ b/plugins/addons/dashboard/class_dashboard.inc @@ -35,8 +35,8 @@ class dashboard extends simplePlugin 'mainAttr' => FALSE ] ], - 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 30]], - 'plPriority' => 0, + 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 40]], + 'plPriority' => 10, 'plProvidedAcls' => [ 'dashboard' => _('See dashboard') diff --git a/plugins/addons/mailtemplate/class_mailTemplate.inc b/plugins/addons/mailtemplate/class_mailTemplate.inc new file mode 100644 index 0000000000000000000000000000000000000000..7010fddf40c6c70d4e67da8b3ba1aaddde4fed1e --- /dev/null +++ b/plugins/addons/mailtemplate/class_mailTemplate.inc @@ -0,0 +1,88 @@ +<?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 mailTemplate extends simplePlugin +{ + var $displayHeader = FALSE; + + public static function plInfo (): array + { + return [ + 'plShortName' => _('Mail Template'), + 'plDescription' => _('Mail Tempmlate'), + 'plObjectClass' => ['fdMailTemplate'], + 'plFilter' => '(objectClass=fdMailTemplate)', + 'plObjectType' => ['mailTemplate' => [ + 'name' => _('Mail Template'), + 'ou' => get_ou('mailTemplateRDN'), + 'icon' => 'geticon.php?context=applications&icon=dsa&size=16', + ]], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + global $config; + return [ + // Attributes are grouped by section + 'mailTemplate' => [ + 'name' => _('Mail Object'), + 'attrs' => [ + new StringAttribute( + _('Mail Template Name'), _('Mail Template Name'), + 'cn', TRUE + ), + new StringAttribute( + _('Mail Subject'), _('Mail Subject'), + 'fdMailTemplateSubject', TRUE + ), + new TextAreaAttribute( + _('Mail Template Body'), _('Text to be sent to recipient'), + 'fdMailTemplateBody', TRUE + ), + new TextAreaAttribute( + _('Mail Signature'), _('Mail Signature'), + 'fdMailTemplateSignature', FALSE + ), + new FileDownloadAttribute( + _('Attachment'), _('Import a file for this e-mail'), + 'fdMailTemplateAttachment', FALSE, '', TRUE + ), + new BooleanAttribute( + _('Read Receipt'), + _('Read Receipt'), + 'fdMailTemplateReadReceipt', FALSE + ), + ] + ], + ]; + } + + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + + } + +} diff --git a/plugins/addons/tasks/class_tasks.inc b/plugins/addons/tasks/class_tasks.inc new file mode 100644 index 0000000000000000000000000000000000000000..2cf626fc0c6d21ff744aa6a46c6f58ba91f44267 --- /dev/null +++ b/plugins/addons/tasks/class_tasks.inc @@ -0,0 +1,84 @@ +<?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 tasks extends simplePlugin +{ + protected $displayHeader = FALSE; + + static function plInfo (): array + { + return [ + 'plShortName' => _('Tasks'), + 'plDescription' => _('Tasks'), + 'plObjectClass' => ['fdTasks'], + 'plFilter' => '(objectClass=fdTasks)', + 'plPriority' => 41, + 'plObjectType' => ['tasks' => [ + 'name' => _('Tasks'), + 'ou' => get_ou('tasksRDN'), + 'icon' => 'geticon.php?context=applications&icon=dsa&size=16', + ]], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + return [ + // Attributes are grouped by section + 'tasks' => [ + 'name' => _('Tasks Generic | Saving will create un-modifiable subtasks'), + 'attrs' => [ + new StringAttribute( + _('Task Name'), _('Name for this task'), + 'cn', TRUE + ), + new DateTimeAttribute( + _('Schedule'), '', + 'fdTasksScheduleDate', FALSE + ), + + new HiddenAttribute('fdTasksStatus', TRUE, '1', '', 'Status', 'Status of the task'), + new HiddenAttribute('fdTasksCreationDate', TRUE, date("Y-m-d h:i:sa"), '', 'StartDate', 'Start Date And Time Of A Task'), + ] + ], + 'subTasks' => [ + 'name' => _('Creation of Sub Tasks - Starting this task'), + 'attrs' => [ + new BooleanAttribute( + _('Activate SubTasks'), _('Trigger the creation of this task and related subtasks'), + 'fdSubTasksActivation', FALSE + ), + ] + ], + ]; + } + + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + + $this->attributesAccess['fdSubTasksActivation']->setInLdap(FALSE); + } + +} diff --git a/plugins/addons/tasks/class_tasksGranular.inc b/plugins/addons/tasks/class_tasksGranular.inc new file mode 100644 index 0000000000000000000000000000000000000000..fec3e35248b928cf0d803ee7e8f8d68833475fdc --- /dev/null +++ b/plugins/addons/tasks/class_tasksGranular.inc @@ -0,0 +1,84 @@ +<?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 tasksGranular extends simplePlugin +{ + + static function plInfo (): array + { + return [ + 'plShortName' => _('Tasks Granular'), + 'plDescription' => _('Granular tasks mangement allowing details reports'), + 'plObjectClass' => ['fdTasksGranular'], + 'plFilter' => '(objectClass=fdTasksGranular)', + 'plPriority' => 41, + 'plObjectType' => ['tasksGranular' => [ + 'name' => _('TasksGranular'), + 'ou' => get_ou('tasksRDN'), + 'icon' => 'geticon.php?context=applications&icon=dsa&size=16', + ]], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + /* + * Info : getAttributesInfo return is important for the management class. + * It is the return of that method which render the columns and data properly. + * Although not used by the interface directly, it is created by simpleTab during + * the save of mailTasks. + */ + static function getAttributesInfo (): array + { + return [ + // Attributes are grouped by section + 'tasksGranular' => [ + 'name' => _('Tasks Granular'), + 'attrs' => [ + new StringAttribute( + _('Task Granular Name'), _('Name for this task'), + 'cn', TRUE + ), + new HiddenAttribute('fdTasksGranularStatus', TRUE, '1', '', 'Status', 'Status of the task'), + new HiddenAttribute('fdTasksGranularMaster', TRUE, '', '', 'Master CN', 'Name of the Master task'), + new HiddenAttribute('fdTasksGranularType', TRUE, '', '', 'Type', 'Type of the task'), + new HiddenAttribute('fdTasksGranularRef', TRUE, '', '', 'Type', 'Reference towards a required CN (mail template E.g'), + new MailAttribute( + _('Email'), + _('Email address which will be sent to'), 'fdTasksGranularMail', TRUE), + new MailAttribute( + _('Email'), + _('Email address which will be sent from'), 'fdTasksGranularMailFrom', TRUE), + new DateTimeAttribute( + _('Schedule'), '', + 'fdTasksGranularSchedule', FALSE + ) + ] + ] + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + } + +} diff --git a/plugins/addons/tasks/class_tasksMail.inc b/plugins/addons/tasks/class_tasksMail.inc new file mode 100644 index 0000000000000000000000000000000000000000..51b111731b93214b77d61279669c9d8634922ff7 --- /dev/null +++ b/plugins/addons/tasks/class_tasksMail.inc @@ -0,0 +1,276 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org) + + Copyright (C) 2018-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 tasksMail extends simplePlugin +{ + protected $displayHeader = TRUE; + + static function plInfo (): array + { + return [ + 'plShortName' => _('Tasks Mail'), + 'plDescription' => _('Tasks Mail Object'), + 'plIcon' => 'geticon.php?context=applications&icon=supann&size=48', + 'plSmallIcon' => 'geticon.php?context=applications&icon=supann-status&size=16', + 'plPriority' => 42, + 'plObjectClass' => ['fdTasksMail'], + 'plFilter' => '(objectClass=fdTasksMail)', + 'plObjectType' => ['tasks'], + 'plConflicts' => [''], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()), + 'plForeignKeys' => [ + 'fdTasksMailUsers' => [ + ['user','dn','fdTasksMailUsers=%oldvalue%','*'] + ] + ], + ]; + } + + static function getAttributesInfo (): array + { + return [ + // Attributes are grouped by section + 'taskMail' => [ + 'name' => _('Task Mail Object'), + 'attrs' => [ + new SelectAttribute( + _('Mail Template'), _('Mail Template Object Selection'), + 'fdTasksMailObject', FALSE + ), + new HiddenArrayAttribute('fdTasksEmailsFromDN', FALSE, ''), + ] + ], + 'From Component' => [ + 'name' => _('Sender Address'), + 'attrs' => [ + new MailAttribute( + _('Sender email address'), + _('Email address from which mails will be sent'), 'fdTasksEmailSender', TRUE, 'to.be@chang.ed'), + ] + ], + 'UserGroupSelection' => [ + 'name' => _('Recipients Users and/or Groups'), + 'attrs' => [ + new UsersGroupsRolesAttribute( + _('Members'), _('Users or groups to assign to this task.'), + 'fdTasksMailUsers', TRUE + ), + ], + ], + 'tasksMailType' => [ + 'name' => _('Type of e-mail address desired'), + 'attrs' => [ + new SelectAttribute( + _('Mail Type - If not found, priority will apply'), _('Mail Type Object Selection'), + 'fdTasksMailType', FALSE + ), + ], + ] + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + + //Search within LDAP and retrieve all mail objects for current base. + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + $ldap->search('(&(objectClass=fdMailTemplate))', ['cn']); + $tmpSearch = []; + while ($attrs = $ldap->fetch()) { + $tmpSearch[$attrs['cn'][0]] = $attrs['cn'][0]; + } + asort($tmpSearch); + $this->attributesAccess['fdTasksMailObject']->setChoices(array_keys($tmpSearch), array_values($tmpSearch)); + + $mailAttrTypes = [ + 'mail' => 'mail - [gosaMailAccount primary]', + 'gosaMailAlternateAddress' => 'gosaMailAlternateAddress', + 'gosaMailForwardingAddress' => 'gosaMailForwardingAddress', + 'supannAutreMail' => 'supannAutreMail', + 'supannMailPerso' => 'supannMailPerso', + 'supannMailPrive' => 'supannMailPrive' + ]; + + $this->attributesAccess['fdTasksMailType']->setChoices(array_keys($mailAttrTypes), array_values($mailAttrTypes)); + + } + + /* + * Must return bool to be compliant with the interface + * Allows attributes values based on others to be updated before save. + */ + public function update (): bool + { + parent::update(); + + // get the value of type mail desired and if null set default + $mailAttr = $this->attributesAccess['fdTasksMailType']->getValue(); + if (empty($mailAttr)) { + $mailAttr = 'mail'; + } + + // create a method which return the objectype and attribute names required + $mailObject = $this->getMailObject($mailAttr); + + // send the objectype and attrs name to the below method + $this->setEmailsFromSelectedDN($mailObject, $mailAttr); + + return TRUE; + } + + /* + * Return the objectype searched for by setEmailFromSelectedDN + */ + public function getMailObject (string $mailAttr) : string + { + switch ($mailAttr) { + case 'mail' : + case 'gosaMailAlternateAddress' : + case 'gosaMailForwardingAddress': + return 'gosaMailAccount'; + + case 'supannAutreMail' : + case 'supannMailPerso' : + case 'supannMailPrive' : + return 'supannPerson'; + + default : + return 'gosaMailAccount'; + } + } + + /* + * Populate the fdTasksEmailsFromDN attribute with related mails addresses. + */ + public function setEmailsFromSelectedDN ($mailObject, $mailAttr) : void + { + global $config; + + $ldap = $config->get_ldap_link(); + $attributeValue = $this->attributesAccess['fdTasksMailUsers']->getValue(); + + if ($attributeValue && !empty($attributeValue)) { + + $mailList = []; + + foreach ($this->attributesAccess['fdTasksMailUsers']->getValue() as $dn) { + + $ldap->cd($dn); + + // filter and attributes should be equals to the arguments passed to this method + $filter = "(objectClass=$mailObject)"; + $attrs = [$mailAttr]; + + $ldap->search($filter, $attrs); + $info = $ldap->fetch(); + + if (!empty($info[$mailAttr][0]) && isset($info[$mailAttr][0])) { + // In case of private supann mail, remove the prefix + $mailList[] = preg_replace('/.+?(?=supann)/', '', $info[$mailAttr][0]); + + // A possible enhancement is to recall itself with another mailObject / attr + } + } + $this->attributesAccess['fdTasksEmailsFromDN']->setValue(array_values($mailList)); + } + } + + function save (): array + { + $execTasks = $this->parent->getBaseObject()->fdSubTasksActivation ?? NULL; + + if ($execTasks) { + $this->generateSlaveTasks(); + } + + $errors = parent::save(); + return $errors; + } + + /* + * Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated. + * It would be dangerous to edit subs tasks if some are under processed already. + */ + public function generateSlaveTasks () + { + $emails = $this->attributesAccess['fdTasksEmailsFromDN']->getValue(); + // Ref is supposed to be the mail object CN in this class + $ref = $this->attributesAccess['fdTasksMailObject']->getValue(); + $from = $this->attributesAccess['fdTasksEmailSender']->getValue(); + // Incremental id allowing creation of different CN for sub tasks + $id = 0; + + // Take the attribute from the other tabs - attribute cannot be null or unset by default + $schedule = $this->parent->getBaseObject()->fdTasksScheduleDate ?? NULL; + + if (isset($emails) && !empty($emails)) { + foreach ($emails as $email) { + $id ++; + + // Here we create the object taskGranular + $tabObject = objects::create('TasksGranular'); + + // remove 'dn' keeping only 'cn' + $rmDn = preg_replace('/(?=,).*/', '', $this->dn); + + // only take the cn without dc + preg_match('/cn=(.*)/', $rmDn, $matches); + + $subTaskName = $matches[1].'-SubTask-'.$id; + + $values['tasksGranular'] = [ + "cn" => $subTaskName, + "fdTasksGranularType" => 'Mail Object', + "fdTasksGranularMaster" => $this->dn, + "fdTasksGranularMail" => $email, + "fdTasksGranularSchedule" => $schedule, + "fdTasksGranularRef" => $ref, + "fdTasksGranularMailFrom" => $from + ]; + + foreach ($values as $tab => $tabvalues) { + if (!isset($tabObject->by_object[$tab])) { + echo "Error tab does not contains attributes values" .PHP_EOL; + } + $error = $tabObject->by_object[$tab]->deserializeValues($tabvalues); + if ($error !== TRUE) { + echo 'Error during deserializing' .$error .PHP_EOL; + } + + $tabObject->current = $tab; + $tabObject->update(); + $tabObject->loadTabs(); + } + + $errors = $tabObject->save(); + + // Showing errors should be better, enhancement here required. + if (!empty($errors)) { + $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName))); + $show_error->display(); + } + } + } + } +} diff --git a/plugins/admin/mailtemplate/class_mailTemplateManagement.inc b/plugins/admin/mailtemplate/class_mailTemplateManagement.inc new file mode 100644 index 0000000000000000000000000000000000000000..f211ee33e68752f8e80ee13fe67b105787ee904d --- /dev/null +++ b/plugins/admin/mailtemplate/class_mailTemplateManagement.inc @@ -0,0 +1,159 @@ +<?php + +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2011-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 mailTemplateManagement extends management +{ + + public static $columns = [ + ['ObjectTypeColumn', []], + ['LinkColumn', ['attributes' => 'cn', 'label' => 'Template Name']], + ['ActionsColumn', ['label' => 'Actions']], + ]; + + static function plInfo (): array + { + return [ + 'plShortName' => _('Mail Template'), + 'plTitle' => _('Mail Template'), + 'plDescription' => _('Manages mails templates'), + 'plIcon' => 'geticon.php?context=types&icon=user&size=48', + 'plManages' => ['mailTemplate'], + 'plSection' => 'conf', + 'plPriority' => 30, + 'plProvidedAcls' => [], + ]; + } + + protected function configureActions () + { + global $config; + + $createMenu = []; + + foreach ($this->objectTypes as $type) { + $infos = objects::infos($type); + $img = 'geticon.php?context=actions&icon=document-new&size=16'; + if (isset($infos['icon'])) { + $img = $infos['icon']; + } + $createMenu[] = new Action( + 'new_'.$type, $infos['name'], $img, + '0', 'newEntry', + [$infos['aclCategory'].'/'.$infos['mainTab'].'/c'] + ); + } + + $this->registerAction( + new SubMenuAction( + 'new', _('Create'), 'geticon.php?context=actions&icon=document-new&size=16', + $createMenu + ) + ); + + // Add export actions + $exportMenu = []; + foreach ($this->exporters as $action => $exporter) { + $exportMenu[] = new Action( + $action, $exporter['label'], $exporter['image'], + '0', 'export' + ); + } + $this->registerAction( + new SubMenuAction( + 'export', _('Export list'), 'geticon.php?context=actions&icon=document-export&size=16', + $exportMenu + ) + ); + + $this->registerAction( + new Action( + 'edit', _('Edit'), 'geticon.php?context=actions&icon=document-edit&size=16', + '+', 'editEntry' + ) + ); + $this->actions['edit']->setSeparator(TRUE); + + if (!$this->skipCpHandler) { + $this->registerAction( + new Action( + 'cut', _('Cut'), 'geticon.php?context=actions&icon=edit-cut&size=16', + '+', 'copyPasteHandler', + ['dr'] + ) + ); + $this->registerAction( + new Action( + 'copy', _('Copy'), 'geticon.php?context=actions&icon=edit-copy&size=16', + '+', 'copyPasteHandler', + ['r'] + ) + ); + $this->registerAction( + new Action( + 'paste', _('Paste'), 'geticon.php?context=actions&icon=edit-paste&size=16', + '0', 'copyPasteHandler', + ['w'] + ) + ); + $this->actions['paste']->setEnableFunction([$this, 'enablePaste']); + } + + $this->registerAction( + new Action( + 'remove', _('Remove'), 'geticon.php?context=actions&icon=edit-delete&size=16', + '+', 'removeRequested', + ['d'] + ) + ); + + if (!static::$skipSnapshots && ($config->get_cfg_value('enableSnapshots') == 'TRUE')) { + $this->registerAction( + new Action( + 'snapshot', _('Create snapshot'), 'geticon.php?context=actions&icon=snapshot&size=16', + '1', 'createSnapshotDialog', + ['/SnapshotHandler/c'] + ) + ); + $this->registerAction( + new Action( + 'restore', _('Restore snapshot'), 'geticon.php?context=actions&icon=document-restore&size=16', + '*', 'restoreSnapshotDialog', + ['w', '/SnapshotHandler/r'] + ) + ); + $this->actions['snapshot']->setSeparator(TRUE); + $this->actions['restore']->setEnableFunction([$this, 'enableSnapshotRestore']); + } + + + /* Actions from footer are not in any menus and do not need a label */ + $this->registerAction(new HiddenAction('apply', 'applyChanges')); + $this->registerAction(new HiddenAction('save', 'saveChanges')); + $this->registerAction(new HiddenAction('cancel', 'cancelEdit')); + $this->registerAction(new HiddenAction('cancelDelete', 'cancelEdit')); + $this->registerAction(new HiddenAction('removeConfirmed', 'removeConfirmed')); + if (!$this->skipConfiguration) { + $this->registerAction(new HiddenAction('configure', 'configureDialog')); + } + } + + +} diff --git a/plugins/admin/tasks/class_tasksColumn.inc b/plugins/admin/tasks/class_tasksColumn.inc new file mode 100644 index 0000000000000000000000000000000000000000..85a7fa3b0b1d290d86c9e8abfc224cd2dd05151b --- /dev/null +++ b/plugins/admin/tasks/class_tasksColumn.inc @@ -0,0 +1,91 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2011-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. +*/ + +/*! + * \brief Column rendering Tasks columns + */ +class TasksColumn extends Column +{ + // Keep in mind this method is being called for each value. + protected function renderSingleValue (ListingEntry $entry, string $value): string + { + if ($value == '') { + return ' '; + } else { + switch ($this->attributes[0]) { + case 'fdTasksStatus': + return static::filterStatus($value); + + case 'fdTasksGranularStatus': + return static::filterStatus($value); + + // This case needs optimization + case 'fdTasksMailObject': + return "Mail Object"; + + case 'fdTasksScheduleDate': + return static::generateDateFormat($value); + + case 'fdTasksGranularSchedule': + return static::generateDateFormat($value); + + case 'fdTasksGranularMaster': + return static::generateMasterTaskName($value); + + default: + return parent::renderSingleValue($entry, $value); + } + } + } + + static function filterStatus (string $status = NULL): string + { + // A call towards a status map would be interesting here. + switch ($status) { + case "1" : + return "Created"; + + case "2" : + return "Processed"; + + default : + return $status; + } + } + + static function generateDateFormat ($value) : string + { + // Z is added to value to match ldap generaliseztime + $datetime = (new LdapGeneralizedTime)->fromString($value.'Z'); + $result = $datetime->format('Y-m-d H:i:s'); + return $result; + } + + static function generateMasterTaskName ($value) : string + { + // remove 'dn' keeping only 'cn' + $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 new file mode 100644 index 0000000000000000000000000000000000000000..735a07e88845d290d13363a3052db1254dde68ec --- /dev/null +++ b/plugins/admin/tasks/class_tasksDashboard.inc @@ -0,0 +1,135 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2011-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 tasksDashboard extends management +{ + + function __construct ($objectTypes = FALSE, array $filterElementDefinitions = [['TabFilterElement', []],]) + { + parent::__construct($objectTypes, $filterElementDefinitions); + + // Alllow the creation of custom filtering + $this->setupFilters(); + } + + // Actions collumn are removed compared to parent. + public static $columns = [ + ['Column', ['attributes' => 'cn', 'label' => 'Tasks']], + ['TasksColumn', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']], + ['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']], + ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], + ['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], + ['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], + ['ActionsColumn', ['label' => 'Actions']], + ]; + + // No modification tools are required. + protected $skipCpHandler = TRUE; + public static $skipSnapshots = TRUE; + public static $skipTemplates = TRUE; + + static function plInfo () + { + return [ + 'plShortName' => _('Tasks Dashboard'), + 'plDescription' => _('Provide a reporting mechanism for tasks'), + 'plTitle' => _('Tasks Dashboard'), + 'plIcon' => 'geticon.php?context=applications&icon=argonaut&size=48', + 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 40]], + 'plPriority' => 10, + 'plManages' => ['tasksGranular'], + 'plProvidedAcls' => [], + ]; + } + + // Allowing us to add additional actions and remove unrequired ones. + protected function configureActions () + { + $this->registerAction( + new Action( + 'tasksRenew', + _('Renew the selected task'), + 'geticon.php?context=actions&icon=view-refresh&size=16', + '+', + 'tasksRenew' + ) + ); + + $this->actions['tasksRenew']->setSeparator(TRUE); + $this->actions['tasksRenew']->setEnableFunction([$this, 'setTasksActionStatus']); + + } + + // This method is triggered by the user action click on tasksRenew + function tasksRenew (array $action) + { + foreach ((array)$action['targets'] as $dn) { + $this->tasksUpdate($dn); + } + } + + function tasksUpdate ($dn) + { + $tabObject = objects::open($dn, 'tasksGranular'); + $tabObject->by_object['tasksGranular']->attributesAccess['fdTasksGranularStatus']->setValue(1); + $errors = $tabObject->save(); + + if (!empty($errors)) { + $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error updating: "%s" !.'), $dn))); + $show_error->display(); + } + } + + // This method is triggered during initiation of the dashboard, allowing proper icons status + function setTasksActionStatus () : BOOL + { + return TRUE; + } + + function setupFilters () + { + // array of states allowing proper filtering + $status = [ + 'Completed' => [ + 'name' => 'Completed tasks', + 'filter' => '(fdTasksGranularStatus=2)', + 'icon' => 'geticon.php?context=actions&icon=add&size=16', + ], + 'Scheduled' => [ + 'name' => 'Scheduled tasks', + 'filter' => '(fdTasksGranularStatus=1)', + 'icon' => 'geticon.php?context=actions&icon=system-update&size=16', + ], + 'Failed' => [ + 'name' => 'Failed tasks', + // filter status must be updated if the status strategy changes + 'filter' => '(!(|(fdTasksGranularStatus=1)(fdTasksGranularStatus=2)))', + 'icon' => 'geticon.php?context=actions&icon=remove&size=16', + ], + ]; + + $this->filter->addElement(new CheckBoxesFilterElement($this->filter, _('Status'), $status, '|')); + } + + // End of Class +} + + + diff --git a/plugins/admin/tasks/class_tasksManagement.inc b/plugins/admin/tasks/class_tasksManagement.inc new file mode 100644 index 0000000000000000000000000000000000000000..0b95d5ca7268d908eec82568cdfcb8f1af983a01 --- /dev/null +++ b/plugins/admin/tasks/class_tasksManagement.inc @@ -0,0 +1,59 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2011-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 tasksManagement extends management +{ + + protected $skipCpHandler = TRUE; + + /* + * LinkColumn exists by class collumn + * TasksColumn is a new class for Tasks bassed on argonaut column definition + */ + public static $columns = [ + ['LinkColumn', ['attributes' => 'cn', 'label' => 'Tasks']], + //below fdTasksMailObject must be change to have a type defined within task creation (new ldap attributes ?hidden) + ['TasksColumn', ['attributes' => 'fdTasksMailObject', 'label' => 'Types']], + ['Column', ['attributes' => 'fdTasksCreationDate', 'label' => 'Creation Date']], + ['TasksColumn', ['attributes' => 'fdTasksScheduleDate', 'label' => 'Scheduled']], + ['ActionsColumn', ['label' => 'Actions']], + ]; + + static function plInfo () + { + return [ + 'plShortName' => _('Tasks'), + 'plDescription' => _('Provide a mechanism to create and manage tasks'), + 'plTitle' => _('Tasks'), + 'plIcon' => 'geticon.php?context=applications&icon=argonaut&size=48', + 'plSection' => 'conf', + 'plPriority' => 40, + 'plManages' => ['tasks'], + 'plProvidedAcls' => [], + ]; + } + + protected function setUpListing () + { + /* Set baseMode to FALSE */ + $this->listing = new managementListing($this, FALSE); + } + +} diff --git a/plugins/config/class_macroConfig.inc b/plugins/config/class_macroConfig.inc new file mode 100644 index 0000000000000000000000000000000000000000..656647444907a250027c2388b5c3c28793eced80 --- /dev/null +++ b/plugins/config/class_macroConfig.inc @@ -0,0 +1,100 @@ +<?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 macrosConfig extends simplePlugin +{ + static function plInfo (): array + { + return [ + 'plShortName' => _('Macro'), + 'plDescription' => _('FusionDirectory macro configuration tool'), + 'plObjectClass' => ['fdMacroConf'], + 'plObjectType' => ['configuration'], + + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + return [ + 'macrosConf' => [ + 'name' => _('Macros'), + 'attrs' => [ + new StringAttribute( + _('Macros RDN'), _('Branch in which Directory Base, Macro will be stored'), + 'fdMacroRDN', TRUE, + 'ou=macroConfig' + ), + ] + ], + 'Macro' => [ + 'name' => _('Mail Object'), + 'attrs' => [ + new SetAttribute( + new CompositeAttribute( + _('Macro definitions'), + 'fdMacroMail', + [ + new SelectAttribute( + '', _('Macro type'), + 'fdMacroTypes', TRUE + ), + new StringAttribute( + _('Macros User Definition'), _('Macro that will be used'), + 'fdMacroOption', TRUE, '' + ), + ], + '/^{(.+)}(.*)$/', + '{%s}%s', + '', + _('Macro settings (wrap the macro with % sign)') + ) + ), + ] + ], + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + + parent::__construct($dn, $object, $parent, $mainTab); + + /* supannTelephonePrive */ + $MacroTypes = [ + 'LOGIN' => _('Login'), + 'UID' => _('UID'), + 'TOKEN' => _('Token'), + ]; + foreach ($config->get_cfg_value('MacroTypes', []) as $line) { + list($type,$label) = explode(':', $line, 2); + $MacroTypes[$type] = $label; + } + $this->attributesAccess['fdMacroMail']->attribute->attributes[0]->setChoices( + array_keys($MacroTypes), + array_values($MacroTypes) + ); + + } + +} + diff --git a/plugins/config/class_mailTemplateConfig.inc b/plugins/config/class_mailTemplateConfig.inc new file mode 100644 index 0000000000000000000000000000000000000000..a1a2e8957ed6635ba889de9367e8a2fa09ef0f8f --- /dev/null +++ b/plugins/config/class_mailTemplateConfig.inc @@ -0,0 +1,52 @@ +<?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 Directory Base, mails templates will be stored'), + 'fdMailTemplateRDN', TRUE, + 'ou=mailTemplate' + ), + ] + ], + ]; + } +} + diff --git a/plugins/config/class_tasksConfig.inc b/plugins/config/class_tasksConfig.inc new file mode 100644 index 0000000000000000000000000000000000000000..313a9925b86b988abe4f75f01efabbfe1785fb83 --- /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); + + } + +} +