Code

Apply patch for #5572
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / class_workstationGeneric.inc
index 1872e0223810c285164264b49e96075436e04f9c..7d516ab70879585ab604401e4a6622fab83c403c 100644 (file)
@@ -473,21 +473,29 @@ class workgeneric extends plugin
 
     if ($this->orig_dn != $this->dn){
       $ldap= $this->config->get_ldap_link();
-      $ldap->cd ($this->base);
+      # Do not allow objects with the same name in other departments, either
+      $ldap->cd ($this->config->current['BASE']);
 
       if($this->cn == "wdefault"){
         $ldap->cat($this->dn);
       }else{
-        $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
+        $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn", "gosaUnitTag"));
       }
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".get_ou('systemIncomingRDN')."/", $ldap->getDN())){
             continue;
           } else {
-            if ($attrs['dn'] != $this->orig_dn){
-              $message[]= msgPool::duplicated(_("Name"));
-              break;
+            if ($attrs['dn'] != $this->orig_dn) {
+              if (isset($this->config->current['HONOURUNITTAGS']) &&
+                  preg_match('/true/i', $this->config->current['HONOURUNITTAGS']) &&
+                  $attrs['gosaUnitTag'][0] != $this->get_gosaUnitTag()) {
+                # the new/moved object is in a different administrative unit, this is not a duplicate 
+                continue;
+              } else {
+                $message[]= msgPool::duplicated(_("Name"));
+                break;
+              }
             }
           }
         }
@@ -756,15 +764,16 @@ class workgeneric extends plugin
   {
     /* Find out what is set in the object group as XDriver */
     $inherit_xdriver = 0;
+    $inherit_xy_sync = 0;
     if ($this->dn != 'new' || $this->ogroup) {
         $ldap = $this->config->get_ldap_link();
         $entry = NULL;
         /* If initialized with an object group we need to use this instead of
          * an object group we'll become a member in */
         if ($this->ogroup) {
-            $entry = $ldap->cat($this->ogroup, array("gotoXDriver"));
+            $entry = $ldap->cat($this->ogroup, array("gotoXDriver", "gotoXHsync", "gotoXVsync"));
         }else {
-          $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("gotoXDriver"));
+          $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("gotoXDriver", "gotoXHsync", "gotoXVsync"));
           if ($ldap->count() == 1) {
             $entry = $ldap->fetch();
           }
@@ -777,7 +786,10 @@ class workgeneric extends plugin
             if (in_array($entry['gotoXDriver'][0], $xdrivers)) {
               $inherit_xdriver = 1;
             }
-        }
+            if (isset($entry['gotoXHsync']) and isset($entry['gotoXVsync'])) {
+              $inherit_xy_sync = 1;
+            }
+        } 
     }
 
     $this->gotoSyslogServer  = "default";
@@ -793,6 +805,11 @@ class workgeneric extends plugin
               }
           }
       }
+      
+      /* Inherit VSync/HSync if defined in the object group */
+      if ($inherit_xy_sync) {
+        $this->parent->by_object['workservice']->InheritXYSync = TRUE;
+      }
     }
 
     /* Set workstation startup attributes to inherited */