Code

Removed duplicated code
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 11 May 2006 13:53:18 +0000 (13:53 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 11 May 2006 13:53:18 +0000 (13:53 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3300 594d385d-05f5-0310-b6e9-bd551577e9d8

TODO
include/class_plugin.inc
plugins/admin/departments/class_departmentGeneric.inc

diff --git a/TODO b/TODO
index 3b471aad2f38dbc9470bd2f0b912c8e5c7287b37..8e841253466170171fc482d5e05b344820e1dca4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -34,6 +34,7 @@ Now:
 * evaluate what effects a ldap->cat(..., $this->attributes)
   will have to other plugins in class_plugin.inc
 * Changing LDAP-Servers -> start tab! Actions?
+* Can't rename servers!
 
 
 Target for 2.5:
index 654a63896787a80d2ba578f7d5f5de56aa505919..7a24d0e8c1c335a28372e2ffa002dc7a9a4c9bae 100644 (file)
@@ -854,7 +854,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
@@ -905,13 +905,17 @@ class plugin
       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
       $attrs= $ldap->fetch();
       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
-        echo sprintf(_("Processing: Object '%s' is already tagged"), $dn);
-        flush();
+        if ($show) {
+          echo sprintf(_("Processing: Object '%s' is already tagged"), $dn);
+          flush();
+        }
         return;
       }
       if (count($attrs)){
-        echo sprintf(_("Processing: Adding tag (%s) to object '%s'"), $dn);
-        flush();
+        if ($show){
+          echo sprintf(_("Processing: Adding tag (%s) to object '%s'"), $dn);
+          flush();
+        }
         $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
         $nattrs['objectClass']= array();
         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
@@ -937,8 +941,10 @@ class plugin
         return;
       }
       if (count($attrs)){
-        echo sprintf(_("Processing: Removing tag from object '%s'"), $dn);
-        flush();
+        if ($show){
+          echo sprintf(_("Processing: Removing tag from object '%s'"), $dn);
+          flush();
+        }
         $nattrs= array("gosaUnitTag" => array());
         $nattrs['objectClass']= array();
         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
index a6104aecec0e7a619046426a2dcd381ab92a38d9..61160d2f6dd7590e749cf72aa506c7d0fc878051 100644 (file)
@@ -374,7 +374,7 @@ class department extends plugin
                        /* Fix entry if needed */
                        if ($fix){
         echo "asdfasdfasdfasdf";
-                               $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag);
+                               $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, true);
                        }
                }
                        echo '<p class="seperator">&nbsp;</p>';
@@ -489,102 +489,6 @@ class department extends plugin
                return $this->rec_cpy;
        }
 
-       function handle_object_tagging($dn= "", $tag= "")
-       {
-               //FIXME: How to optimize this? We have at least two
-               //       LDAP accesses per object. It would be a good
-               //       idea to have it integrated.
-
-               /* No dn? Self-operation... */
-               if ($dn == ""){
-                       $dn= $this->dn;
-
-                       /* No tag? Find it yourself... */
-                       if ($tag == ""){
-                               $len= strlen($dn);
-
-                               echo sprintf(_("No tag for %s - looking for one..."),$dn);
-                               $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 sprintf(_("Possibly relevant: %s"),$key);
-                                               $relevant[strlen($key)]= $ntag;
-                                               continue;
-                                       }
-
-                               }
-                               if (count($relevant)){
-                                       ksort($relevant);
-                                       $tmp= array_keys($relevant);
-                                       $idx= end($tmp);
-                                       $tag= $relevant[$idx];
-                                       $this->gosaUnitTag= $tag;
-                               }
-                       }
-               }
-
-
-               /* Set tag? */
-               if ($tag != ""){
-                       /* Set objectclass and attribute */
-                       $ldap= $this->config->get_ldap_link();
-                       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
-                       $attrs= $ldap->fetch();
-                       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
-                               echo sprintf(_("%s is already tagged"),$dn);
-                               return;
-                       }
-                       if (count($attrs)){
-                               echo sprintf(_("Add tagging (%s) to %s"),$tag,$dn);
-                               $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
-                               $nattrs['objectClass']= array();
-                               for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
-                                       $oc= $attrs['objectClass'][$i];
-                                       if ($oc != "gosaAdministrativeUnitTag"){
-                                               $nattrs['objectClass'][]= $oc;
-                                       }
-                               }
-                               $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
-                               $ldap->cd($dn);
-                               $ldap->modify($nattrs);
-                       } else {
-                               echo sprintf(_("Not tagging (%s) %s - seems to have moved away"),$tag,$dn);
-                       }
-
-               } else {
-                       /* Remove objectclass and attribute */
-                       $ldap= $this->config->get_ldap_link();
-                       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
-                       $attrs= $ldap->fetch();
-                       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
-                               echo sprintf(_("%s is not tagged"),$dn);
-                               return;
-                       }
-                       if (count($attrs)){
-                               echo sprintf(_("Remove tagging from %s"),$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;
-                                       }
-                               }
-                               $ldap->cd($dn);
-                               $ldap->modify($nattrs);
-                               show_ldap_error($ldap->get_error());
-                       } else {
-                               echo sprintf(_("Not removing tag (%s) %s - seems to have moved away"),$tag,$dn);
-                       }
-               }
-       }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>