index 1926e94f04238174a9dcf3c42c867b84d8e1e544..08626e248e47382e578ea438ae417740b2aceaf2 100644 (file)
/* Configuration file location */
define ("CONFIG_DIR", "/etc/gosa");
-define ("CONFIG_FILE", "gosa.conf-trunk");
+define ("CONFIG_FILE", "gosa.conf");
define ("CONFIG_TEMPLATE_DIR", "../contrib/");
-define ("HELP_BASEDIR", "/var/www/doc/");
/* Define get_list flags */
define("GL_NONE", 0);
/* Build a sub-directory style list of the tree level
specified in $dn */
+ global $config;
+ $dn = preg_replace("/".normalizePreg($config->current['BASE'])."$/i","",$dn);
+ if(empty($dn)) return("/");
+
foreach (split(',', $dn) as $rdn){
/* We're only interested in organizational units... */
} else {
$smarty->assign ("action", _("Edit anyway"));
}
- $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries '%s'"), "<b>".$msg."</b>", ""));
+ $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries %s"), "<b>".$msg."</b>", ""));
return ($smarty->fetch (get_template_path('islocked.tpl')));
}
@@ -2671,10 +2674,53 @@ function send_binary_content($data,$name,$type = "application/octet-stream")
HTML output, without breaking quotes.
@param The String we want to encode.
@return The encoded String
-*/
+ */
function xmlentities($str)
+{
+ if(is_string($str)){
+ return(htmlentities($str,ENT_QUOTES));
+ }elseif(is_array($str)){
+ foreach($str as $name => $value){
+ $str[$name] = xmlentities($value);
+ }
+ }
+ return($str);
+}
+
+
+/*! \brief Updates all accessTo attributes from a given value to a new one.
+ For example if a host is renamed.
+ @param String $from The source accessTo name.
+ @param String $to The destination accessTo name.
+*/
+function update_accessTo($from,$to)
{
- return (htmlentities($str,ENT_QUOTES));
+ global $config;
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+ $ldap->search("(&(objectClass=trustAccount)(accessTo=".$from."))",array("objectClass","accessTo"));
+ while($attrs = $ldap->fetch()){
+ $new_attrs = array("accessTo" => array());
+ $dn = $attrs['dn'];
+ for($i = 0 ; $i < $attrs['objectClass']['count']; $i++){
+ $new_attrs['objectClass'][] = $attrs['objectClass'][$i];
+ }
+ for($i = 0 ; $i < $attrs['accessTo']['count']; $i++){
+ if($attrs['accessTo'][$i] == $from){
+ if(!empty($to)){
+ $new_attrs['accessTo'][] = $to;
+ }
+ }else{
+ $new_attrs['accessTo'][] = $attrs['accessTo'][$i];
+ }
+ }
+ $ldap->cd($dn);
+ $ldap->modify($new_attrs);
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, "update_accessTo($from,$to)"));
+ }
+ new log("modify","update_accessTo($from,$to)",$dn,array_keys($new_attrs),$ldap->get_error());
+ }
}