From 3d4bfc79483450ed9b3b70144961d9634a26a1d0 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Mon, 16 May 2022 11:24:46 +0100 Subject: [PATCH] :sparkles: Feat(Tasks) - Adds mail task, proper columns Adds management required columns, back processing still has to be developped --- contrib/openldap/core-fd.schema | 27 +++++- plugins/addons/tasks/class_tasks.inc | 2 +- plugins/addons/tasks/class_tasksColumn.inc | 93 +++++++++++++++++++ .../addons/tasks/class_tasksManagement.inc | 14 ++- 4 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 plugins/addons/tasks/class_tasksColumn.inc diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema index 8bd590c37..8b0eb33f9 100644 --- a/contrib/openldap/core-fd.schema +++ b/contrib/openldap/core-fd.schema @@ -285,7 +285,15 @@ attributetype ( 1.3.6.1.4.1.38414.88.1.26 NAME 'fdMTInvitationReplyTo' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) -# Classes +##### Tasks Attributes ##### + +attributetype ( 1.3.6.1.4.1.38414.89.1.1 NAME 'fdTasksMailObject' + DESC 'Fusion Directory - Tasks for mail template objects' + 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 DESC 'GOsa - Class to mark Departments for GOsa' @@ -322,7 +330,6 @@ objectclass ( 1.3.6.1.4.1.38414.62.2.2 NAME 'fdSubscriptionInformation' SUP top DESC 'FusionDirectory - Information about current subscription' MUST ( cn ) MAY ( uid $ fdSubscriptionStartDate $ fdSubscriptionEndDate $ fdSubscriptionType $ fdSubscriptionContractId $ fdSubscriptionName )) -<<<<<<< HEAD # Classes Macros Related @@ -332,8 +339,6 @@ objectclass ( 1.3.6.1.4.1.38414.90.2.1 NAME 'fdMacroConf' MUST ( cn ) MAY ( fdMacroRDN $ fdMacroMail $ fdMacroInvitations $ fdMacroUserRecovery $ fdMacroUserReminder ) ) -======= - ### Mail Template Related Object Class ### objectclass (1.3.6.1.4.1.38414.88.2.1 NAME 'fdMailTemplate' @@ -369,4 +374,16 @@ objectclass ( 1.3.6.1.4.1.38414.88.2.5 NAME 'fdMailTemplateInvitations' SUP top AUXILIARY MUST ( cn $ fdMTInvitationEmailSubject $ fdMTInvitationEmailContent) MAY ( fdMTInvitationReplyTo ) ) ->>>>>>> 6205-enhancement-mail-template-object-invitations + +### Tasks Related Object Class ### + +objectclass (1.3.6.1.4.1.38414.89.2.1 NAME 'fdTasks' + DESC 'FusionDirectory - Tasks objects' + MUST ( cn ) + MAY ( ) ) + +objectclass (1.3.6.1.4.1.38414.89.2.2 NAME 'fdTasksMail' + DESC 'FusionDirectory - Tasks objects Mail' + SUP top AUXILIARY + MUST ( cn ) + MAY ( fdTasksMailObject ) ) diff --git a/plugins/addons/tasks/class_tasks.inc b/plugins/addons/tasks/class_tasks.inc index a51c7e02d..adada3bc6 100644 --- a/plugins/addons/tasks/class_tasks.inc +++ b/plugins/addons/tasks/class_tasks.inc @@ -48,7 +48,7 @@ class tasks extends simplePlugin 'name' => _('Tasks Generic'), 'attrs' => [ new StringAttribute( - _('Task Name'), _('Mail Template Name'), + _('Task Name'), _('Name for this task'), 'cn', TRUE ), ] diff --git a/plugins/addons/tasks/class_tasksColumn.inc b/plugins/addons/tasks/class_tasksColumn.inc new file mode 100644 index 000000000..97e2be359 --- /dev/null +++ b/plugins/addons/tasks/class_tasksColumn.inc @@ -0,0 +1,93 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2011-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. +*/ + +/*! + * \brief Column rendering Tasks + */ +class tasksColumn extends Column + + +{ + protected function renderSingleValue (ListingEntry $entry, string $value): string + { + if ($value == '') { + return ' '; + } else { + switch ($this->attributes[0]) { + case 'TYPE': + return static::filterTypes($value, $entry['PROGRESS']); + case 'TIMESTAMP': + return static::filterSchedule($value); + case 'STATUS': + return static::filterStatus($entry->row, $value, $entry['SUBSTATUS']); + default: + return parent::renderSingleValue($entry, $value); + } + } + } + + static function filterTypes (string $name, string $targetdn, string $targettype): string + { + $text = ''; + if (!empty($name) && ($name != 'none')) { + $text = $name; + } + if (!empty($targetdn) && !empty($targettype)) { + return objects::link($targetdn, $targettype, '', $text, TRUE); + } else { + return htmlescape($text); + } + } + + static function filterSchedule (string $stamp): string + { + if ($stamp == '19700101000000') { + return htmlescape(_('immediately')); + } else { + return htmlescape(date('d.m.Y H:i:s', strtotime($stamp))); + } + } + + static function filterStatus (int $row, string $status, string $substatus): string + { + if ($status == 'waiting') { + $status = '<img class="center" src="geticon.php?context=status&icon=task-waiting&size=16" alt="clock"/> '.htmlescape(_('Waiting')); + } + if ($status == 'error') { + $status = '<input class="center" type="image" src="geticon.php?context=status&icon=task-failure&size=16" title="'.htmlescape(_('Show error')).'" '. + 'name="listing_showError_'.$row.'" style="padding:1px"/>'.htmlescape(_('Error')); + } + if ($status == 'processed') { + $status = '<img class="center" src="geticon.php?context=status&icon=task-complete&size=16" alt=""/> '.htmlescape(_('Processed')); + } + + /* Special handling for all entries that have + STATUS == "processing" && PROGRESS == NUMERIC + */ + if ($status == 'processing' && $substatus) { + $status = $substatus; + } elseif ($status == 'processing') { + $status = preg_replace('/ /', ' ', htmlescape(_('in progress'))); + } + + return $status; + } +} diff --git a/plugins/addons/tasks/class_tasksManagement.inc b/plugins/addons/tasks/class_tasksManagement.inc index d5a62a9e8..6f746aef9 100644 --- a/plugins/addons/tasks/class_tasksManagement.inc +++ b/plugins/addons/tasks/class_tasksManagement.inc @@ -21,12 +21,16 @@ class tasksManagement extends management { - /* Default columns */ - + /* + * LinkColun exists by class collumn + * TasksColumn is a new class for Tasks bassed on argonaut column definition + */ public static $columns = [ - ['ObjectTypeColumn', []], - ['LinkColumn', ['attributes' => 'cn', 'label' => 'Tasks']], - ['ActionsColumn', ['label' => 'Actions']], + ['LinkColumn', ['attributes' => 'cn', 'label' => 'Tasks']], + ['tasksColumn', ['attributes' => 'TYPE', 'label' => 'Types']], + ['tasksColumn', ['attributes' => 'TIMESTAMP', 'label' => 'Schedule']], + ['tasksColumn', ['attributes' => 'STATUS', 'label' => 'Status']], + ['ActionsColumn', ['label' => 'Actions']], ]; static function plInfo () -- GitLab