Code

Updated config registry
[gosa.git] / gosa-core / include / class_config.inc
index ae1b6b08edd9e3ef5893aa01974b010cc4dd74be..c76fc746c40b6e2ac45d994cedb41d56980d70be 100644 (file)
@@ -60,16 +60,19 @@ class config  {
   var $idepartments= array();
   var $adepartments= array();
   var $tdepartments= array();
+  var $department_info= array();
   var $filename = "";
   var $last_modified = 0;
 
+  public $configRegistry = NULL;
+
   /*! \brief Class constructor of the config class
    *  
    *  \param string 'filename' path to the configuration file
    *  \param string 'basedir' base directory
    *
    * */
-  function __construct($filename, $basedir= "")
+  function config($filename, $basedir= "")
   {
     $this->parser = xml_parser_create();
     $this->basedir= $basedir;
@@ -81,6 +84,9 @@ class config  {
     if ($filename != ""){
       $this->parse($filename);
     }
+
+    // Load configuration registry
+    $this->configRegistry = new configRegistry($this);
   }
 
 
@@ -149,8 +155,8 @@ class config  {
     fclose($fh);
     if(!xml_parse($this->parser, chop($xmldata))){
       $msg = sprintf(_("XML error in gosa.conf: %s at line %d"),
-            xml_error_string(xml_get_error_code($this->parser)),
-            xml_get_current_line_number($this->parser));
+            bold(xml_error_string(xml_get_error_code($this->parser))),
+            bold(xml_get_current_line_number($this->parser)));
       msg_dialog::display(_("Configuration error"), $msg, FATAL_ERROR_DIALOG);
       exit;
     }
@@ -246,6 +252,10 @@ class config  {
                   }
                   break;
 
+      case 'PATHMENU':
+                  $this->data['PATHMENU']= array(); ;
+                  break;
+
                   /* Inser plugins */
       case 'PLUGIN':
                   if ($this->tags[$this->level-3] == 'MENU' &&
@@ -253,6 +263,9 @@ class config  {
 
                     $this->data['MENU'][$this->section][$this->gpc++]= $attrs;
                   }
+                  if ($this->tags[$this->level-2] == 'PATHMENU'){
+                    $this->data['PATHMENU'][$this->gpc++]= $attrs;
+                  }
                   if ($this->tags[$this->level-2] == 'SERVICEMENU'){
                     $this->data['SERVICE'][$attrs['CLASS']]= $attrs;
                   }
@@ -314,7 +327,7 @@ class config  {
       /* Check for connection */
       if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
         $smarty= get_smarty();
-        msg_dialog::display(_("LDAP error"), _("Cannot bind to LDAP. Please contact the system administrator."), FATAL_ERROR_DIALOG);
+        msg_dialog::display(_("LDAP error"), _("Cannot bind to LDAP!"), FATAL_ERROR_DIALOG);
         exit();
       }
 
@@ -390,8 +403,8 @@ class config  {
       $bases= array();
       $servers= array();
       foreach ($this->current['REFERRAL'] as $ref){
-        $server= preg_replace('%^(.*)/[^/]+$%', '\\1', $ref['URI']);
-        $base= preg_replace('%^.*/([^/]+)$%', '\\1', $ref['URI']);
+        $server= preg_replace('%^(.*://[^/]+)/.*$%', '\\1', $ref['URI']);
+        $base= preg_replace('%^.*://[^/]+/(.*)$%', '\\1', $ref['URI']);
         $bases[$base]= strlen($base);
         $servers[$base]= $server;
       }
@@ -720,7 +733,7 @@ class config  {
     $types = departmentManagement::get_support_departments();
     
     /* Create a list of attributes to fetch */
-    $ldap_values = array("objectClass","gosaUnitTag");
+    $ldap_values = array("objectClass","gosaUnitTag", "description");
     $filter = "";
     foreach($types as $type){
       $ldap_values[] = $type['ATTR'];
@@ -739,16 +752,18 @@ class config  {
       foreach($types as $t => $data){
         if(in_array($data['OC'],$attrs['objectClass'])){
           $type_data = $data;
-          break;    
+          break;
         }
       }
 
-      /* Unknown department type -> skip 
-       */
+      /* Unknown department type -> skip */
       if(!count($type_data)) continue;
 
       $dn= $ldap->getDN();
       $this->tdepartments[$dn]= "";
+      $this->department_info[$dn]= array("img" => $type_data['IMG'],
+                                         "description" => isset($attrs['description'][0])?$attrs['description'][0]:"",
+                                         "name" => $attrs[$type_data['ATTR']][0]);
 
       /* Save administrative departments */
       if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
@@ -765,7 +780,6 @@ class config  {
       if ($dn == $ignore_dn){
         continue;
       }
-
       $c_dn = convert_department_dn($dn)." (".$type_data['ATTR'].")";
 
       /* Only assign non-root departments */
@@ -1061,7 +1075,8 @@ class config  {
    *
    *
    */
-  function get_cfg_value($name, $default= "") {
+  function get_cfg_value($name, $default= "") 
+  {
     $name= strtoupper($name);
 
     /* Check if we have a current value for $name */
@@ -1100,7 +1115,7 @@ class config  {
     /* Check contributed config version and current config version.
      */
     if(($this->config_version == "NOT SET") || ($this->config_version != $current && !empty($this->config_version))){
-      msg_dialog::display(_("Configuration"),_("The configuration file you are using seems to be outdated. Please move the GOsa configuration file away to run the GOsa setup again."));
+      msg_dialog::display(_("Configuration"),_("The configuration file you are using is outdated. Please move the GOsa configuration file away to run the GOsa setup again."));
     }
   }
 
@@ -1142,8 +1157,8 @@ class config  {
         if(!session::is_set("snapshotFailMessageSend")){
           session::set("snapshotFailMessageSend",TRUE);
           msg_dialog::display(_("Configuration error"),
-              sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."),
-                      "snapshotBase"), ERROR_DIALOG);
+              sprintf(_("The snapshot functionality is enabled, but the required variable %s is not set."),
+                      bold("snapshotBase")), ERROR_DIALOG);
         }
         return(FALSE);
       }
@@ -1155,7 +1170,7 @@ class config  {
         if(!session::is_set("snapshotFailMessageSend")){
           session::set("snapshotFailMessageSend",TRUE);
           msg_dialog::display(_("Configuration error"),
-              sprintf(_("The snapshot functionality is enabled, but the required compression module is missing. Please install '%s'."),"php5-zip / php5-gzip"), ERROR_DIALOG);
+              sprintf(_("The snapshot functionality is enabled, but the required compression module is missing. Please install %s."), bold("php5-zip / php5-gzip")), ERROR_DIALOG);
         }
         return(FALSE);
       }
@@ -1173,8 +1188,8 @@ class config  {
             if(!session::is_set("snapshotFailMessageSend")){
               session::set("snapshotFailMessageSend",TRUE);
               msg_dialog::display(_("Configuration error"),
-                  sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."),
-                    $missing), ERROR_DIALOG);
+                  sprintf(_("The snapshot functionality is enabled, but the required variable %s is not set."),
+                    bold($missing)), ERROR_DIALOG);
             }
             return(FALSE);
           }