Code

Udpated todo
[gosa.git] / include / class_config.inc
index bca1f5bdcc49db7763f14aacde8e40f3bee7e838..d13bcf5d919b2d3e1c477dbccc692ea8736de9b5 100644 (file)
@@ -45,6 +45,7 @@ class config  {
   /* Keep a copy of the current deparment list */
   var $departments= array();
   var $idepartments= array();
+  var $adepartments= array();
 
   function config($filename, $basedir= "")
   {
@@ -462,6 +463,44 @@ class config  {
     }
   }
 
+
+  function get_departments($ignore_dn= "")
+  {
+    global $config;
+
+    /* Initialize result hash */
+    $result= array();
+    $administrative= array();
+    $result['/']= $this->current['BASE'];
+
+    /* Get list of department objects */
+    $ldap= $this->get_ldap_link();
+    $ldap->cd ($this->current['BASE']);
+    $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
+    while ($attrs= $ldap->fetch()){
+      $dn= $ldap->getDN();
+
+      /* Save administrative departments */
+      if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
+          isset($attrs['gosaUnitTag'][0])){
+        $administrative[$dn]= $attrs['gosaUnitTag'][0];
+      }
+    
+      if ($dn == $ignore_dn){
+        continue;
+      }
+
+      /* Only assign non-root departments */
+      if ($dn != $result['/']){
+        $result[convert_department_dn($dn)]= $dn;
+      }
+    }
+
+    $this->adepartments= $administrative;
+    $this->departments= $result;
+  }
+
+
   function make_idepartments($max_size= 28)
   {
     global $config;