Verified Commit 3553abe2 authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(MailTemplate) - Adds proper fields for Invitations

Add invitations fields and verifications of mail list imported.
Adapts the core-fd.schema.
Showing with 73 additions and 15 deletions
+73 -15
......@@ -160,7 +160,6 @@ attributetype ( 1.3.6.1.4.1.38414.88.1.11 NAME 'fdMailTemplateSubject'
# 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
......@@ -233,6 +232,31 @@ attributetype ( 1.3.6.1.4.1.38414.88.1.23 NAME 'fdMTUserReminderForwardExpiratio
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 )
attributetype ( 1.3.6.1.4.1.38414.88.1.27 NAME 'fdMTInvitationEmailList'
DESC 'FusionDirectory - Lists of emails registered - received'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-VALUE )
# Classes
objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.4 NAME 'gosaDepartment' SUP top AUXILIARY
......@@ -300,3 +324,9 @@ objectclass ( 1.3.6.1.4.1.38414.88.2.4 NAME 'fdMailTemplateUserReminder'
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 $ fdMTInvitationEmailList ) )
......@@ -42,7 +42,34 @@ class mailTemplateInvitations extends simplePlugin
static function getAttributesInfo (): array
{
return [
'main' => [
'name' => _('Invitation'),
'attrs' => [
new StringAttribute(
_('Email subject'), _('Subject of the email sent for this invitation'),
'fdMTInvitationEmailSubject', TRUE
),
new TextAreaAttribute(
_('Email content'), _('Content of the email sent for this invitation'),
'fdMTInvitationEmailContent', TRUE,
'A default Email here - was previously fetched by default configuration'
),
]
],
'emails' => [
'name' => _('Emails'),
'attrs' => [
new StringAttribute(
_('Reply to'), _('Email address set as "Reply to" in the sent emails'),
'fdMTInvitationReplyTo', FALSE
),
new FileTextAreaAttribute(
_('Emails'), _('List of email adresses of people to invite - one per line'),
'fdMTInvitationEmailList', FALSE,
'.txt', TRUE, FALSE
),
]
]
];
}
......@@ -52,23 +79,24 @@ class mailTemplateInvitations extends simplePlugin
parent::__construct($dn, $object, $parent, $mainTab);
}
protected function shouldSave (): bool
/*
* Used to verify if the list of emails imported by the mails_file are correct emails format.
*
*/
function check (): array
{
global $config;
$errors = parent::check();
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search('(&(objectClass=fdMailTemplateInvitations))', ['cn','fdMailTemplateInvitations']);
while ($attrs = $ldap->fetch()) {
if (isset($this->attrs['fdMailTemplateInvitations'])) {
$error = new FusionDirectoryError(htmlescape(sprintf(_('Invitations Mail Template Is Already Existing!'))));
$error->display();
return FALSE;
$emails = explode("\n", $this->fdMTInvitationEmailList);
foreach ($emails as $email) {
if (!tests::is_email($email)) {
$errors[] = new SimplePluginCheckError(
$this->attributesAccess['fdMTInvitationEmailList'],
htmlescape(sprintf(_('"%s" is not a valid email address'), $email))
);
}
}
return TRUE;
return $errors;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment