From 57ec49e0ada2ca2490e3b6568a7cb881e9807e17 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Tue, 25 Feb 2025 15:48:59 +0000
Subject: [PATCH] :sparkles: Feat(ListingManagement) - adapted

Adaps class listing to php8.2
---
 include/management/class_ListingEntry.inc | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/management/class_ListingEntry.inc b/include/management/class_ListingEntry.inc
index 0f7cdbb3f..9dee22006 100755
--- a/include/management/class_ListingEntry.inc
+++ b/include/management/class_ListingEntry.inc
@@ -40,36 +40,39 @@ class ListingEntry implements ArrayAccess
    * \brief Object type
    */
   public $type;
+
+  private $attrs;
   protected $listing;
 
   /* Cache where columns may store stuff */
   public $cache = [];
 
-  public function __construct (managementListing $listing, string $type, string $dn, private array $attrs, int $row = NULL)
+  public function __construct (managementListing $listing, string $type, string $dn, array $attrs, int $row = NULL)
   {
     $this->listing  = $listing;
     $this->type     = $type;
     $this->dn       = $dn;
     $this->aclBase  = $dn;
+    $this->attrs    = $attrs;
     $this->row      = $row;
   }
 
-  public function offsetSet ($offset, $value) : void
+  public function offsetSet ($offset, $value)
   {
     $this->attrs[$offset] = $value;
   }
 
-  public function offsetExists ($offset) : bool
+  public function offsetExists ($offset)
   {
     return isset($this->attrs[$offset]);
   }
 
-  public function offsetUnset ($offset) : void
+  public function offsetUnset ($offset)
   {
     unset($this->attrs[$offset]);
   }
 
-  public function offsetGet ($offset) : mixed
+  public function offsetGet ($offset)
   {
     return (isset($this->attrs[$offset]) ? $this->attrs[$offset] : NULL);
   }
@@ -81,12 +84,12 @@ class ListingEntry implements ArrayAccess
 
   public function isTemplate (): bool
   {
-    return preg_match('/^template_/', (string) $this->type);
+    return preg_match('/^template_/', $this->type);
   }
 
   public function getTemplatedType (): string
   {
-    return preg_replace('/^template_/', '', (string) $this->type);
+    return preg_replace('/^template_/', '', $this->type);
   }
 
   public function getTemplatedFields (): array
@@ -101,7 +104,7 @@ class ListingEntry implements ArrayAccess
     $infos  = objects::infos($this->getTemplatedType());
     $rights = $ui->get_permissions($this->aclBase, $infos['aclCategory'].'/'.($this->isTemplate() ? 'template' : $infos['mainTab']));
     foreach (str_split($acls) as $acl) {
-      if (!str_contains((string) $rights, $acl)) {
+      if (strpos($rights, $acl) === FALSE) {
         return FALSE;
       }
     }
@@ -125,3 +128,4 @@ class ListingEntry implements ArrayAccess
     return $ui->allow_snapshot_restore($this->aclBase, $infos['aclCategory'], FALSE);
   }
 }
+
-- 
GitLab