Verified Commit 5c4484ee authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(MailTemplate) - Adds User Reminder

Adds user reminder capability as well as adding conflict between
user recovery and itself. Disallowing the activation of the tab.
Showing with 241 additions and 2 deletions
+241 -2
...@@ -158,6 +158,81 @@ attributetype ( 1.3.6.1.4.1.38414.88.1.11 NAME 'fdMailTemplateSubject' ...@@ -158,6 +158,81 @@ attributetype ( 1.3.6.1.4.1.38414.88.1.11 NAME 'fdMailTemplateSubject'
SUBSTR caseIgnoreSubstringsMatch SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40) 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 )
# Classes # Classes
objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.4 NAME 'gosaDepartment' SUP top AUXILIARY objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.4 NAME 'gosaDepartment' SUP top AUXILIARY
...@@ -203,7 +278,6 @@ objectclass (1.3.6.1.4.1.38414.88.2.1 NAME 'fdMailTemplate' ...@@ -203,7 +278,6 @@ objectclass (1.3.6.1.4.1.38414.88.2.1 NAME 'fdMailTemplate'
MUST ( cn $ fdMailTemplateBody $ fdMailTemplateSubject ) MUST ( cn $ fdMailTemplateBody $ fdMailTemplateSubject )
MAY ( fdMailTemplateSignature $ fdMailTemplateReadReceipt $ fdMailTemplateAttachment ) ) MAY ( fdMailTemplateSignature $ fdMailTemplateReadReceipt $ fdMailTemplateAttachment ) )
objectclass (1.3.6.1.4.1.38414.88.2.2 NAME 'fdMailTemplateUserRecovery' objectclass (1.3.6.1.4.1.38414.88.2.2 NAME 'fdMailTemplateUserRecovery'
DESC 'FusionDirectory - template mail object Recovery' DESC 'FusionDirectory - template mail object Recovery'
SUP top AUXILIARY SUP top AUXILIARY
...@@ -215,3 +289,14 @@ objectclass ( 1.3.6.1.4.1.38414.88.2.3 NAME 'fdMailTemplateConf' ...@@ -215,3 +289,14 @@ objectclass ( 1.3.6.1.4.1.38414.88.2.3 NAME 'fdMailTemplateConf'
SUP top AUXILIARY SUP top AUXILIARY
MUST ( cn ) MUST ( cn )
MAY ( fdMailTemplateRDN ) ) 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) )
...@@ -34,6 +34,7 @@ class mailTemplateUserRecovery extends simplePlugin ...@@ -34,6 +34,7 @@ class mailTemplateUserRecovery extends simplePlugin
'plObjectClass' => ['fdMailTemplateUserRecovery'], 'plObjectClass' => ['fdMailTemplateUserRecovery'],
'plFilter' => '(objectClass=fdMailTemplateUserRecovery)', 'plFilter' => '(objectClass=fdMailTemplateUserRecovery)',
'plObjectType' => ['mailTemplate'], 'plObjectType' => ['mailTemplate'],
'plConflicts' => ['mailTemplateUserReminder'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
]; ];
} }
...@@ -97,7 +98,7 @@ class mailTemplateUserRecovery extends simplePlugin ...@@ -97,7 +98,7 @@ class mailTemplateUserRecovery extends simplePlugin
$ldap->search('(&(objectClass=fdMailTemplateUserRecovery))', ['cn','fdMTPasswordRecoveryMailSubject']); $ldap->search('(&(objectClass=fdMailTemplateUserRecovery))', ['cn','fdMTPasswordRecoveryMailSubject']);
while ($attrs = $ldap->fetch()) { while ($attrs = $ldap->fetch()) {
if (isset($this->attrs['fdMTPasswordRecoveryMailSubject'])) { if (isset($this->attrs['fdMTPasswordRecoveryMailSubject'])) {
$error = new FusionDirectoryError(htmlescape(sprintf(_('User Reminder Template Is Already Existing!')))); $error = new FusionDirectoryError(htmlescape(sprintf(_('User Recovery Mail Template Is Already Existing!'))));
$error->display(); $error->display();
return FALSE; return FALSE;
......
<?php
class mailTemplateUserReminder extends simplePlugin
{
protected $displayHeader = TRUE;
static function plInfo (): array
{
return [
'plShortName' => _('Mail Template User Reminder'),
'plDescription' => _('Mail Template User Reminder'),
'plIcon' => 'geticon.php?context=applications&icon=supann&size=48',
'plSmallIcon' => 'geticon.php?context=applications&icon=supann-status&size=16',
'plPriority' => 32,
'plObjectClass' => ['fdMailTemplateUserReminder'],
'plFilter' => '(objectClass=fdMailTemplateUserReminder)',
'plObjectType' => ['mailTemplate'],
'plConflicts' => ['mailTemplateUserRecovery'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'emailppolicy' => [
'name' => _('Ppolicy email settings'),
'attrs' => [
new BooleanAttribute(
_('Forward alerts to the manager'), _('Forward ppolicy alerts to the manager'),
'fdMTUserReminderForwardPpolicyAlert', FALSE,
TRUE
),
new StringAttribute(
_('Subject'), _('Subject of the ppolicy alert email'),
'fdMTUserReminderPpolicyAlertSubject', FALSE,
_('[FusionDirectory] Your password is about to expire')
),
new TextAreaAttribute(
_('Body (%s are cn and login)'),
_('Body of the ppolicy alert email, sent when the user password is about to expire.'),
'fdMTUserReminderPpolicyAlertBody', FALSE,
_('Dear %sn%,'."\n".
'your password for account %login% is about to expire, please change your password: '."\n".
'https://'.$_SERVER['SERVER_NAME'].
(($_SERVER['SERVER_PORT'] != '80') ? ':'.$_SERVER['SERVER_PORT'] : '').
(empty($_SERVER['REQUEST_URI']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI']).
"\n")
)
]
],
'alert_mail_reminder' => [
'name' => _('Alert email settings'),
'attrs' => [
new BooleanAttribute(
_('Forward alerts to the manager'), _('Forward alerts to the manager'),
'fdMTUserReminderForwardAlert', TRUE,
TRUE
),
new StringAttribute(
_('Subject'), _('Subject of the alert email'),
'fdMTUserReminderAlertSubject', FALSE,
_('[FusionDirectory] Your account is about to expire')
),
new TextAreaAttribute(
_('Body'),
_('Body of the alert email, sent when the user is about to expire.'),
'fdMTUserReminderAlertBody', FALSE,
_('Dear %sn%,'."\n".
'your account %login% is about to expire, please use this link to avoid this: '."\n".
'https://'.$_SERVER['SERVER_NAME'].
(($_SERVER['SERVER_PORT'] != '80') ? ':'.$_SERVER['SERVER_PORT'] : '').
(empty($_SERVER['REQUEST_URI']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI']).
'/expired_postpone.php?uid=%login%&token=%token%'."\n")
)
]
],
'alert_mail_confirmation' => [
'name' => _('Confirmation email settings'),
'attrs' => [
new BooleanAttribute(
_('Forward confirmation to the manager'), _('Forward account extension confirmation to the manager'),
'fdMTUserReminderForwardConfirmation', TRUE,
TRUE
),
new StringAttribute(
_('Subject'), _('Subject of the confirmation email'),
'fdMTUserReminderConfirmationSubject', FALSE,
_('[FusionDirectory] Your account expiration has been postponed')
),
new TextAreaAttribute(
_('Body'),
_('Body of the confirmation email, sent when the user has postponed expiration.'),
'fdMTUserReminderConfirmationBody', FALSE,
_('Dear %sn%,'."\n".' your account %login% expiration has been successfully postponed.'."\n")
),
]
],
'alert_mail_expiration' => [
'name' => _('Expiration email settings'),
'attrs' => [
new BooleanAttribute(
_('Forward to the manager'), _('Forward account expiration to the manager'),
'fdMTUserReminderForwardExpiration', TRUE,
TRUE
),
new StringAttribute(
_('Subject'), _('Subject of the expiration email'),
'fdMTUserReminderExpirationSubject', FALSE,
_('[FusionDirectory] Your account has expired')
),
new TextAreaAttribute(
_('Body (%s are cn and login)'),
_('Body of the expiration email, sent when the user has expired.'),
'fdMTUserReminderExpirationBody', FALSE,
_('Dear %sn%,'."\n".' your account %login% has expired.'."\n")
),
]
],
];
}
function __construct (string $dn = NULL, $object = NULL, $parent = NULL, bool $mainTab = FALSE, array $attributesInfo = NULL)
{
parent::__construct($dn, $object, $parent, $mainTab, $attributesInfo);
if (!class_available('ppolicy')) {
$this->attributesAccess['fdMTUserReminderForwardPpolicyAlert']->setDisabled(TRUE);
$this->attributesAccess['fdMTUserReminderPpolicyAlertSubject']->setDisabled(TRUE);
$this->attributesAccess['fdMTUserReminderPpolicyAlertBody']->setDisabled(TRUE);
}
}
protected function shouldSave (): bool
{
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search('(&(objectClass=fdMailTemplateUserReminder))', ['cn','fdMTUserReminderAlertSubject']);
while ($attrs = $ldap->fetch()) {
if (isset($this->attrs['fdMTUserReminderAlertSubject'])) {
$error = new FusionDirectoryError(htmlescape(sprintf(_('User Reminder Mail Template Is Already Existing!'))));
$error->display();
return FALSE;
}
}
return TRUE;
}
}
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