From 1bc65825dd7466f01f941d87bb6ca3c8fc46cb39 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 24 Feb 2025 17:19:29 +0000
Subject: [PATCH] :sparkles: (Mangement) - adds some files to php 8.2

Adds file to php8.2
---
 include/management/class_ListingEntry.inc        | 11 ++++-------
 .../class_ManagementConfigurationDialog.inc      | 16 ++++++++--------
 include/management/class_managementFilter.inc    | 12 ++++++------
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/include/management/class_ListingEntry.inc b/include/management/class_ListingEntry.inc
index 759c6acb9..0f7cdbb3f 100755
--- a/include/management/class_ListingEntry.inc
+++ b/include/management/class_ListingEntry.inc
@@ -40,20 +40,17 @@ 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, array $attrs, int $row = NULL)
+  public function __construct (managementListing $listing, string $type, string $dn, private array $attrs, int $row = NULL)
   {
     $this->listing  = $listing;
     $this->type     = $type;
     $this->dn       = $dn;
     $this->aclBase  = $dn;
-    $this->attrs    = $attrs;
     $this->row      = $row;
   }
 
@@ -84,12 +81,12 @@ class ListingEntry implements ArrayAccess
 
   public function isTemplate (): bool
   {
-    return preg_match('/^template_/', $this->type);
+    return preg_match('/^template_/', (string) $this->type);
   }
 
   public function getTemplatedType (): string
   {
-    return preg_replace('/^template_/', '', $this->type);
+    return preg_replace('/^template_/', '', (string) $this->type);
   }
 
   public function getTemplatedFields (): array
@@ -104,7 +101,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 (strpos($rights, $acl) === FALSE) {
+      if (!str_contains((string) $rights, $acl)) {
         return FALSE;
       }
     }
diff --git a/include/management/class_ManagementConfigurationDialog.inc b/include/management/class_ManagementConfigurationDialog.inc
index d0dfa4d89..72736c1bd 100755
--- a/include/management/class_ManagementConfigurationDialog.inc
+++ b/include/management/class_ManagementConfigurationDialog.inc
@@ -128,10 +128,10 @@ class ManagementConfigurationDialog extends ManagementDialog
       $this->attributesAccess['resetInLdap']->setVisible(FALSE);
     }
 
-    if (!$config->hasManagementConfig(get_class($this->parent), TRUE)) {
+    if (!$config->hasManagementConfig($this->parent::class, TRUE)) {
       $this->attributesAccess['resetInLdapUser']->setVisible(FALSE);
     }
-    if (!$config->hasManagementConfig(get_class($this->parent), FALSE)) {
+    if (!$config->hasManagementConfig($this->parent::class, FALSE)) {
       $this->attributesAccess['resetInLdap']->setVisible(FALSE);
     }
 
@@ -169,7 +169,7 @@ class ManagementConfigurationDialog extends ManagementDialog
       return TRUE;
     } elseif ((is_object($attr) && in_array($attr->getLdapName(), $configAttrs)) || in_array($attr, $configAttrs)) {
       $acl = $ui->get_permissions(CONFIGRDN.$config->current['BASE'], 'configuration/configInLdap', 'fdManagementConfig', $this->readOnly());
-      return (strpos($acl, 'w') !== FALSE);
+      return (str_contains((string) $acl, 'w'));
     } else {
       return parent::attrIsWriteable($attr);
     }
@@ -178,7 +178,7 @@ class ManagementConfigurationDialog extends ManagementDialog
   function handle_resetInLdapUser ()
   {
     global $config;
-    $errors = $config->updateManagementConfig(get_class($this->parent), NULL, TRUE);
+    $errors = $config->updateManagementConfig($this->parent::class, NULL, TRUE);
     msg_dialog::displayChecks($errors);
     if (empty($errors)) {
       $this->attributesAccess['resetInLdapUser']->setVisible(FALSE);
@@ -188,7 +188,7 @@ class ManagementConfigurationDialog extends ManagementDialog
   function handle_resetInLdap ()
   {
     global $config;
-    $errors = $config->updateManagementConfig(get_class($this->parent), NULL, FALSE);
+    $errors = $config->updateManagementConfig($this->parent::class, NULL, FALSE);
     msg_dialog::displayChecks($errors);
     if (empty($errors)) {
       $this->attributesAccess['resetInLdap']->setVisible(FALSE);
@@ -213,7 +213,7 @@ class ManagementConfigurationDialog extends ManagementDialog
     foreach ($values as $value) {
       $column = [$value[0], []];
       if (!empty($value[1])) {
-        $jsonDecoded = json_decode($value[1], TRUE);
+        $jsonDecoded = json_decode((string) $value[1], TRUE);
         if ($jsonDecoded !== NULL) {
           $column[1]['attributes'] = $jsonDecoded;
         } else {
@@ -228,11 +228,11 @@ class ManagementConfigurationDialog extends ManagementDialog
     $this->parent->setColumnConfiguration($columnInfos);
 
     if ($this->saveInLdapUser) {
-      return $config->updateManagementConfig(get_class($this->parent), $columnInfos, TRUE);
+      return $config->updateManagementConfig($this->parent::class, $columnInfos, TRUE);
     }
 
     if ($this->saveInLdap) {
-      return $config->updateManagementConfig(get_class($this->parent), $columnInfos);
+      return $config->updateManagementConfig($this->parent::class, $columnInfos);
     }
 
     return [];
diff --git a/include/management/class_managementFilter.inc b/include/management/class_managementFilter.inc
index aa58142c3..7cdfb3342 100755
--- a/include/management/class_managementFilter.inc
+++ b/include/management/class_managementFilter.inc
@@ -120,7 +120,7 @@ class managementFilter
       $this->parent->listing->fillSearchedAttributes($type, $attrs);
       foreach ($attrs as $attr => $acl) {
         $rights = $ui->get_permissions($base, $acl, $attr);
-        if (strpos($rights, 'r') !== FALSE) {
+        if (str_contains((string) $rights, 'r')) {
           $this->searchAttributes[$type][] = $attr;
         }
       }
@@ -143,12 +143,12 @@ class managementFilter
     $searchAttrs = [];
     foreach ($this->searchAttributes as $type => $attrs) {
       foreach ($attrs as $attr) {
-        $searchAttrs[] = strtolower($type).'/'.$attr;
+        $searchAttrs[] = strtolower((string) $type).'/'.$attr;
       }
     }
     $smarty->assign('SEARCHDESC', sprintf(_('Searches in %s'), implode(', ', $searchAttrs)));
 
-    $parentClass = get_class($this->parent);
+    $parentClass = $this->parent::class;
     if (!$parentClass::$skipTemplates) {
       $smarty->assign('TEMPLATES',  $this->showTemplates);
     }
@@ -201,7 +201,7 @@ class managementFilter
 
       $elementFilters = [];
       if (!empty($this->search)) {
-        if (preg_match('/^\(.+\)$/', $this->search)) {
+        if (preg_match('/^\(.+\)$/', (string) $this->search)) {
           $elementFilters[] = $this->search;
         } else {
           $searchAttributesTmp    = $this->searchAttributes[$type];
@@ -224,7 +224,7 @@ class managementFilter
         $filter = '(&'.implode('', $typeElementFilters).')';
       }
 
-      $parentClass = get_class($this->parent);
+      $parentClass = $this->parent::class;
       if (!$parentClass::$skipTemplates && $this->showTemplates) {
         try {
           $ldapEntries = objects::ls($type, $attrsAsked, (($this->scope == 'one') ? 'ou=templates,'.$searchBase : $searchBase), $filter, TRUE, $this->scope, TRUE);
@@ -290,7 +290,7 @@ class managementFilter
           continue;
         }
         foreach ($this->parent->whiteList['branches'] as $branch) {
-          if (preg_match('/'.preg_quote($branch, '/').'$/', $dn)) {
+          if (preg_match('/'.preg_quote((string) $branch, '/').'$/', $dn)) {
             continue 2;
           }
         }
-- 
GitLab