X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_plugin.inc;h=15180d73cbd1719b2805435b63ce8ae03a597d83;hb=0f0c15aed1684ff97f0aabd6f74140c6ce6a0cbd;hp=52a2a03792ba65b58a3cccc26b5d999efc037f2c;hpb=da3cd1ec47581e95b7a66d39f2aad442f196085e;p=gosa.git diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 52a2a0379..15180d73c 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -622,7 +622,7 @@ class plugin /* Try to use plain entry first */ $dn= "$attribute=".$this->$attribute.",$base"; - $ldap->cat ($dn); + $ldap->cat ($dn, array('dn')); if (!$ldap->fetch()){ return ($dn); } @@ -634,7 +634,7 @@ class plugin } $dn= "$attribute=".$this->$attribute."+$attr=".$this->$attr.",$base"; - $ldap->cat ($dn); + $ldap->cat ($dn, array('dn')); if (!$ldap->fetch()){ return ($dn); } @@ -681,7 +681,6 @@ class plugin } $ldap->cat($src_dn); - $attrs= array(); $attrs= $ldap->fetch(); if (!count($attrs)){ trigger_error("Trying to move $src_dn, which does not seem to exist.", @@ -739,7 +738,15 @@ class plugin /* Save copy */ $ldap->connect(); $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dst_dn)); + + /* FAIvariable=.../..., cn=.. + could not be saved, because the attribute FAIvariable was different to + the dn FAIvariable=..., cn=... */ + if(in_array_ics("FAIdebconfInfo",$new['objectClass'])){ + $new['FAIvariable'] = $ldap->fix($new['FAIvariable']); + } $ldap->cd($dst_dn); $ldap->add($new); @@ -780,7 +787,7 @@ class plugin $ldap= $this->config->get_ldap_link(); /* Check if destination exists - abort */ - $ldap->cat($dst_dn); + $ldap->cat($dst_dn, array('dn')); if ($ldap->fetch()){ trigger_error("recursive_move $dst_dn already exists.", E_USER_WARNING); @@ -855,7 +862,7 @@ class plugin } - function handle_object_tagging($dn= "", $tag= "") + function handle_object_tagging($dn= "", $tag= "", $show= false) { //FIXME: How to optimize this? We have at least two // LDAP accesses per object. It would be a good @@ -869,7 +876,7 @@ class plugin if ($tag == ""){ $len= strlen($dn); - echo "DEBUG: No tag for $dn - looking for one...
"; + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging"); $relevant= array(); foreach ($this->config->adepartments as $key => $ntag){ @@ -880,7 +887,7 @@ class plugin /* This one matches with the latter part. Break and don't fix this entry */ if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){ - echo "DEBUG: Possibly relevant: $key
"; + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging"); $relevant[strlen($key)]= $ntag; continue; } @@ -903,14 +910,20 @@ class plugin if ($tag != ""){ /* Set objectclass and attribute */ $ldap= $this->config->get_ldap_link(); - $ldap->cat($dn); + $ldap->cat($dn, array('gosaUnitTag', 'objectClass')); $attrs= $ldap->fetch(); if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){ - echo "DEBUG: $dn is already tagged
"; + if ($show) { + echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."
"; + flush(); + } return; } if (count($attrs)){ - echo "DEBUG: Add tagging ($tag) to $dn.
"; + if ($show){ + echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."
"; + flush(); + } $nattrs= array("gosaUnitTag" => $this->gosaUnitTag); $nattrs['objectClass']= array(); for ($i= 0; $i<$attrs['objectClass']['count']; $i++){ @@ -922,31 +935,39 @@ class plugin $nattrs['objectClass'][]= "gosaAdministrativeUnitTag"; $ldap->cd($dn); $ldap->modify($nattrs); + show_ldap_error($ldap->get_error(), _("Handle object tagging failed")); } else { - echo "DEBUG: not tagging ($tag) $dn - seems to have moved away
"; + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging"); } } else { /* Remove objectclass and attribute */ $ldap= $this->config->get_ldap_link(); - $ldap->cat($dn); + $ldap->cat($dn, array('gosaUnitTag', 'objectClass')); $attrs= $ldap->fetch(); - if (!in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){ - echo "DEBUG: $dn is not tagged
"; + if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){ + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging"); return; } - echo "DEBUG: Remove tagging from $dn.
"; - $nattrs= array("gosaUnitTag" => array()); - $nattrs['objectClass']= array(); - for ($i= 0; $i<$attrs['objectClass']['count']; $i++){ - $oc= $attrs['objectClass'][$i]; - if ($oc != "gosaAdministrativeUnitTag"){ - $nattrs['objectClass'][]= $oc; + if (count($attrs)){ + if ($show){ + echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."
"; + flush(); } + $nattrs= array("gosaUnitTag" => array()); + $nattrs['objectClass']= array(); + for ($i= 0; $i<$attrs['objectClass']['count']; $i++){ + $oc= $attrs['objectClass'][$i]; + if ($oc != "gosaAdministrativeUnitTag"){ + $nattrs['objectClass'][]= $oc; + } + } + $ldap->cd($dn); + $ldap->modify($nattrs); + show_ldap_error($ldap->get_error(), _("Handle object tagging failed")); + } else { + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging"); } - $ldap->cd($dn); - $ldap->modify($nattrs); - show_ldap_error($ldap->get_error()); } }