From 62d0b86ace12427167952f82b5703de99aa5b759 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:36:59 +0100
Subject: [PATCH 01/30] change to audit

---
 plugins/tasks/Audit.php | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 6e51ae7..88043a4 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,10 +4,12 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
+  private string $errorMessage;
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -47,13 +49,12 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $nonEmptyResults = $this->recursiveArrayFilter($result);
+    $filteredResults = $this->recursiveArrayFilter($result);
 
-    if (!empty($nonEmptyResults)) {
-      return $nonEmptyResults;
-    } else {
-      return ['No audit requiring removal'];
+    if (empty($filteredResults)) {
+        return [$this->errorMessage];
     }
+    return $filteredResults;
   }
 
   /**
@@ -66,23 +67,30 @@ class Audit implements EndpointInterface
     $result = [];
 
     foreach ($auditSubTasks as $task) {
-
       // If the tasks must be treated - status and scheduled - process the sub-tasks
       if ($this->gateway->statusAndScheduleCheck($task)) {
-
-        // Retrieve data from the main task.
-        $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-        // Simply get the days to retain audit.
-        $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
-
-        // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
-        $result[] = $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
+        $result[] = $this->processScheduledTask($task);
       }
     }
 
     return $result;
   }
 
+  /**
+   * @param array $task
+   * @return array
+   * @throws Exception
+   */
+  private function processScheduledTask(array $task): array
+  {
+      // Retrieve data from the main task.
+      $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
+      // Simply get the days to retain audit.
+      $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
+      // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
+      return $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
+  }
+
   /**
    * @param string $mainTaskDn
    * @return array
-- 
GitLab


From 1344abd04b9b9f7f81b5b3e8d15905a5c2493c41 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:39:01 +0100
Subject: [PATCH 02/30] fix phpstan

---
 plugins/tasks/Audit.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 88043a4..915d6ad 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,12 +4,11 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
-  private string $errorMessage;
+  private string $errorMessage = 'No audit requiring removal';
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
-    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -81,7 +80,7 @@ class Audit implements EndpointInterface
    * @return array
    * @throws Exception
    */
-  private function processScheduledTask(array $task): array
+  private function processScheduledTask (array $task): array
   {
       // Retrieve data from the main task.
       $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-- 
GitLab


From 40534d785cee1f954f2ef648c39c71fc1fab5165 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:36:59 +0100
Subject: [PATCH 03/30] change to audit

---
 plugins/tasks/Audit.php | 59 +++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index c4bbe40..19f1e53 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,10 +4,12 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
+  private string $errorMessage;
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -47,13 +49,12 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $nonEmptyResults = Utils::recursiveArrayFilter($result);
+    $filteredResults = Utils::recursiveArrayFilter($result);
 
-    if (!empty($nonEmptyResults)) {
-      return $nonEmptyResults;
-    } else {
-      return ['No audit requiring removal'];
+    if (empty($filteredResults)) {
+        return [$this->errorMessage];
     }
+    return $filteredResults;
   }
 
   /**
@@ -66,23 +67,30 @@ class Audit implements EndpointInterface
     $result = [];
 
     foreach ($auditSubTasks as $task) {
-
       // If the tasks must be treated - status and scheduled - process the sub-tasks
       if ($this->gateway->statusAndScheduleCheck($task)) {
-
-        // Retrieve data from the main task.
-        $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-        // Simply get the days to retain audit.
-        $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
-
-        // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
-        $result[] = $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
+        $result[] = $this->processScheduledTask($task);
       }
     }
 
     return $result;
   }
 
+  /**
+   * @param array $task
+   * @return array
+   * @throws Exception
+   */
+  private function processScheduledTask(array $task): array
+  {
+      // Retrieve data from the main task.
+      $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
+      // Simply get the days to retain audit.
+      $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
+      // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
+      return $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
+  }
+
   /**
    * @param string $mainTaskDn
    * @return array
@@ -119,4 +127,27 @@ class Audit implements EndpointInterface
 
     return $audit;
   }
+
+  /**
+   * @param array $array
+   * @return array
+   * Note : Recursively filters out empty values and arrays at any depth.
+   */
+  private function recursiveArrayFilter (array $array): array
+  {
+    // First filter the array for non-empty elements
+    $filtered = array_filter($array, function ($item) {
+      if (is_array($item)) {
+        // Recursively filter the sub-array
+        $item = $this->recursiveArrayFilter($item);
+        // Only retain non-empty arrays
+        return !empty($item);
+      } else {
+        // Retain non-empty scalar values
+        return !empty($item);
+      }
+    });
+
+    return $filtered;
+  }
 }
\ No newline at end of file
-- 
GitLab


From f1d641e68f33202f50944e784def4c95a02b1569 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:39:01 +0100
Subject: [PATCH 04/30] fix phpstan

---
 plugins/tasks/Audit.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 19f1e53..eb16731 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,12 +4,11 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
-  private string $errorMessage;
+  private string $errorMessage = 'No audit requiring removal';
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
-    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -81,7 +80,7 @@ class Audit implements EndpointInterface
    * @return array
    * @throws Exception
    */
-  private function processScheduledTask(array $task): array
+  private function processScheduledTask (array $task): array
   {
       // Retrieve data from the main task.
       $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-- 
GitLab


From 0e48b2817e5460060647bf880453841bd014cf91 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 12:18:47 +0100
Subject: [PATCH 05/30] rebase

---
 plugins/tasks/Audit.php | 23 -----------------------
 1 file changed, 23 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index eb16731..4e709f3 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -126,27 +126,4 @@ class Audit implements EndpointInterface
 
     return $audit;
   }
-
-  /**
-   * @param array $array
-   * @return array
-   * Note : Recursively filters out empty values and arrays at any depth.
-   */
-  private function recursiveArrayFilter (array $array): array
-  {
-    // First filter the array for non-empty elements
-    $filtered = array_filter($array, function ($item) {
-      if (is_array($item)) {
-        // Recursively filter the sub-array
-        $item = $this->recursiveArrayFilter($item);
-        // Only retain non-empty arrays
-        return !empty($item);
-      } else {
-        // Retain non-empty scalar values
-        return !empty($item);
-      }
-    });
-
-    return $filtered;
-  }
 }
\ No newline at end of file
-- 
GitLab


From 9c15a227e192a64e0b9bbf7464406321ce04579d Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:05:43 +0100
Subject: [PATCH 06/30] Add mail utils

---
 library/MailUtils.php | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 library/MailUtils.php

diff --git a/library/MailUtils.php b/library/MailUtils.php
new file mode 100644
index 0000000..44b1f48
--- /dev/null
+++ b/library/MailUtils.php
@@ -0,0 +1,22 @@
+<?php
+
+class MailUtils
+{
+    private function __construct()
+    {
+    }
+
+    public static function sendMail($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
+    {
+        $mail_controller = new \FusionDirectory\Mail\MailLib($setFrom,
+            $setBCC,
+            $recipients,
+            $body,
+            $signature,
+            $subject,
+            $receipt,
+            $attachments);
+
+        return $mail_controller->sendMail();
+    }
+}
\ No newline at end of file
-- 
GitLab


From 5148a244899e239680ffe53f5958292c3b234545 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:10:44 +0100
Subject: [PATCH 07/30] add method

---
 library/MailUtils.php | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/library/MailUtils.php b/library/MailUtils.php
index 44b1f48..81eaa33 100644
--- a/library/MailUtils.php
+++ b/library/MailUtils.php
@@ -19,4 +19,16 @@ class MailUtils
 
         return $mail_controller->sendMail();
     }
+
+    /**
+     * @return array
+     * Note : A simple retrieval methods of the mail backend configuration set in FusionDirectory
+     */
+    public static function getMailObjectConfiguration (TaskGateway $gateway): array
+    {
+        return $gateway->getLdapTasks(
+            "(objectClass=fdTasksConf)",
+            ["fdTasksConfLastExecTime", "fdTasksConfIntervalEmails", "fdTasksConfMaxEmails"]
+        );
+    }
 }
\ No newline at end of file
-- 
GitLab


From 1122e57075ea37b688b2acb43ccb8bdda716499c Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:22:52 +0100
Subject: [PATCH 08/30] fix indent

---
 library/MailUtils.php | 52 +++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/library/MailUtils.php b/library/MailUtils.php
index 81eaa33..8779224 100644
--- a/library/MailUtils.php
+++ b/library/MailUtils.php
@@ -2,33 +2,33 @@
 
 class MailUtils
 {
-    private function __construct()
-    {
-    }
+  private function __construct()
+  {
+  }
 
-    public static function sendMail($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
-    {
-        $mail_controller = new \FusionDirectory\Mail\MailLib($setFrom,
-            $setBCC,
-            $recipients,
-            $body,
-            $signature,
-            $subject,
-            $receipt,
-            $attachments);
+  public static function sendMail($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
+  {
+    $mail_controller = new \FusionDirectory\Mail\MailLib($setFrom,
+      $setBCC,
+      $recipients,
+      $body,
+      $signature,
+      $subject,
+      $receipt,
+      $attachments);
 
-        return $mail_controller->sendMail();
-    }
+    return $mail_controller->sendMail();
+  }
 
-    /**
-     * @return array
-     * Note : A simple retrieval methods of the mail backend configuration set in FusionDirectory
-     */
-    public static function getMailObjectConfiguration (TaskGateway $gateway): array
-    {
-        return $gateway->getLdapTasks(
-            "(objectClass=fdTasksConf)",
-            ["fdTasksConfLastExecTime", "fdTasksConfIntervalEmails", "fdTasksConfMaxEmails"]
-        );
-    }
+  /**
+   * @return array
+   * Note : A simple retrieval methods of the mail backend configuration set in FusionDirectory
+   */
+  public static function getMailObjectConfiguration (TaskGateway $gateway): array
+  {
+    return $gateway->getLdapTasks(
+      "(objectClass=fdTasksConf)",
+      ["fdTasksConfLastExecTime", "fdTasksConfIntervalEmails", "fdTasksConfMaxEmails"]
+    );
+  }
 }
\ No newline at end of file
-- 
GitLab


From 9261ef6e64fc9fc1b768e96a0555ee69238236f1 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:23:22 +0100
Subject: [PATCH 09/30] fix indent

---
 library/MailUtils.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/library/MailUtils.php b/library/MailUtils.php
index 8779224..5fc496a 100644
--- a/library/MailUtils.php
+++ b/library/MailUtils.php
@@ -2,11 +2,11 @@
 
 class MailUtils
 {
-  private function __construct()
+  private function __construct ()
   {
   }
 
-  public static function sendMail($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
+  public static function sendMail ($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
   {
     $mail_controller = new \FusionDirectory\Mail\MailLib($setFrom,
       $setBCC,
-- 
GitLab


From b34fa9cdd5a9d8de30936d2120fe6b90cf325a0e Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:36:59 +0100
Subject: [PATCH 10/30] change to audit

---
 plugins/tasks/Audit.php | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 4e709f3..88043a4 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,11 +4,12 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
-  private string $errorMessage = 'No audit requiring removal';
+  private string $errorMessage;
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -48,7 +49,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = Utils::recursiveArrayFilter($result);
+    $filteredResults = $this->recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
@@ -80,7 +81,7 @@ class Audit implements EndpointInterface
    * @return array
    * @throws Exception
    */
-  private function processScheduledTask (array $task): array
+  private function processScheduledTask(array $task): array
   {
       // Retrieve data from the main task.
       $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
@@ -126,4 +127,27 @@ class Audit implements EndpointInterface
 
     return $audit;
   }
+
+  /**
+   * @param array $array
+   * @return array
+   * Note : Recursively filters out empty values and arrays at any depth.
+   */
+  private function recursiveArrayFilter (array $array): array
+  {
+    // First filter the array for non-empty elements
+    $filtered = array_filter($array, function ($item) {
+      if (is_array($item)) {
+        // Recursively filter the sub-array
+        $item = $this->recursiveArrayFilter($item);
+        // Only retain non-empty arrays
+        return !empty($item);
+      } else {
+        // Retain non-empty scalar values
+        return !empty($item);
+      }
+    });
+
+    return $filtered;
+  }
 }
\ No newline at end of file
-- 
GitLab


From fa18660788a8902fab04aee57e567d7c4fcebe9f Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:29:02 +0100
Subject: [PATCH 11/30] fix indent

---
 plugins/tasks/Audit.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 88043a4..a391904 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -4,12 +4,11 @@ class Audit implements EndpointInterface
 {
 
   private TaskGateway $gateway;
-  private string $errorMessage;
+  private string $errorMessage = 'No audit requiring removal';
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
-    $this->errorMessage = 'No audit requiring removal';
   }
 
   /**
@@ -84,7 +83,7 @@ class Audit implements EndpointInterface
   private function processScheduledTask(array $task): array
   {
       // Retrieve data from the main task.
-      $auditMainTask = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
+      $auditMainTask  = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
       // Simply get the days to retain audit.
       $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
       // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
-- 
GitLab


From c45fe531adea328a156ea727f46c659d5bbdfa7e Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:30:16 +0100
Subject: [PATCH 12/30] fix indent

---
 plugins/tasks/Audit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index a391904..43321cd 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -80,7 +80,7 @@ class Audit implements EndpointInterface
    * @return array
    * @throws Exception
    */
-  private function processScheduledTask(array $task): array
+  private function processScheduledTask (array $task): array
   {
       // Retrieve data from the main task.
       $auditMainTask  = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-- 
GitLab


From 6c6ee4a7bcda770dd0557ee76f1cf5d407bfa2a7 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 11:08:10 +0100
Subject: [PATCH 13/30] use maps

---
 plugins/tasks/Audit.php | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 43321cd..71881c8 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -63,16 +63,10 @@ class Audit implements EndpointInterface
    */
   public function processAuditDeletion (array $auditSubTasks): array
   {
-    $result = [];
-
-    foreach ($auditSubTasks as $task) {
-      // If the tasks must be treated - status and scheduled - process the sub-tasks
-      if ($this->gateway->statusAndScheduleCheck($task)) {
-        $result[] = $this->processScheduledTask($task);
-      }
-    }
-
-    return $result;
+    return array_values(array_map(
+        fn($task) => $this->processScheduledTask($task),
+        array_filter($auditSubTasks, fn($task) => $this->gateway->statusAndScheduleCheck($task))
+    ));
   }
 
   /**
-- 
GitLab


From 41484ce88c00fc5c62c307a1322d098b5a0aa30d Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 11:11:09 +0100
Subject: [PATCH 14/30] use maps

---
 library/Utils.php | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/library/Utils.php b/library/Utils.php
index 1c132ac..24e8309 100644
--- a/library/Utils.php
+++ b/library/Utils.php
@@ -13,20 +13,12 @@ class Utils
    */
   public static function recursiveArrayFilter (array $array): array
   {
-    // First filter the array for non-empty elements
-    $filtered = array_filter($array, function ($item) {
-      if (is_array($item)) {
-        // Recursively filter the sub-array
-        $item = self::recursiveArrayFilter($item);
-        // Only retain non-empty arrays
-        return !empty($item);
-      } else {
-        // Retain non-empty scalar values
+    return array_filter($array, function ($item) {
+        if (is_array($item)) {
+            $item = self::recursiveArrayFilter($item);
+        }
         return !empty($item);
-      }
     });
-
-    return $filtered;
   }
 
   /**
@@ -40,12 +32,10 @@ class Utils
   {
     $matching = [];
 
-    if (!empty($elements)) {
-      foreach ($elements as $element) {
-        foreach ($keys as $key) {
-          if (!empty($element) && array_key_exists($key, $element)) {
-            $matching[] = $key;
-          }
+    foreach ($elements as $element) {
+      foreach ($keys as $key) {
+        if (!empty($element) && array_key_exists($key, $element)) {
+          $matching[] = $key;
         }
       }
     }
-- 
GitLab


From 5a8e1bb21a3231f8886e192f7ad5bcf51d764550 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 11:12:26 +0100
Subject: [PATCH 15/30] indent

---
 library/Utils.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/library/Utils.php b/library/Utils.php
index 24e8309..7e31d9b 100644
--- a/library/Utils.php
+++ b/library/Utils.php
@@ -14,10 +14,10 @@ class Utils
   public static function recursiveArrayFilter (array $array): array
   {
     return array_filter($array, function ($item) {
-        if (is_array($item)) {
-            $item = self::recursiveArrayFilter($item);
-        }
-        return !empty($item);
+      if (is_array($item)) {
+          $item = self::recursiveArrayFilter($item);
+      }
+      return !empty($item);
     });
   }
 
-- 
GitLab


From 6cad872c769fe0a349833fb52226560108293bfa Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 11:56:04 +0100
Subject: [PATCH 16/30] make non static

---
 library/Utils.php                             | 75 -------------------
 library/{ => plugins}/MailUtils.php           |  6 +-
 .../ReminderTokenUtils.php}                   | 40 ++++++----
 library/plugins/Utils.php                     | 59 +++++++++++++++
 plugins/tasks/Audit.php                       | 27 +------
 plugins/tasks/Notifications.php               |  6 +-
 plugins/tasks/Reminder.php                    | 16 ++--
 7 files changed, 103 insertions(+), 126 deletions(-)
 delete mode 100644 library/Utils.php
 rename library/{ => plugins}/MailUtils.php (70%)
 rename library/{TokenUtils.php => plugins/ReminderTokenUtils.php} (77%)
 create mode 100644 library/plugins/Utils.php

diff --git a/library/Utils.php b/library/Utils.php
deleted file mode 100644
index 7e31d9b..0000000
--- a/library/Utils.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-
-class Utils
-{
-  private function __construct ()
-  {
-  }
-
-  /**
-   * @param array $array
-   * @return array
-   * Note : Recursively filters out empty values and arrays at any depth.
-   */
-  public static function recursiveArrayFilter (array $array): array
-  {
-    return array_filter($array, function ($item) {
-      if (is_array($item)) {
-          $item = self::recursiveArrayFilter($item);
-      }
-      return !empty($item);
-    });
-  }
-
-  /**
-   * Find matching keys between 2 lists.
-   *
-   * @param array|null $elements
-   * @param array $keys
-   * @return array
-   */
-  public static function findMatchingKeys (?array $elements, array $keys): array
-  {
-    $matching = [];
-
-    foreach ($elements as $element) {
-      foreach ($keys as $key) {
-        if (!empty($element) && array_key_exists($key, $element)) {
-          $matching[] = $key;
-        }
-      }
-    }
-
-    return $matching;
-  }
-
-  /**
-   * @param $array
-   * @return array
-   * Note : simply return all values of a multi-dimensional array.
-   */
-  public static function getArrayValuesRecursive ($array)
-  {
-    $values = [];
-    foreach ($array as $value) {
-      if (is_array($value)) {
-        // If value is an array, merge its values recursively
-        $values = array_merge($values, self::getArrayValuesRecursive($value));
-      } else {
-        // If value is not an array, add it to the result
-        $values[] = $value;
-      }
-    }
-    return $values;
-  }
-
-  /**
-   * @param string $text
-   * @return string
-   * Note : This come from jwtToken, as it is completely private - it is cloned here for now.
-   */
-  public static function base64urlEncode (string $text): string
-  {
-    return str_replace(["+", "/", "="], ["A", "B", ""], base64_encode($text));
-  }
-}
\ No newline at end of file
diff --git a/library/MailUtils.php b/library/plugins/MailUtils.php
similarity index 70%
rename from library/MailUtils.php
rename to library/plugins/MailUtils.php
index 5fc496a..87f4c64 100644
--- a/library/MailUtils.php
+++ b/library/plugins/MailUtils.php
@@ -2,11 +2,11 @@
 
 class MailUtils
 {
-  private function __construct ()
+  public function __construct ()
   {
   }
 
-  public static function sendMail ($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
+  public function sendMail ($setFrom, $setBCC, $recipients, $body, $signature, $subject, $receipt, $attachments)
   {
     $mail_controller = new \FusionDirectory\Mail\MailLib($setFrom,
       $setBCC,
@@ -24,7 +24,7 @@ class MailUtils
    * @return array
    * Note : A simple retrieval methods of the mail backend configuration set in FusionDirectory
    */
-  public static function getMailObjectConfiguration (TaskGateway $gateway): array
+  public function getMailObjectConfiguration (TaskGateway $gateway): array
   {
     return $gateway->getLdapTasks(
       "(objectClass=fdTasksConf)",
diff --git a/library/TokenUtils.php b/library/plugins/ReminderTokenUtils.php
similarity index 77%
rename from library/TokenUtils.php
rename to library/plugins/ReminderTokenUtils.php
index 8552514..4ead9b4 100644
--- a/library/TokenUtils.php
+++ b/library/plugins/ReminderTokenUtils.php
@@ -1,8 +1,8 @@
 <?php
 
-class TokenUtils
+class ReminderTokenUtils
 {
-  private function __construct ()
+  public function __construct ()
   {
   }
 
@@ -12,7 +12,7 @@ class TokenUtils
    * @return string
    * @throws Exception
    */
-  public static function generateToken (string $userDN, int $timeStamp, TaskGateway $gateway): string
+  public function generateToken (string $userDN, int $timeStamp, TaskGateway $gateway): string
   {
     $token = NULL;
     // Salt has been generated with APG.
@@ -25,10 +25,10 @@ class TokenUtils
     $token_hmac = hash_hmac("sha256", $time . $payload, $_ENV["SECRET_KEY"], TRUE);
 
     // We need to have a token allowed to be used within an URL.
-    $token = Utils::base64urlEncode($token_hmac);
+    $token = $this->base64urlEncode($token_hmac);
 
     // Save token within LDAP
-    self::saveTokenInLdap($userDN, $token, $timeStamp, $gateway);
+    $this->saveTokenInLdap($userDN, $token, $timeStamp, $gateway);
 
     return $token;
   }
@@ -41,7 +41,7 @@ class TokenUtils
    * @return bool
    * @throws Exception
    */
-  public static function saveTokenInLdap (string $userDN, string $token, int $days, TaskGateway $gateway): bool
+  private function saveTokenInLdap (string $userDN, string $token, int $days, TaskGateway $gateway): bool
   {
     $result = FALSE;
 
@@ -64,17 +64,17 @@ class TokenUtils
 
 
     // Verify if token ou branch exists
-    if (!self::tokenBranchExist('ou=tokens' . ',' . $_ENV["LDAP_BASE"], $gateway)) {
+    if (!$this->tokenBranchExist('ou=tokens' . ',' . $_ENV["LDAP_BASE"], $gateway)) {
       // Create the branch
-      self::createBranchToken($gateway);
+      $this->createBranchToken($gateway);
     }
 
     // The user token DN creation
     $userTokenDN = 'cn=' . $uid . ',ou=tokens' . ',' . $_ENV["LDAP_BASE"];
     // Verify if a token already exists for specified user and remove it to create new one correctly.
-    if (self::tokenBranchExist($userTokenDN, $gateway)) {
+    if ($this->tokenBranchExist($userTokenDN, $gateway)) {
       // Remove the user token
-      self::removeUserToken($userTokenDN, $gateway);
+      $this->removeUserToken($userTokenDN, $gateway);
     }
 
     // Add token to LDAP for specific UID
@@ -95,7 +95,7 @@ class TokenUtils
    * @return int
    * Note : Simply return the difference between first and second call. (First call can be null).
    */
-  public static function getTokenExpiration (int $subTaskCall, int $firstCall, int $secondCall): int
+  public function getTokenExpiration (int $subTaskCall, int $firstCall, int $secondCall): int
   {
     // if firstCall is empty, secondCall is the timestamp expiry for the token.
     $result = $secondCall;
@@ -115,7 +115,7 @@ class TokenUtils
    * @return void
    * Note : Simply remove the token for specific user DN
    */
-  public static function removeUserToken ($userTokenDN, TaskGateway $gateway): void
+  private function removeUserToken ($userTokenDN, TaskGateway $gateway): void
   {
     // Add token to LDAP for specific UID
     try {
@@ -130,7 +130,7 @@ class TokenUtils
    * Create ou=pluginManager LDAP branch
    * @throws Exception
    */
-  public static function createBranchToken (TaskGateway $gateway): void
+  private function createBranchToken (TaskGateway $gateway): void
   {
     try {
       ldap_add(
@@ -153,7 +153,7 @@ class TokenUtils
    * @param string $taskDN
    * @return array
    */
-  public static function generateTokenUrl (string $token, array $mailTemplateForm, string $taskDN): array
+  public function generateTokenUrl (string $token, array $mailTemplateForm, string $taskDN): array
   {
     //Only take the cn of the main task name :
     preg_match('/cn=([^,]+),ou=/', $taskDN, $matches);
@@ -173,7 +173,7 @@ class TokenUtils
    * @return bool
    * Note : Simply inspect if the branch for token is existing.
    */
-  public static function tokenBranchExist (string $dn, TaskGateway $gateway): bool
+  private function tokenBranchExist (string $dn, TaskGateway $gateway): bool
   {
     $result = FALSE;
 
@@ -195,4 +195,14 @@ class TokenUtils
 
     return $result;
   }
+
+    /**
+     * @param string $text
+     * @return string
+     * Note : This come from jwtToken, as it is completely private - it is cloned here for now.
+     */
+    private function base64urlEncode (string $text): string
+    {
+        return str_replace(["+", "/", "="], ["A", "B", ""], base64_encode($text));
+    }
 }
\ No newline at end of file
diff --git a/library/plugins/Utils.php b/library/plugins/Utils.php
new file mode 100644
index 0000000..10eafe6
--- /dev/null
+++ b/library/plugins/Utils.php
@@ -0,0 +1,59 @@
+<?php
+
+class Utils
+{
+  public function __construct ()
+  {
+  }
+
+  /**
+   * @param array $array
+   * @return array
+   * Note : Recursively filters out empty values and arrays at any depth.
+   */
+  public function recursiveArrayFilter (array $array): array
+  {
+    return array_filter($array, function ($item) {
+      if (is_array($item)) {
+          $item = $this->recursiveArrayFilter($item);
+      }
+      return !empty($item);
+    });
+  }
+
+  /**
+   * Find matching keys between 2 lists.
+   *
+   * @param array|null $elements
+   * @param array $keys
+   * @return array
+   */
+  public function findMatchingKeys (?array $elements, array $keys): array
+  {
+    $matching = [];
+
+    if (!empty($elements)) {
+      foreach ($elements as $element) {
+        foreach ($keys as $key) {
+          if (!empty($element) && array_key_exists($key, $element)) {
+            $matching[] = $key;
+          }
+        }
+      }
+    }
+
+    return $matching;
+  }
+
+  /**
+   * @param $array
+   * @return array
+   * Note : simply return all values of a multi-dimensional array.
+   */
+  public function getArrayValuesRecursive ($array)
+  {
+    return array_reduce($array, function ($carry, $value) {
+      return array_merge($carry, is_array($value) ? $this->getArrayValuesRecursive($value) : [$value]);
+    }, []);
+  }
+}
\ No newline at end of file
diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 71881c8..4d14803 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -5,10 +5,12 @@ class Audit implements EndpointInterface
 
   private TaskGateway $gateway;
   private string $errorMessage = 'No audit requiring removal';
+  private Utils $utils;
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->utils = new Utils();
   }
 
   /**
@@ -48,7 +50,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = $this->recursiveArrayFilter($result);
+    $filteredResults = $this->utils->recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
@@ -120,27 +122,4 @@ class Audit implements EndpointInterface
 
     return $audit;
   }
-
-  /**
-   * @param array $array
-   * @return array
-   * Note : Recursively filters out empty values and arrays at any depth.
-   */
-  private function recursiveArrayFilter (array $array): array
-  {
-    // First filter the array for non-empty elements
-    $filtered = array_filter($array, function ($item) {
-      if (is_array($item)) {
-        // Recursively filter the sub-array
-        $item = $this->recursiveArrayFilter($item);
-        // Only retain non-empty arrays
-        return !empty($item);
-      } else {
-        // Retain non-empty scalar values
-        return !empty($item);
-      }
-    });
-
-    return $filtered;
-  }
 }
\ No newline at end of file
diff --git a/plugins/tasks/Notifications.php b/plugins/tasks/Notifications.php
index e17ffe3..4547b87 100644
--- a/plugins/tasks/Notifications.php
+++ b/plugins/tasks/Notifications.php
@@ -4,10 +4,12 @@ class Notifications implements EndpointInterface
 {
 
   private TaskGateway $gateway;
+  private Utils $utils;
 
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->utils = new Utils();
   }
 
   /**
@@ -82,7 +84,7 @@ class Notifications implements EndpointInterface
         $this->gateway->unsetCountKeys($monitoredSupannResource);
 
         // Find matching attributes between audited and monitored attributes
-        $matchingAttrs = Utils::findMatchingKeys($auditAttributes, $monitoredAttrs);
+        $matchingAttrs = $this->utils->findMatchingKeys($auditAttributes, $monitoredAttrs);
 
         // Verify Supann resource state if applicable
         if ($this->shouldVerifySupannResource($monitoredSupannResource, $auditAttributes)) {
@@ -183,7 +185,7 @@ class Notifications implements EndpointInterface
     }
 
     // Get all the values only of a multidimensional array.
-    $auditedValues = Utils::getArrayValuesRecursive($auditedAttrs);
+    $auditedValues = $this->utils->getArrayValuesRecursive($auditedAttrs);
 
     if (in_array($monitoredSupannState, $auditedValues)) {
       $result = TRUE;
diff --git a/plugins/tasks/Reminder.php b/plugins/tasks/Reminder.php
index 1faeff7..ceb619a 100644
--- a/plugins/tasks/Reminder.php
+++ b/plugins/tasks/Reminder.php
@@ -4,10 +4,12 @@ class Reminder implements EndpointInterface
 {
 
   private TaskGateway $gateway;
-
+  private ReminderTokenUtils $reminderTokenUtils;
+  
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
+    $this->reminderTokenUtils = new ReminderTokenUtils();
   }
 
   /**
@@ -109,13 +111,13 @@ class Reminder implements EndpointInterface
             $reminders[$remindersMainTaskName]['subTask'][$task['cn'][0]]['uid'] = $task['fdtasksgranulardn'][0];
 
             // Create timeStamp expiration for token
-            $tokenExpire = TokenUtils::getTokenExpiration($task['fdtasksgranularhelper'][0],
+            $tokenExpire = $this->reminderTokenUtils->getTokenExpiration($task['fdtasksgranularhelper'][0],
               $remindersMainTask[0]['fdtasksreminderfirstcall'][0],
               $remindersMainTask[0]['fdtasksremindersecondcall'][0]);
             // Create token for SubTask
-            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
+            $token = $this->reminderTokenUtils->generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
             // Edit the mailForm with the url link containing the token
-            $tokenMailTemplateForm = TokenUtils::generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
+            $tokenMailTemplateForm = $this->reminderTokenUtils->generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
             // Recipient email form
             $reminders[$remindersMainTaskName]['subTask'][$task['cn'][0]]['mail'] = $tokenMailTemplateForm;
 
@@ -136,13 +138,13 @@ class Reminder implements EndpointInterface
             $reminders[$remindersMainTaskName]['subTask'][$task['cn'][0]]['uid'] = $task['fdtasksgranulardn'][0];
 
             // Create timeStamp expiration for token
-            $tokenExpire = TokenUtils::getTokenExpiration($task['fdtasksgranularhelper'][0],
+            $tokenExpire = $this->reminderTokenUtils->getTokenExpiration($task['fdtasksgranularhelper'][0],
               $remindersMainTask[0]['fdtasksreminderfirstcall'][0],
               $remindersMainTask[0]['fdtasksremindersecondcall'][0]);
             // Create token for SubTask
-            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
+            $token = $this->reminderTokenUtils->generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
             // Edit the mailForm with the url link containing the token
-            $tokenMailTemplateForm = TokenUtils::generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
+            $tokenMailTemplateForm = $this->reminderTokenUtils->generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
             // Recipient email form
             $reminders[$remindersMainTaskName]['subTask'][$task['cn'][0]]['mail'] = $tokenMailTemplateForm;
 
-- 
GitLab


From 3237044330bca6ccdde669a86339531d33178741 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 11:57:20 +0100
Subject: [PATCH 17/30] fix indent

---
 library/plugins/ReminderTokenUtils.php | 18 +++++++++---------
 plugins/tasks/Reminder.php             |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/library/plugins/ReminderTokenUtils.php b/library/plugins/ReminderTokenUtils.php
index 4ead9b4..bb08d24 100644
--- a/library/plugins/ReminderTokenUtils.php
+++ b/library/plugins/ReminderTokenUtils.php
@@ -196,13 +196,13 @@ class ReminderTokenUtils
     return $result;
   }
 
-    /**
-     * @param string $text
-     * @return string
-     * Note : This come from jwtToken, as it is completely private - it is cloned here for now.
-     */
-    private function base64urlEncode (string $text): string
-    {
-        return str_replace(["+", "/", "="], ["A", "B", ""], base64_encode($text));
-    }
+  /**
+   * @param string $text
+   * @return string
+   * Note : This come from jwtToken, as it is completely private - it is cloned here for now.
+   */
+  private function base64urlEncode (string $text): string
+  {
+    return str_replace(["+", "/", "="], ["A", "B", ""], base64_encode($text));
+  }
 }
\ No newline at end of file
diff --git a/plugins/tasks/Reminder.php b/plugins/tasks/Reminder.php
index ceb619a..180eca7 100644
--- a/plugins/tasks/Reminder.php
+++ b/plugins/tasks/Reminder.php
@@ -5,7 +5,7 @@ class Reminder implements EndpointInterface
 
   private TaskGateway $gateway;
   private ReminderTokenUtils $reminderTokenUtils;
-  
+
   public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
-- 
GitLab


From dd15900298016ebce4ceb196600c1c0e6dd604e3 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:29:02 +0100
Subject: [PATCH 18/30] fix indent

---
 plugins/tasks/Audit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 4d14803..3493fe8 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -50,7 +50,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = $this->utils->recursiveArrayFilter($result);
+    $filteredResults = $this->recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
-- 
GitLab


From 70c8b6671d0bee326972031054c5a9ed30d7bca1 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 12:02:23 +0100
Subject: [PATCH 19/30] fix audit

---
 plugins/tasks/Audit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 3493fe8..4d14803 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -50,7 +50,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = $this->recursiveArrayFilter($result);
+    $filteredResults = $this->utils->recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
-- 
GitLab


From 94ea7908a8245aec01b132a760cd8ce098edc6a4 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 12:04:52 +0100
Subject: [PATCH 20/30] fix indent

---
 plugins/tasks/Audit.php | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 4d14803..2dafb4b 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -78,12 +78,12 @@ class Audit implements EndpointInterface
    */
   private function processScheduledTask (array $task): array
   {
-      // Retrieve data from the main task.
-      $auditMainTask  = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
-      // Simply get the days to retain audit.
-      $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
-      // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
-      return $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
+    // Retrieve data from the main task.
+    $auditMainTask  = $this->getAuditMainTask($task['fdtasksgranularmaster'][0]);
+    // Simply get the days to retain audit.
+    $auditRetention = $auditMainTask[0]['fdaudittasksretention'][0];
+    // Verification of all audit and their potential removal based on retention days passed, also update subtasks.
+    return $this->checkAuditPassedRetention($auditRetention, $task['dn'], $task['cn'][0]);
   }
 
   /**
-- 
GitLab


From be6c1ffd4905035d8f91d5c9207e0f18fec60d94 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Tue, 25 Mar 2025 12:05:43 +0100
Subject: [PATCH 21/30] fix indent

---
 plugins/tasks/Audit.php | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index 2dafb4b..e3556bb 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -65,10 +65,7 @@ class Audit implements EndpointInterface
    */
   public function processAuditDeletion (array $auditSubTasks): array
   {
-    return array_values(array_map(
-        fn($task) => $this->processScheduledTask($task),
-        array_filter($auditSubTasks, fn($task) => $this->gateway->statusAndScheduleCheck($task))
-    ));
+    return array_values(array_map(fn($task) => $this->processScheduledTask($task), array_filter($auditSubTasks, fn($task) => $this->gateway->statusAndScheduleCheck($task))));
   }
 
   /**
-- 
GitLab


From 1887a914b1d0f265ead2908a66ef34dda0ae6ed8 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Mar 2025 10:46:00 +0000
Subject: [PATCH 22/30] :sparkles: Feat(gateway) - simply add gateway to get
 methods

---
 .gitignore                 | 7 +++++++
 library/TaskController.php | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index a474600..84558c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,9 @@
 .vendor/
 .composer.lock
+filelist
+phpstan.neon
+.idea/fusiondirectory-orchestrator.iml
+.idea/modules.xml
+.idea/php.xml
+.idea/vcs.xml
+.idea/codeStyles/codeStyleConfig.xml
diff --git a/library/TaskController.php b/library/TaskController.php
index 849f5b6..2b4ddf3 100644
--- a/library/TaskController.php
+++ b/library/TaskController.php
@@ -55,7 +55,7 @@ class TaskController
           switch ($objectType) {
             case $objectType:
               if (class_exists($objectType)) {
-                $endpoint = new $objectType;
+                $endpoint = new $objectType($this->gateway);
                 $result   = $endpoint->processEndPointGet();
               }
               break;
-- 
GitLab


From 6977538fdfd4fffcede3462235fa41711b3c1283 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Mar 2025 15:21:23 +0000
Subject: [PATCH 23/30] :sparkles: feat(archive) - implement Archive endpoint
 with GET, PATCH, POST, and DELETE methods

---
 plugins/tasks/Archive.php | 98 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 plugins/tasks/Archive.php

diff --git a/plugins/tasks/Archive.php b/plugins/tasks/Archive.php
new file mode 100644
index 0000000..e7838f8
--- /dev/null
+++ b/plugins/tasks/Archive.php
@@ -0,0 +1,98 @@
+<?php
+
+class Archive implements EndpointInterface
+{
+  private TaskGateway $gateway;
+
+  public function __construct(TaskGateway $gateway)
+  {
+    $this->gateway = $gateway;
+  }
+
+  /**
+   * @return array
+   * Part of the interface of orchestrator plugin to treat GET method
+   */
+  public function processEndPointGet(): array
+  {
+    // Retrieve tasks of type 'archive'
+    return $this->gateway->getObjectTypeTask('archive');
+  }
+
+  /**
+   * @param array|null $data
+   * @return array
+   * @throws Exception
+   * Note: Part of the interface of orchestrator plugin to treat PATCH method
+   */
+  public function processEndPointPatch(array $data = NULL): array
+  {
+    $result = [];
+    $archiveTasks = $this->gateway->getObjectTypeTask('archive');
+
+    // Initialize the webservice object
+    // TODO
+    $webservice = new FusionDirectory\Rest\WebServiceCall($_ENV['FUSION_DIRECTORY_API_URL'] . '/archive', 'POST');
+    $webservice->setCurlSettings();
+
+    foreach ($archiveTasks as $task) {
+      // Verify the task status and schedule
+      if ($this->gateway->statusAndScheduleCheck($task)) {
+        // Retrieve the user's supannAccountStatus
+        $userStatus = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
+
+        // Check if the user meets the "toBeArchived" condition
+        // TODO
+        if ($userStatus === 'toBeArchived') {
+          // Trigger the archive method via the webservice
+          $archiveResult = $webservice->triggerArchive($task['fdtasksgranulardn'][0]);
+
+          // Update the task status based on the result
+          if ($archiveResult === TRUE) {
+            $result[$task['dn']]['result'] = "User successfully archived.";
+            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2'); // Mark task as completed
+          } else {
+            $result[$task['dn']]['result'] = "Error archiving user.";
+            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '3'); // Mark task as failed
+          }
+        } else {
+          $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
+        }
+      }
+    }
+
+    return $result;
+  }
+
+  /**
+   * @param array|null $data
+   * @return array
+   * Note: Part of the interface of orchestrator plugin to treat POST method
+   */
+  public function processEndPointPost(array $data = NULL): array
+  {
+    return [];
+  }
+
+  /**
+   * @param array|null $data
+   * @return array
+   * Note: Part of the interface of orchestrator plugin to treat DELETE method
+   */
+  public function processEndPointDelete(array $data = NULL): array
+  {
+    return [];
+  }
+
+  /**
+   * Retrieve the supannAccountStatus of a user
+   * @param string $userDn
+   * @return string|null
+   */
+  private function getUserSupannAccountStatus(string $userDn): ?string
+  {
+    // Logic to retrieve the supannAccountStatus attribute of the user
+    $user = $this->gateway->getLdapEntry($userDn, ['supannAccountStatus']);
+    return $user['supannAccountStatus'][0] ?? NULL;
+  }
+}
\ No newline at end of file
-- 
GitLab


From 5d600fe89739467ac8da1e00d2e97c205e3aa010 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Mar 2025 16:44:58 +0000
Subject: [PATCH 24/30] :sparkles: feat(archive) - enhance Archive
 functionality with WebServiceCall integration and improved error handling

---
 .idea/.gitignore          |  8 ++++++++
 plugins/tasks/Archive.php | 30 ++++++++++++++++++++----------
 2 files changed, 28 insertions(+), 10 deletions(-)
 create mode 100755 .idea/.gitignore

diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100755
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/plugins/tasks/Archive.php b/plugins/tasks/Archive.php
index e7838f8..77492f8 100644
--- a/plugins/tasks/Archive.php
+++ b/plugins/tasks/Archive.php
@@ -1,5 +1,7 @@
 <?php
 
+use FusionDirectory\Rest\WebServiceCall;
+
 class Archive implements EndpointInterface
 {
   private TaskGateway $gateway;
@@ -30,11 +32,6 @@ class Archive implements EndpointInterface
     $result = [];
     $archiveTasks = $this->gateway->getObjectTypeTask('archive');
 
-    // Initialize the webservice object
-    // TODO
-    $webservice = new FusionDirectory\Rest\WebServiceCall($_ENV['FUSION_DIRECTORY_API_URL'] . '/archive', 'POST');
-    $webservice->setCurlSettings();
-
     foreach ($archiveTasks as $task) {
       // Verify the task status and schedule
       if ($this->gateway->statusAndScheduleCheck($task)) {
@@ -42,19 +39,32 @@ class Archive implements EndpointInterface
         $userStatus = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
 
         // Check if the user meets the "toBeArchived" condition
-        // TODO
         if ($userStatus === 'toBeArchived') {
-          // Trigger the archive method via the webservice
-          $archiveResult = $webservice->triggerArchive($task['fdtasksgranulardn'][0]);
+          // Construct the archive URL
+          $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
+
+          // Initialize the WebServiceCall object
+          $webServiceCall = new WebServiceCall($archiveUrl, 'POST');
+          $webServiceCall->setCurlSettings();
 
-          // Update the task status based on the result
-          if ($archiveResult === TRUE) {
+          // Execute the request
+          $response = curl_exec($webServiceCall->ch);
+
+          // Handle any cURL errors
+          $webServiceCall->handleCurlError($webServiceCall->ch);
+
+          // Decode and process the response
+          $responseData = json_decode($response, true);
+          if ($responseData && isset($responseData['success']) && $responseData['success'] === true) {
             $result[$task['dn']]['result'] = "User successfully archived.";
             $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2'); // Mark task as completed
           } else {
             $result[$task['dn']]['result'] = "Error archiving user.";
             $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '3'); // Mark task as failed
           }
+
+          // Close the cURL resource
+          curl_close($webServiceCall->ch);
         } else {
           $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
         }
-- 
GitLab


From e92fd7ffafc649bc380644fc8dc783eac9c830c7 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Tue, 25 Mar 2025 00:40:12 +0000
Subject: [PATCH 25/30] :sparkles: feat(archive) - refactor archiving logic to
 streamline user status checks and enhance error handling (still error from
 API)

---
 plugins/tasks/Archive.php | 107 ++++++++++++++++++++++++--------------
 1 file changed, 69 insertions(+), 38 deletions(-)

diff --git a/plugins/tasks/Archive.php b/plugins/tasks/Archive.php
index 77492f8..f2bd8fb 100644
--- a/plugins/tasks/Archive.php
+++ b/plugins/tasks/Archive.php
@@ -32,43 +32,45 @@ class Archive implements EndpointInterface
     $result = [];
     $archiveTasks = $this->gateway->getObjectTypeTask('archive');
 
-    foreach ($archiveTasks as $task) {
-      // Verify the task status and schedule
-      if ($this->gateway->statusAndScheduleCheck($task)) {
-        // Retrieve the user's supannAccountStatus
-        $userStatus = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
-
-        // Check if the user meets the "toBeArchived" condition
-        if ($userStatus === 'toBeArchived') {
-          // Construct the archive URL
-          $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
-
-          // Initialize the WebServiceCall object
-          $webServiceCall = new WebServiceCall($archiveUrl, 'POST');
-          $webServiceCall->setCurlSettings();
-
-          // Execute the request
-          $response = curl_exec($webServiceCall->ch);
-
-          // Handle any cURL errors
-          $webServiceCall->handleCurlError($webServiceCall->ch);
-
-          // Decode and process the response
-          $responseData = json_decode($response, true);
-          if ($responseData && isset($responseData['success']) && $responseData['success'] === true) {
-            $result[$task['dn']]['result'] = "User successfully archived.";
-            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2'); // Mark task as completed
-          } else {
-            $result[$task['dn']]['result'] = "Error archiving user.";
-            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '3'); // Mark task as failed
-          }
+    // Initialize the WebServiceCall object for login
+    $webServiceCall = new WebServiceCall($_ENV['FUSION_DIRECTORY_API_URL'] . '/login', 'POST');
+    $webServiceCall->setCurlSettings(); // Perform login and set the token
 
-          // Close the cURL resource
-          curl_close($webServiceCall->ch);
-        } else {
-          $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
+    foreach ($archiveTasks as $task) {
+        try {
+            if (!$this->gateway->statusAndScheduleCheck($task)) {
+                // Skip this task if it does not meet the status and schedule criteria
+                continue;
+            }
+
+            // Receive null or 'toBeArchived'
+            $supannState = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
+
+            if ($supannState !== 'toBeArchived') {
+                // The task does not meet the criteria for archiving and can therefore be suppressed
+                $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
+                $this->gateway->removeSubTask($task['dn']);
+                continue;
+            }
+
+            // Set the archive endpoint and method using the same WebServiceCall object
+            $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
+            $webServiceCall->setCurlSettings($archiveUrl, [], 'POST'); // Update settings for the archive request
+            $response = $webServiceCall->execute();
+
+            print_r([$response]);
+              exit;
+
+            if (isset($response['success']) && $response['success'] === true) {
+                $result[$task['dn']]['result'] = "User successfully archived.";
+                $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2');
+            } else {
+                throw new Exception("Invalid API response format");
+            }
+        } catch (Exception $e) {
+            $result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage();
+            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], $e->getMessage());
         }
-      }
     }
 
     return $result;
@@ -101,8 +103,37 @@ class Archive implements EndpointInterface
    */
   private function getUserSupannAccountStatus(string $userDn): ?string
   {
-    // Logic to retrieve the supannAccountStatus attribute of the user
-    $user = $this->gateway->getLdapEntry($userDn, ['supannAccountStatus']);
-    return $user['supannAccountStatus'][0] ?? NULL;
+      $supannState = $this->gateway->getLdapTasks(
+          '(objectClass=supannPerson)',
+          ['supannRessourceEtatDate'],
+          '',
+          $userDn
+      );
+  
+      if ($this->hasToBeArchived($supannState)) {
+          return 'toBeArchived';
+      }
+  
+      return null;
+  }
+
+  private function hasToBeArchived(array $supannState): bool
+  {
+      if (!isset($supannState[0]['supannressourceetatdate']) || !is_array($supannState[0]['supannressourceetatdate'])) {
+          return false;
+      }
+
+      foreach ($supannState[0]['supannressourceetatdate'] as $key => $value) {
+          // Skip non-numeric keys (e.g., 'count')
+          if (!is_numeric($key)) {
+              continue;
+          }
+
+          if (strpos($value, '{COMPTE}I:toBeArchived') !== false) {
+              return true;
+          }
+      }
+
+      return false;
   }
 }
\ No newline at end of file
-- 
GitLab


From cc2e13d47f463c48e5b06fffce321bafd4f8fb88 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Tue, 25 Mar 2025 11:57:08 +0000
Subject: [PATCH 26/30] :sparkles: feat(archive) - update archive request
 settings and improve error handling for unexpected HTTP status codes

---
 plugins/tasks/Archive.php | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/plugins/tasks/Archive.php b/plugins/tasks/Archive.php
index f2bd8fb..593c99d 100644
--- a/plugins/tasks/Archive.php
+++ b/plugins/tasks/Archive.php
@@ -55,17 +55,15 @@ class Archive implements EndpointInterface
 
             // Set the archive endpoint and method using the same WebServiceCall object
             $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
-            $webServiceCall->setCurlSettings($archiveUrl, [], 'POST'); // Update settings for the archive request
+            $webServiceCall->setCurlSettings($archiveUrl, NULL, 'POST'); // Update settings for the archive request
             $response = $webServiceCall->execute();
 
-            print_r([$response]);
-              exit;
-
-            if (isset($response['success']) && $response['success'] === true) {
+            // Check if the HTTP status code is 204
+            if ($webServiceCall->getHttpStatusCode() === 204) {
                 $result[$task['dn']]['result'] = "User successfully archived.";
                 $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2');
             } else {
-                throw new Exception("Invalid API response format");
+                throw new Exception("Unexpected HTTP status code: " . $webServiceCall->getHttpStatusCode());
             }
         } catch (Exception $e) {
             $result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage();
-- 
GitLab


From 6867f825cf1f0290dcadc65a0bac66af9f71cba2 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Tue, 25 Mar 2025 15:17:33 +0000
Subject: [PATCH 27/30] :art: style(archive) - apply consistent spacing in
 method signatures and improve code readability

---
 plugins/tasks/Archive.php | 112 +++++++++++++++++++-------------------
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/plugins/tasks/Archive.php b/plugins/tasks/Archive.php
index 593c99d..2ef3e2f 100644
--- a/plugins/tasks/Archive.php
+++ b/plugins/tasks/Archive.php
@@ -6,7 +6,7 @@ class Archive implements EndpointInterface
 {
   private TaskGateway $gateway;
 
-  public function __construct(TaskGateway $gateway)
+  public function __construct (TaskGateway $gateway)
   {
     $this->gateway = $gateway;
   }
@@ -15,7 +15,7 @@ class Archive implements EndpointInterface
    * @return array
    * Part of the interface of orchestrator plugin to treat GET method
    */
-  public function processEndPointGet(): array
+  public function processEndPointGet (): array
   {
     // Retrieve tasks of type 'archive'
     return $this->gateway->getObjectTypeTask('archive');
@@ -27,7 +27,7 @@ class Archive implements EndpointInterface
    * @throws Exception
    * Note: Part of the interface of orchestrator plugin to treat PATCH method
    */
-  public function processEndPointPatch(array $data = NULL): array
+  public function processEndPointPatch (array $data = NULL): array
   {
     $result = [];
     $archiveTasks = $this->gateway->getObjectTypeTask('archive');
@@ -37,38 +37,38 @@ class Archive implements EndpointInterface
     $webServiceCall->setCurlSettings(); // Perform login and set the token
 
     foreach ($archiveTasks as $task) {
-        try {
-            if (!$this->gateway->statusAndScheduleCheck($task)) {
-                // Skip this task if it does not meet the status and schedule criteria
-                continue;
-            }
-
-            // Receive null or 'toBeArchived'
-            $supannState = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
-
-            if ($supannState !== 'toBeArchived') {
-                // The task does not meet the criteria for archiving and can therefore be suppressed
-                $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
-                $this->gateway->removeSubTask($task['dn']);
-                continue;
-            }
-
-            // Set the archive endpoint and method using the same WebServiceCall object
-            $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
-            $webServiceCall->setCurlSettings($archiveUrl, NULL, 'POST'); // Update settings for the archive request
-            $response = $webServiceCall->execute();
-
-            // Check if the HTTP status code is 204
-            if ($webServiceCall->getHttpStatusCode() === 204) {
-                $result[$task['dn']]['result'] = "User successfully archived.";
-                $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2');
-            } else {
-                throw new Exception("Unexpected HTTP status code: " . $webServiceCall->getHttpStatusCode());
-            }
-        } catch (Exception $e) {
-            $result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage();
-            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], $e->getMessage());
+      try {
+        if (!$this->gateway->statusAndScheduleCheck($task)) {
+            // Skip this task if it does not meet the status and schedule criteria
+            continue;
         }
+
+          // Receive null or 'toBeArchived'
+          $supannState = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
+
+        if ($supannState !== 'toBeArchived') {
+            // The task does not meet the criteria for archiving and can therefore be suppressed
+            $result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
+            $this->gateway->removeSubTask($task['dn']);
+            continue;
+        }
+
+          // Set the archive endpoint and method using the same WebServiceCall object
+          $archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
+          $webServiceCall->setCurlSettings($archiveUrl, NULL, 'POST'); // Update settings for the archive request
+          $response = $webServiceCall->execute();
+
+          // Check if the HTTP status code is 204
+        if ($webServiceCall->getHttpStatusCode() === 204) {
+            $result[$task['dn']]['result'] = "User successfully archived.";
+            $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2');
+        } else {
+            throw new Exception("Unexpected HTTP status code: " . $webServiceCall->getHttpStatusCode());
+        }
+      } catch (Exception $e) {
+          $result[$task['dn']]['result'] = "Error archiving user: " . $e->getMessage();
+          $this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], $e->getMessage());
+      }
     }
 
     return $result;
@@ -79,7 +79,7 @@ class Archive implements EndpointInterface
    * @return array
    * Note: Part of the interface of orchestrator plugin to treat POST method
    */
-  public function processEndPointPost(array $data = NULL): array
+  public function processEndPointPost (array $data = NULL): array
   {
     return [];
   }
@@ -89,7 +89,7 @@ class Archive implements EndpointInterface
    * @return array
    * Note: Part of the interface of orchestrator plugin to treat DELETE method
    */
-  public function processEndPointDelete(array $data = NULL): array
+  public function processEndPointDelete (array $data = NULL): array
   {
     return [];
   }
@@ -99,7 +99,7 @@ class Archive implements EndpointInterface
    * @param string $userDn
    * @return string|null
    */
-  private function getUserSupannAccountStatus(string $userDn): ?string
+  private function getUserSupannAccountStatus (string $userDn): ?string
   {
       $supannState = $this->gateway->getLdapTasks(
           '(objectClass=supannPerson)',
@@ -107,31 +107,31 @@ class Archive implements EndpointInterface
           '',
           $userDn
       );
-  
-      if ($this->hasToBeArchived($supannState)) {
-          return 'toBeArchived';
-      }
-  
-      return null;
+
+    if ($this->hasToBeArchived($supannState)) {
+        return 'toBeArchived';
+    }
+
+      return NULL;
   }
 
-  private function hasToBeArchived(array $supannState): bool
+  private function hasToBeArchived (array $supannState): bool
   {
-      if (!isset($supannState[0]['supannressourceetatdate']) || !is_array($supannState[0]['supannressourceetatdate'])) {
-          return false;
-      }
+    if (!isset($supannState[0]['supannressourceetatdate']) || !is_array($supannState[0]['supannressourceetatdate'])) {
+        return FALSE;
+    }
 
-      foreach ($supannState[0]['supannressourceetatdate'] as $key => $value) {
-          // Skip non-numeric keys (e.g., 'count')
-          if (!is_numeric($key)) {
-              continue;
-          }
+    foreach ($supannState[0]['supannressourceetatdate'] as $key => $value) {
+        // Skip non-numeric keys (e.g., 'count')
+      if (!is_numeric($key)) {
+          continue;
+      }
 
-          if (strpos($value, '{COMPTE}I:toBeArchived') !== false) {
-              return true;
-          }
+      if (strpos($value, '{COMPTE}I:toBeArchived') !== FALSE) {
+          return TRUE;
       }
+    }
 
-      return false;
+      return FALSE;
   }
 }
\ No newline at end of file
-- 
GitLab


From 64c0b7dffe6f4766febf759d11be42ed893f65f6 Mon Sep 17 00:00:00 2001
From: Benoit Mortier <benoit.mortier@fusiondirectory.org>
Date: Tue, 25 Mar 2025 18:11:35 +0100
Subject: [PATCH 28/30] :ambulance: fix(centos) remove centos from the builds

Signed-off-by: Benoit Mortier <benoit.mortier@fusiondirectory.org>
---
 .gitlab-ci.yml | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1e84902..8356ce6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -93,10 +93,3 @@ trigger-ci-ubuntu-focal:
     project: ubuntu/focal-fusiondirectory-orchestrator-dev
     branch: "main"
 
-trigger-ci-centos-7:
-  stage: trigger
-  only:
-    - dev
-  trigger:
-    project: centos/centos7-fusiondirectory-orchestrator-dev
-    branch: "main"
-- 
GitLab


From 8fc447077b15fad09443cd9ca479701db67fe191 Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 10:36:59 +0100
Subject: [PATCH 29/30] change to audit

---
 plugins/tasks/Audit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index e3556bb..db8ef72 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -50,7 +50,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = $this->utils->recursiveArrayFilter($result);
+    $filteredResults = Utils::recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
-- 
GitLab


From 9d24c66f394a1c9c17f5ab00933e279a6570116b Mon Sep 17 00:00:00 2001
From: Oana-Eliza Alexa <43857161+alexaeliza@users.noreply.github.com>
Date: Mon, 24 Mar 2025 13:29:02 +0100
Subject: [PATCH 30/30] fix indent

---
 plugins/tasks/Audit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php
index db8ef72..e3556bb 100644
--- a/plugins/tasks/Audit.php
+++ b/plugins/tasks/Audit.php
@@ -50,7 +50,7 @@ class Audit implements EndpointInterface
     $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit'));
 
     // Recursive function to filter out empty arrays at any depth
-    $filteredResults = Utils::recursiveArrayFilter($result);
+    $filteredResults = $this->utils->recursiveArrayFilter($result);
 
     if (empty($filteredResults)) {
         return [$this->errorMessage];
-- 
GitLab