X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=gosa-core%2Finclude%2Ffunctions.inc;h=da98e1f39e56afda8c68a36086a29a6c2780d7bb;hb=ee4b43becd604a9234b23a9b6faab3ca7bdf2631;hp=6ec34cd1f5b4449537061a949cbcc718ea349c30;hpb=8773ce7598843d3216569e541f4ef32f74866234;p=gosa.git diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 6ec34cd1f..da98e1f39 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -144,8 +144,14 @@ spl_autoload_register('__gosa_autoload'); */ function class_available($name) { - global $class_mapping; - return(isset($class_mapping[$name])); + global $class_mapping, $config; + + $disabled = array(); + if($config instanceOf config && $config->configRegistry instanceOf configRegistry){ + $disabled = $config->configRegistry->getDisabledPlugins(); + } + + return(isset($class_mapping[$name]) && !isset($disabled[$name])); } @@ -203,7 +209,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: "; @@ -245,8 +251,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"; } @@ -308,7 +314,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"); } else { $theme= "default"; } @@ -466,7 +472,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"; } @@ -570,8 +576,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 = explode(",", $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; @@ -795,7 +801,7 @@ function add_lock($object, $user) /* 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()){ @@ -807,14 +813,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; } } @@ -856,7 +862,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()){ @@ -883,7 +889,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")); @@ -917,7 +923,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)); @@ -967,7 +973,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)); @@ -1396,74 +1402,40 @@ function get_sub_department($value) * Example: * \code * # Determine LDAP base where systems are stored - * $base = get_ou('systemRDN') . $this->config->current['BASE']; + * $base = get_ou("systemManagement", "systemRDN") . $this->config->current['BASE']; * $ldap->cd($base); * \endcode * */ -function get_ou($name) +function get_ou($class,$name) { - global $config; + global $config; - $map = array( - "roleRDN" => "ou=roles,", - "ogroupRDN" => "ou=groups,", - "applicationRDN" => "ou=apps,", - "systemRDN" => "ou=systems,", - "serverRDN" => "ou=servers,ou=systems,", - "terminalRDN" => "ou=terminals,ou=systems,", - "workstationRDN" => "ou=workstations,ou=systems,", - "printerRDN" => "ou=printers,ou=systems,", - "phoneRDN" => "ou=phones,ou=systems,", - "componentRDN" => "ou=netdevices,ou=systems,", - "sambaMachineAccountRDN" => "ou=winstation,", - - "faxBlocklistRDN" => "ou=gofax,ou=systems,", - "systemIncomingRDN" => "ou=incoming,", - "aclRoleRDN" => "ou=aclroles,", - "phoneMacroRDN" => "ou=macros,ou=asterisk,ou=configs,ou=systems,", - "phoneConferenceRDN" => "ou=conferences,ou=asterisk,ou=configs,ou=systems,", - - "faiBaseRDN" => "ou=fai,ou=configs,ou=systems,", - "faiScriptRDN" => "ou=scripts,", - "faiHookRDN" => "ou=hooks,", - "faiTemplateRDN" => "ou=templates,", - "faiVariableRDN" => "ou=variables,", - "faiProfileRDN" => "ou=profiles,", - "faiPackageRDN" => "ou=packages,", - "faiPartitionRDN"=> "ou=disk,", - - "sudoRDN" => "ou=sudoers,", - - "deviceRDN" => "ou=devices,", - "mimetypeRDN" => "ou=mime,"); - - /* Preset ou... */ - if ($config->get_cfg_value($name, "_not_set_") != "_not_set_"){ - $ou= $config->get_cfg_value($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)){ - $ou = @LDAP::convert("ou=$ou"); - } else { - $ou = @LDAP::convert("$ou"); + if(!$config->configRegistry->propertyExists($class,$name)){ + trigger_error("No department mapping found for type ".$name); + return ""; } - if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){ - return($ou); - }else{ - return("$ou,"); + $ou = $config->configRegistry->getPropertyValue($class,$name); + if ($ou != ""){ + if (!preg_match('/^[^=]+=[^=]+/', $ou)){ + $ou = @LDAP::convert("ou=$ou"); + } else { + $ou = @LDAP::convert("$ou"); + } + + if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){ + return($ou); + }else{ + if(!preg_match("/,$/", $ou)){ + return("$ou,"); + }else{ + return($ou); + } + } + + } else { + return ""; } - - } else { - return ""; - } } @@ -1473,7 +1445,7 @@ function get_ou($name) * */ function get_people_ou() { - return (get_ou("userRDN")); + return (get_ou("core", "userRDN")); } @@ -1483,7 +1455,7 @@ function get_people_ou() */ function get_groups_ou() { - return (get_ou("groupRDN")); + return (get_ou("core", "groupRDN")); } @@ -1493,7 +1465,7 @@ function get_groups_ou() */ function get_winstations_ou() { - return (get_ou("sambaMachineAccountRDN")); + return (get_ou("wingeneric", "sambaMachineAccountRDN")); } @@ -1535,7 +1507,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); } @@ -2627,10 +2599,10 @@ function get_base_from_hook($dn, $attrib) { global $config; - if ($config->get_cfg_value("baseIdHook") != ""){ + if ($config->get_cfg_value("core","baseIdHook") != ""){ /* Call hook script - if present */ - $command= $config->get_cfg_value("baseIdHook"); + $command= $config->get_cfg_value("core","baseIdHook"); if ($command != ""){ $command.= " '".LDAP::fix($dn)."' $attrib"; @@ -2641,17 +2613,17 @@ function get_base_from_hook($dn, $attrib) return ($output[0]); } else { msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG); - return ($config->get_cfg_value("uidNumberBase")); + return ($config->get_cfg_value("core","uidNumberBase")); } } else { msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG); - return ($config->get_cfg_value("uidNumberBase")); + return ($config->get_cfg_value("core","uidNumberBase")); } } else { msg_dialog::display(_("Warning"), _("'baseIdHook' is not available. Using default base!"), WARNING_DIALOG); - return ($config->get_cfg_value("uidNumberBase")); + return ($config->get_cfg_value("core","uidNumberBase")); } } @@ -3011,7 +2983,7 @@ function change_password ($dn, $password, $mode=0, $hash= "") } /* Find postmodify entries for this class */ - $command= $config->search("password", "POSTMODIFY",array('menu')); + $command= $config->get_cfg_value("password","postmodify"); if ($command != ""){ /* Walk through attribute list */ @@ -3046,7 +3018,7 @@ function generate_smb_nt_hash($password) global $config; # Try to use gosa-si? - if ($config->get_cfg_value("gosaSupportURI") != ""){ + if ($config->get_cfg_value("core","gosaSupportURI") != ""){ $res= gosaSupportDaemon::send("gosa_gen_smb_hash", "GOSA", array("password" => $password), TRUE); if (isset($res['XML']['HASH'])){ $hash= $res['XML']['HASH']; @@ -3059,7 +3031,7 @@ function generate_smb_nt_hash($password) return (""); } } else { - $tmp= $config->get_cfg_value('sambaHashHook')." ".escapeshellarg($password); + $tmp= $config->get_cfg_value("core",'sambaHashHook')." ".escapeshellarg($password); @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute"); exec($tmp, $ar); @@ -3068,7 +3040,7 @@ function generate_smb_nt_hash($password) $hash= current($ar); if ($hash == "") { - msg_dialog::display(_("Configuration error"), sprintf(_("Generating SAMBA hash by running %s failed: check %s!"), bold($config->get_cfg_value('sambaHashHook'), bold("sambaHashHook"))), ERROR_DIALOG); + msg_dialog::display(_("Configuration error"), sprintf(_("Generating SAMBA hash by running %s failed: check %s!"), bold($config->get_cfg_value("core",'sambaHashHook'), bold("sambaHashHook"))), ERROR_DIALOG); return (""); } } @@ -3102,7 +3074,7 @@ function getEntryCSN($dn) } /* Get attribute that we should use as serial number */ - $attr= $config->get_cfg_value("modificationDetectionAttribute"); + $attr= $config->get_cfg_value("core","modificationDetectionAttribute"); if($attr != ""){ $ldap = $config->get_ldap_link(); $ldap->cat($dn,array($attr)); @@ -3342,7 +3314,7 @@ function get_next_id($attrib, $dn) { global $config; - switch ($config->get_cfg_value("idAllocationMethod", "traditional")){ + switch ($config->get_cfg_value("core","idAllocationMethod")){ case "pool": return get_next_id_pool($attrib); case "traditional": @@ -3358,8 +3330,8 @@ function get_next_id_pool($attrib) { global $config; /* Fill informational values */ - $min= $config->get_cfg_value("${attrib}PoolMin", 10000); - $max= $config->get_cfg_value("${attrib}PoolMax", 40000); + $min= $config->get_cfg_value("core","${attrib}PoolMin"); + $max= $config->get_cfg_value("core","${attrib}PoolMax"); /* Sanity check */ if ($min >= $max) { @@ -3382,8 +3354,8 @@ function get_next_id_pool($attrib) { /* If it does not exist, create one with these defaults */ if ($ldap->count() == 0) { /* Fill informational values */ - $minUserId= $config->get_cfg_value("uidPoolMin", 10000); - $minGroupId= $config->get_cfg_value("gidPoolMin", 10000); + $minUserId= $config->get_cfg_value("core","uidNumberPoolMin"); + $minGroupId= $config->get_cfg_value("core","gidNumberPoolMin"); /* Add as default */ $attrs= array("objectClass" => array("organizationalUnit", "sambaUnixIdPool")); @@ -3473,10 +3445,10 @@ function get_next_id_traditional($attrib, $dn) /* get the ranges */ $tmp = array('0'=> 1000); - if (preg_match('/posixAccount/', $oc) && $config->get_cfg_value("uidNumberBase") != ""){ - $tmp= explode('-',$config->get_cfg_value("uidNumberBase")); - } elseif($config->get_cfg_value("gidNumberBase") != ""){ - $tmp= explode('-',$config->get_cfg_value("gidNumberBase")); + if (preg_match('/posixAccount/', $oc) && $config->get_cfg_value("core","uidNumberBase") != ""){ + $tmp= explode('-',$config->get_cfg_value("core","uidNumberBase")); + } elseif($config->get_cfg_value("core","gidNumberBase") != ""){ + $tmp= explode('-',$config->get_cfg_value("core","gidNumberBase")); } /* Set hwm to max if not set - for backward compatibility */ @@ -3487,7 +3459,7 @@ function get_next_id_traditional($attrib, $dn) $hwm= pow(2,32); } /* Find out next free id near to UID_BASE */ - if ($config->get_cfg_value("baseIdHook") == ""){ + if ($config->get_cfg_value("core","baseIdHook") == ""){ $base= $lwm; } else { /* Call base hook */ @@ -3533,10 +3505,10 @@ function image($path, $action= "", $title= "", $align= "middle") // Get theme if (isset ($config)){ - $theme= $config->get_cfg_value("theme", "default"); + $theme= $config->get_cfg_value("core","theme"); } else { - # For debuging - avoid that there's no theme set - die("config not set!"); + + // Fall back to default theme $theme= "default"; }