Code

Fixed encoding detection of the ldap backend.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Jul 2011 13:04:43 +0000 (13:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Jul 2011 13:04:43 +0000 (13:04 +0000)
-Do not check encoding on each page reload, instead cache results.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20946 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc

index 5bd013a85ded0f79a48c9d20e401d319c2736d3b..eae0753ceee665b22910ddee690b85ca457f4cdb 100644 (file)
@@ -115,6 +115,21 @@ class LDAP
      */
     static function updateSpecialCharHandling()
     {
+        global $config;
+
+        // Load results from the session if they exists.
+        if(session::is_set('LDAP::updateSpecialCharHandling')){
+            $data = session::get('LDAP::updateSpecialCharHandling');
+            $attrs = array("characterMap", "characterMapRegFrom", "characterMapRegTo", "readableMapRegFrom", "readableMapRegTo");
+            foreach($attrs as $attr){
+                LDAP::$$attr = $data[$attr];
+            }
+            
+            $attrs = array(implode(LDAP::$characterMapRegFrom,', '),implode(LDAP::$characterMapRegTo,', '));
+            @DEBUG(DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,$attrs,"(Cached) Detected special-char handling for LDAP actions");
+            return;
+        }
+
         // Set a default character handling.
         LDAP::$characterMapRegFrom = array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/", "/\001DQ/");
         LDAP::$characterMapRegTo = array("\,", "(", ")", "/", '\"');
@@ -150,6 +165,14 @@ class LDAP
                 LDAP::$characterMap = array();
             }
         }
+        
+        // Store results in the session.
+        $attrs = array("characterMap", "characterMapRegFrom", "characterMapRegTo", "readableMapRegFrom", "readableMapRegTo");
+        $data = array();
+        foreach($attrs as $attr){
+            $data[$attr] = LDAP::$$attr;
+        }
+        session::set("LDAP::updateSpecialCharHandling", $data);
 
         $attrs = array(implode(LDAP::$characterMapRegFrom,', '),implode(LDAP::$characterMapRegTo,', '));
         @DEBUG(DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,$attrs,"Detected special-char handling for LDAP actions");