X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Ffunctions.inc;h=76d422f3e8741e7e225f19528338b601200bf527;hb=0998bc227b3037c4f3f79ef60aa34e3811b853a3;hp=621f74bc6b053c1b7b2cd74f67ab9707dc8cde50;hpb=0afa593cc5359ac937d71e3ff467f5504799963c;p=gosa.git
diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc
index 621f74bc6..76d422f3e 100644
--- a/gosa-core/include/functions.inc
+++ b/gosa-core/include/functions.inc
@@ -120,21 +120,22 @@ $REWRITE= array( "ä" => "ae",
*
* \param string 'class_name' The currently requested class
*/
-function __autoload($class_name) {
+function __gosa_autoload($class_name) {
global $class_mapping, $BASE_DIR;
if ($class_mapping === NULL){
- echo sprintf(_("Fatal error: no class locations defined - please run '%s' to fix this"), "update-gosa");
+ echo sprintf(_("Fatal error: no class locations defined - please run %s to fix this"), bold("update-gosa"));
exit;
}
if (isset($class_mapping["$class_name"])){
require_once($BASE_DIR."/".$class_mapping["$class_name"]);
} else {
- echo sprintf(_("Fatal error: cannot instantiate class '%s' - try running '%s' to fix this"), $class_name, "update-gosa");
+ echo sprintf(_("Fatal error: cannot instantiate class %s - try running %s to fix this"), bold($class_name), bold("update-gosa"));
exit;
}
}
+spl_autoload_register('__gosa_autoload');
/*! \brief Checks if a class is available.
@@ -202,7 +203,7 @@ function make_seed() {
* */
function DEBUG($level, $line, $function, $file, $data, $info="")
{
- if (session::global_get('DEBUGLEVEL') & $level){
+ if (session::global_get('debugLevel') & $level){
$output= "DEBUG[$level] ";
if ($function != ""){
$output.= "($file:$function():$line) - $info: ";
@@ -244,8 +245,8 @@ function get_browser_language()
}
/* Check for global language settings in gosa.conf */
- if (isset ($config) && $config->get_cfg_value('language') != ""){
- $lang = $config->get_cfg_value('language');
+ if (isset ($config) && $config->get_cfg_value("core",'language') != ""){
+ $lang = $config->get_cfg_value("core",'language');
if(!preg_match("/utf/i",$lang)){
$lang .= ".UTF-8";
}
@@ -307,7 +308,7 @@ function get_template_path($filename= '', $plugin= FALSE, $path= "")
/* Set theme */
if (isset ($config)){
- $theme= $config->get_cfg_value("theme", "default");
+ $theme= $config->get_cfg_value("core","theme", "default");
} else {
$theme= "default";
}
@@ -444,7 +445,7 @@ function ldap_init ($server, $base, $binddn='', $pass='')
/* Sadly we've no proper return values here. Use the error message instead. */
if (!$ldap->success()){
msg_dialog::display(_("Fatal error"),
- sprintf(_("FATAL: Error when connecting the LDAP. Server said '%s'."), $ldap->get_error()),
+ sprintf(_("Error while connecting to LDAP: %s"), $ldap->get_error()),
FATAL_ERROR_DIALOG);
exit();
}
@@ -465,7 +466,7 @@ function process_htaccess ($username, $kerberos= FALSE)
$config->set_current($name);
$mode= "kerberos";
- if ($config->get_cfg_value("useSaslForKerberos") == "true"){
+ if ($config->get_cfg_value("core","useSaslForKerberos") == "true"){
$mode= "sasl";
}
@@ -515,7 +516,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!"), FATAL_ERROR_DIALOG);
+ msg_dialog::display(_("LDAP error"), _("User ID is not unique!"), FATAL_ERROR_DIALOG);
return (NULL);
}
$attrs= $ldap->fetch();
@@ -527,6 +528,7 @@ function ldap_login_user_htaccess ($username)
/* Bail out if we have login restrictions set, for security reasons
the message is the same than failed user/pw */
if (!$ui->loginAllowed()){
+ new log("security","login","",array(),"Login restriction for user \"$username\", login not permitted");
return (NULL);
}
@@ -568,8 +570,8 @@ function ldap_login_user ($username, $password)
$ldap->cd($config->current['BASE']);
$allowed_attributes = array("uid","mail");
$verify_attr = array();
- if($config->get_cfg_value("loginAttribute") != ""){
- $tmp = split(",", $config->get_cfg_value("loginAttribute"));
+ if($config->get_cfg_value("core","loginAttribute") != ""){
+ $tmp = explode(",", $config->get_cfg_value("core","loginAttribute"));
foreach($tmp as $attr){
if(in_array($attr,$allowed_attributes)){
$verify_attr[] = $attr;
@@ -600,7 +602,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."), FATAL_ERROR_DIALOG);
+ msg_dialog::display(_("Internal error"), _("User ID is not unique!"), FATAL_ERROR_DIALOG);
return (NULL);
}
@@ -623,6 +625,7 @@ function ldap_login_user ($username, $password)
/* Bail out if we have login restrictions set, for security reasons
the message is the same than failed user/pw */
if (!$ui->loginAllowed()){
+ new log("security","login","",array(),"Login restriction for user \"$username\", login not permitted");
return (NULL);
}
@@ -786,17 +789,17 @@ function add_lock($object, $user)
/* Just a sanity check... */
if ($object == "" || $user == ""){
- msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
+ msg_dialog::display(_("Internal error"), _("Error while locking entry!"), ERROR_DIALOG);
return;
}
/* Check for existing entries in lock area */
$ldap= $config->get_ldap_link();
- $ldap->cd ($config->get_cfg_value("config"));
+ $ldap->cd ($config->get_cfg_value("core","config"));
$ldap->search("(&(objectClass=gosaLockEntry)(gosaUser=$user)(gosaObject=".base64_encode($object)."))",
array("gosaUser"));
if (!$ldap->success()){
- msg_dialog::display(_("Configuration error"), sprintf(_("Cannot create locking information in LDAP tree. Please contact your administrator!")."
"._('LDAP server returned: %s'), "
".$ldap->get_error().""), ERROR_DIALOG);
+ msg_dialog::display(_("Configuration error"), sprintf(_("Cannot store lock information in LDAP!")."
"._('Error: %s'), "
".$ldap->get_error().""), ERROR_DIALOG);
return;
}
@@ -804,14 +807,14 @@ function add_lock($object, $user)
if ($ldap->count() == 0){
$attrs= array();
$name= md5($object);
- $ldap->cd("cn=$name,".$config->get_cfg_value("config"));
+ $ldap->cd("cn=$name,".$config->get_cfg_value("core","config"));
$attrs["objectClass"] = "gosaLockEntry";
$attrs["gosaUser"] = $user;
$attrs["gosaObject"] = base64_encode($object);
$attrs["cn"] = "$name";
$ldap->add($attrs);
if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), "cn=$name,".$config->get_cfg_value("config"), 0, ERROR_DIALOG));
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), "cn=$name,".$config->get_cfg_value("core","config"), 0, ERROR_DIALOG));
return;
}
}
@@ -853,7 +856,7 @@ function del_lock ($object)
/* Check for existance and remove the entry */
$ldap= $config->get_ldap_link();
- $ldap->cd ($config->get_cfg_value("config"));
+ $ldap->cd ($config->get_cfg_value("core","config"));
$ldap->search ("(&(objectClass=gosaLockEntry)(gosaObject=".base64_encode($object)."))", array("gosaObject"));
$attrs= $ldap->fetch();
if ($ldap->getDN() != "" && $ldap->success()){
@@ -880,7 +883,7 @@ function del_user_locks($userdn)
/* Get LDAP ressources */
$ldap= $config->get_ldap_link();
- $ldap->cd ($config->get_cfg_value("config"));
+ $ldap->cd ($config->get_cfg_value("core","config"));
/* Remove all objects of this user, drop errors silently in this case. */
$ldap->search("(&(objectClass=gosaLockEntry)(gosaUser=$userdn))", array("gosaUser"));
@@ -904,7 +907,7 @@ function get_lock ($object)
/* Sanity check */
if ($object == ""){
- msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
+ msg_dialog::display(_("Internal error"), _("Error while locking entry!"), ERROR_DIALOG);
return("");
}
@@ -914,7 +917,7 @@ function get_lock ($object)
/* Get LDAP link, check for presence of the lock entry */
$user= "";
$ldap= $config->get_ldap_link();
- $ldap->cd ($config->get_cfg_value("config"));
+ $ldap->cd ($config->get_cfg_value("core","config"));
$ldap->search("(&(objectClass=gosaLockEntry)(gosaObject=".base64_encode($object)."))", array("gosaUser"));
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), "", LDAP_SEARCH, ERROR_DIALOG));
@@ -924,9 +927,6 @@ function get_lock ($object)
/* Check for broken locking information in LDAP */
if ($ldap->count() > 1){
- /* Hmm. We're removing broken LDAP information here and issue a warning. */
- 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()){
$ldap->rmdir($attrs['dn']);
@@ -967,7 +967,7 @@ function get_multiple_locks($objects)
/* Get LDAP link, check for presence of the lock entry */
$user= "";
$ldap= $config->get_ldap_link();
- $ldap->cd ($config->get_cfg_value("config"));
+ $ldap->cd ($config->get_cfg_value("core","config"));
$ldap->search($filter, array("gosaUser","gosaObject"));
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), "", LDAP_SEARCH, ERROR_DIALOG));
@@ -1051,7 +1051,7 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra
// 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));
+ " This may slow down GOsa. Used filter: %s", $filter));
}
$tmp = get_list($filter, $category,$base,$attributes,$flags);
return($tmp);
@@ -1229,9 +1229,9 @@ function check_sizelimit()
/* Eventually show dialog */
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!"),
+ $smarty->assign('warning', sprintf(_("The current size limit of %d entries is exceeded!"),
session::global_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"), ''));
+ $smarty->assign('limit_message', sprintf(_("Set the size limit to %s"), ''));
return($smarty->fetch(get_template_path('sizelimit.tpl')));
}
@@ -1243,12 +1243,12 @@ function print_sizelimit_warning()
{
if (session::global_is_set('size_limit') && session::global_get('size_limit') >= 10000000 ||
(session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
- $config= "";
+ $config= "";
} else {
$config= "";
}
if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
- return ("("._("incomplete").") $config");
+ return ("("._("list is incomplete").") $config");
}
return ("");
}
@@ -1357,7 +1357,7 @@ function convert_department_dn($dn, $base = NULL)
$dep= "";
- foreach (split(',', $dn) as $rdn){
+ foreach (explode(',', $dn) as $rdn){
$dep = preg_replace("/^[^=]+=/","",$rdn)."/".$dep;
}
@@ -1438,8 +1438,8 @@ function get_ou($name)
"mimetypeRDN" => "ou=mime,");
/* Preset ou... */
- if ($config->get_cfg_value($name, "_not_set_") != "_not_set_"){
- $ou= $config->get_cfg_value($name);
+ if ($config->get_cfg_value("core",$name, "_not_set_") != "_not_set_"){
+ $ou= $config->get_cfg_value("core",$name);
} elseif (isset($map[$name])) {
$ou = $map[$name];
return($ou);
@@ -1535,7 +1535,7 @@ function strict_uid_mode()
global $config;
if (isset($config)){
- return ($config->get_cfg_value("strictNamingRules") == "true");
+ return ($config->get_cfg_value("core","strictNamingRules") == "true");
}
return (TRUE);
}
@@ -1626,15 +1626,7 @@ function gen_locked_message($user, $dn, $allow_readonly = FALSE)
/* Prepare and show template */
$smarty= get_smarty();
$smarty->assign("allow_readonly",$allow_readonly);
- if(is_array($dn)){
- $msg = "