From 47eff66b58033ca0bdfd87e2e40c0ecdb1fe4a64 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Mon, 9 May 2022 17:58:02 +0100 Subject: [PATCH] :sparkles: Feat(MailTemplate) - Adds Mail Template Invitations Adds Mail Template invitations first page, no fields yet. First commit --- .../class_mailTemplateInvitations.inc | 74 +++++++++++++++++++ .../class_mailTemplateUserRecovery.inc | 4 +- .../class_mailTemplateUserReminder.inc | 22 +++++- .../mailtemplate/class_mailTemplateConfig.inc | 2 +- 4 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 plugins/addons/mailtemplate/class_mailTemplateInvitations.inc diff --git a/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc b/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc new file mode 100644 index 000000000..72d75d473 --- /dev/null +++ b/plugins/addons/mailtemplate/class_mailTemplateInvitations.inc @@ -0,0 +1,74 @@ +<?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 mailTemplateInvitations extends simplePlugin +{ + protected $displayHeader = TRUE; + + static function plInfo (): array + { + return [ + 'plShortName' => _('Mail Template Invitations'), + 'plDescription' => _('Mail Template Invitations'), + 'plIcon' => 'geticon.php?context=applications&icon=supann&size=48', + 'plSmallIcon' => 'geticon.php?context=applications&icon=supann-status&size=16', + 'plPriority' => 33, + 'plObjectClass' => ['fdMailTemplateInvitations'], + 'plFilter' => '(objectClass=fdMailTemplateInvitations)', + 'plObjectType' => ['mailTemplate'], + 'plConflicts' => ['mailTemplateUserReminder', 'mailTemplateUserRecovery'], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + return [ + + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + } + + protected function shouldSave (): bool + { + global $config; + + $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; + } + } + + return TRUE; + } + +} diff --git a/plugins/addons/mailtemplate/class_mailTemplateUserRecovery.inc b/plugins/addons/mailtemplate/class_mailTemplateUserRecovery.inc index 0d11b850a..efa76ec0f 100644 --- a/plugins/addons/mailtemplate/class_mailTemplateUserRecovery.inc +++ b/plugins/addons/mailtemplate/class_mailTemplateUserRecovery.inc @@ -2,7 +2,7 @@ /* This code is part of FusionDirectory (http://www.fusiondirectory.org) - Copyright (C) 2018-2019 FusionDirectory + 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 @@ -34,7 +34,7 @@ class mailTemplateUserRecovery extends simplePlugin 'plObjectClass' => ['fdMailTemplateUserRecovery'], 'plFilter' => '(objectClass=fdMailTemplateUserRecovery)', 'plObjectType' => ['mailTemplate'], - 'plConflicts' => ['mailTemplateUserReminder'], + 'plConflicts' => ['mailTemplateUserReminder', 'mailTemplateInvitations'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) ]; } diff --git a/plugins/addons/mailtemplate/class_mailTemplateUserReminder.inc b/plugins/addons/mailtemplate/class_mailTemplateUserReminder.inc index d885606ff..455d9bc7b 100644 --- a/plugins/addons/mailtemplate/class_mailTemplateUserReminder.inc +++ b/plugins/addons/mailtemplate/class_mailTemplateUserReminder.inc @@ -1,5 +1,25 @@ <?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 mailTemplateUserReminder extends simplePlugin { protected $displayHeader = TRUE; @@ -15,7 +35,7 @@ class mailTemplateUserReminder extends simplePlugin 'plObjectClass' => ['fdMailTemplateUserReminder'], 'plFilter' => '(objectClass=fdMailTemplateUserReminder)', 'plObjectType' => ['mailTemplate'], - 'plConflicts' => ['mailTemplateUserRecovery'], + 'plConflicts' => ['mailTemplateUserRecovery', 'mailTemplateInvitations'], 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) ]; } diff --git a/plugins/config/mailtemplate/class_mailTemplateConfig.inc b/plugins/config/mailtemplate/class_mailTemplateConfig.inc index 6a6c26678..a1a2e8957 100644 --- a/plugins/config/mailtemplate/class_mailTemplateConfig.inc +++ b/plugins/config/mailtemplate/class_mailTemplateConfig.inc @@ -1,7 +1,7 @@ <?php /* This code is part of FusionDirectory (http://www.fusiondirectory.org/) - Copyright (C) 2012-2016 FusionDirectory + 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 -- GitLab