index bab07709a5bb257c505272a0d67e806e3fb93fb8..15180d73cbd1719b2805435b63ce8ae03a597d83 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
/* 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);
}
- 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
if ($tag == ""){
$len= strlen($dn);
- echo "DEBUG: No tag for $dn - looking for one...<br>";
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
$relevant= array();
foreach ($this->config->adepartments as $key => $ntag){
/* 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<br>";
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
$relevant[strlen($key)]= $ntag;
continue;
}
$ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
$attrs= $ldap->fetch();
if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
- echo "DEBUG: $dn is already tagged<br>";
+ if ($show) {
+ echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
+ flush();
+ }
return;
}
if (count($attrs)){
- echo "DEBUG: Add tagging ($tag) to $dn.<br>";
+ if ($show){
+ echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
+ flush();
+ }
$nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
$nattrs['objectClass']= array();
for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
$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<br>";
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
}
} else {
$ldap= $this->config->get_ldap_link();
$ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
$attrs= $ldap->fetch();
- if (!in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
- echo "DEBUG: $dn is not tagged<br>";
+ if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
return;
}
if (count($attrs)){
- echo "DEBUG: Remove tagging from $dn.<br>";
+ if ($show){
+ echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
+ flush();
+ }
$nattrs= array("gosaUnitTag" => array());
$nattrs['objectClass']= array();
for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
}
$ldap->cd($dn);
$ldap->modify($nattrs);
- show_ldap_error($ldap->get_error());
+ show_ldap_error($ldap->get_error(), _("Handle object tagging failed"));
} else {
- echo "DEBUG: not removing tag ($tag) $dn - seems to have moved away<br>";
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
}
}