Code

Updated department management
[gosa.git] / gosa-core / include / class_listing.inc
index 24b8cba925d46491d0b023a313ff0896311e5cd1..c917e961a2508fd926cec0885361520e076451ee 100644 (file)
@@ -45,6 +45,7 @@ class listing {
   var $pid;
   var $objectTypes= array();
   var $objectTypeCount= array();
+  var $objectDnMapping= array();
   var $copyPasteHandler= null;
   var $snapshotHandler= null;
   var $exporter= array();
@@ -438,8 +439,9 @@ class listing {
     global $config;
     $ui= get_userinfo();
 
-    // Reset object counter
+    // Reset object counter / DN mapping
     $this->objectTypeCount= array();
+    $this->objectDnMapping= array();
 
     // Do not do anything if this is not our PID
     if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) {
@@ -451,6 +453,7 @@ class listing {
       $base= validate($_POST['BASE']);
       if (isset($this->bases[$base])) {
         $this->base= $base;
+        session::global_set("CurrentMainBase", $this->base);
       }
     }
 
@@ -675,6 +678,11 @@ class listing {
           $params[]= $this->pid;
         }
 
+        // base is replaced by the current base
+        if ($param == "base") {
+          $params[]= $this->getBase();
+        }
+
         // Fixie with "" is passed directly
         if (preg_match('/^".*"$/', $param)){
           $params[]= preg_replace('/"/', '', $param);
@@ -750,12 +758,14 @@ class listing {
 
     $objectType= $this->getObjectType($this->objectTypes, $classes);
     if ($objectType) {
+      $this->objectDnMapping[$dn]= $objectType["objectClass"];
       $result= "<img class='center' title='".LDAP::fix($dn)."' src='".$objectType["image"]."'>";
       if (!isset($this->objectTypeCount[$objectType['label']])) {
         $this->objectTypeCount[$objectType['label']]= 0;
       }
       $this->objectTypeCount[$objectType['label']]++;
     }
+
     return $result;
   }
 
@@ -1024,7 +1034,7 @@ class listing {
     // Load shortcut
     $actions= &$this->xmlData['actionmenu']['action'];
     $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
-             "<ul class='level1' id='root'><li><a href='#'>Aktionen&nbsp;<img ".
+             "<ul class='level1' id='root'><li><a href='#'>"._("Actions")."&nbsp;<img ".
              "border=0 class='center' src='images/lists/sort-down.png'></a>";
 
     // Build ul/li list
@@ -1036,6 +1046,7 @@ class listing {
 
   function recurseActions($actions)
   {
+    global $class_mapping;
     static $level= 2;
     $result= "<ul class='level$level'>";
     $separator= "";
@@ -1047,6 +1058,16 @@ class listing {
         continue;
       }
 
+      // Skip entry if there're missing dependencies
+      if (isset($action['depends'])) {
+        $deps= is_array($action['depends'])?$action['depends']:array($action['depends']);
+        foreach($deps as $clazz) {
+          if (!isset($class_mapping[$clazz])){
+            continue 2;
+          }
+        }
+      }
+
       // Fill image if set
       $img= "";
       if (isset($action['image'])){
@@ -1436,6 +1457,15 @@ class listing {
     return $result;
   }
 
+
+  function getType($dn)
+  {
+    if (isset($this->objectDnMapping[$dn])) {
+      return $this->objectDnMapping[$dn];
+    }
+    return null;
+  }
+
 }
 
 ?>