summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1c845a)
raw | patch | inline | side by side (parent: a1c845a)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 26 Jun 2009 08:41:50 +0000 (08:41 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 26 Jun 2009 08:41:50 +0000 (08:41 +0000) |
an object to an own function and use this one inside
of tag_attrs. This way the function can be used in other
parts of gosa, where comparisons with the GosaUnitTag of
a new object may be desired
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13798 594d385d-05f5-0310-b6e9-bd551577e9d8
of tag_attrs. This way the function can be used in other
parts of gosa, where comparisons with the GosaUnitTag of
a new object may be desired
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13798 594d385d-05f5-0310-b6e9-bd551577e9d8
trunk/gosa-core/include/class_plugin.inc | patch | blob | history |
index d1acf6346b502a5dca0c9798d06970057fb0b365..bdf87cde35950d675f113d5794f811aaaa2bf818 100644 (file)
}
}
- function tag_attrs(&$at, $dn= "", $tag= "", $show= false)
- {
- /* Skip tagging?
- If this is called from departmentGeneric, we have to skip this
- tagging procedure.
- */
- if($this->skipTagging){
- return;
+ function getGosaUnitTag() {
+ $dn = $this->dn;
+ $len = strlen($dn);
+ @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 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('/(^|,)'.preg_quote($key, '/').'$/', $dn)){
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
+ $relevant[strlen($key)]= $ntag;
+ continue;
+ }
}
- /* No dn? Self-operation... */
- if ($dn == ""){
- $dn= $this->dn;
+ /* 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];
+ }
- /* No tag? Find it yourself... */
- if ($tag == ""){
- $len= strlen($dn);
+ return $tag;
+ }
- @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
- $relevant= array();
+ function get_gosaUnitTag($dn = "")
+ {
+ if ($dn == "") {
+ $dn = $this->dn;
+ }
+
+ $len = strlen($dn);
+ @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 is bigger than our dn, its not relevant... */
$tmp= array_keys($relevant);
$idx= end($tmp);
$tag= $relevant[$idx];
- $this->gosaUnitTag= $tag;
+ return $tag;
}
+
+ }
+
+ function tag_attrs(&$at, $dn= "", $tag= "", $show= false)
+ {
+ /* Skip tagging?
+ If this is called from departmentGeneric, we have to skip this
+ tagging procedure.
+ */
+ if($this->skipTagging){
+ return;
+ }
+
+ /* No dn? Self-operation... */
+ if ($dn == ""){
+ $dn= $this->dn;
+
+ /* No tag? Find it yourself... */
+ if ($tag == ""){
+ $tag = $this->get_gosaUnitTag();
}
}
}
}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>