From f77cc69758847f9ba2aa1d0bcb4bf7d73eb210fe Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Mar 2025 14:44:19 +0000
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(archive):=20add=20warnings=20f?=
 =?UTF-8?q?or=20missing=20SupAnn=20Account=20Status=20plugin=20in=20archiv?=
 =?UTF-8?q?eTask?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 archive/workflow/class_archiveTask.inc | 32 +++++++++++++++++++-------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/archive/workflow/class_archiveTask.inc b/archive/workflow/class_archiveTask.inc
index a27afd7d86..01f1b19426 100644
--- a/archive/workflow/class_archiveTask.inc
+++ b/archive/workflow/class_archiveTask.inc
@@ -79,6 +79,12 @@ class archiveTask extends simplePlugin
     // SupAnn Status management
     if (class_available('supannAccountStatus')) {
       $this->setSupannStates();
+    } else {
+        msg_dialog::display(
+            _('Warning'),
+            _('The SupAnn Account Status plugin is not activated. This task cannot function properly without it.'),
+            WARNING_DIALOG
+        );
     }
   }
 
@@ -144,13 +150,23 @@ class archiveTask extends simplePlugin
    */
   function save (): array
   {
-    // Verify if this task has to be executed upon saving.
-    $execTasks = $this->parent->getBaseObject()->fdSubTasksActivation ?? NULL;
-
-    if ($execTasks) {
-      $this->generateSlaveTasks();
-    }
-
-    return parent::save();
+      // Check if the SupAnn Account Status plugin is available (It should not happen as attributes verification will trigger errors before save)
+      if (!class_available('supannAccountStatus')) {
+          msg_dialog::display(
+              _('Error'),
+              _('The SupAnn Account Status plugin is not activated. This task cannot be saved or executed without it.'),
+              ERROR_DIALOG
+          );
+          return []; // Return an empty array to indicate no action was taken
+      }
+  
+      // Verify if this task has to be executed upon saving
+      $execTasks = $this->parent->getBaseObject()->fdSubTasksActivation ?? NULL;
+  
+      if ($execTasks) {
+          $this->generateSlaveTasks();
+      }
+  
+      return parent::save();
   }
 }
\ No newline at end of file
-- 
GitLab