Code

Replaced print_red with msg_dialog, for testing
[gosa.git] / include / class_config.inc
index 762c6e0f91510fe01dc74e672eddb143d97d8df6..036872656097e5a8e376521e14ff64081267e1d1 100644 (file)
@@ -38,7 +38,7 @@ class config  {
 
   /* Configuration data */
   var $data= array( 'TABS' => array(), 'LOCATIONS' => array(), 'SERVERS' => array(),
-      'MAIN' => array( 'LANGUAGES' => array(), 'FAXFORMATS' => array() ),
+      'MAIN' => array( 'FAXFORMATS' => array() ),
       'MENU' => array(), 'SERVICE' => array());
   var $basedir= "";
 
@@ -143,15 +143,6 @@ class config  {
                   }
                   break;
 
-                  /* Handle language */
-      case 'LANGUAGE':
-                  if ($this->tags[$this->level-2] == 'MAIN'){
-                    /* Add languages */
-                    $this->data['MAIN']['LANGUAGES'][$attrs['NAME']]= 
-                      $attrs['TAG'];
-                  }
-                  break;
-
                   /* Handle faxformat */
       case 'FAXFORMAT':        
                   if ($this->tags[$this->level-2] == 'MAIN'){
@@ -317,7 +308,7 @@ class config  {
   function load_servers ()
   {
     /* Only perform actions if current is set */
-    if ($this->current == NULL){
+    if ($this->current === NULL){
       return;
     }
 
@@ -336,7 +327,7 @@ class config  {
           "sieve_server" => $attrs['goImapSieveServer'][0],
           "sieve_port" => $attrs['goImapSievePort'][0]);
     }
-    error_reporting(E_ALL);
+    error_reporting(E_ALL | E_STRICT);
 
     /* Get kerberos server. FIXME: only one is supported currently */
     $ldap->cd ($this->current['BASE']);
@@ -420,6 +411,8 @@ class config  {
           'PASSWORD'   => $attrs['goGlpiPassword'][0],
           'DB'         => $attrs['goGlpiDatabase'][0]);
     }
+
+
     /* Get logdb server */
     $ldap->cd ($this->current['BASE']);
     $ldap->search ("(objectClass=goLogDBServer)");
@@ -430,6 +423,22 @@ class config  {
           'PASSWORD' => $attrs['goLogPassword'][0]);
     }
 
+
+    /* GOsa logging databases */
+    $ldap->cd ($this->current['BASE']);
+    $ldap->search ("(objectClass=gosaLogServer)");
+    if ($ldap->count()){
+      while($attrs= $ldap->fetch()){
+      $this->data['SERVERS']['LOGGING'][$attrs['cn'][0]]= 
+          array(
+          'DN'    => $attrs['dn'],
+          'USER'  => $attrs['goLogDBUser'][0],
+          'DB'    => $attrs['goLogDB'][0],
+          'PWD'   => $attrs['goLogDBPassword'][0]);
+      }
+    }
+
+
     /* Get NFS server lists */
     $tmp= array("default");
     $ldap->cd ($this->current['BASE']);
@@ -626,6 +635,7 @@ class config  {
     $depth ++;
 
     /* Walk through array */   
+    ksort($arr);
     foreach($arr as $name => $entries){
 
       /* If this department is the last in the current tree position 
@@ -646,7 +656,7 @@ class config  {
       if(isset($entries['ENTRY'])){
         $a = "";
         for($i = 0 ; $i < $depth ; $i ++){
-          $a.="&nbsp;";
+          $a.=".";
         }
         $ret[$entries['ENTRY']]=$a."&nbsp;".$name;
       }        
@@ -741,6 +751,46 @@ class config  {
     return FALSE;
   }
 
+
+  function __search(&$arr, $name, $return)
+  {
+    $return= strtoupper($return);
+    if (is_array($arr)){
+      foreach ($arr as &$a){
+        if (isset($a['CLASS']) && strcasecmp($name, $a['CLASS']) == 0){
+          return(isset($a[$return])?$a[$return]:"");
+        } else {
+          $res= $this->__search ($a, $name, $return);
+          if ($res != ""){
+            return $res;
+          }
+        }
+      }
+    }
+    return ("");
+  }
+
+
+  function search($class, $value, $categories= "")
+  {
+    if (is_array($categories)){
+      foreach ($categories as $category){
+        $res= $this->__search($this->data[strtoupper($category)], $class, $value);
+        if ($res != ""){
+          return $res;
+        }
+      }
+    } else {
+      if ($categories == "") {
+        return $this->__search($this->data, $class, $value);
+      } else {
+        return $this->__search($this->data[strtoupper($categories)], $class, $value);
+      }
+    } 
+
+    return ("");
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: