From 68da4335de3cd2864a1311a9e0eb64a0ef3dbf9b Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Thu, 11 Aug 2022 16:12:29 +0100
Subject: [PATCH] :sparkles: Feat(Tasks) - First usages of column info

Each cells of tasks management report informations.
Not proper ones yet, but it is a start.
---
 contrib/openldap/core-fd.schema               | 26 ++++++++++++++-----
 plugins/addons/tasks/class_tasks.inc          |  2 ++
 plugins/addons/tasks/class_tasksColumn.inc    | 10 ++++++-
 .../addons/tasks/class_tasksManagement.inc    |  8 +++---
 4 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema
index 280c3353c..4800378cc 100644
--- a/contrib/openldap/core-fd.schema
+++ b/contrib/openldap/core-fd.schema
@@ -303,8 +303,22 @@ attributetype ( 1.3.6.1.4.1.38414.89.1.2 NAME 'fdTasksSchedule'
 attributetype ( 1.3.6.1.4.1.38414.89.1.3 NAME 'fdTasksMailUsers'
   DESC 'Fusion Directory - Tasks Mail Users Recipient'
   EQUALITY caseExactMatch
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE )
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+attributetype ( 1.3.6.1.4.1.38414.89.1.4 NAME 'fdTasksStatus'
+  DESC 'Fusion Directory - Task Status'
+  EQUALITY caseExactMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+attributetype ( 1.3.6.1.4.1.38414.89.1.5 NAME 'fdTasksEndDate'
+  DESC 'Fusion Directory - Task End Date'
+  EQUALITY caseExactMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+
+attributetype ( 1.3.6.1.4.1.38414.89.1.6 NAME 'fdTasksCreationDate'
+  DESC 'Fusion Directory - Task Start Date'
+  EQUALITY caseExactMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
 
 ##### Classes #####
 
@@ -392,11 +406,11 @@ objectclass ( 1.3.6.1.4.1.38414.88.2.5 NAME 'fdMailTemplateInvitations'
 
 objectclass (1.3.6.1.4.1.38414.89.2.1 NAME 'fdTasks'
   DESC 'FusionDirectory - Tasks objects'
-  MUST ( cn )
-  MAY ( fdTasksSchedule ) )
+  MUST ( cn $ fdTasksStatus $ fdTasksCreationDate )
+  MAY ( fdTasksSchedule $ fdTasksEndDate) )
 
 objectclass (1.3.6.1.4.1.38414.89.2.2 NAME 'fdTasksMail'
   DESC 'FusionDirectory - Tasks objects Mail'
   SUP top AUXILIARY
-  MUST ( fdTasksMailObject )
-  MAY ( fdTasksMailUsers) )
+  MUST ( fdTasksMailObject ) 
+  MAY ( fdTasksMailUsers ) )
diff --git a/plugins/addons/tasks/class_tasks.inc b/plugins/addons/tasks/class_tasks.inc
index 46c510688..73ec09b32 100644
--- a/plugins/addons/tasks/class_tasks.inc
+++ b/plugins/addons/tasks/class_tasks.inc
@@ -56,6 +56,8 @@ class tasks extends simplePlugin
           'fdTasksSchedule', FALSE,
           ''
         ),
+        new HiddenAttribute('fdTasksStatus', TRUE, '1', '', 'Status', 'Status of the task'),
+        new HiddenAttribute('fdTasksCreationDate', TRUE, date("Y-m-d h:i:sa"), '', 'StartDate', 'Start Date And Time Of A Task'),
         ]
       ],
     ];
diff --git a/plugins/addons/tasks/class_tasksColumn.inc b/plugins/addons/tasks/class_tasksColumn.inc
index 66b742233..1e57764ec 100644
--- a/plugins/addons/tasks/class_tasksColumn.inc
+++ b/plugins/addons/tasks/class_tasksColumn.inc
@@ -24,8 +24,13 @@
  * Important that a "query method" must be defined in order to have the listing
  */
 class tasksColumn extends Column
-
 {
+
+  function __construct (managementListing $parent, array $attributes = NULL, string $label = NULL)
+  {
+    parent::__construct($parent, ['supannRessourceEtatDate', 'supannRessourceEtat'], $label);
+  }
+
   protected function renderSingleValue (ListingEntry $entry, string $value): string
   {
     if ($value == '') {
@@ -53,10 +58,13 @@ class tasksColumn extends Column
   static function filterSchedule (): string
   {
     //A method retrieving the time set by the task
+     return '';
   }
 
   static function filterStatus (): string
   {
     //A method retrieving the status of the task
+     return '';
   }
 }
+
diff --git a/plugins/addons/tasks/class_tasksManagement.inc b/plugins/addons/tasks/class_tasksManagement.inc
index f44badd82..14e72b071 100644
--- a/plugins/addons/tasks/class_tasksManagement.inc
+++ b/plugins/addons/tasks/class_tasksManagement.inc
@@ -27,9 +27,11 @@ class tasksManagement extends management
   */
   public static $columns = [
     ['LinkColumn',  ['attributes' => 'cn', 'label' => 'Tasks']],
-    ['tasksColumn', ['attributes' => 'TYPE',   'label' => 'Types']],
-    ['tasksColumn', ['attributes' => 'TIMESTAMP', 'label' => 'Schedule']],
-    ['tasksColumn', ['attributes' => 'STATUS', 'label' => 'Status']],
+    //below fdTasksMailObject must be change to have a type defined within task creation (new ldap attributes ?hidden)
+    ['Column', ['attributes' => 'fdTasksMailObject',   'label' => 'Types']],
+    ['Column', ['attributes' => 'fdTasksSchedule', 'label' => 'Schedule']],
+    //below fdTasksStatus attribute needs to be calculated based on the type of the task.
+    ['Column', ['attributes' => 'fdTasksStatus', 'label' => 'Status']],
     ['ActionsColumn', ['label' => 'Actions']],
   ];
 
-- 
GitLab