Code

Added some checks to logging class
[gosa.git] / include / class_config.inc
index 516195d7b43468767e91ee34c0ffe0ab00072cc2..7ef00cb6c44ed0147f48022ff48ab5fd674ce3c4 100644 (file)
@@ -241,6 +241,10 @@ class config  {
     if (!isset($this->current['GROUPS'])){
       $this->current['GROUPS']= "ou=groups";
     }
+
+    if (isset($this->current['INITIAL_BASE'])){
+      $_SESSION['CurrentMainBase']= $this->current['INITIAL_BASE'];
+    }
   
     /* Remove possibly added ',' from end of group and people ou */
     $this->current['GROUPS'] = preg_replace("/,*$/","",$this->current['GROUPS']);
@@ -363,26 +367,46 @@ class config  {
           'PASSWORD' => $attrs['goFaxPassword'][0]);
     }
 
+
     /* Get asterisk servers */
     $ldap->cd ($this->current['BASE']);
     $ldap->search ("(objectClass=goFonServer)");
-    $this->data['SERVERS']['FON']= array(); 
+    $this->data['SERVERS']['FON']= array();
     if ($ldap->count()){
       while ($attrs= $ldap->fetch()){
-        $this->data['SERVERS']['FON'][]= array( 
-            'SERVER'   => $attrs['cn'][0],
-            'LOGIN'    => $attrs['goFonAdmin'][0],
-            'PASSWORD'         => $attrs['goFonPassword'][0],
-            'DB'               => "gophone",
-            'SIP_TABLE'                => "sip_users",
-            'EXT_TABLE'        => "extensions",
-            'VOICE_TABLE'      => "voicemail_users",
-            'QUEUE_TABLE'      => "queues",
-            'QUEUE_MEMBER_TABLE'       => "queue_members");
+
+        /* Add 0 entry for development */
+        if(count($this->data['SERVERS']['FON']) == 0){
+          $this->data['SERVERS']['FON'][0]= array(
+              'DN'      => $attrs['dn'],
+              'SERVER'  => $attrs['cn'][0],
+              'LOGIN'   => $attrs['goFonAdmin'][0],
+              'PASSWORD'  => $attrs['goFonPassword'][0],
+              'DB'    => "gophone",
+              'SIP_TABLE'   => "sip_users",
+              'EXT_TABLE'   => "extensions",
+              'VOICE_TABLE' => "voicemail_users",
+              'QUEUE_TABLE' => "queues",
+              'QUEUE_MEMBER_TABLE'  => "queue_members");
+        }
+
+        /* Add entry with 'dn' as index */
+        $this->data['SERVERS']['FON'][$attrs['dn']]= array(
+            'DN'      => $attrs['dn'],
+            'SERVER'  => $attrs['cn'][0],
+            'LOGIN'   => $attrs['goFonAdmin'][0],
+            'PASSWORD'  => $attrs['goFonPassword'][0],
+            'DB'    => "gophone",
+            'SIP_TABLE'   => "sip_users",
+            'EXT_TABLE'   => "extensions",
+            'VOICE_TABLE' => "voicemail_users",
+            'QUEUE_TABLE' => "queues",
+            'QUEUE_MEMBER_TABLE'  => "queue_members");
       }
     }
 
-    /* Get asterisk servers */
+
+    /* Get glpi server */
     $ldap->cd ($this->current['BASE']);
     $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
     if ($ldap->count()){
@@ -396,14 +420,16 @@ class config  {
           'PASSWORD'   => $attrs['goGlpiPassword'][0],
           'DB'         => $attrs['goGlpiDatabase'][0]);
     }
+
     /* Get logdb server */
     $ldap->cd ($this->current['BASE']);
-    $ldap->search ("(objectClass=goLogDBServer)");
+    $ldap->search ("(objectClass=goLogDBServer)",array("cn","goLogDBServerUser","goLogDBServerPassword","goLogDB"));
     if ($ldap->count()){
       $attrs= $ldap->fetch();
-      $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
-          'LOGIN' => $attrs['goLogAdmin'][0],
-          'PASSWORD' => $attrs['goLogPassword'][0]);
+      $this->data['SERVERS']['LOGGING'][$attrs['cn'][0]]= 
+          array('USER'    => $attrs['goLogDBServerUser'][0],
+          'PWD'     => $attrs['goLogDBServerPassword'][0],
+          'DB'      => $attrs['goLogDB'][0]);
     }
 
     /* Get NFS server lists */