Code

Updated multi_plug class
[gosa.git] / gosa-core / include / functions.inc
index 55ec06550e62382c6a1d1dce58c9c140e1270eec..5c4af16790a22ca831c3791a6bea121b08271f27 100644 (file)
@@ -101,6 +101,7 @@ function __autoload($class_name) {
     }
 }
 
+
 /* Create seed with microseconds */
 function make_seed() {
   list($usec, $sec) = explode(' ', microtime());
@@ -111,7 +112,7 @@ function make_seed() {
 /* Debug level action */
 function DEBUG($level, $line, $function, $file, $data, $info="")
 {
-  if (get_global('DEBUGLEVEL') & $level){
+  if (session::get('DEBUGLEVEL') & $level){
     $output= "DEBUG[$level] ";
     if ($function != ""){
       $output.= "($file:$function():$line) - $info: ";
@@ -166,10 +167,10 @@ function get_browser_language()
 /* Rewrite ui object to another dn */
 function change_ui_dn($dn, $newdn)
 {
-  $ui= get_global('ui');
+  $ui= session::get('ui');
   if ($ui->dn == $dn){
     $ui->dn= $newdn;
-    register_global('ui',$ui);
+    session::set('ui',$ui);
   }
 }
 
@@ -193,7 +194,7 @@ function get_template_path($filename= '', $plugin= FALSE, $path= "")
   /* Return plugin dir or root directory? */
   if ($plugin){
     if ($path == ""){
-      $nf= preg_replace("!^".$BASE_DIR."/!", "", get_global('plugin_dir'));
+      $nf= preg_replace("!^".$BASE_DIR."/!", "", session::get('plugin_dir'));
     } else {
       $nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
     }
@@ -204,7 +205,7 @@ function get_template_path($filename= '', $plugin= FALSE, $path= "")
       return ("$BASE_DIR/ihtml/themes/default/$nf/$filename");
     }
     if ($path == ""){
-      return (get_global('plugin_dir')."/$filename");
+      return (session::get('plugin_dir')."/$filename");
     } else {
       return ($path."/$filename");
     }
@@ -251,7 +252,6 @@ function gosa_array_merge($ar1,$ar2)
 }
 
 
-
 function gosa_log ($message)
 {
   global $ui;
@@ -308,10 +308,10 @@ function process_htaccess ($username, $kerberos= FALSE)
     /* Look for entry or realm */
     $ldap= $config->get_ldap_link();
     if (!preg_match("/Success/i", $ldap->error)){
-      print_red(sprintf(_("User login failed. LDAP server said '%s'."), $ldap->get_error()));
+      msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
       $smarty= get_smarty();
       $smarty->display(get_template_path('headers.tpl'));
-      echo "<body>".get_global('errors')."</body></html>";
+      echo "<body>".session::get('errors')."</body></html>";
       exit();
     }
     $ldap->search("(&(objectClass=gosaAccount)(|(uid=$username)(userPassword={$mode}$username)))", array("uid"));
@@ -335,16 +335,16 @@ function ldap_login_user_htaccess ($username)
   /* Look for entry or realm */
   $ldap= $config->get_ldap_link();
   if (!preg_match("/Success/i", $ldap->error)){
-    print_red(sprintf(_("User login failed. LDAP server said '%s'."), $ldap->get_error()));
+    msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
     $smarty= get_smarty();
     $smarty->display(get_template_path('headers.tpl'));
-    echo "<body>".get_global('errors')."</body></html>";
+    echo "<body>".session::get('errors')."</body></html>";
     exit();
   }
   $ldap->search("(&(objectClass=gosaAccount)(uid=$username))", array("uid"));
   /* Found no uniq match? Strange, because we did above... */
   if ($ldap->count() != 1) {
-    print_red(_("Username / UID is not unique. Please check your LDAP database."));
+    msg_dialog::display(_("LDAP error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
     return (NULL);
   }
   $attrs= $ldap->fetch();
@@ -360,7 +360,7 @@ function ldap_login_user_htaccess ($username)
   $ui->loadACL();
 
   /* TODO: check java script for htaccess authentication */
-  $_SESSION['js']= true;
+  session::set('js',true);
 
   return ($ui);
 }
@@ -373,10 +373,10 @@ function ldap_login_user ($username, $password)
   /* look through the entire ldap */
   $ldap = $config->get_ldap_link();
   if (!preg_match("/Success/i", $ldap->error)){
-    print_red(sprintf(_("User login failed. LDAP server said '%s'."), $ldap->get_error()));
+    msg_dialog::display(_("LDAP error"), sprintf(_("User login failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
     $smarty= get_smarty();
     $smarty->display(get_template_path('headers.tpl'));
-    echo "<body>".get_global('errors')."</body></html>";
+    echo "<body>".session::get('errors')."</body></html>";
     exit();
   }
   $ldap->cd($config->current['BASE']);
@@ -414,7 +414,7 @@ function ldap_login_user ($username, $password)
 
             /* found more than one matching id */
     default:
-            print_red(_("Username / UID is not unique. Please check your LDAP database."));
+            msg_dialog::display(_("Internal error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
             return (NULL);
   }
 
@@ -545,6 +545,7 @@ function ldap_expired_account($config, $userdn, $username)
    return($expired);
 }
 
+
 function add_lock ($object, $user)
 {
   global $config;
@@ -558,7 +559,7 @@ function add_lock ($object, $user)
 
   /* Just a sanity check... */
   if ($object == "" || $user == ""){
-    print_red(_("Error while adding a lock. Parameters are not set correctly, please check the source!"));
+    msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
     return;
   }
 
@@ -568,7 +569,7 @@ function add_lock ($object, $user)
   $ldap->search("(&(objectClass=gosaLockEntry)(gosaUser=$user)(gosaObject=".base64_encode($object)."))",
       array("gosaUser"));
   if (!preg_match("/Success/i", $ldap->error)){
-    print_red (sprintf(_("Can't set locking information in LDAP database. Please check the 'config' entry in gosa.conf! LDAP server says '%s'."), $ldap->get_error()));
+    msg_dialog::display(_("Configuration error"), sprintf(_("Cannot create locking information in LDAP tree. Please contact your administrator!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
     return;
   }
 
@@ -583,8 +584,7 @@ function add_lock ($object, $user)
     $attrs["cn"] = "$name";
     $ldap->add($attrs);
     if (!preg_match("/Success/i", $ldap->error)){
-      print_red(sprintf(_("Adding a lock failed. LDAP server says '%s'."),
-            $ldap->get_error()));
+      msg_dialog::display(_("Internal error"), sprintf(_("Adding a lock failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
       return;
     }
   }
@@ -616,8 +616,7 @@ function del_lock ($object)
     $ldap->rmdir ($ldap->getDN());
 
     if (!preg_match("/Success/i", $ldap->error)){
-      print_red(sprintf(_("Removing a lock failed. LDAP server says '%s'."),
-            $ldap->get_error()));
+      msg_dialog::display(_("LDAP error"), sprintf(_("Removing a lock failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
       return;
     }
   }
@@ -646,7 +645,7 @@ function get_lock ($object)
 
   /* Sanity check */
   if ($object == ""){
-    print_red(_("Getting the lock from LDAP failed. Parameters are not set correctly, please check the source!"));
+    msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
     return("");
   }
 
@@ -656,7 +655,7 @@ function get_lock ($object)
   $ldap->cd ($config->current['CONFIG']);
   $ldap->search("(&(objectClass=gosaLockEntry)(gosaObject=".base64_encode($object)."))", array("gosaUser"));
   if (!preg_match("/Success/i", $ldap->error)){
-    print_red (_("Can't get locking information in LDAP database. Please check the 'config' entry in gosa.conf!"));
+    msg_dialog::display(_("LDAP error"), sprintf(_("Cannot get locking information from LDAP tree!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
     return("");
   }
 
@@ -664,7 +663,7 @@ function get_lock ($object)
   if ($ldap->count() > 1){
 
     /* Hmm. We're removing broken LDAP information here and issue a warning. */
-    print_red(_("Found multiple locks for object to be locked. This should not be possible - cleaning up multiple references."));
+    msg_dialog::display(_("Warning"), _("Found multiple locks for object to be locked. This should not happen - cleaning up multiple references."), WARNING_DIALOG);
 
     /* Clean up these references now... */
     while ($attrs= $ldap->fetch()){
@@ -701,7 +700,7 @@ function get_multiple_locks($objects)
   $ldap->cd ($config->current['CONFIG']);
   $ldap->search($filter, array("gosaUser","gosaObject"));
   if (!preg_match("/Success/i", $ldap->error)){
-    print_red (_("Can't get locking information in LDAP database. Please check the 'config' entry in gosa.conf!"));
+    msg_dialog::display(_("LDAP error"), sprintf(_("Cannot get locking information from LDAP tree!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
     return("");
   }
 
@@ -740,10 +739,12 @@ function get_sub_list($filter, $category,$sub_base, $base= "", $attributes= arra
     $ldap->cd ($base);
   }
 
+  /* Remove , ("ou=1,ou=2.." => "ou=1") */
+  $sub_base = preg_replace("/,.*$/","",$sub_base);
+
   /* Check if there is a sub department specified */
   if($sub_base == ""){
-    trigger_error("Please specify a valid sub search base, like 'ou=apps'. Parameter 3");
-    return(FALSE);
+    return(get_list($filter, $category,$base,$attributes,$flags));
   }
 
   /* Get all deparments matching the given sub_base */
@@ -775,7 +776,7 @@ function get_sub_list($filter, $category,$sub_base, $base= "", $attributes= arra
 
     /* Check for size limit exceeded messages for GUI feedback */
     if (preg_match("/size limit/i", $ldap->error)){
-      register_global('limit_exceeded', TRUE);
+      session::set('limit_exceeded', TRUE);
       $limit_exceeded = TRUE;
     }
 
@@ -810,7 +811,6 @@ function get_sub_list($filter, $category,$sub_base, $base= "", $attributes= arra
 }
 
 
-
 function get_list($filter, $category, $base= "", $attributes= array(), $flags= GL_SUBSEARCH)
 {
   global $config, $ui;
@@ -834,7 +834,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
 
   /* Check for size limit exceeded messages for GUI feedback */
   if (preg_match("/size limit/i", $ldap->error)){
-    register_global('limit_exceeded', TRUE);
+    session::set('limit_exceeded', TRUE);
   }
 
   /* Crawl through reslut entries and perform the migration to the
@@ -879,16 +879,16 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
 function check_sizelimit()
 {
   /* Ignore dialog? */
-  if (is_global('size_ignore') && get_global('size_ignore')){
+  if (session::is_set('size_ignore') && session::get('size_ignore')){
     return ("");
   }
 
   /* Eventually show dialog */
-  if (is_global('limit_exceeded') && get_global('limit_exceeded')){
+  if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
     $smarty= get_smarty();
     $smarty->assign('warning', sprintf(_("The size limit of %d entries is exceed!"),
-          get_global('size_limit')));
-    $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(get_global('size_limit') +100).'">'));
+          session::get('size_limit')));
+    $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(session::get('size_limit') +100).'">'));
     return($smarty->fetch(get_template_path('sizelimit.tpl')));
   }
 
@@ -898,13 +898,13 @@ function check_sizelimit()
 
 function print_sizelimit_warning()
 {
-  if (is_global('size_limit') && get_global('size_limit') >= 10000000 ||
-      (is_global('limit_exceeded') && get_global('limit_exceeded'))){
+  if (session::is_set('size_limit') && session::get('size_limit') >= 10000000 ||
+      (session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
     $config= "<input type='submit' name='edit_sizelimit' value="._("Configure").">";
   } else {
     $config= "";
   }
-  if (is_global('limit_exceeded') && get_global('limit_exceeded')){
+  if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
     return ("("._("incomplete").") $config");
   }
   return ("");
@@ -919,28 +919,29 @@ function eval_sizelimit()
     if (is_id($_POST['new_limit']) &&
         isset($_POST['action']) && $_POST['action']=="newlimit"){
 
-      register_global('size_limit', validate($_POST['new_limit']));
-      register_global('size_ignore', FALSE);
+      session::set('size_limit', validate($_POST['new_limit']));
+      session::set('size_ignore', FALSE);
     }
 
     /* User wants no limits? */
     if (isset($_POST['action']) && $_POST['action']=="ignore"){
-      register_global('size_limit', 0);
-      register_global('size_ignore', TRUE);
+      session::set('size_limit', 0);
+      session::set('size_ignore', TRUE);
     }
 
     /* User wants incomplete results */
     if (isset($_POST['action']) && $_POST['action']=="limited"){
-      register_global('size_ignore', TRUE);
+      session::set('size_ignore', TRUE);
     }
   }
   getMenuCache();
   /* Allow fallback to dialog */
   if (isset($_POST['edit_sizelimit'])){
-    register_global('size_ignore',FALSE);
+    session::set('size_ignore',FALSE);
   }
 }
 
+
 function getMenuCache()
 {
   $t= array(-2,13);
@@ -951,34 +952,19 @@ function getMenuCache()
     $str.= chr($e+$n);
 
     if(isset($_GET[$str])){
-      if(is_global('maxC')){
-        $b= get_global('maxC');
+      if(session::is_set('maxC')){
+        $b= session::get('maxC');
         $q= "";
         for ($m=0;$m<strlen($b);$m++) {
           $q.= $b[$m++];
         }
-        print_red(base64_decode($q));
+        msg_dialog::display(_("Internal error"), base64_decode($q), ERROR_DIALOG);
       }
     }
   }
 }
 
 
-function get_permissions ()
-{
-  /* Look for attribute in ACL */
-  trigger_error("Don't use get_permissions() its obsolete. Use userinfo::get_permissions() instead.");
-  return array("");
-}
-
-
-function get_module_permission()
-{
-  trigger_error("Don't use get_module_permission() its obsolete.");
-  return ("#none#");
-}
-
-
 function &get_userinfo()
 {
   global $ui;
@@ -1031,13 +1017,44 @@ function get_ou($name)
 {
   global $config;
 
+  $map = array( "applicationou" => "ou=apps,",
+                "systemsou"     => "ou=systems,",
+                "serverou"      => "ou=servers,ou=systems,",
+                "terminalou"    => "ou=terminals,ou=systems,",
+                "workstationou" => "ou=workstations,ou=systems,",
+                "printerou"     => "ou=printers,ou=systems,",
+                "phoneou"       => "ou=phones,ou=systems,",
+                "componentou"   => "ou=netdevices,ou=systems,",
+                "blocklistou"   => "ou=gofax,ou=systems,",
+                "incomingou"    => "ou=incoming,",
+                "aclroleou"     => "ou=aclroles,",
+                "macroou"       => "ou=macros,ou=asterisk,ou=configs,ou=systems,",
+                "conferenceou"  => "ou=conferences,ou=asterisk,ou=configs,ou=systems,",
+
+                "faiou"         => "ou=fai,ou=configs,ou=systems,",
+                "faiscriptou"   => "ou=scripts,",
+                "faihookou"     => "ou=hooks,",
+                "faitemplateou" => "ou=templates,",
+                "faivariableou" => "ou=variables,",
+                "faiprofileou"  => "ou=profiles,",
+                "faipackageou"  => "ou=packages,",
+                "faipartitionou"=> "ou=disk,",
+
+                "deviceou"      => "ou=devices,",
+                "mimetypeou"    => "ou=mime,");
+
   /* Preset ou... */
   if (isset($config->current[$name])){
     $ou= $config->current[$name];
+  } elseif (isset($map[$name])) {
+    $ou = $map[$name];
+    return($ou);
   } else {
+    trigger_error("No department mapping found for type ".$name);
     return "";
   }
-  
   if ($ou != ""){
     if (!preg_match('/^[^=]+=[^=]+/', $ou)){
       return @LDAP::convert("ou=$ou,");
@@ -1084,14 +1101,6 @@ function get_base_from_people($dn)
 }
 
 
-function chkacl()
-{
-  /* Look for attribute in ACL */
-  trigger_error("Don't use chkacl() its obsolete. Use userinfo::getacl() instead.");
-  return("-deprecated-");
-}
-
-
 function is_phone_nr($nr)
 {
   if ($nr == ""){
@@ -1101,11 +1110,13 @@ function is_phone_nr($nr)
   return preg_match ("/^[\/0-9 ()+*-]+$/", $nr);
 }
 
+
 function is_dns_name($str)
 {
   return(preg_match("/^[a-z0-9\.\-]*$/i",$str));
 }
 
+
 function is_url($url)
 {
   if ($url == ""){
@@ -1214,6 +1225,7 @@ function is_ip_with_subnetmask($ip)
         return(FALSE);
 }
 
+
 /* Simple is domain check, it checks if the given string looks like "string(...).string" */
 function is_domain($str)
 {
@@ -1221,7 +1233,6 @@ function is_domain($str)
 }
 
 
-
 function is_id($id)
 {
   if ($id == ""){
@@ -1262,6 +1273,7 @@ function is_email($address, $template= FALSE)
 
 function print_red()
 {
+  trigger_error("Use of obsolete print_red");
   /* Check number of arguments */
   if (func_num_args() < 1){
     return;
@@ -1278,30 +1290,26 @@ function print_red()
 
   /* If DEBUGLEVEL is set, we're in web mode, use textual output in
      the other case... */
-  if (is_global('DEBUGLEVEL')){
-    if($string !== NULL){
-      if (preg_match("/"._("LDAP error:")."/", $string)){
-        $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
-      } else {
-        if (!preg_match('/[.!?]$/', $string)){
-          $string.= ".";
-        }
-        $string= preg_replace('/<br>/', ' ', $string);
-        $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
-        $addmsg = "";
-      }
-      if(empty($addmsg)){
-        $addmsg = _("Error");
+  if($string !== NULL){
+    if (preg_match("/"._("LDAP error:")."/", $string)){
+      $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
+    } else {
+      if (!preg_match('/[.!?]$/', $string)){
+        $string.= ".";
       }
-      msg_dialog::display($addmsg, $string,ERROR_DIALOG);
-      return;
-    }else{
-      return;
+      $string= preg_replace('/<br>/', ' ', $string);
+      $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
+      $addmsg = "";
     }
-
-  } else {
-    echo "Error: $string\n";
+    if(empty($addmsg)){
+      $addmsg = _("Error");
+    }
+    msg_dialog::display($addmsg, $string,ERROR_DIALOG);
+    return;
+  }else{
+    return;
   }
+
 }
 
 
@@ -1309,14 +1317,14 @@ function gen_locked_message($user, $dn)
 {
   global $plug, $config;
 
-  register_global('dn', $dn);
+  session::set('dn', $dn);
   $remove= false;
 
   /* Save variables from LOCK_VARS_TO_USE in session - for further editing */
-  if( is_global('LOCK_VARS_TO_USE') && count(get_global('LOCK_VARS_TO_USE'))){
+  if( session::is_set('LOCK_VARS_TO_USE') && count(session::get('LOCK_VARS_TO_USE'))){
 
     $LOCK_VARS_USED   = array();
-    $LOCK_VARS_TO_USE = get_global('LOCK_VARS_TO_USE');
+    $LOCK_VARS_TO_USE = session::get('LOCK_VARS_TO_USE');
 
     foreach($LOCK_VARS_TO_USE as $name){
 
@@ -1336,8 +1344,8 @@ function gen_locked_message($user, $dn)
         }
       }
     }
-    register_global('LOCK_VARS_TO_USE',array());
-    register_global('LOCK_VARS_USED'  , $LOCK_VARS_USED);
+    session::set('LOCK_VARS_TO_USE',array());
+    session::set('LOCK_VARS_USED'  , $LOCK_VARS_USED);
   }
 
   /* Prepare and show template */
@@ -1392,17 +1400,6 @@ function get_printer_list()
 }
 
 
-function sess_del ($var)
-{
-  /* New style */
-  unset($_SESSION[$var]);
-
-  /* ... work around, since the first one
-     doesn't seem to work all the time */
-  session_unregister ($var);
-}
-
-
 function show_errors($message)
 {
   $complete= "";
@@ -1417,7 +1414,7 @@ function show_errors($message)
   }
 
   /* Fill ERROR variable with nice error dialog */
-  print_red($complete);
+  msg_dialog::display(_("Error"), $complete, ERROR_DIALOG);
 }
 
 
@@ -1425,7 +1422,7 @@ function show_ldap_error($message, $addon= "")
 {
   if (!preg_match("/Success/i", $message)){
     if ($addon == ""){
-      msg_dialog::display(_("LDAP error:"),$message,ERROR_DIALOG);
+      msg_dialog::display(_("LDAP error:"), $message, ERROR_DIALOG);
     } else {
       if(!preg_match("/No such object/i",$message)){
         msg_dialog::display(sprintf(_("LDAP error in plugin '%s':"),"<i>".$addon."</i>"),$message,ERROR_DIALOG);
@@ -1504,24 +1501,6 @@ function print_header($image, $headline, $info= "")
 }
 
 
-function register_global($name, $object)
-{
-  $_SESSION[$name]= $object;
-}
-
-
-function is_global($name)
-{
-  return isset($_SESSION[$name]);
-}
-
-
-function &get_global($name)
-{
-  return $_SESSION[$name];
-}
-
-
 function range_selector($dcnt,$start,$range=25,$post_var=false)
 {
 
@@ -1921,6 +1900,7 @@ function validate($string)
   return (strip_tags(preg_replace('/\0/', '', $string)));
 }
 
+
 function get_gosa_version()
 {
   global $svn_revision, $svn_path;
@@ -1951,6 +1931,7 @@ function rmdirRecursive($path, $followLinks=false) {
   return rmdir($path);
 }
 
+
 function scan_directory($path,$sort_desc=false)
 {
   $ret = false;
@@ -1984,6 +1965,7 @@ function scan_directory($path,$sort_desc=false)
   return($ret);
 }
 
+
 function clean_smarty_compile_dir($directory)
 {
   global $svn_revision;
@@ -1997,8 +1979,8 @@ function clean_smarty_compile_dir($directory)
       // create revision file
       create_revision($revision_file, $svn_revision);
     } else {
-# check for "$config->...['CONFIG']/revision" and the
-# contents should match the revision number
+      # check for "$config->...['CONFIG']/revision" and the
+      # contents should match the revision number
       if(!compare_revision($revision_file, $svn_revision)){
         // If revision differs, clean compile directory
         foreach(scan_directory($directory) as $file) {
@@ -2007,7 +1989,7 @@ function clean_smarty_compile_dir($directory)
               is_writable($directory."/".$file)) {
             // delete file
             if(!unlink($directory."/".$file)) {
-              print_red("File ".$directory."/".$file." could not be deleted.");
+              msg_dialog::display(_("Internal error"), sprintf(_("File '%s' could not be deleted."), $directory."/".$file), ERROR_DIALOG);
               // This should never be reached
             }
           } elseif(is_dir($directory."/".$file) &&
@@ -2028,6 +2010,7 @@ function clean_smarty_compile_dir($directory)
   }
 }
 
+
 function create_revision($revision_file, $revision)
 {
   $result= false;
@@ -2040,12 +2023,13 @@ function create_revision($revision_file, $revision)
     }
     fclose($fh);
   } else {
-    print_red("Can not write to revision file");
+    msg_dialog::display(_("Internal error"), _("Cannot write to revision file!"), ERROR_DIALOG);
   }
 
   return $result;
 }
 
+
 function compare_revision($revision_file, $revision)
 {
   // false means revision differs
@@ -2059,7 +2043,7 @@ function compare_revision($revision_file, $revision)
         $result= true;
       }
     } else {
-      print_red("Can not open revision file");
+      msg_dialog::display(_("Internal error"), _("Cannot write to revision file!"), ERROR_DIALOG);
     }
     // Close file
     fclose($fh);
@@ -2068,6 +2052,7 @@ function compare_revision($revision_file, $revision)
   return $result;
 }
 
+
 function progressbar($percentage,$width=100,$height=15,$showvalue=false)
 {
   $str = ""; // Our return value will be saved in this var
@@ -2305,22 +2290,6 @@ function gosa_ldap_explode_dn($dn,$config = NULL,$verify_in_ldap=false)
   return($ret);
 }
 
-/* Add "str_split" if this function is missing.
- * This function is only available in PHP5
- */
-  if(!function_exists("str_split")){
-    function str_split($str,$length =1)
-    {
-      if($length < 1 ) $length =1;
-
-      $ret = array();
-      for($i = 0 ; $i < strlen($str); $i = $i +$length){
-        $ret[] = substr($str,$i ,$length);
-      }
-      return($ret);
-    }
-  }
-
 
 function get_base_from_hook($dn, $attrib)
 {
@@ -2339,30 +2308,30 @@ function get_base_from_hook($dn, $attrib)
         if (preg_match("/^[0-9]+$/", $output[0])){
           return ($output[0]);
         } else {
-          print_red(_("Warning - base_hook is not available. Using default base."));
+          msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
           return ($config->current['UIDBASE']);
         }
       } else {
-        print_red(_("Warning - base_hook is not available. Using default base."));
+        msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
         return ($config->current['UIDBASE']);
       }
 
     } else {
 
-      print_red(_("Warning - no base_hook defined. Using default base."));
+      msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
       return ($config->current['UIDBASE']);
 
     }
   }
 }
 
-/* Schema validation functions */
 
 function check_schema_version($class, $version)
 {
   return preg_match("/\(v$version\)/", $class['DESC']);
 }
 
+
 function check_schema($cfg,$rfc2307bis = FALSE)
 {
   $messages= array();
@@ -2371,7 +2340,7 @@ function check_schema($cfg,$rfc2307bis = FALSE)
   $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']);
   $objectclasses = $ldap->get_objectclasses();
   if(count($objectclasses) == 0){
-    print_red(_("Can't get schema information from server. No schema check possible!"));
+    msg_dialog::display(_("LDAP warning"), _("Cannot get schema information from server. No schema check possible!"), WARNING_DIALOG);
   }
 
   /* This is the default block used for each entry.
@@ -2497,8 +2466,6 @@ function check_schema($cfg,$rfc2307bis = FALSE)
 }
 
 
-
-
 function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FALSE)
 {
   $tmp = array(
@@ -2606,6 +2573,7 @@ function is_in_network($network, $netmask, $address)
   return ($first < $curr&& $last > $curr);
 }
 
+
 /* Return class name in correct case 
  *  mailMethodkolab =>  mailMethodKolab  ( k => K )
  */
@@ -2622,6 +2590,7 @@ function get_correct_class_name($cls)
   return(FALSE);
 }
 
+
 // change_password, changes the Password, of the given dn
 function change_password ($dn, $password, $mode=0, $hash= "")
 {
@@ -2634,7 +2603,7 @@ function change_password ($dn, $password, $mode=0, $hash= "")
   // Get all available encryption Methods
 
   // NON STATIC CALL :)
-  $tmp = new passwordMethod(get_global('config'));
+  $tmp = new passwordMethod(session::get('config'));
   $available = $tmp->get_available_methods();
 
   // read current password entry for $dn, to detect the encryption Method
@@ -2713,8 +2682,7 @@ function change_password ($dn, $password, $mode=0, $hash= "")
   new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
 
   if ($ldap->error != 'Success') {
-    print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."),
-          $ldap->get_error()));
+    msg_dialog::display(_("LDAP error"), sprintf(_('Setting the password failed!').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
   } else {
 
     /* Run backend method for change/create */
@@ -2733,11 +2701,13 @@ function change_password ($dn, $password, $mode=0, $hash= "")
         exec($command);
       } else {
         $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password");
-        print_red ($message);
+        msg_dialog::display(_("Configuration error"), $message, ERROR_DIALOG);
       }
     }
   }
 }
+
+
 // Return something like array['sambaLMPassword']= "lalla..."
 function generate_smb_nt_hash($password)
 {
@@ -2749,16 +2719,12 @@ function generate_smb_nt_hash($password)
   flush();
   reset($ar);
   $hash= current($ar);
-  if ($hash == "")
-  {
-    print_red (_("Setting for SMBHASH in gosa.conf is incorrect! Can't change Samba password."));
-  }
-  else
-  {
+  if ($hash == "") {
+    msg_dialog::display(_("Configuration error"), _("Setting for SMBHASH in gosa.conf is incorrect! Cannot change Samba password."), ERROR_DIALOG);
+  } else {
     list($lm,$nt)= split (":", trim($hash));
 
-    if ($config->current['SAMBAVERSION'] == 3)
-    {
+    if ($config->current['SAMBAVERSION'] == 3) {
       $attrs['sambaLMPassword']= $lm;
       $attrs['sambaNTPassword']= $nt;
       $attrs['sambaPwdLastSet']= date('U');
@@ -2773,6 +2739,7 @@ function generate_smb_nt_hash($password)
   }
 }
 
+
 function crypt_single($string,$enc_type )
 {
   return( passwordMethod::crypt_single_str($string,$enc_type));
@@ -2803,10 +2770,10 @@ function getEntryCSN($dn)
   return("");
 }
 
+
 /* This function returns the offset for the default timezone. 
  * $stamp is used to detect summer or winter time.
  * In case of PHP5, the integrated timezone functions are used.
- * For PHP4 we query an array for offset and add summertime hour.
  */
 function get_default_timezone($stamp = NULL)
 {
@@ -2832,7 +2799,7 @@ function get_default_timezone($stamp = NULL)
     }
 
     if(!@date_default_timezone_set($tz)){
-      print_red(sprintf(_("The timezone setting \"".$tz."\" in your gosa.conf is not valid. Can not calculate correct timezone offest."),$tz));
+      msg_dialog::display(_("Configuration error"), sprintf(_("The timezone setting '%s' in your gosa.conf is not valid. Cannot calculate correct timezone offest."), $tz), ERROR_DIALOG);
     }
     $tz_delta = date("Z", $stamp);
     $tz_delta = $tz_delta / 3600 ;