From 56765b8119d129cccdd392b337394824c722a349 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Tue, 31 Oct 2023 18:39:35 +0000 Subject: [PATCH] :sparkles: (Mail) - sub nodes attachments Adds subnodes attachments during first creation. Apply or update has to be fixed. --- contrib/openldap/core-fd.schema | 11 ++- .../mailtemplate/class_mailTemplate.inc | 86 ++++++++++++------- 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index a90e63149..b64b48bef 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -121,8 +121,8 @@ attributetype ( 1.3.6.1.4.1.38414.62.1.7 NAME 'fdMailTemplateSignature' SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) -attributetype ( 1.3.6.1.4.1.38414.62.1.8 NAME 'fdMailTemplateAttachment' - DESC 'FusionDirectory - template mail field' +attributetype ( 1.3.6.1.4.1.38414.62.1.8 NAME 'fdMailAttachmentsContent' + DESC 'FusionDirectory - attachment data in bin format' EQUALITY octetStringMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) @@ -447,8 +447,13 @@ objectclass (1.3.6.1.4.1.38414.62.2.3 NAME 'fdPluginManager' objectclass (1.3.6.1.4.1.38414.62.2.4 NAME 'fdMailTemplate' DESC 'FusionDirectory - template mail object' + SUP top STRUCTURAL MUST ( cn $ fdMailTemplateBody $ fdMailTemplateSubject ) - MAY ( fdMailTemplateSignature $ fdMailTemplateReadReceipt $ fdMailTemplateAttachment ) ) + MAY ( fdMailTemplateSignature $ fdMailTemplateReadReceipt)) + +objectclass (1.3.6.1.4.1.38414.62.2.10 NAME 'fdMailAttachments' + DESC 'FusionDirectory - mail template attachments' + MUST ( cn $ fdMailAttachmentsContent )) objectclass ( 1.3.6.1.4.1.38414.62.2.5 NAME 'fdMailTemplateConf' DESC 'FusionDirectory Mail Template Configuration' diff --git a/plugins/configuration/mailtemplate/class_mailTemplate.inc b/plugins/configuration/mailtemplate/class_mailTemplate.inc index e447ae0a3..048f2cb96 100644 --- a/plugins/configuration/mailtemplate/class_mailTemplate.inc +++ b/plugins/configuration/mailtemplate/class_mailTemplate.inc @@ -26,14 +26,14 @@ class mailTemplate extends simplePlugin public static function plInfo (): array { return [ - 'plShortName' => _('Mail Template'), + 'plShortName' => _('Mail Template'), 'plDescription' => _('Mail Template'), 'plObjectClass' => ['fdMailTemplate'], - 'plFilter' => '(objectClass=fdMailTemplate)', - 'plObjectType' => ['mailTemplate' => [ - 'name' => _('Mail Template'), - 'ou' => get_ou('mailTemplateRDN'), - 'icon' => 'geticon.php?context=applications&icon=mail-template&size=16', + 'plFilter' => '(objectClass=fdMailTemplate)', + 'plObjectType' => ['mailTemplate' => [ + 'name' => _('Mail Template'), + 'ou' => get_ou('mailTemplateRDN'), + 'icon' => 'geticon.php?context=applications&icon=mail-template&size=16', ]], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) ]; @@ -45,33 +45,46 @@ class mailTemplate extends simplePlugin return [ // Attributes are grouped by section 'mailTemplate' => [ - 'name' => _('Mail Object'), + '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 - ), + 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 BooleanAttribute( + _('Read Receipt'), + _('Read Receipt'), + 'fdMailTemplateReadReceipt', FALSE + ), + new SubNodesAttribute( + '', _('Attachments'), + 'attachments', ['fdMailAttachments'], + [ + new StringAttribute( + _('Name'), _('The name of the attachment file'), + 'cn', TRUE + ), + new FileDownloadAttribute( + _('Attachment'), _('Import a file for this e-mail'), + 'fdMailAttachmentsContent', FALSE, '', TRUE + ), + ], + FALSE, /* no order */ + [], + TRUE /* edit enabled */ + ), ] ], ]; @@ -85,4 +98,13 @@ class mailTemplate extends simplePlugin } + function ldap_save (): array + { + global $config; + $errors = parent::ldap_save(); + $this->attributesAccess['attachments']->postLdapSave($config->get_ldap_link()); + return $errors; + } + + } -- GitLab