X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Ffunctions.inc;h=677ebb193c86fbe16d749bfa387c3804ab54980c;hb=d304d276784b0675372dcdb402a61bfdd3f8488d;hp=1da4e832c9b95fead61c302f443836260335dc7a;hpb=883f54e7d1c2ba71d5bbff6d848c6b3a6306e7c9;p=gosa.git diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 1da4e832c..677ebb193 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -1,7 +1,9 @@ get_ldap_link(); if (!preg_match("/Success/i", $ldap->error)){ - msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'

'._('LDAP server returned: %s'), "

".$ldap->get_error().""), ERROR_DIALOG); + msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'

'._('LDAP server returned: %s'), "

".$ldap->get_error().""), FATAL_ERROR_DIALOG); $smarty= get_smarty(); $smarty->display(get_template_path('headers.tpl')); echo "".session::get('errors').""; @@ -375,7 +377,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 +406,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.")."

"._('LDAP server returned: %s'), "

".$ldap->get_error().""), ERROR_DIALOG); + msg_dialog::display(_("LDAP error"), sprintf(_("User login failed.")."

"._('LDAP server returned: %s'), "

".$ldap->get_error().""), FATAL_ERROR_DIALOG); $smarty= get_smarty(); $smarty->display(get_template_path('headers.tpl')); echo "".session::get('errors').""; @@ -445,7 +447,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); } @@ -758,46 +760,66 @@ function get_multiple_locks($objects) function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= array(), $flags= GL_SUBSEARCH) { global $config, $ui; + $departments = array(); + +# $start = microtime(TRUE); /* Get LDAP link */ $ldap= $config->get_ldap_link($flags & GL_SIZELIMIT); /* Set search base to configured base if $base is empty */ if ($base == ""){ - $ldap->cd ($config->current['BASE']); - } else { - $ldap->cd ($base); + $base = $config->current['BASE']; } + $ldap->cd ($base); /* Ensure we have an array as department list */ if(is_string($sub_deps)){ $sub_deps = array($sub_deps); } - /* Remove , ("ou=1,ou=2.." => "ou=1") */ + /* Remove ,.*$ ("ou=1,ou=2.." => "ou=1") */ $sub_bases = array(); foreach($sub_deps as $key => $sub_base){ - $sub_bases[$key] = preg_replace("/,.*$/","",$sub_base); - } + if(empty($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(). + /* Subsearch is activated and we got an empty sub_base. + * (This may be the case if you have empty people/group ous). + * Fall back to old get_list(). + * A log entry will be written. + */ + if($flags & GL_SUBSEARCH){ + $sub_bases = array(); + break; + }else{ + + /* Do NOT search within subtrees is requeste and the sub base is empty. + * Append all known departments that matches the base. + */ + $departments[$base] = $base; + } + }else{ + $sub_bases[$key] = preg_replace("/,.*$/","",$sub_base); + } + } + + /* 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)){ - gosa_log("debug","get_sub_list","",$attributes,sprintf("get_sub_list(): Falling back to get_list(), due to empty sub_bases parameter. This may slow down GOsa.",$src,$attrs['dn'])); + 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)); } - $tmp = get_list($filter, $category,$base,$attributes,$flags | GL_SUBSEARCH); + $tmp = get_list($filter, $category,$base,$attributes,$flags); return($tmp); } /* Get all deparments matching the given sub_bases */ - $departments = array(); $base_filter= ""; foreach($sub_bases as $sub_base){ $base_filter .= "(".$sub_base.")"; @@ -881,6 +903,9 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra } } } +# if(microtime(TRUE) - $start > 0.1){ +# echo sprintf("
GET_SUB_LIST  %s .| %f  --- $base -----$filter ---- $flags
",__LINE__,microtime(TRUE) - $start); +# } return($result); } @@ -889,6 +914,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); @@ -948,7 +975,10 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G } } } - + +# if(microtime(TRUE) - $start > 0.1){ +# echo sprintf("
GET_LIST %s .| %f  --- $base -----$filter ---- $flags
",__LINE__,microtime(TRUE) - $start); +# } return ($result); } @@ -1333,15 +1363,8 @@ function show_errors($message) /* Assemble the message array to a plain string */ foreach ($message as $error){ - if ($complete == ""){ - $complete= $error; - } else { - $complete= "$error
$complete"; - } + msg_dialog::display(_("Error"), $error, ERROR_DIALOG); } - - /* Fill ERROR variable with nice error dialog */ - msg_dialog::display(_("Error"), $complete, ERROR_DIALOG); }