From 2f5bdcd8e55a55b15f397940150fd0f1e49f65bc Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 9 May 2006 10:42:54 +0000 Subject: [PATCH] * Added debugging again * Fixed removing of tags git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3230 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_plugin.inc | 47 +++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 4e761fbaa..7884026d7 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -852,38 +852,51 @@ class plugin function handle_object_tagging($dn= "", $tag= "") { /* Skip if nothing has changed */ - if (!$this->is_modified){ + if ($dn == "" && !$this->is_modified){ return; } /* No dn? Self-operation... */ if ($dn == ""){ $dn= $this->dn; - } - /* No tag? Find it yourself... */ - if ($tag == ""){ - $len= strlen($this->dn); - $fix= true; - foreach ($this->config->adepartments as $key => $tag){ - /* This one is shorter than our dn, its not relevant... */ - if ($len >= strlen($key)){ - continue; + /* No tag? Find it yourself... */ + if ($tag == ""){ + $len= strlen($dn); + + echo "No tag for $dn - looking for one...
"; + $relevant= array(); + foreach ($this->config->adepartments as $key => $ntag){ + + /* This one is bigger than our dn, its not relevant... */ + if ($len <= strlen($key)){ + continue; + } + + /* This one matches with the latter part. Break and don't fix this entry */ + if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){ + echo "Possibly relevant: $key
"; + $relevant[strlen($key)]= $ntag; + continue; + } + } - /* This one matches with the latter part. Break and don't fix this entry */ - if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){ - $fix= false; - break; + /* If we've some relevant tags to set, just get the longest one */ + if (count($relevant)){ + ksort($relevant); + $tmp= array_keys($relevant); + $idx= end($tmp); + $tag= $relevant[$idx]; + $this->gosaUnitTag= $tag; } } - $this->gosaUnitTag= $tag; } /* Set tag? */ if ($tag != ""){ - #echo "Add tagging ($tag) to $dn.
"; + echo "Add tagging ($tag) to $dn.
"; /* Set objectclass and attribute */ $ldap= $this->config->get_ldap_link(); @@ -904,7 +917,7 @@ class plugin print_red($ldap->get_error()); } } else { - #echo "Remove tagging from $dn.
"; + echo "Remove tagging from $dn.
"; /* Remove objectclass and attribute */ $ldap= $this->config->get_ldap_link(); -- 2.30.2