From a2526605df5deb06e94c42f36b03c6f4c57b6aee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Tue, 22 Oct 2019 15:10:52 +0200
Subject: [PATCH] :ambulance: fix(core) Remove ugly storing of object dn in
 session

There was two functions for storing/getting object dn from session for
 no reason.

issue #6038
---
 html/main.php                                   |  6 ------
 include/functions.inc                           | 12 ------------
 include/management/class_management.inc         | 13 ++-----------
 include/simpleplugin/class_simpleManagement.inc |  9 ++-------
 plugins/admin/acl/class_aclManagement.inc       |  2 --
 5 files changed, 4 insertions(+), 38 deletions(-)

diff --git a/html/main.php b/html/main.php
index ddcef8e14..5433436d1 100644
--- a/html/main.php
+++ b/html/main.php
@@ -169,12 +169,6 @@ if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 2048000)) {
   msg_dialog::display(_("Configuration error"), _("Running out of memory!"), WARNING_DIALOG);
 }
 
-/* Load department list when plugin has changed. That is some kind of
-   compromise between speed and beeing up to date */
-if (isset($_GET['reset'])) {
-  set_object_info();
-}
-
 /* show web frontend */
 $smarty->assign("date", date("l, dS F Y H:i:s O"));
 $lang = session::get('lang');
diff --git a/include/functions.inc b/include/functions.inc
index b0c4459df..0ff4d6611 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -1835,18 +1835,6 @@ function cred_decrypt ($input, $password)
   return openssl_decrypt($input, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
 }
 
-
-function get_object_info ()
-{
-  return session::get('objectinfo');
-}
-
-
-function set_object_info ($str = "")
-{
-  session::set('objectinfo', $str);
-}
-
 /*!
  * \brief Test if an ip is the network range
  *
diff --git a/include/management/class_management.inc b/include/management/class_management.inc
index 0e67ce012..75c49e07f 100644
--- a/include/management/class_management.inc
+++ b/include/management/class_management.inc
@@ -589,9 +589,8 @@ class management
     $smarty->assign('headline', $this->title);
     $smarty->assign('headline_image', $this->icon);
 
-    $info = get_object_info();
-    if ($info != '') {
-      return '<div class="pluginfo">'.$info."</div>\n";
+    if (is_object($this->tabObject) && ($this->currentDn != '')) {
+      return '<div class="pluginfo">'.$this->currentDn."</div>\n";
     }
     return '';
   }
@@ -617,8 +616,6 @@ class management
     $this->tabObject          = NULL;
     $this->last_dialogObject  = $this->dialogObject;
     $this->dialogObject       = NULL;
-
-    set_object_info();
   }
 
   protected function listAclCategories (): array
@@ -719,8 +716,6 @@ class management
 
     $this->currentDn = 'new';
 
-    set_object_info($this->currentDn);
-
     // Open object
     $this->openTabObject(objects::create($type));
     @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDn, 'Create entry initiated');
@@ -735,8 +730,6 @@ class management
 
     $this->currentDn = 'new';
 
-    set_object_info($this->currentDn);
-
     // Open object
     $this->openTabObject(objects::createTemplate($type));
     @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDn, 'Create template entry initiated');
@@ -841,7 +834,6 @@ class management
 
     // Get the dn of the object and create lock
     $this->currentDn = $target;
-    set_object_info($this->currentDn);
     if ($locks = get_locks($this->currentDn, TRUE)) {
       return gen_locked_message($locks, $this->currentDn, TRUE);
     }
@@ -1230,7 +1222,6 @@ class management
         $this->listing->focusDn($dn);
         $entry = $this->listing->getEntry($dn);
         $this->currentDn = $dn;
-        set_object_info($this->currentDn);
         add_lock($this->currentDn, $ui->dn);
 
         // Open object
diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc
index de90f18a5..aa99423ed 100644
--- a/include/simpleplugin/class_simpleManagement.inc
+++ b/include/simpleplugin/class_simpleManagement.inc
@@ -511,9 +511,8 @@ class simpleManagement
     $smarty->assign('headline', $plTitle);
     $smarty->assign('headline_image', $plIcon);
 
-    $info = get_object_info();
-    if ($info != '') {
-      return '<div class="pluginfo">'.$info."</div>\n";
+    if (is_object($this->tabObject) && ($this->dn != '')) {
+      return '<div class="pluginfo">'.$this->dn."</div>\n";
     }
     return '';
   }
@@ -577,8 +576,6 @@ class simpleManagement
     $this->dn               = 'new';
     $this->is_single_edit   = FALSE;
 
-    set_object_info($this->dn);
-
     // Open object
     $this->openTabObject(objects::open($this->dn, $type));
     @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, "Create new entry initiated!");
@@ -774,7 +771,6 @@ class simpleManagement
 
       // Get the dn of the object and creates lock
       $this->dn = array_pop($target);
-      set_object_info($this->dn);
       if ($locks = get_locks($this->dn, TRUE)) {
         return gen_locked_message($locks, $this->dn, TRUE);
       }
@@ -871,7 +867,6 @@ class simpleManagement
     $this->dialogObject       = NULL;
 
     $this->skipFooter   = FALSE;
-    set_object_info();
   }
 
   /*!
diff --git a/plugins/admin/acl/class_aclManagement.inc b/plugins/admin/acl/class_aclManagement.inc
index 889270f98..f774ce252 100644
--- a/plugins/admin/acl/class_aclManagement.inc
+++ b/plugins/admin/acl/class_aclManagement.inc
@@ -187,8 +187,6 @@ class aclManagement extends management
 
     $this->currentDn        = $dn;
 
-    set_object_info($this->currentDn);
-
     $this->openTabObject($tabObject);
     @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDn, 'Creating new ACLĂ‚ assignment');
   }
-- 
GitLab