Code

removed unused code
[gosa.git] / gosa-plugins / systems / admin / systems / class_componentGeneric.inc
index 5815a4a90ed5cfec54b70cf46eed28ea658a658a..002b38b2eb4c3fe12d580b6c3e15e2b56c079d73 100644 (file)
@@ -31,6 +31,8 @@ class componentGeneric extends plugin
   var $cn= "";
   var $description= "";
   var $orig_dn= "";
+  var $orig_cn= "";
+  var $orig_base= "";
 
   /* attribute list for save action */
   var $attributes= array("cn", "description");
@@ -48,11 +50,14 @@ class componentGeneric extends plugin
       $this->base= dn2base($ui->dn);
       $this->cn= "";
     } else {
-      $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+      $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_ou("componentou"))."/", "", $this->dn);
     }
     $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true);
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
+
+    $this->orig_base = $this->base;
+    $this->orig_cn = $this->cn;
   }
 
 
@@ -68,8 +73,8 @@ class componentGeneric extends plugin
 
     /* Do we represent a valid phone? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
-        _("This 'dn' has no network features.")."</b>";
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
+        msgPool::noValidExtension(_("component"))."</b>";
       return($display);
     }
 
@@ -151,7 +156,10 @@ class componentGeneric extends plugin
     
     new log("remove","component/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of system component/generic with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+    }
+
     $this->handle_post_events(array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
 
     /* Delete references to object groups */
@@ -232,6 +240,14 @@ class componentGeneric extends plugin
       }
     }
 
+    /* Check if we are allowed to create or move this object
+     */
+    if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+      $message[] = msgPool::permCreate();
+    }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+      $message[] = msgPool::permMove();
+    }
+
     return ($message);
   }
 
@@ -271,10 +287,6 @@ class componentGeneric extends plugin
       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
       
     } else {
-      if ($this->orig_dn != $this->dn){
-        $this->move($this->orig_dn, $this->dn);
-      }
-
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
@@ -285,7 +297,9 @@ class componentGeneric extends plugin
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save();
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system component/generic with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
   }
 
   /* Return plugin informations for acl handling */