Code

Updated password field handling
[gosa.git] / gosa-core / include / class_pathNavigator.inc
index 601b8908294b97cfd890a12ee1b035f9d9c02ffd..6140e0e0146290e591bf152726ecba82c2dccc21 100644 (file)
@@ -3,10 +3,9 @@
 class pathNavigator
 {
 
-  static function registerPlugin($class)
+  static function registerPlugin($class, $title= "")
   {
-    
-    $str = $title = "";
+    $str = "";
 
     // Display headline of management plugins
     if($class instanceOf management && isset($class->plHeadline)){
@@ -15,9 +14,7 @@ class pathNavigator
 
     // Shown title of sub dialogs (They have no plHeadline set.)
     if($class instanceOf plugin && !isset($class->plHeadline)){
-      if(empty($class->pathTitle)){
-        $str = "Missing: ".get_class($class);
-      }else{
+      if(!empty($class->pathTitle)){
         $str = _($class->pathTitle);
       }
     }
@@ -30,15 +27,22 @@ class pathNavigator
         if(!session::is_set("pathNavigator::registerPlugin:{$class->dn}")){
           global $config;
           $ldap = $config->get_ldap_link();
-          $ldap->cat($class->dn, array('cn'));
-          if($ldap->count()){
-            $attrs = $ldap->fetch();
-            $str = $attrs['cn'][0];
+
+          if(!empty($class->dn)){
+            $namingAttr = preg_replace("/^([^=]*)=.*$/","\\1",$class->dn);
+
+            $ldap->cat($class->dn, array($namingAttr));
+            if($ldap->count()){
+              $attrs = $ldap->fetch();
+              $str = $attrs[$namingAttr][0];
+            }
+            session::set("pathNavigator::registerPlugin:{$class->dn}", $str);
           }
-          session::set("pathNavigator::registerPlugin:{$class->dn}", $str);
         }
         $str = session::get("pathNavigator::registerPlugin:{$class->dn}");
-        $title = $class->dn;
+        if(empty($title)){
+          $title = $class->dn;
+        }
       }
     }
 
@@ -49,26 +53,47 @@ class pathNavigator
     
     if(!empty($str)){
       $cur = session::get('pathNavigator::position');
-
-      if(!empty($title)) $title = " title='{$title}' ";
-
-      $cur.= "\n<li {$title} class='left path-element'>{$str}</li>";
+      $entry = array('TITLE' => $title, 'NAME' => $str);
+      $cur[] = $entry;
       session::set('pathNavigator::position', $cur);
     }
   }
 
   static function getCurrentPath()
   {
-    $path = session::get('pathNavigator::position');
+    // Ensure that we've a position value initialized. 
+    if(!session::is_set('pathNavigator::position')) {
+        session::set('pathNavigator::position',array());
+    }
+
+    // Get position and validate its value
+    $list = session::get('pathNavigator::position');
+    if(!is_array($list)){
+        $list = array();
+    }
+
+    // Build up title and path string.
+    $path = "";
+    $sTitle = "";
+    foreach($list as $entry){
+        $title = (!empty($entry['TITLE']))? 'title="'.htmlentities(LDAP::fix($entry['TITLE']),ENT_COMPAT,'UTF-8').'"': '';
+        $path.= "\n<li {$title} class='left path-element'>{$entry['NAME']}</li>";
+        $sTitle .= " - ".$entry['NAME'];
+    }
+
+    // If no path is given then show a simple 'Welcome to GOsa' string.
     if(empty($path)){
       $path = "<li class='left path-element'>"._("Welcome to GOsa")."</li>";
     }
+
+    $smarty = get_smarty();
+    $smarty->assign('title', 'GOsa '.$sTitle);
     return($path);
   }
 
   static function clear()
   {
-    session::set('pathNavigator::position','');
+    session::set('pathNavigator::position', array());
   }
 }