diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index dead589e6b92b741dc2a81bba4973de7b3566eaf..b74c4544eb92b868c09c74d2e48758276f9db21e 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -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 ) ) diff --git a/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc b/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc index 72d75d473c5976c1211b8e001d63e113a406b143..131988663dac7df939786691bc580bf694766cc6 100644 --- a/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc +++ b/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc @@ -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; } - }