Code

Replaced print_red with msg_dialog, for testing
[gosa.git] / include / class_config.inc
index 7ef00cb6c44ed0147f48022ff48ab5fd674ce3c4..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']);
@@ -421,17 +412,33 @@ class config  {
           'DB'         => $attrs['goGlpiDatabase'][0]);
     }
 
+
     /* Get logdb server */
     $ldap->cd ($this->current['BASE']);
-    $ldap->search ("(objectClass=goLogDBServer)",array("cn","goLogDBServerUser","goLogDBServerPassword","goLogDB"));
+    $ldap->search ("(objectClass=goLogDBServer)");
     if ($ldap->count()){
       $attrs= $ldap->fetch();
+      $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
+          'LOGIN' => $attrs['goLogAdmin'][0],
+          '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('USER'    => $attrs['goLogDBServerUser'][0],
-          'PWD'     => $attrs['goLogDBServerPassword'][0],
-          'DB'      => $attrs['goLogDB'][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']);
@@ -628,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 
@@ -648,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;
       }        
@@ -743,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: