Code

Updated users
[gosa.git] / gosa-core / include / functions.inc
index a0ee267ba9a9156543e01d360e31e7310118e775..9b735693646d6ac239757b0fac8b3cbb4f2867e2 100644 (file)
@@ -366,7 +366,7 @@ function ldap_login_user_htaccess ($username)
   /* Look for entry or realm */
   $ldap= $config->get_ldap_link();
   if (!preg_match("/Success/i", $ldap->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);
+    msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), FATAL_ERROR_DIALOG);
     $smarty= get_smarty();
     $smarty->display(get_template_path('headers.tpl'));
     echo "<body>".session::get('errors')."</body></html>";
@@ -375,7 +375,7 @@ function ldap_login_user_htaccess ($username)
   $ldap->search("(&(objectClass=gosaAccount)(uid=$username))", array("uid"));
   /* Found no uniq match? Strange, because we did above... */
   if ($ldap->count() != 1) {
-    msg_dialog::display(_("LDAP error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
+    msg_dialog::display(_("LDAP error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), FATAL_ERROR_DIALOG);
     return (NULL);
   }
   $attrs= $ldap->fetch();
@@ -404,7 +404,7 @@ function ldap_login_user ($username, $password)
   /* look through the entire ldap */
   $ldap = $config->get_ldap_link();
   if (!preg_match("/Success/i", $ldap->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);
+    msg_dialog::display(_("LDAP error"), sprintf(_("User login failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), FATAL_ERROR_DIALOG);
     $smarty= get_smarty();
     $smarty->display(get_template_path('headers.tpl'));
     echo "<body>".session::get('errors')."</body></html>";
@@ -445,7 +445,7 @@ function ldap_login_user ($username, $password)
 
             /* found more than one matching id */
     default:
-            msg_dialog::display(_("Internal error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
+            msg_dialog::display(_("Internal error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), FATAL_ERROR_DIALOG);
             return (NULL);
   }
 
@@ -760,6 +760,8 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra
   global $config, $ui;
   $departments = array();
 
+#  $start = microtime(TRUE);
+
   /* Get LDAP link */
   $ldap= $config->get_ldap_link($flags & GL_SIZELIMIT);
 
@@ -792,30 +794,24 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra
         /* Do NOT search within subtrees is requeste and the sub base is empty. 
          * Append all known departments that matches the base.
          */
-        foreach($config->departments as $d_base){
-          if(!in_array($d_base,$departments) && preg_match("/".normalizePreg($base)."$/",$d_base)){
-            $departments[$d_base] = $d_base;
-          }
-        }
+        $departments[$base] = $base;
       }
     }else{
       $sub_bases[$key] = preg_replace("/,.*$/","",$sub_base);
     }
   }
   
-  /* Check if we have enabled the sub_dir search support AND 
-   *  if there is a sub department specified.
-   * If not, fall back to old method, get_list().
+   /* If there is no sub_department specified, fall back to old method, get_list().
    */
-  $sub_enabled = isset($config->current['SUB_LIST_SUPPORT']) && preg_match("/true/i",$config->current['SUB_LIST_SUPPORT']);
-  if(!count($sub_bases) || !$sub_enabled){
+  if(!count($sub_bases) && !count($departments)){
     
     /* Log this fall back, it may be an unpredicted behaviour.
      */
-    if(!count($sub_bases)){
+    if(!count($sub_bases) && !count($departments)){
       // log($action,$objecttype,$object,$changes_array = array(),$result = "") 
       new log("debug","all",__FILE__,$attributes,
-          sprintf("get_sub_list(): Falling back to get_list(), due to empty sub_bases parameter. This may slow down GOsa. Search was: '%s'",$filter));
+          sprintf("get_sub_list(): Falling back to get_list(), due to empty sub_bases parameter.".
+            " This may slow down GOsa. Search was: '%s'",$filter));
     }
     $tmp = get_list($filter, $category,$base,$attributes,$flags);
     return($tmp);
@@ -905,6 +901,9 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra
       }
     }
   }
+#  if(microtime(TRUE) - $start > 0.1){
+#    echo sprintf("<pre>GET_SUB_LIST  %s .| %f  --- $base -----$filter ---- $flags</pre>",__LINE__,microtime(TRUE) - $start);
+#  }
   return($result);
 }
 
@@ -913,6 +912,8 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
 {
   global $config, $ui;
 
+#  $start = microtime(TRUE);
+
   /* Get LDAP link */
   $ldap= $config->get_ldap_link($flags & GL_SIZELIMIT);
 
@@ -972,7 +973,10 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
       }
     }
   }
-
+#  if(microtime(TRUE) - $start > 0.1){
+#    echo sprintf("<pre>GET_LIST %s .| %f  --- $base -----$filter ---- $flags</pre>",__LINE__,microtime(TRUE) - $start);
+#  }
   return ($result);
 }
 
@@ -1357,15 +1361,8 @@ function show_errors($message)
 
   /* Assemble the message array to a plain string */
   foreach ($message as $error){
-    if ($complete == ""){
-      $complete= $error;
-    } else {
-      $complete= "$error<br>$complete";
-    }
+    msg_dialog::display(_("Error"), $error, ERROR_DIALOG);
   }
-
-  /* Fill ERROR variable with nice error dialog */
-  msg_dialog::display(_("Error"), $complete, ERROR_DIALOG);
 }